From 448ad5abcf7d18f7731a85d02ca0fc4bc3e4ae23 Mon Sep 17 00:00:00 2001 From: Benau Date: Sat, 21 Apr 2018 16:32:43 +0800 Subject: [PATCH] Clean up network local player handling --- src/network/game_setup.hpp | 10 ---------- src/network/protocols/client_lobby.cpp | 2 -- src/network/protocols/lobby_protocol.cpp | 3 ++- src/network/protocols/server_lobby.cpp | 3 +-- src/race/race_manager.cpp | 1 + src/states_screens/race_result_gui.cpp | 2 +- 6 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/network/game_setup.hpp b/src/network/game_setup.hpp index 4ded38054..54ede216e 100644 --- a/src/network/game_setup.hpp +++ b/src/network/game_setup.hpp @@ -46,9 +46,6 @@ private: /** Information about all connected players. */ std::vector > m_players; - /** Stores the number of local players. */ - int m_num_local_players; - std::vector m_tracks; unsigned m_laps; @@ -61,7 +58,6 @@ public: // ------------------------------------------------------------------------ GameSetup() { - m_num_local_players = 0; m_extra_server_info = -1; reset(); } @@ -73,12 +69,6 @@ public: // ------------------------------------------------------------------------ void update(bool remove_disconnected_players); // ------------------------------------------------------------------------ - /** Sets the number of local players. */ - void setNumLocalPlayers(int n) { m_num_local_players = n; } - // ------------------------------------------------------------------------ - /** Returns the nunber of local players. */ - int getNumLocalPlayers() const { return m_num_local_players; } - // ------------------------------------------------------------------------ /** \brief Get the players that are / were in the game * \return A vector containing pointers on the players profiles. */ const std::vector >& getPlayers() const diff --git a/src/network/protocols/client_lobby.cpp b/src/network/protocols/client_lobby.cpp index d65cedb82..838b72ab7 100644 --- a/src/network/protocols/client_lobby.cpp +++ b/src/network/protocols/client_lobby.cpp @@ -411,8 +411,6 @@ void ClientLobby::connectionAccepted(Event* event) STKHost::get()->setMyHostId(data.getUInt32()); assert(!NetworkConfig::get()->isAddingNetworkPlayers()); - m_game_setup->setNumLocalPlayers((int) - NetworkConfig::get()->getNetworkPlayers().size()); // connection token uint32_t token = data.getToken(); peer->setClientServerToken(token); diff --git a/src/network/protocols/lobby_protocol.cpp b/src/network/protocols/lobby_protocol.cpp index 31ec8caa7..f52df677d 100644 --- a/src/network/protocols/lobby_protocol.cpp +++ b/src/network/protocols/lobby_protocol.cpp @@ -23,6 +23,7 @@ #include "input/device_manager.hpp" #include "modes/world.hpp" #include "network/game_setup.hpp" +#include "network/network_config.hpp" #include "network/network_player_profile.hpp" #include "network/protocols/game_protocol.hpp" #include "network/protocols/game_events_protocol.hpp" @@ -90,7 +91,7 @@ void LobbyProtocol::configRemoteKart( // Set number of global and local players. race_manager->setNumPlayers((int)players.size(), - m_game_setup->getNumLocalPlayers()); + (int)NetworkConfig::get()->getNetworkPlayers().size()); // Create the kart information for the race manager: // ------------------------------------------------- diff --git a/src/network/protocols/server_lobby.cpp b/src/network/protocols/server_lobby.cpp index 4a6c2e893..e445c940f 100644 --- a/src/network/protocols/server_lobby.cpp +++ b/src/network/protocols/server_lobby.cpp @@ -126,11 +126,10 @@ void ServerLobby::setup() m_available_kts.second = { all_t.begin(), all_t.end() }; m_server_registered = false; - m_game_setup->setNumLocalPlayers(0); // no local players on a server + m_server_has_loaded_world.store(false); // Initialise the data structures to detect if all clients and // the server are ready: - m_server_has_loaded_world.store(false); resetPeersReady(); m_peers_votes.clear(); m_server_delay = 0.0; diff --git a/src/race/race_manager.cpp b/src/race/race_manager.cpp index 585fb8bd1..44d7394e8 100644 --- a/src/race/race_manager.cpp +++ b/src/race/race_manager.cpp @@ -76,6 +76,7 @@ RaceManager::RaceManager() m_coin_target = 0; m_started_from_overworld = false; m_have_kart_last_position_on_overworld = false; + m_num_local_players = 0; setMaxGoal(0); setTimeTarget(0.0f); setReverseTrack(false); diff --git a/src/states_screens/race_result_gui.cpp b/src/states_screens/race_result_gui.cpp index 6ad94e703..3ed67de33 100644 --- a/src/states_screens/race_result_gui.cpp +++ b/src/states_screens/race_result_gui.cpp @@ -1479,7 +1479,7 @@ void RaceResultGUI::backToLobby() ("sshot_label_" + StringUtils::toString(n_sshot)).c_str()); assert(sshot != NULL && label != NULL); - // Network grand prix chooses each track 1 bye 1 + // Network grand prix chooses each track 1 by 1 if (track == NULL) { sshot->setImage(file_manager->getAsset(FileManager::GUI,