summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-06-04 21:52:54 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-06-04 21:52:54 +0200
commitea49abd113050eb36fb85ac792cdab0e901b77e6 (patch)
treeee779c823cf4e48697fc7f175fd4244dfbbe2104
parentHealth of monsters is now saved (diff)
downloadcuberite-ea49abd113050eb36fb85ac792cdab0e901b77e6.tar
cuberite-ea49abd113050eb36fb85ac792cdab0e901b77e6.tar.gz
cuberite-ea49abd113050eb36fb85ac792cdab0e901b77e6.tar.bz2
cuberite-ea49abd113050eb36fb85ac792cdab0e901b77e6.tar.lz
cuberite-ea49abd113050eb36fb85ac792cdab0e901b77e6.tar.xz
cuberite-ea49abd113050eb36fb85ac792cdab0e901b77e6.tar.zst
cuberite-ea49abd113050eb36fb85ac792cdab0e901b77e6.zip
-rw-r--r--src/World.cpp12
-rw-r--r--src/WorldStorage/WSSAnvil.cpp13
2 files changed, 22 insertions, 3 deletions
diff --git a/src/World.cpp b/src/World.cpp
index 345c894eb..739ae39d4 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -11,6 +11,7 @@
#include "ChunkMap.h"
#include "Generating/ChunkDesc.h"
#include "OSSupport/Timer.h"
+#include <sstream>
// Serializers
#include "WorldStorage/ScoreboardSerializer.h"
@@ -569,6 +570,11 @@ void cWorld::Start(void)
m_bUseChatPrefixes = IniFile.GetValueSetB("Mechanics", "UseChatPrefixes", true);
m_VillagersShouldHarvestCrops = IniFile.GetValueSetB("Monsters", "VillagersShouldHarvestCrops", true);
int GameMode = IniFile.GetValueSetI("General", "Gamemode", (int)m_GameMode);
+ int Weather = IniFile.GetValueSetI("General", "Weather", (int)m_Weather);
+
+ std::stringstream ss;
+ ss << m_TimeOfDay;
+ Int64 TimeOfDay = _atoi64(IniFile.GetValueSet("General", "TimeInTicks", ss.str()).c_str());
if ((GetDimension() != dimNether) && (GetDimension() != dimEnd))
{
@@ -581,6 +587,7 @@ void cWorld::Start(void)
// Adjust the enum-backed variables into their respective bounds:
m_GameMode = (eGameMode) Clamp(GameMode, (int)gmSurvival, (int)gmAdventure);
m_TNTShrapnelLevel = (eShrapnelLevel)Clamp(TNTShrapnelLevel, (int)slNone, (int)slAll);
+ m_Weather = (eWeather) Clamp(Weather, (int)wSunny, (int)wStorm);
switch (GetDimension())
{
@@ -759,6 +766,11 @@ void cWorld::Stop(void)
IniFile.SetValueI("Physics", "TNTShrapnelLevel", (int)m_TNTShrapnelLevel);
IniFile.SetValueB("Mechanics", "CommandBlocksEnabled", m_bCommandBlocksEnabled);
IniFile.SetValueB("Mechanics", "UseChatPrefixes", m_bUseChatPrefixes);
+ IniFile.SetValueI("General", "Weather", (int)m_Weather);
+
+ std::stringstream ss;
+ ss << m_TimeOfDay;
+ IniFile.SetValue("General", "TimeInTicks", ss.str());
IniFile.WriteFile(m_IniFileName);
m_TickThread.Stop();
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index f58e876e0..c84763ac2 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -2454,9 +2454,16 @@ bool cWSSAnvil::LoadMonsterBaseFromNBT(cMonster & a_Monster, const cParsedNBT &
a_Monster.SetDropChanceChestplate(DropChance[2]);
a_Monster.SetDropChanceLeggings(DropChance[3]);
a_Monster.SetDropChanceBoots(DropChance[4]);
- bool CanPickUpLoot = (a_NBT.GetByte(a_NBT.FindChildByName(a_TagIdx, "CanPickUpLoot")) == 1);
- a_Monster.SetCanPickUpLoot(CanPickUpLoot);
- a_Monster.SetHealth(a_NBT.GetShort(a_NBT.FindChildByName(a_TagIdx, "Health")));
+
+ int LootTag = a_NBT.FindChildByName(a_TagIdx, "CanPickUpLoot");
+ if (LootTag > 0)
+ {
+ bool CanPickUpLoot = (a_NBT.GetByte(LootTag) == 1);
+ a_Monster.SetCanPickUpLoot(CanPickUpLoot);
+ }
+
+ int HealthTag = a_NBT.FindChildByName(a_TagIdx, "Health");
+ a_Monster.SetHealth(HealthTag > 0 ? a_NBT.GetShort(HealthTag) : a_Monster.GetMaxHealth());
return true;
}