Fix child process invalid usage at different places

This commit is contained in:
Benau 2020-02-28 19:52:00 +08:00
parent d41594ea5b
commit 97ad138763
3 changed files with 8 additions and 3 deletions

View File

@ -31,6 +31,7 @@
#include "race/race_manager.hpp"
#include "utils/file_utils.hpp"
#include "utils/log.hpp"
#include "utils/stk_process.hpp"
#include "utils/string_utils.hpp"
#include <algorithm>
@ -75,7 +76,7 @@ void GameSetup::loadWorld()
// goals / time limit and random item location
assert(!m_tracks.empty());
// Disable accidentally unlocking of a challenge
if (PlayerManager::getCurrentPlayer())
if (STKProcess::getType() == PT_MAIN && PlayerManager::getCurrentPlayer())
PlayerManager::getCurrentPlayer()->setCurrentChallenge("");
RaceManager::get()->setTimeTarget(0.0f);
if (RaceManager::get()->isSoccerMode() ||

View File

@ -47,7 +47,8 @@
std::weak_ptr<LobbyProtocol> LobbyProtocol::m_lobby[PT_COUNT];
LobbyProtocol::LobbyProtocol()
: Protocol(PROTOCOL_LOBBY_ROOM)
: Protocol(PROTOCOL_LOBBY_ROOM),
m_process_type(STKProcess::getType())
{
resetGameStartedProgress();
m_game_setup = new GameSetup();
@ -86,7 +87,9 @@ void LobbyProtocol::loadWorld()
StateManager::ActivePlayer *ap = RaceManager::get()->getNumLocalPlayers()>1
? NULL
: StateManager::get()->getActivePlayer(0);
input_manager->getDeviceManager()->setSinglePlayer(ap);
// We only need to use input manager in main process
if (m_process_type == PT_MAIN)
input_manager->getDeviceManager()->setSinglePlayer(ap);
// Load the actual world.
m_game_setup->loadWorld();

View File

@ -102,6 +102,7 @@ public:
};
protected:
const ProcessType m_process_type;
/** Vote from each peer. The host id is used as a key. Note that
* host ids can be non-consecutive, so we cannot use std::vector. */
std::map<uint32_t, PeerVote> m_peers_votes;