Skip to content

Commit e55659c

Browse files
committed
Synchronize KartTeam and 'temporary teams', add a few spectate modes
Both KartTeam and temporary teams are still present, but now ServerLobby ensures that their values correspond to each other. In particular: - you can use commands on temporary teams also on soccer/ctf teams now - you can change the set of available teams in racing/ffa with /availableteams - when changing from racing/ffa to soccer/ctf, /randomteams 2 is done - when changing from soccer/ctf to racing/ffa, teams are cleared - unlike standard implementation, soccer team is not just "not sent", it is defined as KART_TEAM_NONE in racing/ffa - you can set an absent team in soccer/ctf, but that will trigger a new ASM_NO_TEAM spectate mode, which goes away if the mode becomes racing/ffa - as another spectate mode was added, I also added /spectate 2 which allows you to skip games but also not watch them. Yes, it goes against the command name, but sometimes it's really needed. Without arguments /spectate still goes between 0 and 1. - probably something else was done, I forgot already. Hoping nothing crashes
1 parent f0dfa7b commit e55659c

12 files changed

+463
-140
lines changed

NETWORKING.md

+3
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,9 @@ A typical current server configuration xml that fits the current code version is
391391
<!-- Specifies how the server should decide which map vote wins in map selection. 0 corresponds to standard system, 1 - to randomly selecting one of votes. -->
392392
<map-vote-handling value="0" />
393393

394+
<!-- Codes of teams initially available on the server. Format is any subset of rbygopcms (the teams currently available). You can change it from the lobby using hammer command(s), and this will be overridden during soccer and ctf modes. -->
395+
<available-teams value="rbygopcms" />
396+
394397
</server-config>
395398
```
396399

data/commands.xml

+17-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ here later. For now, please refer to the code for the strings being used. -->
3939
/>
4040
</command>
4141
<command name="spectate"
42-
usage="/spectate [0 | 1]"
42+
usage="/spectate [0 | 1 | 2]"
4343
permissions-verbose="everyone"
44-
description="Toggles autospectate mode."
44+
description="Toggles autospectate mode. 0 corresponds to normal mode, 1 - to spectating mode, 2 - to staying permanently in the lobby and not watching."
4545
/>
4646
<command name="addons"
4747
usage="/addons [type]"
@@ -1129,6 +1129,21 @@ here later. For now, please refer to the code for the strings being used. -->
11291129
permissions="UP_EVERYONE"
11301130
state-scope="SS_LOBBY"
11311131
/>
1132+
<command name="availableteams"
1133+
usage="/availableteams"
1134+
permissions-verbose="everyone"
1135+
description="Shows which teams are available on the server. When the mode is soccer or CTF, there are always red and blue teams; in that case, the command shows what will be available in case the mode is changed."
1136+
permissions="UP_EVERYONE"
1137+
state-scope="SS_LOBBY"
1138+
>
1139+
<command name="="
1140+
usage="/availableteams (all, or string of chars rbygopcms which can be empty if quoted)"
1141+
omit-name="true"
1142+
permissions-verbose="hammers"
1143+
description="Allows to set which teams will be available (when the mode is soccer or CTF, acts for the next time when the mode changes to something else)."
1144+
permissions="UP_HAMMER"
1145+
/>
1146+
</command>
11321147
<command name="addondownloadprogress"
11331148
usage="/addondownloadprogress"
11341149
permissions-verbose="everyone (client command)"

src/network/game_setup.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,10 @@ void GameSetup::sortPlayersForGame(
193193
return;
194194
for (unsigned i = 0; i < players.size(); i++)
195195
{
196+
// The same as ServerLobby::setTeamInLobby, but without server lobby.
197+
// Checks for spectate modes are not needed here.
196198
players[i]->setTeam((KartTeam)(i % 2));
199+
players[i]->setTemporaryTeam(TeamUtils::getIndexFromKartTeam(i % 2));
197200
}
198201
} // sortPlayersForGame
199202

src/network/network_player_profile.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class NetworkPlayerProfile
9696
m_handicap.store((HandicapLevel)0);
9797
m_local_player_id = 0;
9898
m_team.store(team);
99-
m_temporary_team = 0;
99+
m_temporary_team = TeamUtils::getIndexFromKartTeam(team);
100100
resetGrandPrixData();
101101
}
102102
// ------------------------------------------------------------------------
@@ -116,7 +116,7 @@ class NetworkPlayerProfile
116116
m_local_player_id = local_player_id;
117117
m_team.store(team);
118118
m_country_code = country_code;
119-
m_temporary_team = 0;
119+
m_temporary_team = TeamUtils::getIndexFromKartTeam(team);
120120
resetGrandPrixData();
121121
}
122122
// ------------------------------------------------------------------------
@@ -150,7 +150,7 @@ class NetworkPlayerProfile
150150
// ------------------------------------------------------------------------
151151
float getDefaultKartColor() const
152152
{
153-
if (m_temporary_team == 0)
153+
if (m_temporary_team == TeamUtils::NO_TEAM)
154154
return m_default_kart_color;
155155
return TeamUtils::getTeamByIndex(m_temporary_team).getColor();
156156
}

0 commit comments

Comments
 (0)