summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-06-05 18:58:29 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-06-05 18:58:29 +0200
commit156c9851b8a099656fa86ea52d989e35e5b7ebf1 (patch)
treef2d8b111aee03dba8f37a8c9bd04952ff1b7926c
parentFixed decision failure (diff)
downloadcuberite-156c9851b8a099656fa86ea52d989e35e5b7ebf1.tar
cuberite-156c9851b8a099656fa86ea52d989e35e5b7ebf1.tar.gz
cuberite-156c9851b8a099656fa86ea52d989e35e5b7ebf1.tar.bz2
cuberite-156c9851b8a099656fa86ea52d989e35e5b7ebf1.tar.lz
cuberite-156c9851b8a099656fa86ea52d989e35e5b7ebf1.tar.xz
cuberite-156c9851b8a099656fa86ea52d989e35e5b7ebf1.tar.zst
cuberite-156c9851b8a099656fa86ea52d989e35e5b7ebf1.zip
Diffstat (limited to '')
-rw-r--r--lib/inifile/iniFile.cpp20
-rw-r--r--lib/inifile/iniFile.h2
-rw-r--r--src/Blocks/WorldInterface.h4
-rw-r--r--src/Chunk.cpp7
-rw-r--r--src/Generating/ChunkGenerator.cpp2
-rw-r--r--src/World.cpp11
-rw-r--r--src/World.h4
7 files changed, 36 insertions, 14 deletions
diff --git a/lib/inifile/iniFile.cpp b/lib/inifile/iniFile.cpp
index ea03f5d35..7515483df 100644
--- a/lib/inifile/iniFile.cpp
+++ b/lib/inifile/iniFile.cpp
@@ -447,6 +447,15 @@ bool cIniFile::SetValueI(const AString & a_KeyName, const AString & a_ValueName,
+bool cIniFile::SetValueI(const AString & a_Keyname, const AString & a_ValueName, const Int64 a_Value, const bool a_CreateIfNotExists)
+{
+ return SetValue(a_Keyname, a_ValueName, Printf("lld", a_Value), a_CreateIfNotExists);
+}
+
+
+
+
+
bool cIniFile::SetValueF(const AString & a_KeyName, const AString & a_ValueName, double const a_Value, const bool a_CreateIfNotExists)
{
return SetValue(a_KeyName, a_ValueName, Printf("%f", a_Value), a_CreateIfNotExists);
@@ -571,6 +580,17 @@ int cIniFile::GetValueSetI(const AString & keyname, const AString & valuename, c
+Int64 cIniFile::GetValueSetI(const AString & keyname, const AString & valuename, const Int64 defValue)
+{
+ AString Data;
+ Printf(Data, "%lld", defValue);
+ return std::stoll(GetValueSet(keyname, valuename, Data));
+}
+
+
+
+
+
bool cIniFile::DeleteValueByID(const int keyID, const int valueID)
{
if ((keyID < (int)keys.size()) && (valueID < (int)keys[keyID].names.size()))
diff --git a/lib/inifile/iniFile.h b/lib/inifile/iniFile.h
index 0bf1d917e..58fecd0cf 100644
--- a/lib/inifile/iniFile.h
+++ b/lib/inifile/iniFile.h
@@ -119,6 +119,7 @@ public:
AString GetValueSet (const AString & keyname, const AString & valuename, const AString & defValue = "");
double GetValueSetF(const AString & keyname, const AString & valuename, const double defValue = 0.0);
int GetValueSetI(const AString & keyname, const AString & valuename, const int defValue = 0);
+ Int64 GetValueSetI(const AString & keyname, const AString & valuename, const Int64 defValue = 0);
bool GetValueSetB(const AString & keyname, const AString & valuename, const bool defValue = false)
{
return (GetValueSetI(keyname, valuename, defValue ? 1 : 0) != 0);
@@ -141,6 +142,7 @@ public:
bool SetValue (const int keyID, const int valueID, const AString & value);
bool SetValue (const AString & a_KeyName, const AString & a_ValueName, const AString & a_Value, const bool a_CreateIfNotExists = true);
bool SetValueI(const AString & a_KeyName, const AString & a_ValueName, const int a_Value, const bool a_CreateIfNotExists = true);
+ bool SetValueI(const AString & a_Keyname, const AString & a_ValueName, const Int64 a_Value, const bool a_CreateIfNotExists = true);
bool SetValueB(const AString & a_KeyName, const AString & a_ValueName, const bool a_Value, const bool a_CreateIfNotExists = true)
{
return SetValueI(a_KeyName, a_ValueName, int(a_Value), a_CreateIfNotExists);
diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h
index 08600d502..7df82197e 100644
--- a/src/Blocks/WorldInterface.h
+++ b/src/Blocks/WorldInterface.h
@@ -37,7 +37,9 @@ public:
virtual void SetTimeOfDay(Int64 a_TimeOfDay) = 0;
- /** Returns true if the current weather has any precipitation - rain or storm */
+ /** Returns true if the current weather has any precipitation - rain or storm
+ Does not check if biome has no downfall, use cChunk::GetBiomeAt(RelX, RelZ) for that
+ */
virtual bool IsWeatherWet(void) const = 0;
};
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index c6122852a..2850dd93b 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -580,7 +580,10 @@ void cChunk::Tick(float a_Dt)
{
// Mobs are tickes inside MobTick (as we don't have to tick them if they are far away from players)
// Don't tick things queued to be removed
- if (!((*itr)->IsMob()) && (std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), (*itr)->GetUniqueID()) == m_EntitiesToRemove.end()))
+ if (
+ !((*itr)->IsMob()) &&
+ (std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), (*itr)->GetUniqueID()) == m_EntitiesToRemove.end())
+ )
{
(*itr)->Tick(a_Dt, *this);
}
@@ -588,7 +591,7 @@ void cChunk::Tick(float a_Dt)
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end();)
{
- std::vector<int>::const_iterator itr2 = std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), (*itr)->GetUniqueID());
+ std::vector<int>::iterator itr2 = std::find(m_EntitiesToRemove.begin(), m_EntitiesToRemove.end(), (*itr)->GetUniqueID());
if (itr2 != m_EntitiesToRemove.end())
{
itr = m_Entities.erase(itr);
diff --git a/src/Generating/ChunkGenerator.cpp b/src/Generating/ChunkGenerator.cpp
index 73f0223e8..1f2958901 100644
--- a/src/Generating/ChunkGenerator.cpp
+++ b/src/Generating/ChunkGenerator.cpp
@@ -52,7 +52,7 @@ bool cChunkGenerator::Start(cPluginInterface & a_PluginInterface, cChunkSink & a
m_ChunkSink = &a_ChunkSink;
MTRand rnd;
- m_Seed = a_IniFile.GetValueSetI("Seed", "Seed", rnd.randInt());
+ m_Seed = a_IniFile.GetValueSetI("Seed", "Seed", (int)rnd.randInt());
AString GeneratorName = a_IniFile.GetValueSet("Generator", "Generator", "Composable");
if (NoCaseCompare(GeneratorName, "Noise3D") == 0)
diff --git a/src/World.cpp b/src/World.cpp
index 739ae39d4..3e02caf8e 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -11,7 +11,6 @@
#include "ChunkMap.h"
#include "Generating/ChunkDesc.h"
#include "OSSupport/Timer.h"
-#include <sstream>
// Serializers
#include "WorldStorage/ScoreboardSerializer.h"
@@ -571,10 +570,7 @@ void cWorld::Start(void)
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());
+ Int64 TimeOfDay = IniFile.GetValueSetI("General", "TimeInTicks", m_TimeOfDay);
if ((GetDimension() != dimNether) && (GetDimension() != dimEnd))
{
@@ -767,10 +763,7 @@ void cWorld::Stop(void)
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.SetValueI("General", "TimeInTicks", m_TimeOfDay);
IniFile.WriteFile(m_IniFileName);
m_TickThread.Stop();
diff --git a/src/World.h b/src/World.h
index 7b87a76ac..80f69f22f 100644
--- a/src/World.h
+++ b/src/World.h
@@ -715,7 +715,9 @@ public:
bool IsWeatherRain (void) const { return (m_Weather == wRain); }
bool IsWeatherStorm(void) const { return (m_Weather == wStorm); }
- /** Returns true if the current weather has any precipitation - rain or storm */
+ /** Returns true if the current weather has any precipitation - rain or storm
+ Does not check if biome has no downfall, use cChunk::GetBiomeAt(RelX, RelZ) for that
+ */
virtual bool IsWeatherWet(void) const override { return (m_Weather != wSunny); }
// tolua_end