]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
MOTD centerprint fixes / changes:
authorterencehill <piuntn@gmail.com>
Fri, 8 Mar 2013 20:56:15 +0000 (21:56 +0100)
committerterencehill <piuntn@gmail.com>
Fri, 8 Mar 2013 21:01:44 +0000 (22:01 +0100)
* Kill initial MOTD centerprint (that appears on server connection) when we know it's showing (in PrintWelcomeMessage()), rather than doing it blindly every time the player joins the game: it fixes MOTD never expiring in Arena.
* Info button now instantly hides initial MOTD.
* If player pressed the info button to see the MOTD and immediately joined the game then don't care, just let the MOTD fade away normally (in 2 seconds); killing the MOTD as before caused the MOTD to pop up again after 2 seconds fading away

qcsrc/server/cl_client.qc
qcsrc/server/command/cmd.qc
qcsrc/server/defs.qh

index 9c2c47203fa98116ed0625c3ff6408f3c685077a..7633e5ff2385e2460e7dcb55995914f14c8cfaac 100644 (file)
@@ -1530,7 +1530,10 @@ void ClientConnect (void)
        if(clienttype(self) == CLIENTTYPE_REAL)
        {
                if(!autocvar_g_campaign)
+               {
+                       self.motd_actived_time = -1;
                        Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_MOTD, getwelcomemessage());
+               }
 
                if(autocvar_g_bugrigs || WEPSET_EQ_AW(g_weaponarena_weapons, WEP_TUBA))
                        stuffcmd(self, "cl_cmd settemp chase_active 1\n");
@@ -2334,11 +2337,9 @@ void LeaveSpectatorMode()
 
                        if(autocvar_g_campaign)
                                { campaign_bots_may_start = 1; }
-                       else
-                               { Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_MOTD); }
 
                        Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_PREVENT_JOIN);
-                       
+
                        PutClientInServer();
 
                        if(IS_PLAYER(self)) { Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_JOIN_PLAY, self.netname); }
@@ -2405,22 +2406,24 @@ void checkSpectatorBlock() {
        }
 }
 
-.float motd_actived_time; // used for both motd and campaign_message
 void PrintWelcomeMessage()
 {
-       if (self.motd_actived_time == 0) { // is there already a message showing?
+       if(self.motd_actived_time == 0)
+       {
                if (autocvar_g_campaign) {
                        if ((self.classname == "player" && self.BUTTON_INFO) || (self.classname != "player")) {
                                self.motd_actived_time = time;
                                Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_MOTD, campaign_message);
                        }
                } else {
-                       if ((time - self.jointime > autocvar_welcome_message_time) && self.BUTTON_INFO) {
+                       if (self.BUTTON_INFO) {
                                self.motd_actived_time = time;
                                Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_MOTD, getwelcomemessage());
                        }
                }
-       } else { // showing MOTD or campaign message
+       }
+       else if(self.motd_actived_time > 0) // showing MOTD or campaign message
+       {
                if (autocvar_g_campaign) {
                        if (self.BUTTON_INFO)
                                self.motd_actived_time = time;
@@ -2429,16 +2432,25 @@ void PrintWelcomeMessage()
                                Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_MOTD);
                        }
                } else {
-                       if ((time - self.jointime) > autocvar_welcome_message_time) {
-                               if (self.BUTTON_INFO)
-                                       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_CPID, CPID_MOTD);
-                               }
+                       if (self.BUTTON_INFO)
+                               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_CPID, CPID_MOTD);
                        }
                }
        }
+       else //if(self.motd_actived_time < 0) // just connected, motd is active
+       {
+               if(self.BUTTON_INFO) // BUTTON_INFO hides initial MOTD
+                       self.motd_actived_time = -2; // wait until BUTTON_INFO gets released
+               else if(self.motd_actived_time == -2 || IS_PLAYER(self) || time - self.jointime > autocvar_welcome_message_time)
+               {
+                       // instanctly hide MOTD
+                       self.motd_actived_time = 0;
+                       Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_MOTD);
+               }
+       }
 }
 
 void ObserverThink()
index 6c1e0ed56f58e79094ed4fcb1ce461bab8533162..f97ef15e4391ad50781c21097c8867041090799c 100644 (file)
@@ -159,7 +159,6 @@ void ClientCommand_join(float request)
                                                
                                                self.classname = "player";
                                                PlayerScore_Clear(self);
-                                               Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_MOTD);
                                                Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_PREVENT_JOIN);
                                                Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_JOIN_PLAY, self.netname);
                                                PutClientInServer();
index 5eaafe4f109e4679aad77b9b4af21f331aa9f3f5..592683a3c73f1baa0c857c8bf0de79c1a5c51c46 100644 (file)
@@ -242,6 +242,7 @@ float game_completion_ratio; // 0 at start, 1 near end
 .float winning;
 .float jointime; // time of joining
 .float alivetime; // time of being alive
+.float motd_actived_time; // used for both motd and campaign_message
 
 float nJoinAllowed(entity ignore);
 #define PREVENT_JOIN_TEXT "^1You may not join the game at this time.\n\nThe player limit reached maximum capacity."