Make it possible to restart race after going back to lobby

At the moment the token is reset by client after each restart
This commit is contained in:
Benau 2018-02-13 15:20:55 +08:00
parent 3290321c5d
commit 46416781fa
4 changed files with 18 additions and 0 deletions

View File

@ -712,6 +712,10 @@ void ClientLobby::raceFinished(Event* event)
void ClientLobby::exitResultScreen(Event *event)
{
RaceResultGUI::getInstance()->backToLobby();
// Will be reset to linked if connected to server, see update(float dt)
m_game_setup = STKHost::get()->setupNewGame();
STKHost::get()->getServerPeerForClient()->unsetClientServerToken();
m_state = NONE;
} // exitResultScreen
//-----------------------------------------------------------------------------

View File

@ -283,6 +283,7 @@ void ServerLobby::update(float dt)
pm->findAndTerminate(PROTOCOL_CONTROLLER_EVENTS);
pm->findAndTerminate(PROTOCOL_KART_UPDATE);
pm->findAndTerminate(PROTOCOL_GAME_EVENTS);
setup();
}
break;
case DONE:

View File

@ -710,6 +710,18 @@ STKPeer* STKHost::getPeer(ENetPeer *enet_peer)
m_next_unique_host_id ++;
return peer;
} // getPeer
// ----------------------------------------------------------------------------
/** \brief Return the only server peer for client.
* \return STKPeer the STKPeer of server.
*/
STKPeer* STKHost::getServerPeerForClient() const
{
assert(m_peers.size() == 1);
assert(NetworkConfig::get()->isClient());
return m_peers[0];
} // getServerPeerForClient
// ----------------------------------------------------------------------------
/** \brief Tells if a peer is known and connected.
* \return True if the peer is known and connected, false elseway.

View File

@ -162,6 +162,7 @@ public:
void removePeer(const STKPeer* peer);
bool isConnectedTo(const TransportAddress& peer_address);
STKPeer *getPeer(ENetPeer *enet_peer);
STKPeer *getServerPeerForClient() const;
std::vector<NetworkPlayerProfile*> getMyPlayerProfiles();
int mustStopListening();
uint16_t getPort() const;