]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Kill another gamemode specific check
authorMario <mario@smbclan.net>
Wed, 14 Oct 2015 13:48:38 +0000 (23:48 +1000)
committerMario <mario@smbclan.net>
Wed, 14 Oct 2015 13:48:38 +0000 (23:48 +1000)
qcsrc/server/command/cmd.qc
qcsrc/server/mutators/events.qh
qcsrc/server/mutators/gamemode_ca.qc
qcsrc/server/mutators/gamemode_lms.qc

index ddfbe57950a0f46ff66ff83532dd89d9c1059bbd..dbb9e1a4858d2c7e66a7e438bee1b3d7bfa17f11 100644 (file)
@@ -465,29 +465,13 @@ void ClientCommand_spectate(float request)
                {
                        if(IS_CLIENT(self))
                        {
-                               if(g_lms)
-                               {
-                                       if(self.lms_spectate_warning)
-                                       {
-                                               // for the forfeit message...
-                                               self.lms_spectate_warning = 2;
-                                               // mark player as spectator
-                                               PlayerScore_Add(self, SP_LMS_RANK, 666 - PlayerScore_Add(self, SP_LMS_RANK, 0));
-                                       }
-                                       else
-                                       {
-                                               self.lms_spectate_warning = 1;
-                                               sprint(self, "WARNING: you won't be able to enter the game again after spectating in LMS. Use the same command again to spectate anyway.\n");
-                                               return;
-                                       }
-                               }
+                               int mutator_returnvalue = MUTATOR_CALLHOOK(ClientCommand_Spectate, self);
 
-                               if((IS_PLAYER(self) || self.caplayer) && autocvar_sv_spectate == 1)
-                               {
-                                       if(self.caplayer && (IS_SPEC(self) || IS_OBSERVER(self)))
-                                               Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_CA_LEAVE);
+                               if(mutator_returnvalue == MUT_SPECCMD_RETURN)
+                                       return;
+
+                               if((IS_PLAYER(self) || mutator_returnvalue == MUT_SPECCMD_FORCE) && autocvar_sv_spectate == 1)
                                        ClientKill_TeamChange(-2); // observe
-                               }
                        }
                        return; // never fall through to usage
                }
index 04ac5c28fcf1e46e001e7f7c0ef38110ea9e1e45..7852b0ad8dea07570c206a6e5236c92ddbc2056b 100644 (file)
@@ -703,4 +703,15 @@ enum {
 int bot_activerealplayers;
 int bot_realplayers;
 MUTATOR_HOOKABLE(Bot_FixCount, EV_Bot_FixCount);
+
+#define EV_ClientCommand_Spectate(i, o) \
+    /**/ i(entity, __self) \
+    /**/
+MUTATOR_HOOKABLE(ClientCommand_Spectate, EV_ClientCommand_Spectate);
+
+enum {
+    MUT_SPECCMD_CONTINUE, // return this flag to make the function continue as normal
+    MUT_SPECCMD_RETURN, // return this flag to make the function return (don't spectate)
+    MUT_SPECCMD_FORCE // return this flag to force the player to spectate, even if they're not a player
+};
 #endif
index eb883118749f4df962eccb03b3ebc73e4e51bb8b..8881ab2eed11be043460a2bc7e759453f8328947 100644 (file)
@@ -443,6 +443,19 @@ MUTATOR_HOOKFUNCTION(ca, Bot_FixCount, CBC_ORDER_EXCLUSIVE)
        return true;
 }
 
+MUTATOR_HOOKFUNCTION(ca, ClientCommand_Spectate)
+{
+       if(self.caplayer)
+       {
+               // they're going to spec, we can do other checks
+               if(autocvar_sv_spectate && (IS_SPEC(self) || IS_OBSERVER(self)))
+                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_CA_LEAVE);
+               return MUT_SPECCMD_FORCE;
+       }
+
+       return MUT_SPECCMD_CONTINUE;
+}
+
 void ca_Initialize()
 {
        allowed_to_spawn = true;
index e9297d88b57b554e1cca0702b6103dd160327410..c065e7a9682eb7123f7fe8a13e5a23538efbb56f 100644 (file)
@@ -212,6 +212,24 @@ MUTATOR_HOOKFUNCTION(lms, Bot_FixCount, CBC_ORDER_EXCLUSIVE)
        return true;
 }
 
+MUTATOR_HOOKFUNCTION(lms, ClientCommand_Spectate)
+{
+       if(self.lms_spectate_warning)
+       {
+               // for the forfeit message...
+               self.lms_spectate_warning = 2;
+               // mark player as spectator
+               PlayerScore_Add(self, SP_LMS_RANK, 666 - PlayerScore_Add(self, SP_LMS_RANK, 0));
+       }
+       else
+       {
+               self.lms_spectate_warning = 1;
+               sprint(self, "WARNING: you won't be able to enter the game again after spectating in LMS. Use the same command again to spectate anyway.\n");
+               return MUT_SPECCMD_RETURN;
+       }
+       return MUT_SPECCMD_CONTINUE;
+}
+
 // scoreboard stuff
 void lms_ScoreRules()
 {