Fixes
This commit is contained in:
parent
aea866f5b1
commit
466ff2204f
@ -1150,6 +1150,7 @@ unsigned int cPlayer::AwardAchievement(const eStatistic a_Ach)
|
||||
{
|
||||
eStatistic Prerequisite = cStatInfo::GetPrerequisite(a_Ach);
|
||||
|
||||
// Check if the prerequisites are met
|
||||
if (Prerequisite != statInvalid)
|
||||
{
|
||||
if (m_Stats.GetValue(Prerequisite) == 0)
|
||||
@ -1166,14 +1167,16 @@ unsigned int cPlayer::AwardAchievement(const eStatistic a_Ach)
|
||||
}
|
||||
else
|
||||
{
|
||||
// First time, announce it
|
||||
cCompositeChat Msg;
|
||||
Msg.AddTextPart(m_PlayerName + " has just earned the achievement ");
|
||||
Msg.AddTextPart(cStatInfo::GetName(a_Ach)); // TODO 2014-05-12 xdot: Use the proper cCompositeChat submessage type and send the actual title
|
||||
Msg.AddTextPart(cStatInfo::GetName(a_Ach)); // TODO 2014-05-12 xdot: Use the proper cCompositeChat part (cAchievement)
|
||||
m_World->BroadcastChat(Msg);
|
||||
|
||||
// Increment the statistic
|
||||
StatValue New = m_Stats.AddValue(a_Ach);
|
||||
|
||||
/* Achievement Get! */
|
||||
// Achievement Get!
|
||||
m_ClientHandle->SendStatistics(m_Stats);
|
||||
|
||||
return New;
|
||||
@ -1707,9 +1710,8 @@ bool cPlayer::LoadFromDisk()
|
||||
|
||||
m_LoadedWorldName = root.get("world", "world").asString();
|
||||
|
||||
/* Load the player stats.
|
||||
* We use the default world name (like bukkit) because stats are shared between dimensions/worlds.
|
||||
*/
|
||||
// Load the player stats.
|
||||
// We use the default world name (like bukkit) because stats are shared between dimensions/worlds.
|
||||
cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), GetName(), &m_Stats);
|
||||
StatSerializer.Load();
|
||||
|
||||
@ -1784,9 +1786,8 @@ bool cPlayer::SaveToDisk()
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Save the player stats.
|
||||
* We use the default world name (like bukkit) because stats are shared between dimensions/worlds.
|
||||
*/
|
||||
// Save the player stats.
|
||||
// We use the default world name (like bukkit) because stats are shared between dimensions/worlds.
|
||||
cStatSerializer StatSerializer(cRoot::Get()->GetDefaultWorld()->GetName(), m_PlayerName, &m_Stats);
|
||||
if (!StatSerializer.Save())
|
||||
{
|
||||
|
@ -181,12 +181,9 @@ public:
|
||||
cStatManager & GetStatManager() { return m_Stats; }
|
||||
|
||||
/** Awards the player an achievement.
|
||||
*
|
||||
* If all prerequisites are met, this method will award the achievement and will broadcast a chat message.
|
||||
* If the achievement has been already awarded to the player, this method will just increment the stat counter.
|
||||
*
|
||||
* Returns the _new_ stat value. (0 = Could not award achievement)
|
||||
*/
|
||||
If all prerequisites are met, this method will award the achievement and will broadcast a chat message.
|
||||
If the achievement has been already awarded to the player, this method will just increment the stat counter.
|
||||
Returns the _new_ stat value. (0 = Could not award achievement) */
|
||||
unsigned int AwardAchievement(const eStatistic a_Ach);
|
||||
|
||||
void SetIP(const AString & a_IP);
|
||||
|
@ -464,7 +464,7 @@ bool cMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((m_SoundHurt != "") && (m_Health > 0))
|
||||
if (!m_SoundHurt.empty() && (m_Health > 0))
|
||||
{
|
||||
m_World->BroadcastSoundEffect(m_SoundHurt, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f);
|
||||
}
|
||||
|
@ -14,12 +14,15 @@
|
||||
cStatSerializer::cStatSerializer(const AString & a_WorldName, const AString & a_PlayerName, cStatManager * a_Manager)
|
||||
: m_Manager(a_Manager)
|
||||
{
|
||||
// Even though stats are shared between worlds, they are (usually) saved
|
||||
// inside the folder of the default world.
|
||||
|
||||
AString StatsPath;
|
||||
Printf(StatsPath, "%s/stats", a_WorldName.c_str());
|
||||
|
||||
m_Path = StatsPath + "/" + a_PlayerName + ".json";
|
||||
|
||||
/* Ensure that the directory exists. */
|
||||
// Ensure that the directory exists.
|
||||
cFile::CreateFolder(FILE_IO_PREFIX + StatsPath);
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,10 @@ public:
|
||||
|
||||
cStatSerializer(const AString & a_WorldName, const AString & a_PlayerName, cStatManager * a_Manager);
|
||||
|
||||
/* Try to load the player statistics. Returns whether the operation was successful or not. */
|
||||
bool Load(void);
|
||||
|
||||
/* Try to save the player statistics. Returns whether the operation was successful or not. */
|
||||
bool Save(void);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user