Clean up icon handling, split spectate icon out of waiting
This commit is contained in:
parent
366ee5caad
commit
042af60417
@ -735,29 +735,26 @@ void ClientLobby::updatePlayerList(Event* event)
|
|||||||
lp.m_local_player_id = local_id;
|
lp.m_local_player_id = local_id;
|
||||||
data.decodeStringW(&lp.m_user_name);
|
data.decodeStringW(&lp.m_user_name);
|
||||||
total_players += lp.m_user_name;
|
total_players += lp.m_user_name;
|
||||||
uint8_t waiting_and_spectator = data.getUInt8();
|
uint8_t boolean_combine = data.getUInt8();
|
||||||
bool is_peer_waiting_for_game = waiting_and_spectator == 1;
|
bool is_peer_waiting_for_game = (boolean_combine & 1) == 1;
|
||||||
bool is_spectator = waiting_and_spectator == 2;
|
bool is_spectator = ((boolean_combine >> 1) & 1) == 1;
|
||||||
bool is_peer_server_owner = data.getUInt8() == 1;
|
bool is_peer_server_owner = ((boolean_combine >> 2) & 1) == 1;
|
||||||
|
bool ready = ((boolean_combine >> 3) & 1) == 1;
|
||||||
// icon to be used, see NetworkingLobby::loadedFromFile
|
// icon to be used, see NetworkingLobby::loadedFromFile
|
||||||
lp.m_icon_id = is_peer_server_owner ? 0 :
|
lp.m_icon_id = is_peer_server_owner ? 0 :
|
||||||
lp.m_online_id != 0 /*if online account*/ ? 1 : 2;
|
lp.m_online_id != 0 /*if online account*/ ? 1 : 2;
|
||||||
if (waiting)
|
if (waiting && !is_peer_waiting_for_game)
|
||||||
{
|
lp.m_icon_id = 3;
|
||||||
if (is_spectator)
|
if (is_spectator)
|
||||||
lp.m_icon_id = 5;
|
lp.m_icon_id = 5;
|
||||||
else if (!is_peer_waiting_for_game)
|
if (ready)
|
||||||
lp.m_icon_id = 3;
|
lp.m_icon_id = 4;
|
||||||
}
|
|
||||||
lp.m_difficulty = (PerPlayerDifficulty)data.getUInt8();
|
lp.m_difficulty = (PerPlayerDifficulty)data.getUInt8();
|
||||||
if (lp.m_difficulty == PLAYER_DIFFICULTY_HANDICAP)
|
if (lp.m_difficulty == PLAYER_DIFFICULTY_HANDICAP)
|
||||||
{
|
{
|
||||||
lp.m_user_name = _("%s (handicapped)", lp.m_user_name);
|
lp.m_user_name = _("%s (handicapped)", lp.m_user_name);
|
||||||
}
|
}
|
||||||
lp.m_kart_team = (KartTeam)data.getUInt8();
|
lp.m_kart_team = (KartTeam)data.getUInt8();
|
||||||
bool ready = data.getUInt8() == 1;
|
|
||||||
if (ready)
|
|
||||||
lp.m_icon_id = 4;
|
|
||||||
if (lp.m_host_id == STKHost::get()->getMyHostId())
|
if (lp.m_host_id == STKHost::get()->getMyHostId())
|
||||||
{
|
{
|
||||||
if (is_peer_server_owner)
|
if (is_peer_server_owner)
|
||||||
|
@ -2358,22 +2358,24 @@ void ServerLobby::updatePlayerList(bool update_when_reset_server)
|
|||||||
.addUInt8(profile->getLocalPlayerId())
|
.addUInt8(profile->getLocalPlayerId())
|
||||||
.encodeString(profile->getName());
|
.encodeString(profile->getName());
|
||||||
std::shared_ptr<STKPeer> p = profile->getPeer();
|
std::shared_ptr<STKPeer> p = profile->getPeer();
|
||||||
pl->addUInt8((uint8_t)
|
uint8_t boolean_combine = 0;
|
||||||
(p && p->isWaitingForGame() ? 1 : p && p->isSpectator() ? 2 : 0));
|
if (p && p->isWaitingForGame())
|
||||||
uint8_t server_owner = 0;
|
boolean_combine |= 1;
|
||||||
|
if (p && p->isSpectator())
|
||||||
|
boolean_combine |= (1 << 1);
|
||||||
if (p && m_server_owner_id.load() == p->getHostId())
|
if (p && m_server_owner_id.load() == p->getHostId())
|
||||||
server_owner = 1;
|
boolean_combine |= (1 << 2);
|
||||||
pl->addUInt8(server_owner);
|
if (ServerConfig::m_owner_less && !game_started &&
|
||||||
|
m_peers_ready.find(p) != m_peers_ready.end() &&
|
||||||
|
m_peers_ready.at(p))
|
||||||
|
boolean_combine |= (1 << 3);
|
||||||
|
pl->addUInt8(boolean_combine);
|
||||||
pl->addUInt8(profile->getPerPlayerDifficulty());
|
pl->addUInt8(profile->getPerPlayerDifficulty());
|
||||||
if (ServerConfig::m_team_choosing &&
|
if (ServerConfig::m_team_choosing &&
|
||||||
race_manager->teamEnabled())
|
race_manager->teamEnabled())
|
||||||
pl->addUInt8(profile->getTeam());
|
pl->addUInt8(profile->getTeam());
|
||||||
else
|
else
|
||||||
pl->addUInt8(KART_TEAM_NONE);
|
pl->addUInt8(KART_TEAM_NONE);
|
||||||
uint8_t ready = (!game_started &&
|
|
||||||
m_peers_ready.find(p) != m_peers_ready.end() &&
|
|
||||||
m_peers_ready.at(p)) ? 1 : 0;
|
|
||||||
pl->addUInt8(ready);
|
|
||||||
pl->encodeString(profile->getCountryId());
|
pl->encodeString(profile->getCountryId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user