]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Updates/fixes for Kill_Notification
authorSamual Lenks <samual@xonotic.org>
Sat, 2 Mar 2013 21:18:13 +0000 (16:18 -0500)
committerSamual Lenks <samual@xonotic.org>
Sat, 2 Mar 2013 21:18:13 +0000 (16:18 -0500)
qcsrc/common/notifications.qc
qcsrc/common/notifications.qh
qcsrc/server/arena.qc
qcsrc/server/cl_client.qc
qcsrc/server/mutators/gamemode_keyhunt.qc
qcsrc/server/w_minstanex.qc

index 3291c48c3b42028b81963ab5084a7cf48a7228c7..bb07c0b7dee2a2e1bcaad561d113e5cbc476dbdb 100644 (file)
@@ -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;
index 179bf9b91967175f4b39add2cafdf7959bfc4914..8c594245d0d4f0c2c2dc41478dcb75ba0517f9a9 100644 (file)
@@ -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;
index bf0605665ba3c435bfef310aebef61b090c49d2d..636b0668dca06674565d66e97d90e3a522c18c44 100644 (file)
@@ -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)
index 287a9e1e76a203329ca0dd315591532b1b5799d4..a95ff18c32a00e3c1db8515d1fc462474a72981b 100644 (file)
@@ -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);
                                }
                        }
                }
index 5533d27baba4c97e3c2e3fe3ea9520b475a0bb56..e0b3b07a5249cb76445e4a31471b5408393c77ef 100644 (file)
@@ -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)
        {
index f80c5f6ce1ada2ebe4e0a41a027869a4249f42e7..1eaa5c4e552cdc14a8f939cdc022c16db0d0e6f1 100644 (file)
@@ -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)