Made sorting of players descending (instead of using > in operator<),
removed kart and unique id from game slot, replaced some forgotten calls to unlock_manager with calls to PlayerManager.
This commit is contained in:
parent
16521fce5a
commit
230e1789f2
@ -22,13 +22,13 @@
|
|||||||
#include "challenges/challenge.hpp"
|
#include "challenges/challenge.hpp"
|
||||||
#include "challenges/challenge_data.hpp"
|
#include "challenges/challenge_data.hpp"
|
||||||
#include "challenges/unlock_manager.hpp"
|
#include "challenges/unlock_manager.hpp"
|
||||||
|
#include "config/player_manager.hpp"
|
||||||
#include "io/utf_writer.hpp"
|
#include "io/utf_writer.hpp"
|
||||||
#include "io/xml_node.hpp"
|
#include "io/xml_node.hpp"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
GameSlot::GameSlot(const XMLNode *node)
|
GameSlot::GameSlot(const XMLNode *node)
|
||||||
{
|
{
|
||||||
m_kart_ident = "";
|
|
||||||
m_points = 0;
|
m_points = 0;
|
||||||
m_first_time = true;
|
m_first_time = true;
|
||||||
m_easy_challenges = 0;
|
m_easy_challenges = 0;
|
||||||
@ -39,7 +39,6 @@ GameSlot::GameSlot(const XMLNode *node)
|
|||||||
// If there is saved data, load it
|
// If there is saved data, load it
|
||||||
if(node)
|
if(node)
|
||||||
{
|
{
|
||||||
node->get("kart", &m_kart_ident);
|
|
||||||
node->get("first-time", &m_first_time);
|
node->get("first-time", &m_first_time);
|
||||||
|
|
||||||
for(unsigned int i=0; i<node->getNumNodes(); i++)
|
for(unsigned int i=0; i<node->getNumNodes(); i++)
|
||||||
@ -201,7 +200,7 @@ void GameSlot::unlockFeature(Challenge* c, RaceManager::Difficulty d,
|
|||||||
if (p == m_locked_features.end())
|
if (p == m_locked_features.end())
|
||||||
{
|
{
|
||||||
c->setSolved(d);
|
c->setSolved(d);
|
||||||
if(do_save) unlock_manager->save();
|
if(do_save) PlayerManager::get()->save();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_locked_features.erase(p);
|
m_locked_features.erase(p);
|
||||||
@ -212,7 +211,7 @@ void GameSlot::unlockFeature(Challenge* c, RaceManager::Difficulty d,
|
|||||||
c->setSolved(d); // reset isActive flag
|
c->setSolved(d); // reset isActive flag
|
||||||
|
|
||||||
// Save the new unlock information
|
// Save the new unlock information
|
||||||
if (do_save) unlock_manager->save();
|
if (do_save) PlayerManager::get()->save();
|
||||||
} // unlockFeature
|
} // unlockFeature
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -267,7 +266,6 @@ void GameSlot::grandPrixFinished()
|
|||||||
void GameSlot::save(UTFWriter &out)
|
void GameSlot::save(UTFWriter &out)
|
||||||
{
|
{
|
||||||
out << L" <game-slot playerID=\"" << m_player_unique_id
|
out << L" <game-slot playerID=\"" << m_player_unique_id
|
||||||
<< L"\" kart=\"" << m_kart_ident
|
|
||||||
<< L"\" firstTime=\"" << m_first_time << L"\">\n";
|
<< L"\" firstTime=\"" << m_first_time << L"\">\n";
|
||||||
std::map<std::string, Challenge*>::const_iterator i;
|
std::map<std::string, Challenge*>::const_iterator i;
|
||||||
for(i = m_challenges_state.begin();
|
for(i = m_challenges_state.begin();
|
||||||
|
@ -43,8 +43,6 @@ const int CHALLENGE_POINTS[] = { 8, 9, 10 };
|
|||||||
|
|
||||||
class GameSlot
|
class GameSlot
|
||||||
{
|
{
|
||||||
std::string m_kart_ident;
|
|
||||||
|
|
||||||
/** Profile names can change, so rather than try to make sure all renames
|
/** Profile names can change, so rather than try to make sure all renames
|
||||||
* are done everywhere, assign a unique ID to each profiler.
|
* are done everywhere, assign a unique ID to each profiler.
|
||||||
* Will save much headaches.
|
* Will save much headaches.
|
||||||
@ -80,8 +78,6 @@ public:
|
|||||||
GameSlot(const XMLNode *node=NULL);
|
GameSlot(const XMLNode *node=NULL);
|
||||||
~GameSlot();
|
~GameSlot();
|
||||||
|
|
||||||
unsigned int getPlayerID() const { return m_player_unique_id; }
|
|
||||||
const std::string& getKartIdent () const { return m_kart_ident; }
|
|
||||||
void computeActive();
|
void computeActive();
|
||||||
bool isLocked (const std::string& feature);
|
bool isLocked (const std::string& feature);
|
||||||
void lockFeature (Challenge *challenge);
|
void lockFeature (Challenge *challenge);
|
||||||
@ -92,11 +88,6 @@ public:
|
|||||||
void save (UTFWriter &out);
|
void save (UTFWriter &out);
|
||||||
void setCurrentChallenge(const std::string &challenge_id);
|
void setCurrentChallenge(const std::string &challenge_id);
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
void setKartIdent(const std::string& kart_ident)
|
|
||||||
{
|
|
||||||
m_kart_ident = kart_ident;
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns the list of recently unlocked features (e.g. call at the end
|
/** Returns the list of recently unlocked features (e.g. call at the end
|
||||||
* of a race to know if any features were unlocked) */
|
* of a race to know if any features were unlocked) */
|
||||||
|
@ -91,21 +91,18 @@ void PlayerProfile::incrementUseFrequency()
|
|||||||
} // incrementUseFrequency
|
} // incrementUseFrequency
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/** Comparison used to sort players. Most frequent players should be
|
/** Comparison used to sort players.
|
||||||
* listed first, so a<b actually means that
|
|
||||||
* a.m_use_frequency > b.m_use_frequency
|
|
||||||
* This way we get a reversed sorted list.
|
|
||||||
*/
|
*/
|
||||||
bool PlayerProfile::operator<(const PlayerProfile &other)
|
bool PlayerProfile::operator<(const PlayerProfile &other)
|
||||||
{
|
{
|
||||||
return getUseFrequency() > other.getUseFrequency();
|
return getUseFrequency() < other.getUseFrequency();
|
||||||
} // operator<
|
} // operator<
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/** \brief Needed for toggling sort order **/
|
/** \brief Needed for toggling sort order **/
|
||||||
bool PlayerProfile::operator>(const PlayerProfile &other)
|
bool PlayerProfile::operator>(const PlayerProfile &other)
|
||||||
{
|
{
|
||||||
return getUseFrequency() < other.getUseFrequency();
|
return getUseFrequency() > other.getUseFrequency();
|
||||||
} // operator>
|
} // operator>
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -88,7 +88,7 @@ void PlayerManager::load()
|
|||||||
if(player->isDefault())
|
if(player->isDefault())
|
||||||
m_current_player = player;
|
m_current_player = player;
|
||||||
}
|
}
|
||||||
m_all_players.insertionSort();
|
m_all_players.insertionSort(/*start*/0, /*desc*/true);
|
||||||
|
|
||||||
if(!m_current_player)
|
if(!m_current_player)
|
||||||
{
|
{
|
||||||
|
@ -52,10 +52,7 @@ public:
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
UTFWriter& operator<< (const T t)
|
UTFWriter& operator<< (const T t)
|
||||||
{
|
{
|
||||||
irr::core::stringw tmp;
|
return operator<<(StringUtils::toString<T>(t));
|
||||||
tmp += t;
|
|
||||||
(*this) << tmp;
|
|
||||||
return *this;
|
|
||||||
} // operator<< (template)
|
} // operator<< (template)
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
bool is_open() { return m_base.is_open(); }
|
bool is_open() { return m_base.is_open(); }
|
||||||
|
@ -385,7 +385,7 @@ void CutsceneWorld::enterRaceOverState()
|
|||||||
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
||||||
|
|
||||||
player->setFirstTime(false);
|
player->setFirstTime(false);
|
||||||
unlock_manager->save();
|
PlayerManager::get()->save();
|
||||||
KartSelectionScreen* s = OfflineKartSelectionScreen::getInstance();
|
KartSelectionScreen* s = OfflineKartSelectionScreen::getInstance();
|
||||||
s->setMultiplayer(false);
|
s->setMultiplayer(false);
|
||||||
s->setGoToOverworldNext();
|
s->setGoToOverworldNext();
|
||||||
|
@ -121,9 +121,7 @@ void EnterPlayerNameDialog::onEnterPressedInternal()
|
|||||||
|
|
||||||
// Finally, add the new player.
|
// Finally, add the new player.
|
||||||
PlayerManager::get()->addNewPlayer(player_name);
|
PlayerManager::get()->addNewPlayer(player_name);
|
||||||
bool created = unlock_manager->createSlotsIfNeeded();
|
PlayerManager::get()->save();
|
||||||
if (created) unlock_manager->save();
|
|
||||||
user_config->saveConfig();
|
|
||||||
|
|
||||||
// It's unsafe to delete from inside the event handler so we do it
|
// It's unsafe to delete from inside the event handler so we do it
|
||||||
// in onUpdate (which checks for m_self_destroy)
|
// in onUpdate (which checks for m_self_destroy)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user