diff --git a/src/guiengine/screen.cpp b/src/guiengine/screen.cpp index 0f64a42cf..ffccd491f 100644 --- a/src/guiengine/screen.cpp +++ b/src/guiengine/screen.cpp @@ -25,6 +25,7 @@ #include "guiengine/modaldialog.hpp" #include "guiengine/widget.hpp" #include "modes/world.hpp" +#include "network/network_config.hpp" #include "states_screens/state_manager.hpp" #include @@ -90,7 +91,8 @@ Screen::~Screen() */ void Screen::init() { - if(m_pause_race && World::getWorld()) + if (m_pause_race && World::getWorld() && + !NetworkConfig::get()->isNetworking()) World::getWorld()->schedulePause(World::IN_GAME_MENU_PHASE); } // init @@ -111,7 +113,8 @@ void Screen::push() */ void Screen::tearDown() { - if(m_pause_race && World::getWorld()) + if (m_pause_race && World::getWorld() && + !NetworkConfig::get()->isNetworking()) World::getWorld()->scheduleUnpause(); } // tearDown diff --git a/src/modes/soccer_world.cpp b/src/modes/soccer_world.cpp index fbb4db5e7..0271ab98f 100644 --- a/src/modes/soccer_world.cpp +++ b/src/modes/soccer_world.cpp @@ -457,6 +457,9 @@ void SoccerWorld::setBallHitter(unsigned int kart_id) */ bool SoccerWorld::isRaceOver() { + if (m_unfair_team) + return true; + if (race_manager->hasTimeTarget()) { return m_count_down_reached_zero; diff --git a/src/modes/soccer_world.hpp b/src/modes/soccer_world.hpp index 190f76b3a..89b9bf18a 100644 --- a/src/modes/soccer_world.hpp +++ b/src/modes/soccer_world.hpp @@ -409,6 +409,9 @@ public: void handlePlayerGoalFromServer(const NetworkString& ns); // ------------------------------------------------------------------------ void handleResetBallFromServer(const NetworkString& ns); + // ------------------------------------------------------------------------ + virtual bool hasTeam() const OVERRIDE { return true; } + // ------------------------------------------------------------------------ }; // SoccerWorld diff --git a/src/modes/world.cpp b/src/modes/world.cpp index 05f25e56e..81e163f94 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -312,6 +312,7 @@ void World::reset() // Reset all data structures that depend on number of karts. irr_driver->reset(); + m_unfair_team = false; } // reset //----------------------------------------------------------------------------- diff --git a/src/modes/world.hpp b/src/modes/world.hpp index 34ba7a37d..777a0c4b8 100644 --- a/src/modes/world.hpp +++ b/src/modes/world.hpp @@ -108,6 +108,8 @@ protected: bool m_stop_music_when_dialog_open; + bool m_unfair_team; + /** Whether highscores should be used for this kind of race. * True by default, change to false in a child class to disable. */ @@ -327,7 +329,11 @@ public: virtual void loadCustomModels() {} // ------------------------------------------------------------------------ void eliminateKart(int kart_number, bool notify_of_elimination = true); - + // ------------------------------------------------------------------------ + void setUnfairTeam(bool val) { m_unfair_team = val; } + // ------------------------------------------------------------------------ + virtual bool hasTeam() const { return false; } + // ------------------------------------------------------------------------ /** Set the network mode (true if networked) */ void setNetworkWorld(bool is_networked) { m_is_network_world = is_networked; } diff --git a/src/network/game_setup.cpp b/src/network/game_setup.cpp index 29b3ebcc7..b032d4fd5 100644 --- a/src/network/game_setup.cpp +++ b/src/network/game_setup.cpp @@ -54,9 +54,19 @@ void GameSetup::update(bool remove_disconnected_players) if (!World::getWorld() || World::getWorld()->getPhase() < WorldStatus::MUSIC_PHASE) return; + int red_count = 0; + int blue_count = 0; for (uint8_t i = 0; i < (uint8_t)m_players.size(); i++) { - if (!m_players[i].expired()) + bool disconnected = m_players[i].expired(); + if (race_manager->getKartInfo(i).getSoccerTeam() == SOCCER_TEAM_RED && + !disconnected) + red_count++; + else if (race_manager->getKartInfo(i).getSoccerTeam() == + SOCCER_TEAM_BLUE && !disconnected) + blue_count++; + + if (!disconnected) continue; AbstractKart* k = World::getWorld()->getKart(i); if (!k->isEliminated()) @@ -72,6 +82,9 @@ void GameSetup::update(bool remove_disconnected_players) STKHost::get()->sendPacketToAllPeers(&p, true); } } + if (m_players.size() != 1 && World::getWorld()->hasTeam() && + (red_count == 0 || blue_count == 0)) + World::getWorld()->setUnfairTeam(true); } // removePlayer //----------------------------------------------------------------------------- diff --git a/src/network/protocols/client_lobby.cpp b/src/network/protocols/client_lobby.cpp index 241f4ef9c..1e55c113b 100644 --- a/src/network/protocols/client_lobby.cpp +++ b/src/network/protocols/client_lobby.cpp @@ -337,6 +337,7 @@ void ClientLobby::update(int ticks) GUIEngine::ModalDialog::dismiss(); if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU) StateManager::get()->enterGameState(); + World::getWorld()->enterRaceOverState(); } break; case DONE: