Removed all references to current user/slot from unlock manager.

This commit is contained in:
hiker 2014-02-10 08:57:16 +11:00
parent 5acf3e1681
commit 8d1591b260
9 changed files with 13 additions and 30 deletions

View File

@ -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; n<PlayerManager::get()->getNumPlayers(); 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,

View File

@ -52,9 +52,6 @@ private:
void readAllChallengesInDirs(const std::vector<std::string>* 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<std::string>& tracks,
std::vector<std::string>& gps);
PlayerProfile* getCurrentPlayer();
GameSlot *createGameSlot(const XMLNode *node=NULL);
}; // UnlockManager

View File

@ -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))

View File

@ -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))

View File

@ -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));

View File

@ -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";

View File

@ -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)

View File

@ -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)
{

View File

@ -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)