diff --git a/src/challenges/unlock_manager.cpp b/src/challenges/unlock_manager.cpp index f04f1ff4c..dbc1d50c7 100644 --- a/src/challenges/unlock_manager.cpp +++ b/src/challenges/unlock_manager.cpp @@ -49,8 +49,6 @@ UnlockManager::UnlockManager() // in main). unlock_manager = this; - m_current_game_slot = 0; - m_locked_sound = sfx_manager->createSoundSource("locked"); @@ -427,18 +425,6 @@ bool UnlockManager::isSupportedVersion(const ChallengeData &challenge) } // isSupportedVersion -//----------------------------------------------------------------------------- - -PlayerProfile* UnlockManager::getCurrentPlayer() -{ - for (unsigned int n=0; ngetNumPlayers(); n++) - { - PlayerProfile* player = PlayerManager::get()->getPlayer(n); - if (player->getUniqueID() == m_current_game_slot) return player; - } - return NULL; -} - //----------------------------------------------------------------------------- void UnlockManager::findWhatWasUnlocked(int points_before, int points_now, diff --git a/src/challenges/unlock_manager.hpp b/src/challenges/unlock_manager.hpp index ae7ab658c..85b6db79b 100644 --- a/src/challenges/unlock_manager.hpp +++ b/src/challenges/unlock_manager.hpp @@ -52,9 +52,6 @@ private: void readAllChallengesInDirs(const std::vector* all_dirs); - /** ID of the active player */ - unsigned int m_current_game_slot; - friend class GameSlot; public: @@ -73,13 +70,10 @@ public: /** Eye- (or rather ear-) candy. Play a sound when user tries to access a locked area */ void playLockSound() const; - unsigned int getCurrentSlotID() const { return m_current_game_slot; } - void findWhatWasUnlocked(int pointsBefore, int pointsNow, std::vector& tracks, std::vector& gps); - PlayerProfile* getCurrentPlayer(); GameSlot *createGameSlot(const XMLNode *node=NULL); }; // UnlockManager diff --git a/src/modes/overworld.cpp b/src/modes/overworld.cpp index 5064e254b..6ac263001 100644 --- a/src/modes/overworld.cpp +++ b/src/modes/overworld.cpp @@ -17,6 +17,7 @@ #include "audio/music_manager.hpp" #include "challenges/unlock_manager.hpp" +#include "config/player_manager.hpp" #include "graphics/irr_driver.hpp" #include "input/device_manager.hpp" #include "input/input.hpp" @@ -63,7 +64,7 @@ void OverWorld::enterOverWorld() InputDevice* device = input_manager->getDeviceList()->getKeyboard(0); // Create player and associate player with keyboard - StateManager::get()->createActivePlayer(unlock_manager->getCurrentPlayer(), + StateManager::get()->createActivePlayer(PlayerManager::get()->getCurrentPlayer(), device, NULL); if (!kart_properties_manager->getKart(UserConfigParams::m_default_kart)) diff --git a/src/modes/world.cpp b/src/modes/world.cpp index b3a18c07b..a2ae337c6 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -752,7 +752,7 @@ void World::updateWorld(float dt) InputDevice* device = input_manager->getDeviceList()->getKeyboard(0); // Create player and associate player with keyboard - StateManager::get()->createActivePlayer(unlock_manager->getCurrentPlayer(), + StateManager::get()->createActivePlayer(PlayerManager::get()->getCurrentPlayer(), device, NULL); if (!kart_properties_manager->getKart(UserConfigParams::m_default_kart)) diff --git a/src/network/protocols/start_game_protocol.cpp b/src/network/protocols/start_game_protocol.cpp index bbf478cd5..1700f18e6 100644 --- a/src/network/protocols/start_game_protocol.cpp +++ b/src/network/protocols/start_game_protocol.cpp @@ -1,5 +1,6 @@ #include "network/protocols/start_game_protocol.hpp" +#include "config/player_manager.hpp" #include "input/device_manager.hpp" #include "input/input_manager.hpp" #include "challenges/unlock_manager.hpp" @@ -113,14 +114,14 @@ void StartGameProtocol::update() rki.setGlobalPlayerId(profile->race_id); rki.setLocalPlayerId(is_me?0:1); rki.setHostId(profile->race_id); - PlayerProfile* profileToUse = unlock_manager->getCurrentPlayer(); - assert(profileToUse); + PlayerProfile* profile_to_use = PlayerManager::get()->getCurrentPlayer(); + assert(profile_to_use); InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice(); int new_player_id = 0; if (StateManager::get()->getActivePlayers().size() >= 1) // 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); + new_player_id = StateManager::get()->createActivePlayer( profile_to_use, device , players[i]->user_profile); device->setPlayer(StateManager::get()->getActivePlayer(new_player_id)); input_manager->getDeviceList()->setSinglePlayer(StateManager::get()->getActivePlayer(new_player_id)); diff --git a/src/states_screens/dialogs/player_info_dialog.cpp b/src/states_screens/dialogs/player_info_dialog.cpp index 0f08be165..4f0f2709c 100644 --- a/src/states_screens/dialogs/player_info_dialog.cpp +++ b/src/states_screens/dialogs/player_info_dialog.cpp @@ -156,7 +156,7 @@ void PlayerInfoDialog::showConfirmDialog() _("Do you really want to delete player '%s' ?", m_player->getName()); - if (unlock_manager->getCurrentSlotID() == m_player->getUniqueID()) + if (PlayerManager::get()->getCurrentPlayer() == m_player) { message = _("You cannot delete this player because it is currently in use."); } @@ -171,7 +171,7 @@ void PlayerInfoDialog::showConfirmDialog() m_irrlicht_window); a->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER); - if (unlock_manager->getCurrentSlotID() != m_player->getUniqueID()) + if (PlayerManager::get()->getCurrentPlayer() != m_player) { ButtonWidget* widget = new ButtonWidget(); widget->m_properties[PROP_ID] = "confirmremove"; diff --git a/src/states_screens/help_screen_1.cpp b/src/states_screens/help_screen_1.cpp index a75d43286..d8ca787b7 100644 --- a/src/states_screens/help_screen_1.cpp +++ b/src/states_screens/help_screen_1.cpp @@ -18,6 +18,7 @@ #include "states_screens/help_screen_1.hpp" #include "challenges/unlock_manager.hpp" +#include "config/player_manager.hpp" #include "guiengine/widget.hpp" #include "guiengine/widgets/list_widget.hpp" #include "guiengine/widgets/ribbon_widget.hpp" @@ -64,7 +65,7 @@ void HelpScreen1::eventCallback(Widget* widget, const std::string& name, const i InputDevice* device = input_manager->getDeviceList()->getKeyboard(0); // Create player and associate player with keyboard - StateManager::get()->createActivePlayer(unlock_manager->getCurrentPlayer(), + StateManager::get()->createActivePlayer(PlayerManager::get()->getCurrentPlayer(), device, NULL); if (kart_properties_manager->getKart(UserConfigParams::m_default_kart) == NULL) diff --git a/src/states_screens/kart_selection.cpp b/src/states_screens/kart_selection.cpp index 4f97c0339..8f9e06c8b 100644 --- a/src/states_screens/kart_selection.cpp +++ b/src/states_screens/kart_selection.cpp @@ -1100,7 +1100,7 @@ bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer) kartsAreaWidget->m_y + kartsAreaWidget->m_h); // ---- Create new active player - PlayerProfile* profile_to_use = unlock_manager->getCurrentPlayer(); + PlayerProfile* profile_to_use = PlayerManager::get()->getCurrentPlayer(); if (!firstPlayer) { diff --git a/src/states_screens/main_menu_screen.cpp b/src/states_screens/main_menu_screen.cpp index c4c8c4158..5ffba1630 100644 --- a/src/states_screens/main_menu_screen.cpp +++ b/src/states_screens/main_menu_screen.cpp @@ -340,7 +340,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, InputDevice* device = input_manager->getDeviceList()->getKeyboard(0); // Create player and associate player with keyboard - StateManager::get()->createActivePlayer(unlock_manager->getCurrentPlayer(), + StateManager::get()->createActivePlayer(PlayerManager::get()->getCurrentPlayer(), device, NULL); if (kart_properties_manager->getKart(UserConfigParams::m_default_kart) == NULL)