adding things in order to be able to leave the world at the end of a network race
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13397 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
commit
057c8f46be
9473
diff.patch
Normal file
9473
diff.patch
Normal file
File diff suppressed because it is too large
Load Diff
@ -175,6 +175,12 @@
|
||||
#include "network/protocols/server_lobby_room_protocol.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "online/http_manager.hpp"
|
||||
#include "network/client_network_manager.hpp"
|
||||
#include "network/server_network_manager.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/protocols/server_lobby_room_protocol.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "online/http_manager.hpp"
|
||||
#include "race/grand_prix_manager.hpp"
|
||||
#include "race/highscore_manager.hpp"
|
||||
#include "race/history.hpp"
|
||||
|
@ -10,6 +10,7 @@
|
||||
NetworkWorld::NetworkWorld()
|
||||
{
|
||||
m_running = false;
|
||||
m_has_run = false;
|
||||
}
|
||||
|
||||
NetworkWorld::~NetworkWorld()
|
||||
@ -18,6 +19,8 @@ NetworkWorld::~NetworkWorld()
|
||||
|
||||
void NetworkWorld::update(float dt)
|
||||
{
|
||||
if (!m_has_run)
|
||||
m_has_run = true;
|
||||
SynchronizationProtocol* protocol = static_cast<SynchronizationProtocol*>(
|
||||
ProtocolManager::getInstance()->getProtocol(PROTOCOL_SYNCHRONIZATION));
|
||||
if (protocol) // if this protocol exists, that's that we play online
|
||||
@ -29,6 +32,12 @@ void NetworkWorld::update(float dt)
|
||||
}
|
||||
}
|
||||
World::getWorld()->updateWorld(dt);
|
||||
if (World::getWorld()->getPhase() >= WorldStatus::RESULT_DISPLAY_PHASE) // means it's the end
|
||||
{
|
||||
// consider the world finished.
|
||||
stop();
|
||||
Log::info("NetworkWorld", "The game is considered finish.");
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkWorld::controllerAction(Controller* controller, PlayerAction action, int value)
|
||||
@ -38,3 +47,10 @@ void NetworkWorld::controllerAction(Controller* controller, PlayerAction action,
|
||||
if (protocol)
|
||||
protocol->controllerAction(controller, action, value);
|
||||
}
|
||||
|
||||
bool NetworkWorld::isRaceOver()
|
||||
{
|
||||
if (!World::getWorld())
|
||||
return false;
|
||||
return (World::getWorld()->getPhase() >= WorldStatus::RESULT_DISPLAY_PHASE);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ class NetworkWorld : public Singleton<NetworkWorld>
|
||||
void start() { m_running = true; }
|
||||
void stop() { m_running = false; }
|
||||
bool isRunning() { return m_running; }
|
||||
bool isRaceOver();
|
||||
|
||||
void controllerAction(Controller* controller, PlayerAction action, int value);
|
||||
|
||||
@ -28,6 +29,7 @@ class NetworkWorld : public Singleton<NetworkWorld>
|
||||
protected:
|
||||
bool m_running;
|
||||
float m_race_time;
|
||||
bool m_has_run;
|
||||
|
||||
private:
|
||||
NetworkWorld();
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "network/network_manager.hpp"
|
||||
#include "network/protocols/start_game_protocol.hpp"
|
||||
#include "network/network_world.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/network_kart_selection.hpp"
|
||||
@ -141,7 +142,26 @@ void ClientLobbyRoomProtocol::update()
|
||||
case SELECTING_KARTS:
|
||||
break;
|
||||
case PLAYING:
|
||||
break;
|
||||
{
|
||||
if (NetworkWorld::getInstance<NetworkWorld>()->isRaceOver()) // race is now over, kill race protocols and return to connected state
|
||||
{
|
||||
Protocol* protocol = NULL;
|
||||
protocol = m_listener->getProtocol(PROTOCOL_CONTROLLER_EVENTS);
|
||||
if (protocol)
|
||||
m_listener->requestTerminate(protocol);
|
||||
else
|
||||
Log::error("ClientLobbyRoomProtocol", "No controller events protocol registered.");
|
||||
|
||||
protocol = m_listener->getProtocol(PROTOCOL_KART_UPDATE);
|
||||
if (protocol)
|
||||
m_listener->requestTerminate(protocol);
|
||||
else
|
||||
Log::error("ClientLobbyRoomProtocol", "No kart update protocol registered.");
|
||||
|
||||
Log::info("ClientLobbyRoomProtocol", "Game finished.");
|
||||
m_state = CONNECTED;
|
||||
}
|
||||
} break;
|
||||
case DONE:
|
||||
m_state = EXITING;
|
||||
m_listener->requestTerminate(this);
|
||||
|
@ -115,7 +115,11 @@ void StartGameProtocol::update()
|
||||
PlayerProfile* profileToUse = unlock_manager->getCurrentPlayer();
|
||||
assert(profileToUse);
|
||||
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
|
||||
int new_player_id = StateManager::get()->createActivePlayer( profileToUse, device , players[i]->user_profile);
|
||||
int new_player_id = 0;
|
||||
if (StateManager::get()->getActivePlayers().size() >= 0) // more than one player, we're the first
|
||||
new_player_id = 0;
|
||||
else
|
||||
new_player_id = StateManager::get()->createActivePlayer( profileToUse, device , players[i]->user_profile);
|
||||
device->setPlayer(StateManager::get()->getActivePlayer(new_player_id));
|
||||
input_manager->getDeviceList()->setSinglePlayer(StateManager::get()->getActivePlayer(new_player_id));
|
||||
|
||||
|
@ -31,7 +31,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace Online{
|
||||
|
||||
/**
|
||||
|
@ -774,7 +774,7 @@ void RaceManager::startSingleRace(const std::string &track_ident,
|
||||
|
||||
setCoinTarget( 0 ); // Might still be set from a previous challenge
|
||||
if (!NetworkWorld::getInstance<NetworkWorld>()->isRunning()) // if not in a network world
|
||||
race_manager->setupPlayerKartInfo(); // do this setup player kart
|
||||
race_manager->setupPlayerKartInfo(); // do this setup player kart
|
||||
|
||||
startNew(from_overworld);
|
||||
}
|
||||
|
@ -36,11 +36,14 @@
|
||||
#include "states_screens/networking_lobby.hpp"
|
||||
#include "states_screens/server_selection.hpp"
|
||||
#include "states_screens/create_server_screen.hpp"
|
||||
#include "modes/demo_world.hpp"
|
||||
#include "states_screens/networking_lobby_settings.hpp"
|
||||
#include "online/servers_manager.hpp"
|
||||
#include "online/messages.hpp"
|
||||
#include "online/request.hpp"
|
||||
#include "modes/demo_world.hpp"
|
||||
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/protocols/connect_to_server.hpp"
|
||||
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/protocols/connect_to_server.hpp"
|
||||
|
Loading…
Reference in New Issue
Block a user