From e27da55c1e8450a98b752586c55c828667ce9758 Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 8 Mar 2013 21:56:15 +0100 Subject: [PATCH] MOTD centerprint fixes / changes: * 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 | 40 ++++++++++++++++++++++++------------- qcsrc/server/command/cmd.qc | 1 - qcsrc/server/defs.qh | 1 + 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 9c2c47203..7633e5ff2 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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() diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 6c1e0ed56..f97ef15e4 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -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(); diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 5eaafe4f1..592683a3c 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -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." -- 2.39.2