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