Move reset active players to main thread
This commit is contained in:
parent
faeaed1117
commit
7e7c07a116
@ -19,6 +19,7 @@
|
||||
#include "network/network_config.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "network/server_config.hpp"
|
||||
#include "network/transport_address.hpp"
|
||||
#include "online/xml_request.hpp"
|
||||
@ -27,6 +28,7 @@
|
||||
#include "states_screens/online/online_lan.hpp"
|
||||
#include "states_screens/online/online_profile_servers.hpp"
|
||||
#include "states_screens/online/online_screen.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
|
||||
NetworkConfig *NetworkConfig::m_network_config = NULL;
|
||||
|
||||
@ -139,3 +141,20 @@ std::vector<GUIEngine::Screen*>
|
||||
}
|
||||
}
|
||||
} // getResetScreens
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Called before (re)starting network race, must be used before adding
|
||||
* split screen players. */
|
||||
void NetworkConfig::clearActivePlayersForClient() const
|
||||
{
|
||||
if (!isClient())
|
||||
return;
|
||||
StateManager::get()->resetActivePlayers();
|
||||
if (input_manager)
|
||||
{
|
||||
input_manager->getDeviceManager()->setAssignMode(NO_ASSIGN);
|
||||
input_manager->getDeviceManager()->setSinglePlayer(NULL);
|
||||
input_manager->setMasterPlayerOnly(false);
|
||||
input_manager->getDeviceManager()->clearLatestUsedDevice();
|
||||
}
|
||||
} // clearActivePlayersForClient
|
||||
|
@ -220,6 +220,8 @@ public:
|
||||
void setJoinedServerVersion(uint32_t v) { m_joined_server_version = v; }
|
||||
// ------------------------------------------------------------------------
|
||||
uint32_t getJoinedServerVersion() const { return m_joined_server_version; }
|
||||
// ------------------------------------------------------------------------
|
||||
void clearActivePlayersForClient() const;
|
||||
}; // class NetworkConfig
|
||||
|
||||
#endif // HEADER_NETWORK_CONFIG
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include "states_screens/online/networking_lobby.hpp"
|
||||
#include "states_screens/online/network_kart_selection.hpp"
|
||||
#include "states_screens/race_result_gui.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/online/tracks_screen.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
@ -94,7 +93,6 @@ ClientLobby::ClientLobby(const TransportAddress& a, std::shared_ptr<Server> s)
|
||||
//-----------------------------------------------------------------------------
|
||||
ClientLobby::~ClientLobby()
|
||||
{
|
||||
clearPlayers();
|
||||
if (m_server->supportsEncryption())
|
||||
{
|
||||
Online::XMLRequest* request =
|
||||
@ -106,23 +104,9 @@ ClientLobby::~ClientLobby()
|
||||
}
|
||||
} // ClientLobby
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void ClientLobby::clearPlayers()
|
||||
{
|
||||
StateManager::get()->resetActivePlayers();
|
||||
if (input_manager)
|
||||
{
|
||||
input_manager->getDeviceManager()->setAssignMode(NO_ASSIGN);
|
||||
input_manager->getDeviceManager()->setSinglePlayer(NULL);
|
||||
input_manager->setMasterPlayerOnly(false);
|
||||
input_manager->getDeviceManager()->clearLatestUsedDevice();
|
||||
}
|
||||
} // clearPlayers
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void ClientLobby::setup()
|
||||
{
|
||||
clearPlayers();
|
||||
m_auto_back_to_lobby_time = std::numeric_limits<uint64_t>::max();
|
||||
m_received_server_result = false;
|
||||
TracksScreen::getInstance()->resetVote();
|
||||
@ -953,6 +937,7 @@ void ClientLobby::exitResultScreen(Event *event)
|
||||
GUIEngine::ModalDialog::dismiss();
|
||||
GUIEngine::ScreenKeyboard::dismiss();
|
||||
|
||||
NetworkConfig::get()->clearActivePlayersForClient();
|
||||
setup();
|
||||
m_auto_started = false;
|
||||
m_state.store(CONNECTED);
|
||||
|
@ -119,7 +119,6 @@ public:
|
||||
bool isWaitingForGame() const { return m_waiting_for_game; }
|
||||
bool isServerAutoGameTime() const { return m_server_auto_game_time; }
|
||||
virtual bool isRacing() const OVERRIDE { return m_state.load() == RACING; }
|
||||
void clearPlayers();
|
||||
};
|
||||
|
||||
#endif // CLIENT_LOBBY_HPP
|
||||
|
@ -270,6 +270,7 @@ void ConnectToServer::update(int ticks)
|
||||
{
|
||||
// Let main thread create ClientLobby for better
|
||||
// synchronization with GUI
|
||||
NetworkConfig::get()->clearActivePlayersForClient();
|
||||
auto cl = LobbyProtocol::create<ClientLobby>(m_server_address,
|
||||
m_server);
|
||||
cl->requestStart();
|
||||
|
@ -326,6 +326,7 @@ void STKHost::init()
|
||||
*/
|
||||
STKHost::~STKHost()
|
||||
{
|
||||
NetworkConfig::get()->clearActivePlayersForClient();
|
||||
requestShutdown();
|
||||
if (m_network_console.joinable())
|
||||
m_network_console.join();
|
||||
|
@ -130,9 +130,7 @@ bool TracksScreen::onEscapePressed()
|
||||
}
|
||||
else
|
||||
{
|
||||
auto cl = LobbyProtocol::get<ClientLobby>();
|
||||
if (cl)
|
||||
cl->clearPlayers();
|
||||
NetworkConfig::get()->clearActivePlayersForClient();
|
||||
}
|
||||
// remove the screen
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user