]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc
Add API to handle in-game status for game modes that temporarily turn players into...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / clanarena / sv_clanarena.qc
index 3d0c292617f9596d0c0ce3c68d9cf374e23de8e5..866a00419c36c0a2be08367f156c3b4c98d98cca 100644 (file)
@@ -125,9 +125,9 @@ bool CA_CheckTeams()
 
 bool ca_isEliminated(entity e)
 {
-       if(e.caplayer == 1 && (IS_DEAD(e) || e.frags == FRAGS_PLAYER_OUT_OF_GAME))
+       if(INGAME_JOINED(e) && (IS_DEAD(e) || e.frags == FRAGS_PLAYER_OUT_OF_GAME))
                return true;
-       if(e.caplayer == 0.5)
+       if(INGAME_JOINING(e))
                return true;
        return false;
 }
@@ -154,7 +154,7 @@ MUTATOR_HOOKFUNCTION(ca, PlayerSpawn)
 {
        entity player = M_ARGV(0, entity);
 
-       player.caplayer = 1;
+       INGAME_STATUS_SET(player, INGAME_STATUS_JOINED);
        if (!warmup_stage)
                eliminatedPlayers.SendFlags |= 1;
 }
@@ -166,7 +166,7 @@ MUTATOR_HOOKFUNCTION(ca, ForbidSpawn)
        // spectators / observers that weren't playing can join; they are
        // immediately forced to observe in the PutClientInServer hook
        // this way they are put in a team and can play in the next round
-       if (!allowed_to_spawn && player.caplayer)
+       if (!allowed_to_spawn && INGAME(player))
                return true;
        return false;
 }
@@ -178,9 +178,9 @@ MUTATOR_HOOKFUNCTION(ca, PutClientInServer)
        if (!allowed_to_spawn && IS_PLAYER(player)) // this is true even when player is trying to join
        {
                TRANSMUTE(Observer, player);
-               if (CS(player).jointime != time && !player.caplayer) // not when connecting
+               if (CS(player).jointime != time && !INGAME(player)) // not when connecting
                {
-                       player.caplayer = 0.5;
+                       INGAME_STATUS_SET(player, INGAME_STATUS_JOINING);
                        Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_CA_JOIN_LATE);
                }
        }
@@ -190,15 +190,15 @@ MUTATOR_HOOKFUNCTION(ca, reset_map_players)
 {
        FOREACH_CLIENT(true, {
                CS(it).killcount = 0;
-               if (!it.caplayer && IS_BOT_CLIENT(it))
+               if (!INGAME(it) && IS_BOT_CLIENT(it))
                {
                        it.team = -1;
-                       it.caplayer = 1;
+                       INGAME_STATUS_SET(it, INGAME_STATUS_JOINED);
                }
-               if (it.caplayer)
+               if (INGAME(it))
                {
                        TRANSMUTE(Player, it);
-                       it.caplayer = 1;
+                       INGAME_STATUS_SET(it, INGAME_STATUS_JOINED);
                        PutClientInServer(it);
                }
        });
@@ -273,21 +273,21 @@ MUTATOR_HOOKFUNCTION(ca, MakePlayerObserver)
        entity player = M_ARGV(0, entity);
 
        bool is_forced = M_ARGV(1, bool);
-       if (is_forced && player.caplayer)
-               player.caplayer = 0;
+       if (is_forced && INGAME(player))
+               INGAME_STATUS_CLEAR(player);
 
        if (IS_PLAYER(player) && !IS_DEAD(player))
                ca_LastPlayerForTeam_Notify(player);
        if (player.killindicator_teamchange == -2) // player wants to spectate
        {
                entcs_update_players(player);
-               player.caplayer = 0;
+               INGAME_STATUS_CLEAR(player);
        }
-       if (player.caplayer)
+       if (INGAME(player))
                player.frags = FRAGS_PLAYER_OUT_OF_GAME;
        if (!warmup_stage)
                eliminatedPlayers.SendFlags |= 1;
-       if (!player.caplayer)
+       if (!INGAME(player))
                return false;  // allow team reset
        return true;  // prevent team reset
 }
@@ -411,7 +411,7 @@ MUTATOR_HOOKFUNCTION(ca, SpectateSet)
        entity client = M_ARGV(0, entity);
        entity targ = M_ARGV(1, entity);
 
-       if (!autocvar_g_ca_spectate_enemies && client.caplayer)
+       if (!autocvar_g_ca_spectate_enemies && INGAME(client))
        if (DIFF_TEAM(targ, client))
                return true;
 }
@@ -420,7 +420,7 @@ MUTATOR_HOOKFUNCTION(ca, SpectateNext)
 {
        entity client = M_ARGV(0, entity);
 
-       if (!autocvar_g_ca_spectate_enemies && client.caplayer
+       if (!autocvar_g_ca_spectate_enemies && INGAME(client)
                && Team_GetNumberOfAlivePlayers(Entity_GetTeam(client)))
        {
                entity targ = M_ARGV(1, entity);
@@ -435,7 +435,7 @@ MUTATOR_HOOKFUNCTION(ca, SpectatePrev)
        entity targ = M_ARGV(1, entity);
        entity first = M_ARGV(2, entity);
 
-       if (!autocvar_g_ca_spectate_enemies && client.caplayer
+       if (!autocvar_g_ca_spectate_enemies && INGAME(client)
                && Team_GetNumberOfAlivePlayers(Entity_GetTeam(client)))
        {
                do { targ = targ.chain; }
@@ -460,7 +460,7 @@ MUTATOR_HOOKFUNCTION(ca, SpectatePrev)
 MUTATOR_HOOKFUNCTION(ca, Bot_FixCount, CBC_ORDER_EXCLUSIVE)
 {
        FOREACH_CLIENT(IS_REAL_CLIENT(it), {
-               if (IS_PLAYER(it) || it.caplayer == 1)
+               if (IS_PLAYER(it) || INGAME_JOINED(it))
                        ++M_ARGV(0, int);
                ++M_ARGV(1, int);
        });
@@ -471,7 +471,7 @@ MUTATOR_HOOKFUNCTION(ca, ClientCommand_Spectate)
 {
        entity player = M_ARGV(0, entity);
 
-       if (player.caplayer)
+       if (INGAME(player))
        {
                // they're going to spec, we can do other checks
                if (autocvar_sv_spectate && (IS_SPEC(player) || IS_OBSERVER(player)))
@@ -487,13 +487,6 @@ MUTATOR_HOOKFUNCTION(ca, HideTeamNagger)
        return true; // doesn't work well with the whole spectator as player thing
 }
 
-MUTATOR_HOOKFUNCTION(ca, GetPlayerStatus)
-{
-       entity player = M_ARGV(0, entity);
-
-       return player.caplayer == 1;
-}
-
 MUTATOR_HOOKFUNCTION(ca, SetWeaponArena)
 {
        if (M_ARGV(0, string) == "0" || M_ARGV(0, string) == "")