Rename to country code for a better name
This commit is contained in:
parent
a569d1f823
commit
44618c2a52
@ -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)
|
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)
|
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
|
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)
|
version TEXT NOT NULL, -- SuperTuxKart version of the host (with OS info)
|
||||||
connected_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- Time when connected
|
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)
|
disconnected_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- Time when disconnected (saved when disconnected)
|
||||||
|
@ -69,7 +69,8 @@ private:
|
|||||||
|
|
||||||
std::atomic<KartTeam> m_team;
|
std::atomic<KartTeam> m_team;
|
||||||
|
|
||||||
std::string m_country_id;
|
/** 2-letter country code of player. */
|
||||||
|
std::string m_country_code;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@ -98,7 +99,7 @@ public:
|
|||||||
float default_kart_color, uint32_t online_id,
|
float default_kart_color, uint32_t online_id,
|
||||||
PerPlayerDifficulty per_player_difficulty,
|
PerPlayerDifficulty per_player_difficulty,
|
||||||
uint8_t local_player_id, KartTeam team,
|
uint8_t local_player_id, KartTeam team,
|
||||||
const std::string& country_id)
|
const std::string& country_code)
|
||||||
{
|
{
|
||||||
m_peer = peer;
|
m_peer = peer;
|
||||||
m_player_name = name;
|
m_player_name = name;
|
||||||
@ -108,7 +109,7 @@ public:
|
|||||||
m_per_player_difficulty.store(per_player_difficulty);
|
m_per_player_difficulty.store(per_player_difficulty);
|
||||||
m_local_player_id = local_player_id;
|
m_local_player_id = local_player_id;
|
||||||
m_team.store(team);
|
m_team.store(team);
|
||||||
m_country_id = country_id;
|
m_country_code = country_code;
|
||||||
resetGrandPrixData();
|
resetGrandPrixData();
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@ -164,7 +165,7 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
KartTeam getTeam() const { return m_team.load(); }
|
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
|
}; // class NetworkPlayerProfile
|
||||||
|
|
||||||
#endif // HEADER_NETWORK_PLAYER_PROFILE
|
#endif // HEADER_NETWORK_PLAYER_PROFILE
|
||||||
|
@ -329,12 +329,12 @@ std::vector<std::shared_ptr<NetworkPlayerProfile> >
|
|||||||
PerPlayerDifficulty ppd = (PerPlayerDifficulty)data.getUInt8();
|
PerPlayerDifficulty ppd = (PerPlayerDifficulty)data.getUInt8();
|
||||||
uint8_t local_id = data.getUInt8();
|
uint8_t local_id = data.getUInt8();
|
||||||
KartTeam team = (KartTeam)data.getUInt8();
|
KartTeam team = (KartTeam)data.getUInt8();
|
||||||
std::string country_id;
|
std::string country_code;
|
||||||
data.decodeString(&country_id);
|
data.decodeString(&country_code);
|
||||||
if (is_specator && host_id == STKHost::get()->getMyHostId())
|
if (is_specator && host_id == STKHost::get()->getMyHostId())
|
||||||
*is_specator = false;
|
*is_specator = false;
|
||||||
auto player = std::make_shared<NetworkPlayerProfile>(peer, player_name,
|
auto player = std::make_shared<NetworkPlayerProfile>(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;
|
std::string kart_name;
|
||||||
data.decodeString(&kart_name);
|
data.decodeString(&kart_name);
|
||||||
player->setKartName(kart_name);
|
player->setKartName(kart_name);
|
||||||
@ -783,7 +783,7 @@ void ClientLobby::updatePlayerList(Event* event)
|
|||||||
auto& local_players = NetworkConfig::get()->getNetworkPlayers();
|
auto& local_players = NetworkConfig::get()->getNetworkPlayers();
|
||||||
std::get<2>(local_players.at(local_id)) = lp.m_difficulty;
|
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);
|
m_lobby_players.push_back(lp);
|
||||||
}
|
}
|
||||||
STKHost::get()->setAuthorisedToControl(client_server_owner);
|
STKHost::get()->setAuthorisedToControl(client_server_owner);
|
||||||
@ -1261,8 +1261,8 @@ void ClientLobby::handleKartInfo(Event* event)
|
|||||||
uint8_t local_id = data.getUInt8();
|
uint8_t local_id = data.getUInt8();
|
||||||
std::string kart_name;
|
std::string kart_name;
|
||||||
data.decodeString(&kart_name);
|
data.decodeString(&kart_name);
|
||||||
std::string country_id;
|
std::string country_code;
|
||||||
data.decodeString(&country_id);
|
data.decodeString(&country_code);
|
||||||
|
|
||||||
RemoteKartInfo& rki = race_manager->getKartInfo(kart_id);
|
RemoteKartInfo& rki = race_manager->getKartInfo(kart_id);
|
||||||
rki.setPlayerName(player_name);
|
rki.setPlayerName(player_name);
|
||||||
@ -1272,7 +1272,7 @@ void ClientLobby::handleKartInfo(Event* event)
|
|||||||
rki.setPerPlayerDifficulty(ppd);
|
rki.setPerPlayerDifficulty(ppd);
|
||||||
rki.setLocalPlayerId(local_id);
|
rki.setLocalPlayerId(local_id);
|
||||||
rki.setKartName(kart_name);
|
rki.setKartName(kart_name);
|
||||||
rki.setCountryId(country_id);
|
rki.setCountryCode(country_code);
|
||||||
addLiveJoiningKart(kart_id, rki, live_join_util_ticks);
|
addLiveJoiningKart(kart_id, rki, live_join_util_ticks);
|
||||||
|
|
||||||
core::stringw msg;
|
core::stringw msg;
|
||||||
|
@ -46,7 +46,7 @@ struct LobbyPlayer
|
|||||||
uint32_t m_online_id;
|
uint32_t m_online_id;
|
||||||
/* Icon used in networking lobby, see NetworkingLobby::loadedFromFile. */
|
/* Icon used in networking lobby, see NetworkingLobby::loadedFromFile. */
|
||||||
int m_icon_id;
|
int m_icon_id;
|
||||||
std::string m_country_id;
|
std::string m_country_code;
|
||||||
/* Icon id for spectator in NetworkingLobby::loadedFromFile is 5. */
|
/* Icon id for spectator in NetworkingLobby::loadedFromFile is 5. */
|
||||||
bool isSpectator() const { return m_icon_id == 5; }
|
bool isSpectator() const { return m_icon_id == 5; }
|
||||||
};
|
};
|
||||||
|
@ -133,7 +133,7 @@ void LobbyProtocol::configRemoteKart(
|
|||||||
rki.setOnlineId(profile->getOnlineId());
|
rki.setOnlineId(profile->getOnlineId());
|
||||||
if (race_manager->teamEnabled())
|
if (race_manager->teamEnabled())
|
||||||
rki.setKartTeam(profile->getTeam());
|
rki.setKartTeam(profile->getTeam());
|
||||||
rki.setCountryId(profile->getCountryId());
|
rki.setCountryCode(profile->getCountryCode());
|
||||||
rki.setNetworkPlayerProfile(profile);
|
rki.setNetworkPlayerProfile(profile);
|
||||||
// Inform the race manager about the data for this kart.
|
// Inform the race manager about the data for this kart.
|
||||||
race_manager->setPlayerKart(i, rki);
|
race_manager->setPlayerKart(i, rki);
|
||||||
|
@ -212,7 +212,7 @@ void ServerLobby::initServerStatsTable()
|
|||||||
" online_id INTEGER UNSIGNED NOT NULL, -- Online if of the host (0 for offline account)\n"
|
" 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"
|
" 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"
|
" 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"
|
" 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"
|
" 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"
|
" 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"
|
oss << "CREATE VIEW IF NOT EXISTS " << view_name << " AS\n"
|
||||||
<< " SELECT host_id, ip,\n"
|
<< " SELECT host_id, ip,\n"
|
||||||
<< " ((ip >> 24) & 255) ||'.'|| ((ip >> 16) & 255) ||'.'|| ((ip >> 8) & 255) ||'.'|| ((ip ) & 255) AS ip_readable,\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"
|
<< " ROUND((STRFTIME(\"%s\", disconnected_time) - STRFTIME(\"%s\", connected_time)) / 60.0, 2) AS time_played,\n"
|
||||||
<< " connected_time, disconnected_time, ping\n"
|
<< " connected_time, disconnected_time, ping\n"
|
||||||
<< " FROM " << m_server_stats_table << ";";
|
<< " FROM " << m_server_stats_table << ";";
|
||||||
@ -270,7 +270,7 @@ void ServerLobby::initServerStatsTable()
|
|||||||
oss << "CREATE VIEW IF NOT EXISTS " << view_name << " AS\n"
|
oss << "CREATE VIEW IF NOT EXISTS " << view_name << " AS\n"
|
||||||
<< " SELECT host_id, ip,\n"
|
<< " SELECT host_id, ip,\n"
|
||||||
<< " ((ip >> 24) & 255) ||'.'|| ((ip >> 16) & 255) ||'.'|| ((ip >> 8) & 255) ||'.'|| ((ip ) & 255) AS ip_readable,\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"
|
<< " ROUND((STRFTIME(\"%s\", 'now') - STRFTIME(\"%s\", connected_time)) / 60.0, 2) AS time_played,\n"
|
||||||
<< " connected_time, ping FROM " << m_server_stats_table << "\n"
|
<< " connected_time, ping FROM " << m_server_stats_table << "\n"
|
||||||
<< " WHERE connected_time = disconnected_time;";
|
<< " WHERE connected_time = disconnected_time;";
|
||||||
@ -1077,7 +1077,7 @@ void ServerLobby::encodePlayers(BareNetworkString* bns,
|
|||||||
.addUInt8(player->getLocalPlayerId())
|
.addUInt8(player->getLocalPlayerId())
|
||||||
.addUInt8(
|
.addUInt8(
|
||||||
race_manager->teamEnabled() ? player->getTeam() : KART_TEAM_NONE)
|
race_manager->teamEnabled() ? player->getTeam() : KART_TEAM_NONE)
|
||||||
.encodeString(player->getCountryId());
|
.encodeString(player->getCountryCode());
|
||||||
bns->encodeString(player->getKartName());
|
bns->encodeString(player->getKartName());
|
||||||
}
|
}
|
||||||
} // encodePlayers
|
} // encodePlayers
|
||||||
@ -1269,7 +1269,7 @@ std::vector<std::shared_ptr<NetworkPlayerProfile> >
|
|||||||
rki.getDefaultKartColor(),
|
rki.getDefaultKartColor(),
|
||||||
rki.getOnlineId(), rki.getDifficulty(),
|
rki.getOnlineId(), rki.getDifficulty(),
|
||||||
rki.getLocalPlayerId(), KART_TEAM_NONE,
|
rki.getLocalPlayerId(), KART_TEAM_NONE,
|
||||||
rki.getCountryId());
|
rki.getCountryCode());
|
||||||
player->setKartName(rki.getKartName());
|
player->setKartName(rki.getKartName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2890,7 +2890,7 @@ void ServerLobby::updatePlayerList(bool update_when_reset_server)
|
|||||||
pl->addUInt8(profile->getTeam());
|
pl->addUInt8(profile->getTeam());
|
||||||
else
|
else
|
||||||
pl->addUInt8(KART_TEAM_NONE);
|
pl->addUInt8(KART_TEAM_NONE);
|
||||||
pl->encodeString(profile->getCountryId());
|
pl->encodeString(profile->getCountryCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't send this message to in-game players
|
// 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.getHostId()).addFloat(rki.getDefaultKartColor())
|
||||||
.addUInt32(rki.getOnlineId()).addUInt8(rki.getDifficulty())
|
.addUInt32(rki.getOnlineId()).addUInt8(rki.getDifficulty())
|
||||||
.addUInt8((uint8_t)rki.getLocalPlayerId())
|
.addUInt8((uint8_t)rki.getLocalPlayerId())
|
||||||
.encodeString(rki.getKartName()).encodeString(rki.getCountryId());
|
.encodeString(rki.getKartName()).encodeString(rki.getCountryCode());
|
||||||
peer->sendPacket(ns, true/*reliable*/);
|
peer->sendPacket(ns, true/*reliable*/);
|
||||||
delete ns;
|
delete ns;
|
||||||
} // handleKartInfo
|
} // handleKartInfo
|
||||||
|
@ -29,6 +29,6 @@ void RemoteKartInfo::copyFrom(std::shared_ptr<NetworkPlayerProfile> p,
|
|||||||
m_difficulty = p->getPerPlayerDifficulty();
|
m_difficulty = p->getPerPlayerDifficulty();
|
||||||
m_default_kart_color = p->getDefaultKartColor();
|
m_default_kart_color = p->getDefaultKartColor();
|
||||||
m_online_id = p->getOnlineId();
|
m_online_id = p->getOnlineId();
|
||||||
m_country_id = p->getCountryId();
|
m_country_code = p->getCountryCode();
|
||||||
m_profile = p;
|
m_profile = p;
|
||||||
} // copyFrom
|
} // copyFrom
|
||||||
|
@ -57,7 +57,7 @@ class RemoteKartInfo
|
|||||||
PerPlayerDifficulty m_difficulty;
|
PerPlayerDifficulty m_difficulty;
|
||||||
float m_default_kart_color;
|
float m_default_kart_color;
|
||||||
uint32_t m_online_id;
|
uint32_t m_online_id;
|
||||||
std::string m_country_id;
|
std::string m_country_code;
|
||||||
std::weak_ptr<NetworkPlayerProfile> m_profile;
|
std::weak_ptr<NetworkPlayerProfile> m_profile;
|
||||||
public:
|
public:
|
||||||
RemoteKartInfo(int player_id, const std::string& kart_name,
|
RemoteKartInfo(int player_id, const std::string& kart_name,
|
||||||
@ -106,8 +106,8 @@ public:
|
|||||||
PerPlayerDifficulty getDifficulty() const { return m_difficulty; }
|
PerPlayerDifficulty getDifficulty() const { return m_difficulty; }
|
||||||
float getDefaultKartColor() const { return m_default_kart_color; }
|
float getDefaultKartColor() const { return m_default_kart_color; }
|
||||||
uint32_t getOnlineId() const { return m_online_id; }
|
uint32_t getOnlineId() const { return m_online_id; }
|
||||||
void setCountryId(const std::string& id) { m_country_id = id; }
|
void setCountryCode(const std::string& id) { m_country_code = id; }
|
||||||
const std::string& getCountryId() const { return m_country_id; }
|
const std::string& getCountryCode() const { return m_country_code; }
|
||||||
void setNetworkPlayerProfile(
|
void setNetworkPlayerProfile(
|
||||||
std::weak_ptr<NetworkPlayerProfile> npp) { m_profile = npp; }
|
std::weak_ptr<NetworkPlayerProfile> npp) { m_profile = npp; }
|
||||||
std::weak_ptr<NetworkPlayerProfile> getNetworkPlayerProfile() const
|
std::weak_ptr<NetworkPlayerProfile> getNetworkPlayerProfile() const
|
||||||
|
Loading…
Reference in New Issue
Block a user