From d53311537bb618a7aedc564823817586583c22c5 Mon Sep 17 00:00:00 2001 From: terencehill Date: Wed, 19 Nov 2014 14:16:22 +0100 Subject: [PATCH] CA: mark eliminated players in the scoreboard --- qcsrc/client/Main.qc | 22 +++++++++++++++++ qcsrc/client/main.qh | 1 + qcsrc/client/scoreboard.qc | 4 +++ qcsrc/common/constants.qh | 2 +- qcsrc/server/mutators/gamemode_ca.qc | 37 ++++++++++++++++++++++++++++ qcsrc/server/mutators/gamemode_ca.qh | 1 + 6 files changed, 66 insertions(+), 1 deletion(-) diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index c0e37ae62..b712e675f 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -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; diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 815c20a33..5bf3e5bc6 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -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; diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index 52bf9190b..e01300df8 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -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")); diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index fb6d781c0..2be0112d7 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -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; diff --git a/qcsrc/server/mutators/gamemode_ca.qc b/qcsrc/server/mutators/gamemode_ca.qc index 0069de3bc..f8efe47a8 100644 --- a/qcsrc/server/mutators/gamemode_ca.qc +++ b/qcsrc/server/mutators/gamemode_ca.qc @@ -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) diff --git a/qcsrc/server/mutators/gamemode_ca.qh b/qcsrc/server/mutators/gamemode_ca.qh index a7c1edfc5..43b403242 100644 --- a/qcsrc/server/mutators/gamemode_ca.qh +++ b/qcsrc/server/mutators/gamemode_ca.qh @@ -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; -- 2.39.2