TFCGameRules: populate serverinfo with teams actually detected to be playable on a given map.

This commit is contained in:
Marco Cawthorne 2023-01-19 16:53:51 -08:00
parent 83304cc7a5
commit 81e27e8502
Signed by: eukara
GPG key ID: CE2032F0A2882A22
2 changed files with 61 additions and 19 deletions

View file

@ -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);
};

View file

@ -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", "");
}