From: Samual Lenks Date: Sat, 2 Mar 2013 21:18:13 +0000 (-0500) Subject: Updates/fixes for Kill_Notification X-Git-Tag: xonotic-v0.7.0~62^2~23^2~41 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e666aff12e3879625672de71fe4fe5bb9fc7a5bd;p=xonotic%2Fxonotic-data.pk3dir.git Updates/fixes for Kill_Notification --- diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index 3291c48c3..bb07c0b7d 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -509,7 +509,7 @@ void Create_Notification_Entity( notif_error = TRUE; } } - else if(cpid != NO_MSG) { notif.nent_cpid = cpid; } + else if(cpid != NO_CPID) { notif.nent_cpid = cpid; } #endif @@ -576,6 +576,7 @@ void Destroy_All_Notifications(void) { entity notif; float i; + #define DESTROY_LOOP(type,count) \ for(i = 1; i <= count; ++i) \ { \ @@ -1012,16 +1013,15 @@ void Read_Notification(float is_new) entity notif; - if(net_type == MSG_CENTER_KILL) + if(net_type == MSG_CENTER_CPID) { if(is_new) { if(net_name == 0) { reset_centerprint_messages(); } - else + else if(net_name != NO_CPID) { - notif = Get_Notif_Ent(MSG_CENTER, net_name); - if not(notif) { backtrace("Read_Notification: Could not find notification entity!\n"); return; } - centerprint_generic(notif.nent_cpid, "", 0, 0); + // in this case, net_name IS the cpid we want to kill + centerprint_generic(net_name, "", 0, 0); } } } @@ -1065,32 +1065,27 @@ void Read_Notification(float is_new) #ifdef SVQC void Net_Notification_Remove() { - #ifdef NOTIFICATIONS_DEBUG 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' notification\n", + "Net_Notification_Remove() at %f: Killed '%s - %s' notification\n", time, - Get_Notif_TypeName(self.nent_net_type) + Get_Notif_TypeName(self.nent_net_type), + self.nent_realent.nent_name )); } else - #endif { - string checkargs = Notification_CheckArgs_TypeName(self.nent_net_type, self.nent_net_name); - if(checkargs != "") { dprint(sprintf("Incorrect usage of Net_Notification_Remove() at %f: %s\n", time, checkargs)); return; } - - #ifdef NOTIFICATIONS_DEBUG - entity realent = Get_Notif_Ent(self.nent_net_type, self.nent_net_name); dprint(sprintf( "Net_Notification_Remove() at %f: Removed '%s - %s' notification\n", time, Get_Notif_TypeName(self.nent_net_type), - realent.nent_name + self.nent_realent.nent_name )); - #endif } + #endif float i; for(i = 0; i < 4; ++i) { if(self.nent_strings[i]) { strunzone(self.nent_strings[i]); } } @@ -1206,36 +1201,74 @@ void Kill_Notification( #endif entity notif, net_notif; + float killed_cpid = NO_CPID; + + switch(net_type) + { + case 0: + { + killed_cpid = 0; // kill ALL centerprints + break; + } + + case MSG_CENTER: + { + if(net_name) + { + entity notif = Get_Notif_Ent(net_type, net_name); + if not(notif) { backtrace("Kill_Notification: Could not find notification entity!\n"); return; } + killed_cpid = notif.nent_cpid; + } + else + { + killed_cpid = 0; // kill ALL centerprints + } + break; + } - // if no name is provided, just kill ALL the centerprint notifications - if(net_type == MSG_CENTER) + case MSG_CENTER_CPID: + { + killed_cpid = net_name; + break; + } + } + + if(killed_cpid != NO_CPID) { net_notif = spawn(); net_notif.classname = "net_kill_notification"; net_notif.nent_broadcast = broadcast; net_notif.nent_client = client; - net_notif.nent_net_type = MSG_CENTER_KILL; - net_notif.nent_net_name = net_name; + net_notif.nent_net_type = MSG_CENTER_CPID; + net_notif.nent_net_name = killed_cpid; Net_LinkEntity(net_notif, FALSE, autocvar_notification_lifetime_runtime, Net_Write_Notification); } for(notif = world; (notif = find(notif, classname, "net_notification"));) { - // now kill the old send notification entity if(net_type) { - if(notif.nent_net_type == net_type) + if(killed_cpid != NO_CPID) + { + if(notif.nent_realent.nent_cpid == killed_cpid) + { + notif.nent_net_name = -1; + notif.nextthink = time; + } + else { continue; } // we ARE looking for a specific CPID, don't kill everything else too + } + else if(notif.nent_net_type == net_type) { if(net_name) { - if(notif.nent_net_name == net_name) { notif.nent_net_name = -1; notif.think(); } + if(notif.nent_net_name == net_name) { notif.nent_net_name = -1; notif.nextthink = time; } else { continue; } // we ARE looking for a certain net_name, don't kill everything else too } - else { notif.nent_net_name = -1; notif.think(); } + else { notif.nent_net_name = -1; notif.nextthink = time; } } else { continue; } // we ARE looking for a certain net_type, don't kill everything else too } - else { notif.nent_net_name = -1; notif.think(); } + else { notif.nent_net_name = -1; notif.nextthink = time; } } } @@ -1299,6 +1332,7 @@ void Send_Notification( #endif entity net_notif = spawn(); + net_notif.nent_realent = notif; net_notif.classname = "net_notification"; net_notif.nent_broadcast = broadcast; net_notif.nent_client = client; diff --git a/qcsrc/common/notifications.qh b/qcsrc/common/notifications.qh index 179bf9b91..8c594245d 100644 --- a/qcsrc/common/notifications.qh +++ b/qcsrc/common/notifications.qh @@ -6,7 +6,7 @@ // main types/groups of notifications #define MSG_INFO 1 // "Global" information messages (sent to console, and notify panel if it has an icon) #define MSG_CENTER 2 // "Personal" centerprint messages -#define MSG_CENTER_KILL 3 // Kill centerprint message +#define MSG_CENTER_CPID 3 // Kill centerprint message #define MSG_MULTI 4 // Subcall MSG_INFO and/or MSG_CENTER notifications #define NO_MSG -12345 @@ -949,6 +949,7 @@ float NOTIF_CPID_COUNT; .string nent_string; // networked notification values +.entity nent_realent; .float nent_broadcast; .entity nent_client; .float nent_net_type; diff --git a/qcsrc/server/arena.qc b/qcsrc/server/arena.qc index bf0605665..636b0668d 100644 --- a/qcsrc/server/arena.qc +++ b/qcsrc/server/arena.qc @@ -199,7 +199,7 @@ void Arena_Warmup() { if(warmup && time < warmup) { - Kill_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ARENA_BEGIN); + Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_ARENA); warmup = 0; } if(champion && g_arena) diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 287a9e1e7..a95ff18c3 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2345,7 +2345,7 @@ void LeaveSpectatorMode() if (self.prevent_join_msgtime) { - Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_JOIN_PREVENT); + Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_PREVENT_JOIN); self.prevent_join_msgtime = 0; } @@ -2362,7 +2362,7 @@ void LeaveSpectatorMode() //player may not join because of g_maxplayers is set if (time - self.prevent_join_msgtime > 2) { - Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_JOIN_PREVENT); + Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_PREVENT_JOIN); self.prevent_join_msgtime = time; } } @@ -2442,7 +2442,7 @@ void PrintWelcomeMessage() self.motd_actived_time = time; else if ((time - self.motd_actived_time > 2) && self.classname == "player") { // hide it some seconds after BUTTON_INFO has been released self.motd_actived_time = 0; - Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_MOTD); + Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_MOTD); } } else { if ((time - self.jointime) > autocvar_welcome_message_time) { @@ -2450,7 +2450,7 @@ void PrintWelcomeMessage() self.motd_actived_time = time; else if (time - self.motd_actived_time > 2) { // hide it some seconds after BUTTON_INFO has been released self.motd_actived_time = 0; - Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_MOTD); + Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_MOTD); } } } diff --git a/qcsrc/server/mutators/gamemode_keyhunt.qc b/qcsrc/server/mutators/gamemode_keyhunt.qc index 5533d27ba..e0b3b07a5 100644 --- a/qcsrc/server/mutators/gamemode_keyhunt.qc +++ b/qcsrc/server/mutators/gamemode_keyhunt.qc @@ -869,7 +869,8 @@ void kh_WaitForPlayers() // delay start of the round until enough players are p void kh_EnableTrackingDevice() // runs after each round { - Kill_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_KEYHUNT_HELP); + Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_KEYHUNT); + Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_KEYHUNT_OTHER); kh_tracking_enabled = TRUE; } @@ -893,7 +894,8 @@ void kh_StartRound() // runs at the start of each round return; } - Kill_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_KEYHUNT_HELP); + Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_KEYHUNT); + Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_KEYHUNT_OTHER); for(i = 0; i < kh_teams; ++i) { diff --git a/qcsrc/server/w_minstanex.qc b/qcsrc/server/w_minstanex.qc index f80c5f6ce..1eaa5c4e5 100644 --- a/qcsrc/server/w_minstanex.qc +++ b/qcsrc/server/w_minstanex.qc @@ -85,7 +85,7 @@ void minstagib_stop_countdown(entity e) { if (!e.minstagib_needammo) return; - Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CENTER_MINSTA_FINDAMMO); + Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_MINSTA_FINDAMMO); e.minstagib_needammo = FALSE; } void minstagib_ammocheck(void)