]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator/gamemode_ca.qc
Cleanse server client commands
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_ca.qc
index ffb231e7bba639356d281d8cf1ac5c38cc6d304a..943fd27d7a27fe86c27750264bb279626f4646c7 100644 (file)
@@ -262,8 +262,9 @@ MUTATOR_HOOKFUNCTION(ca, reset_map_players)
 
 MUTATOR_HOOKFUNCTION(ca, ClientConnect)
 {
-    SELFPARAM();
-       TRANSMUTE(Observer, this);
+    entity player = M_ARGV(0, entity);
+
+       TRANSMUTE(Observer, player);
        return true;
 }
 
@@ -278,9 +279,8 @@ MUTATOR_HOOKFUNCTION(ca, GetTeamCount, CBC_ORDER_EXCLUSIVE)
        M_ARGV(0, float) = ca_teams;
 }
 
-entity ca_LastPlayerForTeam()
+entity ca_LastPlayerForTeam(entity this)
 {
-    SELFPARAM();
        entity last_pl = NULL;
        FOREACH_CLIENT(IS_PLAYER(it) && it != this, {
                if (!IS_DEAD(it))
@@ -293,12 +293,12 @@ entity ca_LastPlayerForTeam()
        return last_pl;
 }
 
-void ca_LastPlayerForTeam_Notify()
+void ca_LastPlayerForTeam_Notify(entity this)
 {
        if (round_handler_IsActive())
        if (round_handler_IsRoundStarted())
        {
-               entity pl = ca_LastPlayerForTeam();
+               entity pl = ca_LastPlayerForTeam(this);
                if (pl)
                        Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
        }
@@ -308,7 +308,7 @@ MUTATOR_HOOKFUNCTION(ca, PlayerDies)
 {
        entity frag_target = M_ARGV(2, entity);
        
-       ca_LastPlayerForTeam_Notify();
+       ca_LastPlayerForTeam_Notify(frag_target);
        if (!allowed_to_spawn)
                frag_target.respawn_flags =  RESPAWN_SILENT;
        if (!warmup_stage)
@@ -321,7 +321,7 @@ MUTATOR_HOOKFUNCTION(ca, ClientDisconnect)
     entity player = M_ARGV(0, entity);
 
        if (player.caplayer == 1)
-               ca_LastPlayerForTeam_Notify();
+               ca_LastPlayerForTeam_Notify(player);
        return true;
 }
 
@@ -335,7 +335,7 @@ MUTATOR_HOOKFUNCTION(ca, MakePlayerObserver)
     entity player = M_ARGV(0, entity);
 
        if (!IS_DEAD(player))
-               ca_LastPlayerForTeam_Notify();
+               ca_LastPlayerForTeam_Notify(player);
        if (player.killindicator_teamchange == -2)
                player.caplayer = 0;
        if (player.caplayer)
@@ -434,19 +434,24 @@ MUTATOR_HOOKFUNCTION(ca, Scores_CountFragsRemaining)
 
 MUTATOR_HOOKFUNCTION(ca, SpectateSet)
 {
-    SELFPARAM();
-       if (!autocvar_g_ca_spectate_enemies && this.caplayer)
-       if (DIFF_TEAM(spec_player, this))
+    entity client = M_ARGV(0, entity);
+    entity targ = M_ARGV(1, entity);
+
+       if (!autocvar_g_ca_spectate_enemies && client.caplayer)
+       if (DIFF_TEAM(targ, client))
                return true;
+
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(ca, SpectateNext)
 {
-    SELFPARAM();
-       if (!autocvar_g_ca_spectate_enemies && this.caplayer)
+    entity client = M_ARGV(0, entity);
+    entity targ = M_ARGV(1, entity);
+
+       if (!autocvar_g_ca_spectate_enemies && client.caplayer)
        {
-               spec_player = CA_SpectateNext(this, spec_player);
+               targ = CA_SpectateNext(client, targ);
                return true;
        }
        return false;
@@ -454,17 +459,20 @@ MUTATOR_HOOKFUNCTION(ca, SpectateNext)
 
 MUTATOR_HOOKFUNCTION(ca, SpectatePrev)
 {
-    SELFPARAM();
-       if (!autocvar_g_ca_spectate_enemies && this.caplayer)
+    entity client = M_ARGV(0, entity);
+    entity targ = M_ARGV(1, entity);
+    entity first = M_ARGV(2, entity);
+
+       if (!autocvar_g_ca_spectate_enemies && client.caplayer)
        {
-               do { spec_player = spec_player.chain; }
-               while(spec_player && DIFF_TEAM(spec_player, this));
+               do { targ = targ.chain; }
+               while(targ && DIFF_TEAM(targ, client));
 
-               if (!spec_player)
+               if (!targ)
                {
-                       for (spec_player = spec_first; spec_player && DIFF_TEAM(spec_player, this); spec_player = spec_player.chain);
+                       for (targ = first; targ && DIFF_TEAM(targ, client); targ = targ.chain);
 
-                       if (spec_player == this.enemy)
+                       if (targ == client.enemy)
                                return MUT_SPECPREV_RETURN;
                }
        }
@@ -476,20 +484,21 @@ MUTATOR_HOOKFUNCTION(ca, Bot_FixCount, CBC_ORDER_EXCLUSIVE)
 {
        FOREACH_CLIENT(IS_REAL_CLIENT(it), {
                if (IS_PLAYER(it) || it.caplayer == 1)
-                       ++bot_activerealplayers;
-               ++bot_realplayers;
+                       ++M_ARGV(0, int);
+               ++M_ARGV(1, int);
        });
        return true;
 }
 
 MUTATOR_HOOKFUNCTION(ca, ClientCommand_Spectate)
 {
-    SELFPARAM();
-       if (this.caplayer)
+    entity player = M_ARGV(0, entity);
+
+       if (player.caplayer)
        {
                // they're going to spec, we can do other checks
-               if (autocvar_sv_spectate && (IS_SPEC(this) || IS_OBSERVER(this)))
-                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_CA_LEAVE);
+               if (autocvar_sv_spectate && (IS_SPEC(player) || IS_OBSERVER(player)))
+                       Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_CA_LEAVE);
                return MUT_SPECCMD_FORCE;
        }
 
@@ -503,13 +512,15 @@ MUTATOR_HOOKFUNCTION(ca, WantWeapon)
 
 MUTATOR_HOOKFUNCTION(ca, GetPlayerStatus)
 {
-       return set_player.caplayer == 1;
+       entity player = M_ARGV(0, entity);
+
+       return player.caplayer == 1;
 }
 
 MUTATOR_HOOKFUNCTION(ca, SetWeaponArena)
 {
        // most weapons arena
-       if (ret_string == "0" || ret_string == "") ret_string = "most";
+       if (M_ARGV(0, string) == "0" || M_ARGV(0, string) == "") M_ARGV(0, string) = "most";
 }
 
 #endif