diff --git a/src/server/gamerules.h b/src/server/gamerules.h index 83bf958..2579e65 100644 --- a/src/server/gamerules.h +++ b/src/server/gamerules.h @@ -18,19 +18,17 @@ class TFCGameRules:CGameRules { void(void) TFCGameRules; - virtual bool(void) IsTeamplay; - - virtual void(NSClientPlayer) PlayerConnect; - virtual void(NSClientPlayer) PlayerDisconnect; - virtual void(NSClientPlayer) PlayerPostFrame; - virtual void(NSClientPlayer) PlayerSpawn; - virtual void(NSClientPlayer) PlayerKill; - virtual void(NSClientPlayer) PlayerRespawn; - virtual void(NSClientPlayer) PlayerDeath; - - virtual void(NSClientPlayer) DropGoalItem; + virtual bool IsTeamplay(void); + virtual void PlayerConnect(NSClientPlayer); + virtual void PlayerDisconnect(NSClientPlayer); + virtual void PlayerPostFrame(NSClientPlayer); + virtual void PlayerSpawn(NSClientPlayer); + virtual void PlayerKill(NSClientPlayer); + virtual void PlayerRespawn(NSClientPlayer); + virtual void PlayerDeath(NSClientPlayer); + virtual void DropGoalItem(NSClientPlayer); virtual float ImpulseCommand(NSClient, float); - - virtual void(void) LevelNewParms; + virtual void LevelNewParms(void); + virtual void InitPostEnts(void); }; diff --git a/src/server/gamerules.qc b/src/server/gamerules.qc index 6e93376..f67bc8c 100644 --- a/src/server/gamerules.qc +++ b/src/server/gamerules.qc @@ -168,13 +168,57 @@ TFCGameRules::ImpulseCommand(NSClient bp, float num) return true; } +void +TFCGameRules::InitPostEnts(void) +{ + int team_count = 0i; + entity e = __NULL__; + + super::InitPostEnts(); + + /* populate the serverinfo field with the teams we have on the map */ + e = find(world, ::classname, "info_teamspawn_blue"); + if (e) { + team_count += 1; + forceinfokey(world, sprintf("team_%i", team_count), "Blue"); + forceinfokey(world, sprintf("teamscore_%i", team_count), "0"); + } + + e = find(world, ::classname, "info_teamspawn_red"); + if (e) { + team_count += 1; + forceinfokey(world, sprintf("team_%i", team_count), "Red"); + forceinfokey(world, sprintf("teamscore_%i", team_count), "0"); + } + + e = find(world, ::classname, "info_teamspawn_green"); + if (e) { + team_count += 1; + forceinfokey(world, sprintf("team_%i", team_count), "Green"); + forceinfokey(world, sprintf("teamscore_%i", team_count), "0"); + } + + e = find(world, ::classname, "info_teamspawn_yellow"); + if (e) { + team_count += 1; + forceinfokey(world, sprintf("team_%i", team_count), "Yellow"); + forceinfokey(world, sprintf("teamscore_%i", team_count), "0"); + } + + forceinfokey(world, "teams", itos(team_count)); +} + void TFCGameRules::TFCGameRules(void) { - /* TODO: Make this depend on the actual spawn types */ - forceinfokey(world, "teams", "2"); - forceinfokey(world, "team_1", "Blue"); - forceinfokey(world, "teamscore_1", "0"); - forceinfokey(world, "team_2", "Red"); - forceinfokey(world, "teamscore_2", "0"); + /* wipe the serverinfo clean */ + forceinfokey(world, "teams", "0"); + forceinfokey(world, "team_1", ""); + forceinfokey(world, "team_2", ""); + forceinfokey(world, "team_3", ""); + forceinfokey(world, "team_4", ""); + forceinfokey(world, "teamscore_1", ""); + forceinfokey(world, "teamscore_2", ""); + forceinfokey(world, "teamscore_3", ""); + forceinfokey(world, "teamscore_4", ""); }