Reserve code for country from players
This commit is contained in:
parent
bb84677e35
commit
45a55a4c9b
@ -69,6 +69,8 @@ private:
|
||||
|
||||
std::atomic<KartTeam> m_team;
|
||||
|
||||
std::string m_country_id;
|
||||
|
||||
public:
|
||||
// ------------------------------------------------------------------------
|
||||
static std::shared_ptr<NetworkPlayerProfile>
|
||||
@ -95,7 +97,8 @@ public:
|
||||
const irr::core::stringw &name, uint32_t host_id,
|
||||
float default_kart_color, uint32_t online_id,
|
||||
PerPlayerDifficulty per_player_difficulty,
|
||||
uint8_t local_player_id, KartTeam team)
|
||||
uint8_t local_player_id, KartTeam team,
|
||||
const std::string& country_id)
|
||||
{
|
||||
m_peer = peer;
|
||||
m_player_name = name;
|
||||
@ -105,6 +108,7 @@ public:
|
||||
m_per_player_difficulty.store(per_player_difficulty);
|
||||
m_local_player_id = local_player_id;
|
||||
m_team.store(team);
|
||||
m_country_id = country_id;
|
||||
resetGrandPrixData();
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
@ -159,7 +163,8 @@ public:
|
||||
void setTeam(KartTeam team) { m_team.store(team); }
|
||||
// ------------------------------------------------------------------------
|
||||
KartTeam getTeam() const { return m_team.load(); }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
const std::string& getCountryId() const { return m_country_id; }
|
||||
}; // class NetworkPlayerProfile
|
||||
|
||||
#endif // HEADER_NETWORK_PLAYER_PROFILE
|
||||
|
@ -267,8 +267,10 @@ void ClientLobby::addAllPlayers(Event* event)
|
||||
PerPlayerDifficulty ppd = (PerPlayerDifficulty)data.getUInt8();
|
||||
uint8_t local_id = data.getUInt8();
|
||||
KartTeam team = (KartTeam)data.getUInt8();
|
||||
std::string country_id;
|
||||
data.decodeString(&country_id);
|
||||
auto player = std::make_shared<NetworkPlayerProfile>(peer, player_name,
|
||||
host_id, kart_color, online_id, ppd, local_id, team);
|
||||
host_id, kart_color, online_id, ppd, local_id, team, country_id);
|
||||
std::string kart_name;
|
||||
data.decodeString(&kart_name);
|
||||
player->setKartName(kart_name);
|
||||
@ -736,6 +738,7 @@ void ClientLobby::updatePlayerList(Event* event)
|
||||
auto& local_players = NetworkConfig::get()->getNetworkPlayers();
|
||||
std::get<2>(local_players.at(local_id)) = lp.m_difficulty;
|
||||
}
|
||||
data.decodeString(&lp.m_country_id);
|
||||
m_lobby_players.push_back(lp);
|
||||
}
|
||||
|
||||
@ -1168,6 +1171,8 @@ void ClientLobby::handleKartInfo(Event* event)
|
||||
uint8_t local_id = data.getUInt8();
|
||||
std::string kart_name;
|
||||
data.decodeString(&kart_name);
|
||||
std::string country_id;
|
||||
data.decodeString(&country_id);
|
||||
|
||||
RemoteKartInfo& rki = race_manager->getKartInfo(kart_id);
|
||||
rki.setPlayerName(player_name);
|
||||
@ -1177,6 +1182,7 @@ void ClientLobby::handleKartInfo(Event* event)
|
||||
rki.setPerPlayerDifficulty(ppd);
|
||||
rki.setLocalPlayerId(local_id);
|
||||
rki.setKartName(kart_name);
|
||||
rki.setCountryId(country_id);
|
||||
addLiveJoiningKart(kart_id, rki, live_join_util_ticks);
|
||||
|
||||
core::stringw msg;
|
||||
|
@ -46,6 +46,7 @@ struct LobbyPlayer
|
||||
uint32_t m_online_id;
|
||||
/* Icon used in networking lobby, see NetworkingLobby::loadedFromFile. */
|
||||
int m_icon_id;
|
||||
std::string m_country_id;
|
||||
/* Icon id for spectator in NetworkingLobby::loadedFromFile is 5. */
|
||||
bool isSpectator() const { return m_icon_id == 5; }
|
||||
};
|
||||
|
@ -133,6 +133,7 @@ void LobbyProtocol::configRemoteKart(
|
||||
rki.setOnlineId(profile->getOnlineId());
|
||||
if (race_manager->teamEnabled())
|
||||
rki.setKartTeam(profile->getTeam());
|
||||
rki.setCountryId(profile->getCountryId());
|
||||
rki.setNetworkPlayerProfile(profile);
|
||||
// Inform the race manager about the data for this kart.
|
||||
race_manager->setPlayerKart(i, rki);
|
||||
|
@ -642,7 +642,8 @@ NetworkString* ServerLobby::getLoadWorldMessage(
|
||||
.addUInt8(player->getPerPlayerDifficulty())
|
||||
.addUInt8(player->getLocalPlayerId())
|
||||
.addUInt8(
|
||||
race_manager->teamEnabled() ? player->getTeam() : KART_TEAM_NONE);
|
||||
race_manager->teamEnabled() ? player->getTeam() : KART_TEAM_NONE)
|
||||
.encodeString(player->getCountryId());
|
||||
if (player->getKartName().empty())
|
||||
{
|
||||
RandomGenerator rg;
|
||||
@ -811,7 +812,8 @@ void ServerLobby::liveJoinRequest(Event* event)
|
||||
std::numeric_limits<uint32_t>::max(),
|
||||
rki.getDefaultKartColor(),
|
||||
rki.getOnlineId(), rki.getDifficulty(),
|
||||
rki.getLocalPlayerId(), KART_TEAM_NONE);
|
||||
rki.getLocalPlayerId(), KART_TEAM_NONE,
|
||||
rki.getCountryId());
|
||||
player->setKartName(rki.getKartName());
|
||||
}
|
||||
else
|
||||
@ -2224,7 +2226,8 @@ void ServerLobby::handleUnencryptedConnection(std::shared_ptr<STKPeer> peer,
|
||||
auto player = std::make_shared<NetworkPlayerProfile>
|
||||
(peer, i == 0 && !online_name.empty() ? online_name : name,
|
||||
peer->getHostId(), default_kart_color, i == 0 ? online_id : 0,
|
||||
per_player_difficulty, (uint8_t)i, KART_TEAM_NONE);
|
||||
per_player_difficulty, (uint8_t)i, KART_TEAM_NONE,
|
||||
""/* reserved for country id */);
|
||||
if (ServerConfig::m_team_choosing)
|
||||
{
|
||||
KartTeam cur_team = KART_TEAM_NONE;
|
||||
@ -2346,6 +2349,7 @@ void ServerLobby::updatePlayerList(bool update_when_reset_server)
|
||||
m_peers_ready.find(p) != m_peers_ready.end() &&
|
||||
m_peers_ready.at(p)) ? 1 : 0;
|
||||
pl->addUInt8(ready);
|
||||
pl->encodeString(profile->getCountryId());
|
||||
}
|
||||
|
||||
// Don't send this message to in-game players
|
||||
@ -3473,7 +3477,7 @@ void ServerLobby::handleKartInfo(Event* event)
|
||||
.addUInt32(rki.getHostId()).addFloat(rki.getDefaultKartColor())
|
||||
.addUInt32(rki.getOnlineId()).addUInt8(rki.getDifficulty())
|
||||
.addUInt8((uint8_t)rki.getLocalPlayerId())
|
||||
.encodeString(rki.getKartName());
|
||||
.encodeString(rki.getKartName()).encodeString(rki.getCountryId());
|
||||
peer->sendPacket(ns, true/*reliable*/);
|
||||
delete ns;
|
||||
} // handleKartInfo
|
||||
|
@ -29,5 +29,6 @@ void RemoteKartInfo::copyFrom(std::shared_ptr<NetworkPlayerProfile> p,
|
||||
m_difficulty = p->getPerPlayerDifficulty();
|
||||
m_default_kart_color = p->getPerPlayerDifficulty();
|
||||
m_online_id = p->getOnlineId();
|
||||
m_country_id = p->getCountryId();
|
||||
m_profile = p;
|
||||
} // copyFrom
|
||||
|
@ -57,6 +57,7 @@ class RemoteKartInfo
|
||||
PerPlayerDifficulty m_difficulty;
|
||||
float m_default_kart_color;
|
||||
uint32_t m_online_id;
|
||||
std::string m_country_id;
|
||||
std::weak_ptr<NetworkPlayerProfile> m_profile;
|
||||
public:
|
||||
RemoteKartInfo(int player_id, const std::string& kart_name,
|
||||
@ -105,6 +106,8 @@ public:
|
||||
PerPlayerDifficulty getDifficulty() const { return m_difficulty; }
|
||||
float getDefaultKartColor() const { return m_default_kart_color; }
|
||||
uint32_t getOnlineId() const { return m_online_id; }
|
||||
void setCountryId(const std::string& id) { m_country_id = id; }
|
||||
const std::string& getCountryId() const { return m_country_id; }
|
||||
void setNetworkPlayerProfile(
|
||||
std::weak_ptr<NetworkPlayerProfile> npp) { m_profile = npp; }
|
||||
std::weak_ptr<NetworkPlayerProfile> getNetworkPlayerProfile() const
|
||||
|
Loading…
Reference in New Issue
Block a user