]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
CA: mark eliminated players in the scoreboard
authorterencehill <piuntn@gmail.com>
Wed, 19 Nov 2014 13:16:22 +0000 (14:16 +0100)
committerterencehill <piuntn@gmail.com>
Wed, 19 Nov 2014 13:16:22 +0000 (14:16 +0100)
qcsrc/client/Main.qc
qcsrc/client/main.qh
qcsrc/client/scoreboard.qc
qcsrc/common/constants.qh
qcsrc/server/mutators/gamemode_ca.qc
qcsrc/server/mutators/gamemode_ca.qh

index c0e37ae62177b536a0d60a085ae6b056684241b8..b712e675fa41550b5f7b300eb567ede55d2a5a5a 100644 (file)
@@ -606,6 +606,27 @@ void Ent_Nagger()
        warmup_stage = (nags & 16);
 }
 
+void Ent_EliminatedPlayers()
+{
+       float sf, i, j, b, f;
+
+       sf = ReadByte();
+       if(sf & 1)
+       {
+               for(j = 0; j < maxclients; ++j)
+                       if(playerslots[j])
+                               playerslots[j].eliminated = 1;
+               for(i = 1; i <= maxclients; i += 8)
+               {
+                       f = ReadByte();
+                       for(j = i-1, b = 1; b < 256; b *= 2, ++j)
+                               if (!(f & b))
+                                       if(playerslots[j])
+                                               playerslots[j].eliminated = 0;
+               }
+       }
+}
+
 void Ent_RandomSeed()
 {
        float s;
@@ -804,6 +825,7 @@ void CSQC_Ent_Update(float bIsNewEntity)
                case ENT_CLIENT_RAINSNOW: Ent_RainOrSnow(); break;
                case ENT_CLIENT_LASER: Ent_Laser(); break;
                case ENT_CLIENT_NAGGER: Ent_Nagger(); break;
+               case ENT_CLIENT_ELIMINATEDPLAYERS: Ent_EliminatedPlayers(); break;
                case ENT_CLIENT_WAYPOINT: Ent_WaypointSprite(); break;
                case ENT_CLIENT_RADARLINK: Ent_RadarLink(); break;
                case ENT_CLIENT_PROJECTILE: Ent_Projectile(); break;
index 815c20a33ed1788eb16129b136bfe18372f3fe87..5bf3e5bc61fc47e2b5d8fce0e20cce11e0d5024d 100644 (file)
@@ -86,6 +86,7 @@ entity teamslots[17];    // 17 teams (including "spectator team")
 .float gotscores;
 .entity owner;
 .float ready;
+.float eliminated;
 
 .void(void) draw;
 .void(void) draw2d;
index 52bf9190b5e0edb2c8aa26cc156d11a601295a2f..e01300df8365c50011f834a5863723054abdc4d1 100644 (file)
@@ -541,6 +541,10 @@ string HUD_GetField(entity pl, float field)
                        {
                                hud_field_icon0 = "gfx/scoreboard/player_ready";
                        }
+                       if(pl.eliminated)
+                       {
+                               hud_field_icon0 = "gfx/scoreboard/player_ready"; // TODO: different icon
+                       }
                        else if(!teamplay)
                        {
                                f = stof(getplayerkeyvalue(pl.sv_entnum, "colors"));
index fb6d781c0c1e16e10e5cfb4fa3a591537b311050..2be0112d79ea149954224636dfb225c70704392a 100644 (file)
@@ -96,7 +96,7 @@ const float ENT_CLIENT_BUMBLE_RAYGUN = 35;
 const float ENT_CLIENT_SPAWNPOINT = 36;
 const float ENT_CLIENT_SPAWNEVENT = 37;
 const float ENT_CLIENT_NOTIFICATION = 38;
-
+const float ENT_CLIENT_ELIMINATEDPLAYERS = 39;
 const float ENT_CLIENT_TURRET = 40;
 const float ENT_CLIENT_AUXILIARYXHAIR = 50;
 const float ENT_CLIENT_VEHICLE = 60;
index 0069de3bcb7ef35805d2f73330ac00ef47fc1eef..f8efe47a881bfaedd6d324deecee2d17232e4e83 100644 (file)
@@ -143,9 +143,40 @@ float CA_CheckTeams()
        return 0;
 }
 
+float EliminatedPlayers_SendEntity(entity to, float sendflags)
+{
+       float i, f, b;
+       entity e;
+       WriteByte(MSG_ENTITY, ENT_CLIENT_ELIMINATEDPLAYERS);
+       WriteByte(MSG_ENTITY, sendflags);
+
+       if(sendflags & 1)
+       {
+               for(i = 1; i <= maxclients; i += 8)
+               {
+                       for(f = 0, e = edict_num(i), b = 1; b < 256; b *= 2, e = nextent(e))
+                       {
+                               if(e.caplayer == 0.5 || (e.caplayer == 1 && (e.deadflag != DEAD_NO || e.frags == FRAGS_LMS_LOSER)))
+                                       f |= b;
+                       }
+                       WriteByte(MSG_ENTITY, f);
+               }
+       }
+
+       return TRUE;
+}
+
+void EliminatedPlayers_Init()
+{
+       Net_LinkEntity(eliminatedPlayers = spawn(), FALSE, 0, EliminatedPlayers_SendEntity);
+}
+
+
 MUTATOR_HOOKFUNCTION(ca_PlayerSpawn)
 {
        self.caplayer = 1;
+       if(!warmup_stage)
+               eliminatedPlayers.SendFlags |= 1;
        return 1;
 }
 
@@ -236,6 +267,8 @@ MUTATOR_HOOKFUNCTION(ca_PlayerDies)
        ca_LastPlayerForTeam_Notify();
        if(!allowed_to_spawn)
                self.respawn_flags =  RESPAWN_SILENT;
+       if(!warmup_stage)
+               eliminatedPlayers.SendFlags |= 1;
        return 1;
 }
 
@@ -259,6 +292,8 @@ MUTATOR_HOOKFUNCTION(ca_MakePlayerObserver)
                self.caplayer = 0;
        if(self.caplayer)
                self.frags = FRAGS_LMS_LOSER;
+       if(!warmup_stage)
+               eliminatedPlayers.SendFlags |= 1;
        return 1;
 }
 
@@ -345,6 +380,8 @@ void ca_Initialize()
        addstat(STAT_BLUEALIVE, AS_INT, bluealive_stat);
        addstat(STAT_YELLOWALIVE, AS_INT, yellowalive_stat);
        addstat(STAT_PINKALIVE, AS_INT, pinkalive_stat);
+
+       EliminatedPlayers_Init();
 }
 
 MUTATOR_DEFINITION(gamemode_ca)
index a7c1edfc53870a43666b596eac2f533dc2ebab7b..43b4032427f97947c824f78db4f71bce6f787ac6 100644 (file)
@@ -1,2 +1,3 @@
 // should be removed in the future, as other code should not have to care
 .float caplayer; // 0.5 if scheduled to join the next round
+entity eliminatedPlayers;