@@ -216,51 +216,8 @@ ServerLobby::ServerLobby() : LobbyProtocol()
216
216
((std::string) ServerConfig::m_help);
217
217
218
218
m_command_manager = CommandManager (nullptr );
219
-
220
- m_team_name_to_index = {
221
- {" red" , 1 }, {" r" , 1 },
222
- {" orange" , 2 }, {" o" , 2 },
223
- {" yellow" , 3 }, {" y" , 3 },
224
- {" green" , 4 }, {" g" , 4 },
225
- {" blue" , 5 }, {" b" , 5 },
226
- {" purple" , 6 }, {" p" , 6 },
227
- {" violet" , 6 }, {" v" , 6 },
228
- {" cyan" , 7 }, {" c" , 7 },
229
- {" magenta" , 8 }, {" m" , 8 },
230
- {" pink" , 8 },
231
- {" sky" , 9 }, {" s" , 9 }
232
- };
233
-
234
- m_team_default_names = {" none" , " red" , " orange" , " yellow" , " green" , " blue" , " purple" , " cyan" , " magenta" , " sky" };
235
-
236
- m_team_index_to_icon = {
237
- {1 , StringUtils::utf32ToUtf8 ({0x1f7e5 })},
238
- {2 , StringUtils::utf32ToUtf8 ({0x1f7e7 })},
239
- {3 , StringUtils::utf32ToUtf8 ({0x1f7e8 })},
240
- {4 , StringUtils::utf32ToUtf8 ({0x1f7e9 })},
241
- {5 , StringUtils::utf32ToUtf8 ({0x1f7e6 })},
242
- {6 , StringUtils::utf32ToUtf8 ({0x1f7ea })},
243
- {7 , StringUtils::utf32ToUtf8 ({0x1f5fd })},
244
- {8 , StringUtils::utf32ToUtf8 ({0x1f338 })},
245
- {9 , StringUtils::utf32ToUtf8 ({0x2604 })}
246
- };
247
-
248
- m_team_name = {" No Team" ,
249
- StringUtils::utf32ToUtf8 ({0x1f7e5 }) + " Red" ,
250
- StringUtils::utf32ToUtf8 ({0x1f7e7 }) + " Orange" ,
251
- StringUtils::utf32ToUtf8 ({0x1f7e8 }) + " Yellow" ,
252
- StringUtils::utf32ToUtf8 ({0x1f7e9 }) + " Green" ,
253
- StringUtils::utf32ToUtf8 ({0x1f7e6 }) + " Blue" ,
254
- StringUtils::utf32ToUtf8 ({0x1f7ea }) + " Purple" ,
255
- StringUtils::utf32ToUtf8 ({0x1f5fd }) + " Cyan" ,
256
- StringUtils::utf32ToUtf8 ({0x1f338 }) + " Magenta" ,
257
- StringUtils::utf32ToUtf8 ({ 0x2604 }) + " Sky"
258
- };
259
-
260
219
m_shuffle_gp = ServerConfig::m_shuffle_gp;
261
-
262
220
m_current_max_players_in_game.store (ServerConfig::m_max_players_in_game);
263
-
264
221
m_consent_on_replays = false ;
265
222
266
223
m_fixed_lap = ServerConfig::m_fixed_lap_count;
@@ -4644,7 +4601,7 @@ void ServerLobby::handleUnencryptedConnection(std::shared_ptr<STKPeer> peer,
4644
4601
auto it2 = m_team_for_player.find (username);
4645
4602
if (it2 != m_team_for_player.end ())
4646
4603
{
4647
- player->setTemporaryTeam (it2->second - 1 );
4604
+ player->setTemporaryTeam (it2->second );
4648
4605
}
4649
4606
peer->addPlayer (player);
4650
4607
}
@@ -4964,8 +4921,8 @@ void ServerLobby::updatePlayerList(bool update_when_reset_server)
4964
4921
prefix = " [" + prefix + " ] " ;
4965
4922
}
4966
4923
int team = profile->getTemporaryTeam ();
4967
- if (team != - 1 ) {
4968
- prefix = m_team_index_to_icon[ team + 1 ] + " " + prefix;
4924
+ if (team != 0 ) {
4925
+ prefix = TeamUtils::getTeamByIndex ( team). getEmoji () + " " + prefix;
4969
4926
}
4970
4927
4971
4928
profile_name = StringUtils::utf8ToWide (prefix) + profile_name;
@@ -7146,36 +7103,6 @@ void ServerLobby::initCategories()
7146
7103
}
7147
7104
}
7148
7105
}
7149
- /*
7150
- Temporary team indexing:
7151
- network_player_profile.hpp: -1 for none, [0..5] for teams
7152
- server config: (-1 for none,) [0..5] for teams
7153
- server lobby command: 0 for none, [1..6] for teams
7154
- m_team_for_player: 0 for none, [1..6] for teams
7155
- Sorry for the confusion.
7156
- */
7157
- // change categories according to the teams
7158
- for (const auto & who: m_team_for_player)
7159
- {
7160
- int idx = who.second ;
7161
- std::string player = who.first ;
7162
- for (const auto & pair: m_team_name_to_index)
7163
- {
7164
- if (pair.second < 0 )
7165
- {
7166
- if (pair.second == -idx)
7167
- {
7168
- m_player_categories[pair.first ].insert (player);
7169
- m_categories_for_player[player].insert (pair.first );
7170
- }
7171
- else
7172
- {
7173
- m_player_categories[pair.first ].erase (player);
7174
- m_categories_for_player[player].erase (pair.first );
7175
- }
7176
- }
7177
- }
7178
- }
7179
7106
} // initCategories
7180
7107
// -----------------------------------------------------------------------------
7181
7108
void ServerLobby::initTournamentPlayers ()
@@ -7527,7 +7454,7 @@ std::string ServerLobby::getGrandPrixStandings(bool showIndividual, bool showTea
7527
7454
for (unsigned i = 0 ; i < results2.size (); i++)
7528
7455
{
7529
7456
response << (i + 1 ) << " . " ;
7530
- response << " " << m_team_name[ results2[i].second ] ;
7457
+ response << " " << TeamUtils::getTeamByIndex ( results2[i].second ). getNameWithEmoji () ;
7531
7458
response << " " << results2[i].first .score ;
7532
7459
response << " " << " (" << StringUtils::timeToString (results2[i].first .time ) << " )" ;
7533
7460
response << " \n " ;
@@ -8165,8 +8092,7 @@ bool ServerLobby::isSoccerGoalTarget() const
8165
8092
// This should be moved later to another unit.
8166
8093
void ServerLobby::setTemporaryTeam (const std::string& username, std::string& arg)
8167
8094
{
8168
- auto it = m_team_name_to_index.find (arg);
8169
- int index = (it == m_team_name_to_index.end () ? 0 : it->second );
8095
+ int index = TeamUtils::getIndexByCode (arg);
8170
8096
m_team_for_player[username] = index ;
8171
8097
irr::core::stringw wide_player_name = StringUtils::utf8ToWide (username);
8172
8098
std::shared_ptr<STKPeer> player_peer = STKHost::get ()->findPeerByName (
@@ -8177,7 +8103,7 @@ void ServerLobby::setTemporaryTeam(const std::string& username, std::string& arg
8177
8103
{
8178
8104
if (profile->getName () == wide_player_name)
8179
8105
{
8180
- profile->setTemporaryTeam (index - 1 );
8106
+ profile->setTemporaryTeam (index );
8181
8107
break ;
8182
8108
}
8183
8109
}
@@ -8192,7 +8118,7 @@ void ServerLobby::clearTemporaryTeams()
8192
8118
8193
8119
for (auto & peer : STKHost::get ()->getPeers ())
8194
8120
for (auto & profile : peer->getPlayerProfiles ())
8195
- profile->setTemporaryTeam (- 1 );
8121
+ profile->setTemporaryTeam (0 );
8196
8122
} // clearTemporaryTeams
8197
8123
// -----------------------------------------------------------------------------
8198
8124
@@ -8209,9 +8135,9 @@ void ServerLobby::shuffleTemporaryTeams(const std::map<int, int>& permutation)
8209
8135
{
8210
8136
for (auto &profile: peer->getPlayerProfiles ())
8211
8137
{
8212
- auto it = permutation.find (profile->getTemporaryTeam () + 1 );
8138
+ auto it = permutation.find (profile->getTemporaryTeam ());
8213
8139
if (it != permutation.end ())
8214
- profile->setTemporaryTeam (it->second - 1 );
8140
+ profile->setTemporaryTeam (it->second );
8215
8141
}
8216
8142
}
8217
8143
auto old_scores = m_gp_team_scores;
0 commit comments