// ================================================
// Unified notification system, written by Samual
-// Last updated: February, 2013
+// Last updated: March, 2013
// ================================================
string Get_Notif_TypeName(float net_type)
{
case MSG_INFO: return "MSG_INFO";
case MSG_CENTER: return "MSG_CENTER";
+ case MSG_CENTER_CPID: return "MSG_CENTER_CPID";
case MSG_MULTI: return "MSG_MULTI";
}
backtrace(sprintf("Get_Notif_TypeName(%d): Improper net type!\n", net_type));
// Initialization Core Functions
// ===============================
+// used by restartnotifs command to initialize notifications
+void Destroy_Notification_Entity(entity notif)
+{
+ if(notif.nent_name != "") { strunzone(notif.nent_name); }
+ if(notif.nent_args != "") { strunzone(notif.nent_args); }
+ if(notif.nent_hudargs != "") { strunzone(notif.nent_hudargs); }
+ if(notif.nent_icon != "") { strunzone(notif.nent_icon); }
+ if(notif.nent_durcnt != "") { strunzone(notif.nent_durcnt); }
+ if(notif.nent_string != "") { strunzone(notif.nent_string); }
+ remove(notif);
+}
+
+void Destroy_All_Notifications(void)
+{
+ entity notif;
+ float i;
+
+ #define DESTROY_LOOP(type,count) \
+ for(i = 1; i <= count; ++i) \
+ { \
+ notif = Get_Notif_Ent(type, i); \
+ if not(notif) { backtrace("Destroy_All_Notifications(): Missing notification entity!\n"); return; } \
+ Destroy_Notification_Entity(notif); \
+ }
+
+ // kill all networked notifications
+ #ifdef SVQC
+ Kill_Notification(NOTIF_ALL, world, 0, 0);
+ #endif
+
+ // kill all real notification entities
+ DESTROY_LOOP(MSG_INFO, NOTIF_INFO_COUNT)
+ DESTROY_LOOP(MSG_CENTER, NOTIF_CENTER_COUNT)
+ DESTROY_LOOP(MSG_MULTI, NOTIF_MULTI_COUNT)
+ #undef DESTROY_LOOP
+}
+
string Process_Notif_Line(
float msg_is_info,
float chat,
}
}
-void Destroy_Notification_Entity(entity notif)
-{
- if(notif.nent_name != "") { strunzone(notif.nent_name); }
- if(notif.nent_args != "") { strunzone(notif.nent_args); }
- if(notif.nent_hudargs != "") { strunzone(notif.nent_hudargs); }
- if(notif.nent_icon != "") { strunzone(notif.nent_icon); }
- if(notif.nent_durcnt != "") { strunzone(notif.nent_durcnt); }
- if(notif.nent_string != "") { strunzone(notif.nent_string); }
- remove(notif);
-}
-
-void Destroy_All_Notifications(void)
-{
- entity notif;
- float i;
-
- #define DESTROY_LOOP(type,count) \
- for(i = 1; i <= count; ++i) \
- { \
- notif = Get_Notif_Ent(type, i); \
- if not(notif) { backtrace("Destroy_All_Notifications(): Missing notification entity!\n"); return; } \
- Destroy_Notification_Entity(notif); \
- }
-
- // kill all networked notifications
- #ifdef SVQC
- Kill_Notification(NOTIF_ALL, world, 0, 0);
- #endif
-
- // kill all real notification entities
- DESTROY_LOOP(MSG_INFO, NOTIF_INFO_COUNT)
- DESTROY_LOOP(MSG_CENTER, NOTIF_CENTER_COUNT)
- DESTROY_LOOP(MSG_MULTI, NOTIF_MULTI_COUNT)
- #undef DESTROY_LOOP
-}
-
// =========================================
// Cvar Handling With 'dumpnotifs' Command
// edit these to match whichever cvars are used for specific notification options
NOTIF_WRITE("\n// HARD CODED notification variables:\n");
- NOTIF_WRITE_HARDCODED("allow_chatboxprint", "1", "Allow notifications to be printed to chat box by setting notification cvar to 2 (You can also set this cvar to 2 to force ALL notifications to be printed to the chatbox)");
- NOTIF_WRITE_HARDCODED("show_location", "0", "Append location information to MSG_INFO death/kill messages");
- NOTIF_WRITE_HARDCODED("show_location_string", "", "Replacement string piped into sprintf, so you can do different messages like this: ' at the %s' or ' (near %s)'");
- NOTIF_WRITE_HARDCODED("show_sprees", "1", "Print information about sprees in death/kill messages");
- NOTIF_WRITE_HARDCODED("show_sprees_center", "1", "Show spree information in MSG_CENTER messages... 0 = off, 1 = target (but only for first victim) and attacker");
- NOTIF_WRITE_HARDCODED("show_sprees_center_specialonly", "1", "Don't show spree information in MSG_CENTER messages if it isn't an achievement");
- NOTIF_WRITE_HARDCODED("show_sprees_info", "3", "Show spree information in MSG_INFO messages... 0 = off, 1 = target only, 2 = attacker only, 3 = target and attacker");
- NOTIF_WRITE_HARDCODED("show_sprees_info_newline", "1", "Show attacker spree information for MSG_INFO messages on a separate line than the death notification itself");
- NOTIF_WRITE_HARDCODED("show_sprees_info_specialonly", "1", "Don't show attacker spree information in MSG_INFO messages if it isn't an achievement");
- NOTIF_WRITE_HARDCODED("item_centerprinttime", "1.5", "How long to show item information centerprint messages (like 'You got the Electro' or such)");
- NOTIF_WRITE_HARDCODED("errors_are_fatal", "1", "If a notification fails upon initialization, cause a Host_Error to stop the program");
- NOTIF_WRITE_HARDCODED("ctf_pickup_team_verbose", "0", "Show extra information if a team mate picks up a flag");
- NOTIF_WRITE_HARDCODED("ctf_pickup_enemy_verbose", "0", "Show extra information if an enemy picks up a flag");
- NOTIF_WRITE_HARDCODED("ctf_capture_verbose", "0", "Show extra information when someone captures a flag");
- NOTIF_WRITE_HARDCODED("frag_verbose", "1", "Show extra information when you frag someone (or when you are fragged");
- NOTIF_WRITE_HARDCODED("lifetime_runtime", "0.5", "Amount of time that notification entities last on the server during runtime (In seconds)");
- NOTIF_WRITE_HARDCODED("lifetime_mapload", "10", "Amount of time that notification entities last immediately at mapload (in seconds) to help prevent notifications from being lost on early init (like gamestart countdown)");
+ NOTIF_WRITE_HARDCODED("allow_chatboxprint", "1", "Allow notifications to be printed to chat box by setting notification cvar to 2 (You can also set this cvar to 2 to force ALL notifications to be printed to the chatbox)");
+ NOTIF_WRITE_HARDCODED("show_location", "0", "Append location information to MSG_INFO death/kill messages");
+ NOTIF_WRITE_HARDCODED("show_location_string", "", "Replacement string piped into sprintf, so you can do different messages like this: ' at the %s' or ' (near %s)'");
+ NOTIF_WRITE_HARDCODED("show_sprees", "1", "Print information about sprees in death/kill messages");
+ NOTIF_WRITE_HARDCODED("show_sprees_center", "1", "Show spree information in MSG_CENTER messages... 0 = off, 1 = target (but only for first victim) and attacker");
+ NOTIF_WRITE_HARDCODED("show_sprees_center_specialonly", "1", "Don't show spree information in MSG_CENTER messages if it isn't an achievement");
+ NOTIF_WRITE_HARDCODED("show_sprees_info", "3", "Show spree information in MSG_INFO messages... 0 = off, 1 = target only, 2 = attacker only, 3 = target and attacker");
+ NOTIF_WRITE_HARDCODED("show_sprees_info_newline", "1", "Show attacker spree information for MSG_INFO messages on a separate line than the death notification itself");
+ NOTIF_WRITE_HARDCODED("show_sprees_info_specialonly", "1", "Don't show attacker spree information in MSG_INFO messages if it isn't an achievement");
+ NOTIF_WRITE_HARDCODED("item_centerprinttime", "1.5", "How long to show item information centerprint messages (like 'You got the Electro' or such)");
+ NOTIF_WRITE_HARDCODED("errors_are_fatal", "1", "If a notification fails upon initialization, cause a Host_Error to stop the program");
+ NOTIF_WRITE_HARDCODED("ctf_pickup_team_verbose", "0", "Show extra information if a team mate picks up a flag");
+ NOTIF_WRITE_HARDCODED("ctf_pickup_enemy_verbose", "0", "Show extra information if an enemy picks up a flag");
+ NOTIF_WRITE_HARDCODED("ctf_capture_verbose", "0", "Show extra information when someone captures a flag");
+ NOTIF_WRITE_HARDCODED("frag_verbose", "1", "Show extra information when you frag someone (or when you are fragged");
+ NOTIF_WRITE_HARDCODED("lifetime_runtime", "0.5", "Amount of time that notification entities last on the server during runtime (In seconds)");
+ NOTIF_WRITE_HARDCODED("lifetime_mapload", "10", "Amount of time that notification entities last immediately at mapload (in seconds) to help prevent notifications from being lost on early init (like gamestart countdown)");
NOTIF_WRITE(sprintf(
strcat(
if(net_type == MSG_CENTER_CPID)
{
+ #ifdef NOTIFICATIONS_DEBUG
+ dprint(sprintf(
+ "Read_Notification(%d) at %f: net_type = %s, net_name = %d\n",
+ is_new,
+ time,
+ Get_Notif_TypeName(net_type),
+ net_name
+ ));
+ #endif
+
if(is_new)
{
if(net_name == 0) { reset_centerprint_messages(); }
// in this case, net_name IS the cpid we want to kill
centerprint_generic(net_name, "", 0, 0);
}
+ else
+ {
+ print(sprintf(
+ "Read_Notification(%d) at %f: ^1TRIED TO KILL NO_CPID CENTERPRINT!\n",
+ is_new,
+ time
+ ));
+ }
}
}
else
void Net_Notification_Remove()
{
if not(self) { dprint(sprintf("Net_Notification_Remove() at %f: Missing self!?\n", time)); return; }
+
#ifdef NOTIFICATIONS_DEBUG
- if(self.nent_net_name == -1)
- {
- dprint(sprintf(
- "Net_Notification_Remove() at %f: Killed '%s - %s' notification\n",
- time,
- Get_Notif_TypeName(self.nent_net_type),
- self.nent_realent.nent_name
- ));
- }
- else
- {
- dprint(sprintf(
- "Net_Notification_Remove() at %f: Removed '%s - %s' notification\n",
- time,
- Get_Notif_TypeName(self.nent_net_type),
- self.nent_realent.nent_name
- ));
- }
+ dprint(sprintf(
+ "Net_Notification_Remove() at %f: %s '%s - %s' notification\n",
+ time,
+ ((self.nent_net_name == -1) ? "Killed" : "Removed"),
+ Get_Notif_TypeName(self.nent_net_type),
+ self.owner.nent_name
+ ));
#endif
float i;
(client == self.nent_client)
||
(
- (client.classname == STR_SPECTATOR)
+ IS_SPEC(client)
&&
(client.enemy == self.nent_client)
)
(client.team == self.nent_client.team)
||
(
- (client.classname == STR_SPECTATOR)
+ IS_SPEC(client)
&&
(client.enemy.team == self.nent_client.team)
)
(client.team == self.nent_client.team)
||
(
- (client.classname == STR_SPECTATOR)
+ IS_SPEC(client)
&&
(
(client.enemy != self.nent_client)
(client != self.nent_client)
&&
!(
- (client.classname == STR_SPECTATOR)
+ IS_SPEC(client)
&&
(client.enemy == self.nent_client)
)
{
if(killed_cpid != NO_CPID)
{
- if(notif.nent_realent.nent_cpid == killed_cpid)
+ if(notif.owner.nent_cpid == killed_cpid)
{
notif.nent_net_name = -1;
notif.nextthink = time;
#endif
entity net_notif = spawn();
- net_notif.nent_realent = notif;
+ net_notif.owner = notif;
net_notif.classname = "net_notification";
net_notif.nent_broadcast = broadcast;
net_notif.nent_client = client;
#undef VARITEM
Send_Notification(broadcast, client, net_type, net_name); // some notifications don't have any arguments at all
}
-
-
-// =============================
-// LEGACY NOTIFICATION SYSTEMS
-// =============================
-
-void Send_CSQC_Centerprint_Generic(entity e, float id, string s, float duration, float countdown_num)
-{
- if ((clienttype(e) == CLIENTTYPE_REAL) && (e.flags & FL_CLIENT))
- {
- msg_entity = e;
- WRITESPECTATABLE_MSG_ONE({
- WriteByte(MSG_ONE, SVC_TEMPENTITY);
- WriteByte(MSG_ONE, TE_CSQC_CENTERPRINT_GENERIC);
- WriteByte(MSG_ONE, id);
- WriteString(MSG_ONE, s);
- if (id != 0 && s != "")
- {
- WriteByte(MSG_ONE, duration);
- WriteByte(MSG_ONE, countdown_num);
- }
- });
- }
-}
#endif // ifdef SVQC