Fixed various minor bugs.
This commit is contained in:
@@ -35,6 +35,8 @@
|
||||
*/
|
||||
void Challenge::load(const XMLNode* challengesNode)
|
||||
{
|
||||
if(m_data->getId()=="olivermath")
|
||||
printf("");
|
||||
const XMLNode* node = challengesNode->getNode( m_data->getId() );
|
||||
if(node == NULL)
|
||||
{
|
||||
|
||||
@@ -265,10 +265,8 @@ void GameSlot::grandPrixFinished()
|
||||
*/
|
||||
void GameSlot::save(UTFWriter &out)
|
||||
{
|
||||
out << " <gameslot playerID=\"" << m_player_unique_id.c_str()
|
||||
<< "\" kart=\"" << m_kart_ident.c_str()
|
||||
<< "\" firstTime=\"" << StringUtils::toString(m_first_time)
|
||||
<< "\"> <!-- " << name.c_str() << " -->\n";
|
||||
out << " <game-slot playerID=\"" << m_player_unique_id
|
||||
<< "\" firstTime=\"" << m_first_time << L"\">\n";
|
||||
std::map<std::string, Challenge*>::const_iterator i;
|
||||
for(i = m_challenges_state.begin();
|
||||
i != m_challenges_state.end(); i++)
|
||||
|
||||
@@ -40,7 +40,7 @@ PlayerProfile::PlayerProfile(const core::stringw& name, bool is_guest)
|
||||
#endif
|
||||
m_name = name;
|
||||
m_is_guest_account = is_guest;
|
||||
m_use_frequency = 0;
|
||||
m_use_frequency = is_guest ? -1 : 0;
|
||||
m_unique_id = PlayerManager::get()->getUniqueId();
|
||||
m_game_slot = unlock_manager->createGameSlot();
|
||||
|
||||
@@ -95,14 +95,14 @@ void PlayerProfile::incrementUseFrequency()
|
||||
*/
|
||||
bool PlayerProfile::operator<(const PlayerProfile &other)
|
||||
{
|
||||
return getUseFrequency() < other.getUseFrequency();
|
||||
return m_use_frequency < other.m_use_frequency;
|
||||
} // operator<
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** \brief Needed for toggling sort order **/
|
||||
bool PlayerProfile::operator>(const PlayerProfile &other)
|
||||
{
|
||||
return getUseFrequency() > other.getUseFrequency();
|
||||
return m_use_frequency > other.m_use_frequency;
|
||||
} // operator>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -54,8 +54,8 @@ private:
|
||||
unsigned int m_magic_number;
|
||||
#endif
|
||||
|
||||
/** Counts how often this player was used. */
|
||||
unsigned int m_use_frequency;
|
||||
/** Counts how often this player was used (always -1 for guests). */
|
||||
int m_use_frequency;
|
||||
|
||||
/** A unique number for this player, used to link it to challenges etc. */
|
||||
unsigned int m_unique_id;
|
||||
@@ -84,47 +84,49 @@ public:
|
||||
#ifdef DEBUG
|
||||
m_magic_number = 0xDEADBEEF;
|
||||
#endif
|
||||
}
|
||||
} // ~PlayerProfile
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the name of this player. */
|
||||
void setName(const core::stringw& name)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
assert(m_magic_number == 0xABCD1234);
|
||||
#endif
|
||||
m_name = name;
|
||||
}
|
||||
} // setName
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the name of this player. */
|
||||
core::stringw getName() const
|
||||
{
|
||||
#ifdef DEBUG
|
||||
assert(m_magic_number == 0xABCD1234);
|
||||
#endif
|
||||
return m_name.c_str();
|
||||
}
|
||||
} // getName
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if this player is a guest account. */
|
||||
bool isGuestAccount() const
|
||||
{
|
||||
#ifdef DEBUG
|
||||
assert(m_magic_number == 0xABCD1234);
|
||||
#endif
|
||||
return m_is_guest_account;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
int getUseFrequency() const
|
||||
{
|
||||
if (m_is_guest_account) return -1;
|
||||
else return m_use_frequency;
|
||||
}
|
||||
} // isGuestAccount
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the unique id of this player. */
|
||||
unsigned int getUniqueID() const { return m_unique_id; }
|
||||
// -----------------------------------------------------------------------
|
||||
/** Returns true if this is the default (last used) player. */
|
||||
bool isDefault() const { return m_is_default; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returned if the feature (kart, track) is locked. */
|
||||
/** Sets if this player is the default player or not. */
|
||||
void setDefault(bool is_default) { m_is_default = is_default; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returnes if the feature (kart, track) is locked. */
|
||||
bool isLocked(const std::string &feature) const
|
||||
{
|
||||
return m_game_slot->isLocked(feature);
|
||||
@@ -133,11 +135,13 @@ public:
|
||||
/** Returns all active challenges. */
|
||||
void computeActive() { m_game_slot->computeActive(); }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the list of recently completed challenges. */
|
||||
std::vector<const ChallengeData*> getRecentlyCompletedChallenges()
|
||||
{
|
||||
return m_game_slot->getRecentlyCompletedChallenges();
|
||||
} // getRecently Completed Challenges
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the currently active challenge. */
|
||||
void setCurrentChallenge(const std::string &name)
|
||||
{
|
||||
m_game_slot->setCurrentChallenge(name);
|
||||
@@ -147,6 +151,8 @@ public:
|
||||
* challenges. */
|
||||
void raceFinished() { m_game_slot->raceFinished(); }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Callback when a GP is finished (to test if a challenge was
|
||||
* fulfilled). */
|
||||
void grandPrixFinished() { m_game_slot->grandPrixFinished(); }
|
||||
// ------------------------------------------------------------------------
|
||||
unsigned int getPoints() const { return m_game_slot->getPoints(); }
|
||||
@@ -182,13 +188,6 @@ public:
|
||||
{
|
||||
return m_game_slot->getNumHardTrophies();
|
||||
} // getNumHardTropies
|
||||
// -----------------------------------------------------------------------
|
||||
/** Returns true if this is the default (last used) player. */
|
||||
bool isDefault() const { return m_is_default; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets if this player is the default player or not. */
|
||||
void setDefault(bool is_default) { m_is_default = is_default; }
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
}; // class PlayerProfile
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ void PlayerManager::create()
|
||||
*/
|
||||
PlayerManager::PlayerManager()
|
||||
{
|
||||
m_current_player = NULL;
|
||||
load();
|
||||
} // PlayerManager
|
||||
|
||||
@@ -167,7 +168,7 @@ void PlayerManager::addDefaultPlayer()
|
||||
m_all_players.push_back(new PlayerProfile(username.c_str()) );
|
||||
|
||||
// add default guest player
|
||||
m_all_players.push_back( new PlayerProfile(_LTR("Guest")) );
|
||||
m_all_players.push_back( new PlayerProfile(_LTR("Guest"), /*guest*/true) );
|
||||
|
||||
|
||||
} // addDefaultPlayer
|
||||
|
||||
Reference in New Issue
Block a user