can now start a game after a server requested it. synchronization does not work for now

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13233 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hilnius
2013-07-15 12:27:32 +00:00
parent ab4a1995c0
commit b36e089ff9
4 changed files with 16 additions and 2 deletions

View File

@@ -29,6 +29,7 @@
#include "input/wiimote_manager.hpp"
#include "modes/profile_world.hpp"
#include "modes/world.hpp"
#include "network/protocol_manager.hpp"
#include "network/network_world.hpp"
#include "race/race_manager.hpp"
#include "states_screens/state_manager.hpp"
@@ -148,6 +149,10 @@ void MainLoop::run()
irr_driver->update(dt);
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("Protocol manager update", 0x7F, 0x00, 0x7F);
ProtocolManager::getInstance()->update();
PROFILER_POP_CPU_MARKER();
PROFILER_SYNC_FRAME();
}

View File

@@ -50,8 +50,9 @@ ProtocolManager::ProtocolManager()
pthread_mutex_lock(&m_exit_mutex); // will let the update function run
m_update_thread = (pthread_t*)(malloc(sizeof(pthread_t)));
pthread_create(m_update_thread, NULL, protocolManagerUpdate, this);
/// NOT USED but updated in main loop (because of GUI crash)
//m_update_thread = (pthread_t*)(malloc(sizeof(pthread_t)));
//pthread_create(m_update_thread, NULL, protocolManagerUpdate, this);
}
ProtocolManager::~ProtocolManager()

View File

@@ -12,6 +12,7 @@
#include "input/input_manager.hpp"
#include "challenges/unlock_manager.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/kart_selection.hpp"
#include "online/current_online_user.hpp"
StartGameProtocol::StartGameProtocol(GameSetup* game_setup) :
@@ -106,6 +107,11 @@ void StartGameProtocol::update()
Log::info("StartGameProtocol", "Players config ready. Starting single race now.");
race_manager->startSingleRace("jungle", 1, false);
m_state = LOADING;
/*
KartSelectionScreen* s = KartSelectionScreen::getInstance();
s->setMultiplayer(false);
s->setFromOverworld(false);
StateManager::get()->pushScreen( s );*/
}
else if (m_state == LOADING)
{
@@ -124,6 +130,7 @@ void StartGameProtocol::ready() // on clients, means the loading is finished
assert(NetworkManager::getInstance()->getPeerCount() == 1);
NetworkString ns;
ns.ai32(NetworkManager::getInstance()->getPeers()[0]->getClientServerToken()).ai8(1);
m_listener->sendMessage(this, ns, true);
}
else // on the server
{

View File

@@ -462,6 +462,7 @@ void RaceManager::startNextRace()
m_kart_status[i].m_last_time = 0;
}
StartGameProtocol* protocol = static_cast<StartGameProtocol*>(
ProtocolManager::getInstance()->getProtocol(PROTOCOL_START_GAME));
if (protocol) // if this protocol exists, that's that we play online