Show spectator icon for player list
This commit is contained in:
parent
1669368176
commit
a05889fa6a
@ -711,13 +711,20 @@ void ClientLobby::updatePlayerList(Event* event)
|
||||
lp.m_local_player_id = local_id;
|
||||
data.decodeStringW(&lp.m_user_name);
|
||||
total_players += lp.m_user_name;
|
||||
bool is_peer_waiting_for_game = data.getUInt8() == 1;
|
||||
uint8_t waiting_and_spectator = data.getUInt8();
|
||||
bool is_peer_waiting_for_game = waiting_and_spectator == 1;
|
||||
bool is_spectator = waiting_and_spectator == 2;
|
||||
bool is_peer_server_owner = data.getUInt8() == 1;
|
||||
// icon to be used, see NetworkingLobby::loadedFromFile
|
||||
lp.m_icon_id = is_peer_server_owner ? 0 :
|
||||
lp.m_online_id != 0 /*if online account*/ ? 1 : 2;
|
||||
if (waiting && !is_peer_waiting_for_game)
|
||||
lp.m_icon_id = 3;
|
||||
if (waiting)
|
||||
{
|
||||
if (is_spectator)
|
||||
lp.m_icon_id = 5;
|
||||
else if (!is_peer_waiting_for_game)
|
||||
lp.m_icon_id = 3;
|
||||
}
|
||||
lp.m_difficulty = (PerPlayerDifficulty)data.getUInt8();
|
||||
if (lp.m_difficulty == PLAYER_DIFFICULTY_HANDICAP)
|
||||
{
|
||||
|
@ -929,6 +929,7 @@ void ServerLobby::finishedLoadingLiveJoinClient(Event* event)
|
||||
live_join_start_time -= m_server_delay;
|
||||
live_join_start_time += 3000;
|
||||
|
||||
bool spectator = false;
|
||||
for (const int id : peer->getAvailableKartIDs())
|
||||
{
|
||||
World::getWorld()->addReservedKart(id);
|
||||
@ -941,6 +942,7 @@ void ServerLobby::finishedLoadingLiveJoinClient(Event* event)
|
||||
{
|
||||
Log::info("ServerLobby", "%s spectating succeeded.",
|
||||
peer->getAddress().toString().c_str());
|
||||
spectator = true;
|
||||
}
|
||||
|
||||
NetworkString* ns = getNetworkString(10);
|
||||
@ -959,6 +961,7 @@ void ServerLobby::finishedLoadingLiveJoinClient(Event* event)
|
||||
|
||||
m_peers_ready[peer] = false;
|
||||
peer->setWaitingForGame(false);
|
||||
peer->setSpectator(spectator);
|
||||
|
||||
peer->sendPacket(ns, true/*reliable*/);
|
||||
delete ns;
|
||||
@ -2261,6 +2264,7 @@ void ServerLobby::handleUnencryptedConnection(std::shared_ptr<STKPeer> peer,
|
||||
.addUInt32(ServerConfig::m_server_version).addFloat(auto_start_timer)
|
||||
.addUInt32(ServerConfig::m_state_frequency);
|
||||
|
||||
peer->setSpectator(false);
|
||||
if (game_started)
|
||||
{
|
||||
peer->setWaitingForGame(true);
|
||||
@ -2322,7 +2326,7 @@ void ServerLobby::updatePlayerList(bool update_when_reset_server)
|
||||
.encodeString(profile->getName());
|
||||
std::shared_ptr<STKPeer> p = profile->getPeer();
|
||||
pl->addUInt8((uint8_t)
|
||||
(p && p->isWaitingForGame() ? 1 : 0));
|
||||
(p && p->isWaitingForGame() ? 1 : p && p->isSpectator() ? 2 : 0));
|
||||
uint8_t server_owner = 0;
|
||||
if (p && m_server_owner_id.load() == p->getHostId())
|
||||
server_owner = 1;
|
||||
@ -3072,6 +3076,7 @@ void ServerLobby::addWaitingPlayersToGame()
|
||||
continue;
|
||||
|
||||
peer->setWaitingForGame(false);
|
||||
peer->setSpectator(false);
|
||||
if (m_peers_ready.find(peer) == m_peers_ready.end())
|
||||
{
|
||||
m_peers_ready[peer] = false;
|
||||
@ -3502,6 +3507,7 @@ void ServerLobby::clientInGameWantsToBackLobby(Event* event)
|
||||
nim->erasePeerInGame(peer);
|
||||
m_peers_ready.erase(peer);
|
||||
peer->setWaitingForGame(true);
|
||||
peer->setSpectator(false);
|
||||
|
||||
NetworkString* reset = getNetworkString(2);
|
||||
reset->setSynchronous(true);
|
||||
@ -3534,6 +3540,7 @@ void ServerLobby::clientSelectingAssetsWantsToBackLobby(Event* event)
|
||||
|
||||
m_peers_ready.erase(peer);
|
||||
peer->setWaitingForGame(true);
|
||||
peer->setSpectator(false);
|
||||
|
||||
NetworkString* reset = getNetworkString(2);
|
||||
reset->setSynchronous(true);
|
||||
|
@ -41,6 +41,7 @@ STKPeer::STKPeer(ENetPeer *enet_peer, STKHost* host, uint32_t host_id)
|
||||
m_validated.store(false);
|
||||
m_average_ping.store(0);
|
||||
m_waiting_for_game.store(true);
|
||||
m_spectator.store(false);
|
||||
m_disconnected.store(false);
|
||||
m_warned_for_high_ping.store(false);
|
||||
m_last_activity.store((int64_t)StkTime::getRealTimeMs());
|
||||
|
@ -68,6 +68,8 @@ protected:
|
||||
/** True if this peer is waiting for game. */
|
||||
std::atomic_bool m_waiting_for_game;
|
||||
|
||||
std::atomic_bool m_spectator;
|
||||
|
||||
std::atomic_bool m_disconnected;
|
||||
|
||||
std::atomic_bool m_warned_for_high_ping;
|
||||
@ -192,6 +194,10 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
bool isWaitingForGame() const { return m_waiting_for_game.load(); }
|
||||
// ------------------------------------------------------------------------
|
||||
void setSpectator(bool val) { m_spectator.store(val); }
|
||||
// ------------------------------------------------------------------------
|
||||
bool isSpectator() const { return m_spectator.load(); }
|
||||
// ------------------------------------------------------------------------
|
||||
bool isDisconnected() const { return m_disconnected.load(); }
|
||||
// ------------------------------------------------------------------------
|
||||
void setDisconnected(bool val) { return m_disconnected.store(val); }
|
||||
|
@ -132,7 +132,7 @@ void NetworkingLobby::loadedFromFile()
|
||||
m_icon_bank->addTextureAsSprite(icon_3);
|
||||
m_icon_bank->addTextureAsSprite(icon_4);
|
||||
m_icon_bank->addTextureAsSprite(icon_5);
|
||||
|
||||
m_icon_bank->addTextureAsSprite(m_spectate_texture);
|
||||
|
||||
if (UserConfigParams::m_hidpi_enabled)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user