diff --git a/NETWORKING.md b/NETWORKING.md index a0d1f6cd3..8b068d4ad 100644 --- a/NETWORKING.md +++ b/NETWORKING.md @@ -229,7 +229,7 @@ CREATE TABLE IF NOT EXISTS (table name above) online_id INTEGER UNSIGNED NOT NULL, -- Online if of the host (0 for offline account) username TEXT NOT NULL, -- First player name in the host (if the host has splitscreen player) player_num INTEGER UNSIGNED NOT NULL, -- Number of player(s) from the host, more than 1 if it has splitscreen player - country_id TEXT NULL DEFAULT NULL, -- Country id of the host + country_code TEXT NULL DEFAULT NULL, -- 2-letter country code of the host version TEXT NOT NULL, -- SuperTuxKart version of the host (with OS info) connected_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- Time when connected disconnected_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- Time when disconnected (saved when disconnected) diff --git a/src/network/network_player_profile.hpp b/src/network/network_player_profile.hpp index 7909bfcba..6cf6c38d4 100644 --- a/src/network/network_player_profile.hpp +++ b/src/network/network_player_profile.hpp @@ -69,7 +69,8 @@ private: std::atomic m_team; - std::string m_country_id; + /** 2-letter country code of player. */ + std::string m_country_code; public: // ------------------------------------------------------------------------ @@ -98,7 +99,7 @@ public: float default_kart_color, uint32_t online_id, PerPlayerDifficulty per_player_difficulty, uint8_t local_player_id, KartTeam team, - const std::string& country_id) + const std::string& country_code) { m_peer = peer; m_player_name = name; @@ -108,7 +109,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; + m_country_code = country_code; resetGrandPrixData(); } // ------------------------------------------------------------------------ @@ -164,7 +165,7 @@ public: // ------------------------------------------------------------------------ KartTeam getTeam() const { return m_team.load(); } // ------------------------------------------------------------------------ - const std::string& getCountryId() const { return m_country_id; } + const std::string& getCountryCode() const { return m_country_code; } }; // class NetworkPlayerProfile #endif // HEADER_NETWORK_PLAYER_PROFILE diff --git a/src/network/protocols/client_lobby.cpp b/src/network/protocols/client_lobby.cpp index c9bdd2cdf..53f2b93d0 100644 --- a/src/network/protocols/client_lobby.cpp +++ b/src/network/protocols/client_lobby.cpp @@ -329,12 +329,12 @@ std::vector > PerPlayerDifficulty ppd = (PerPlayerDifficulty)data.getUInt8(); uint8_t local_id = data.getUInt8(); KartTeam team = (KartTeam)data.getUInt8(); - std::string country_id; - data.decodeString(&country_id); + std::string country_code; + data.decodeString(&country_code); if (is_specator && host_id == STKHost::get()->getMyHostId()) *is_specator = false; auto player = std::make_shared(peer, player_name, - host_id, kart_color, online_id, ppd, local_id, team, country_id); + host_id, kart_color, online_id, ppd, local_id, team, country_code); std::string kart_name; data.decodeString(&kart_name); player->setKartName(kart_name); @@ -783,7 +783,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); + data.decodeString(&lp.m_country_code); m_lobby_players.push_back(lp); } STKHost::get()->setAuthorisedToControl(client_server_owner); @@ -1261,8 +1261,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); + std::string country_code; + data.decodeString(&country_code); RemoteKartInfo& rki = race_manager->getKartInfo(kart_id); rki.setPlayerName(player_name); @@ -1272,7 +1272,7 @@ void ClientLobby::handleKartInfo(Event* event) rki.setPerPlayerDifficulty(ppd); rki.setLocalPlayerId(local_id); rki.setKartName(kart_name); - rki.setCountryId(country_id); + rki.setCountryCode(country_code); addLiveJoiningKart(kart_id, rki, live_join_util_ticks); core::stringw msg; diff --git a/src/network/protocols/client_lobby.hpp b/src/network/protocols/client_lobby.hpp index 6a59df1c0..a5ae57e87 100644 --- a/src/network/protocols/client_lobby.hpp +++ b/src/network/protocols/client_lobby.hpp @@ -46,7 +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; + std::string m_country_code; /* Icon id for spectator in NetworkingLobby::loadedFromFile is 5. */ bool isSpectator() const { return m_icon_id == 5; } }; diff --git a/src/network/protocols/lobby_protocol.cpp b/src/network/protocols/lobby_protocol.cpp index 55fd0ec3d..41b7509f1 100644 --- a/src/network/protocols/lobby_protocol.cpp +++ b/src/network/protocols/lobby_protocol.cpp @@ -133,7 +133,7 @@ void LobbyProtocol::configRemoteKart( rki.setOnlineId(profile->getOnlineId()); if (race_manager->teamEnabled()) rki.setKartTeam(profile->getTeam()); - rki.setCountryId(profile->getCountryId()); + rki.setCountryCode(profile->getCountryCode()); rki.setNetworkPlayerProfile(profile); // Inform the race manager about the data for this kart. race_manager->setPlayerKart(i, rki); diff --git a/src/network/protocols/server_lobby.cpp b/src/network/protocols/server_lobby.cpp index 16c853763..705415957 100644 --- a/src/network/protocols/server_lobby.cpp +++ b/src/network/protocols/server_lobby.cpp @@ -212,7 +212,7 @@ void ServerLobby::initServerStatsTable() " online_id INTEGER UNSIGNED NOT NULL, -- Online if of the host (0 for offline account)\n" " username TEXT NOT NULL, -- First player name in the host (if the host has splitscreen player)\n" " player_num INTEGER UNSIGNED NOT NULL, -- Number of player(s) from the host, more than 1 if it has splitscreen player\n" - " country_id TEXT NULL DEFAULT NULL, -- Country id of the host\n" + " country_code TEXT NULL DEFAULT NULL, -- 2-letter country code of the host\n" " version TEXT NOT NULL, -- SuperTuxKart version of the host (with OS info)\n" " connected_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- Time when connected\n" " disconnected_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- Time when disconnected (saved when disconnected)\n" @@ -252,7 +252,7 @@ void ServerLobby::initServerStatsTable() oss << "CREATE VIEW IF NOT EXISTS " << view_name << " AS\n" << " SELECT host_id, ip,\n" << " ((ip >> 24) & 255) ||'.'|| ((ip >> 16) & 255) ||'.'|| ((ip >> 8) & 255) ||'.'|| ((ip ) & 255) AS ip_readable,\n" - << " port, online_id, username, player_num, country_id, version,\n" + << " port, online_id, username, player_num, country_code, version,\n" << " ROUND((STRFTIME(\"%s\", disconnected_time) - STRFTIME(\"%s\", connected_time)) / 60.0, 2) AS time_played,\n" << " connected_time, disconnected_time, ping\n" << " FROM " << m_server_stats_table << ";"; @@ -270,7 +270,7 @@ void ServerLobby::initServerStatsTable() oss << "CREATE VIEW IF NOT EXISTS " << view_name << " AS\n" << " SELECT host_id, ip,\n" << " ((ip >> 24) & 255) ||'.'|| ((ip >> 16) & 255) ||'.'|| ((ip >> 8) & 255) ||'.'|| ((ip ) & 255) AS ip_readable,\n" - << " port, online_id, username, player_num, country_id, version,\n" + << " port, online_id, username, player_num, country_code, version,\n" << " ROUND((STRFTIME(\"%s\", 'now') - STRFTIME(\"%s\", connected_time)) / 60.0, 2) AS time_played,\n" << " connected_time, ping FROM " << m_server_stats_table << "\n" << " WHERE connected_time = disconnected_time;"; @@ -1077,7 +1077,7 @@ void ServerLobby::encodePlayers(BareNetworkString* bns, .addUInt8(player->getLocalPlayerId()) .addUInt8( race_manager->teamEnabled() ? player->getTeam() : KART_TEAM_NONE) - .encodeString(player->getCountryId()); + .encodeString(player->getCountryCode()); bns->encodeString(player->getKartName()); } } // encodePlayers @@ -1269,7 +1269,7 @@ std::vector > rki.getDefaultKartColor(), rki.getOnlineId(), rki.getDifficulty(), rki.getLocalPlayerId(), KART_TEAM_NONE, - rki.getCountryId()); + rki.getCountryCode()); player->setKartName(rki.getKartName()); } else @@ -2890,7 +2890,7 @@ void ServerLobby::updatePlayerList(bool update_when_reset_server) pl->addUInt8(profile->getTeam()); else pl->addUInt8(KART_TEAM_NONE); - pl->encodeString(profile->getCountryId()); + pl->encodeString(profile->getCountryCode()); } // Don't send this message to in-game players @@ -4079,7 +4079,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.getCountryId()); + .encodeString(rki.getKartName()).encodeString(rki.getCountryCode()); peer->sendPacket(ns, true/*reliable*/); delete ns; } // handleKartInfo diff --git a/src/network/remote_kart_info.cpp b/src/network/remote_kart_info.cpp index e39ee2323..00fe0cad6 100644 --- a/src/network/remote_kart_info.cpp +++ b/src/network/remote_kart_info.cpp @@ -29,6 +29,6 @@ void RemoteKartInfo::copyFrom(std::shared_ptr p, m_difficulty = p->getPerPlayerDifficulty(); m_default_kart_color = p->getDefaultKartColor(); m_online_id = p->getOnlineId(); - m_country_id = p->getCountryId(); + m_country_code = p->getCountryCode(); m_profile = p; } // copyFrom diff --git a/src/network/remote_kart_info.hpp b/src/network/remote_kart_info.hpp index 8f860a89f..60abef7cb 100644 --- a/src/network/remote_kart_info.hpp +++ b/src/network/remote_kart_info.hpp @@ -57,7 +57,7 @@ class RemoteKartInfo PerPlayerDifficulty m_difficulty; float m_default_kart_color; uint32_t m_online_id; - std::string m_country_id; + std::string m_country_code; std::weak_ptr m_profile; public: RemoteKartInfo(int player_id, const std::string& kart_name, @@ -106,8 +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 setCountryCode(const std::string& id) { m_country_code = id; } + const std::string& getCountryCode() const { return m_country_code; } void setNetworkPlayerProfile( std::weak_ptr npp) { m_profile = npp; } std::weak_ptr getNetworkPlayerProfile() const