From 4bdf9256f24448717dfbcc6c16186675a0bd54cf Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 8 Sep 2014 18:56:27 +0100 Subject: Fixed a few compile warnings --- src/World.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/World.cpp b/src/World.cpp index e669f6fa0..319d5851f 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -1592,9 +1592,9 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy MTRand r1; for (int i = 0; i < 60; i++) { - int OfsX = (r1.randInt(3) + r1.randInt(3) + r1.randInt(3) + r1.randInt(3)) / 2 - 3; - int OfsY = r1.randInt(3) + r1.randInt(3) - 3; - int OfsZ = (r1.randInt(3) + r1.randInt(3) + r1.randInt(3) + r1.randInt(3)) / 2 - 3; + int OfsX = static_cast(r1.randInt(3) + r1.randInt(3) + r1.randInt(3) + r1.randInt(3)) / 2 - 3; + int OfsY = static_cast(r1.randInt(3) + r1.randInt(3)) - 3; + int OfsZ = static_cast(r1.randInt(3) + r1.randInt(3) + r1.randInt(3) + r1.randInt(3)) / 2 - 3; BLOCKTYPE Ground = GetBlock(a_BlockX + OfsX, a_BlockY + OfsY, a_BlockZ + OfsZ); if (Ground != E_BLOCK_GRASS) { @@ -2844,7 +2844,7 @@ bool cWorld::SetCommandBlockCommand(int a_BlockX, int a_BlockY, int a_BlockZ, co { AString m_Command; public: - cUpdateCommandBlock(const AString & a_Command) : m_Command(a_Command) {} + cUpdateCommandBlock(const AString & a_CallbackCommand) : m_Command(a_CallbackCommand) {} virtual bool Item(cCommandBlockEntity * a_CommandBlock) override { @@ -3319,20 +3319,25 @@ cFluidSimulator * cWorld::InitializeFluidSimulator(cIniFile & a_IniFile, const c int Falloff = a_IniFile.GetValueSetI(SimulatorSectionName, "Falloff", IsWater ? 1 : 2); int TickDelay = a_IniFile.GetValueSetI(SimulatorSectionName, "TickDelay", IsWater ? 5 : 30); int NumNeighborsForSource = a_IniFile.GetValueSetI(SimulatorSectionName, "NumNeighborsForSource", IsWater ? 2 : -1); + + if ((Falloff > 15) || (Falloff < 0)) + { + LOGWARNING("Falloff for %s simulator is out of range, assuming default of %d", a_FluidName, IsWater ? 1 : 2); + } if (NoCaseCompare(SimulatorName, "floody") == 0) { - res = new cFloodyFluidSimulator(*this, a_SimulateBlock, a_StationaryBlock, Falloff, TickDelay, NumNeighborsForSource); + res = new cFloodyFluidSimulator(*this, a_SimulateBlock, a_StationaryBlock, static_cast(Falloff), TickDelay, NumNeighborsForSource); } else if (NoCaseCompare(SimulatorName, "vanilla") == 0) { - res = new cVanillaFluidSimulator(*this, a_SimulateBlock, a_StationaryBlock, Falloff, TickDelay, NumNeighborsForSource); + res = new cVanillaFluidSimulator(*this, a_SimulateBlock, a_StationaryBlock, static_cast(Falloff), TickDelay, NumNeighborsForSource); } else { // The simulator name doesn't match anything we have, issue a warning: LOGWARNING("%s [Physics]:%s specifies an unknown simulator, using the default \"Vanilla\".", GetIniFileName().c_str(), SimulatorNameKey.c_str()); - res = new cVanillaFluidSimulator(*this, a_SimulateBlock, a_StationaryBlock, Falloff, TickDelay, NumNeighborsForSource); + res = new cVanillaFluidSimulator(*this, a_SimulateBlock, a_StationaryBlock, static_cast(Falloff), TickDelay, NumNeighborsForSource); } } @@ -3442,9 +3447,9 @@ void cWorld::cTaskSendBlockToAllPlayers::Run(cWorld & a_World) public cPlayerListCallback { public: - cPlayerCallback(std::vector & a_SendQueue, cWorld & a_World) : + cPlayerCallback(std::vector & a_SendQueue, cWorld & a_CallbackWorld) : m_SendQueue(a_SendQueue), - m_World(a_World) + m_World(a_CallbackWorld) { } -- cgit v1.2.3 From 2c945c8818a19405c566be1fcb6367a69b0a60c8 Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 8 Sep 2014 19:07:45 +0100 Subject: TimeOfDay does not need to be an Int64 --- src/Blocks/WorldInterface.h | 4 ++-- src/World.cpp | 2 +- src/World.h | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Blocks/WorldInterface.h b/src/Blocks/WorldInterface.h index d1c6f9bfc..b43d011d8 100644 --- a/src/Blocks/WorldInterface.h +++ b/src/Blocks/WorldInterface.h @@ -17,7 +17,7 @@ class cWorldInterface public: virtual ~cWorldInterface() {} - virtual Int64 GetTimeOfDay(void) const = 0; + virtual int GetTimeOfDay(void) const = 0; virtual Int64 GetWorldAge(void) const = 0; virtual eDimension GetDimension(void) const = 0; @@ -44,7 +44,7 @@ public: /** Calls the callback for each player in the list; returns true if all players processed, false if the callback aborted by returning true */ virtual bool ForEachPlayer(cItemCallback & a_Callback) = 0; - virtual void SetTimeOfDay(Int64 a_TimeOfDay) = 0; + virtual void SetTimeOfDay(int a_TimeOfDay) = 0; /** Returns true if it is raining, stormy or snowing at the specified location. This takes into account biomes. */ virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) = 0; diff --git a/src/World.cpp b/src/World.cpp index 319d5851f..e6f967a1b 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -876,7 +876,7 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec) m_TimeOfDaySecs -= 1200.0; } - m_TimeOfDay = (Int64)(m_TimeOfDaySecs * 20.0); + m_TimeOfDay = static_cast(m_TimeOfDaySecs * 20.0); // Updates the sky darkness based on current time of day UpdateSkyDarkness(); diff --git a/src/World.h b/src/World.h index 6316c6811..274bd2dcf 100644 --- a/src/World.h +++ b/src/World.h @@ -157,14 +157,14 @@ public: } virtual Int64 GetWorldAge (void) const override { return m_WorldAge; } - virtual Int64 GetTimeOfDay(void) const override { return m_TimeOfDay; } + virtual int GetTimeOfDay(void) const override { return m_TimeOfDay; } void SetTicksUntilWeatherChange(int a_WeatherInterval) { m_WeatherInterval = a_WeatherInterval; } - virtual void SetTimeOfDay(Int64 a_TimeOfDay) override + virtual void SetTimeOfDay(int a_TimeOfDay) override { m_TimeOfDay = a_TimeOfDay; m_TimeOfDaySecs = (double)a_TimeOfDay / 20.0; @@ -888,7 +888,7 @@ private: double m_WorldAgeSecs; // World age, in seconds. Is only incremented, cannot be set by plugins. double m_TimeOfDaySecs; // Time of day in seconds. Can be adjusted. Is wrapped to zero each day. Int64 m_WorldAge; // World age in ticks, calculated off of m_WorldAgeSecs - Int64 m_TimeOfDay; // Time in ticks, calculated off of m_TimeOfDaySecs + int m_TimeOfDay; // Time in ticks, calculated off of m_TimeOfDaySecs Int64 m_LastTimeUpdate; // The tick in which the last time update has been sent. Int64 m_LastUnload; // The last WorldAge (in ticks) in which unloading was triggerred Int64 m_LastSave; // The last WorldAge (in ticks) in which save-all was triggerred -- cgit v1.2.3 From fb20c2eb854799972822c702bc12fb5ca577897c Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 8 Sep 2014 19:15:29 +0100 Subject: FIxed a couple more warnings --- src/World.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/World.cpp b/src/World.cpp index e6f967a1b..1d0969dfa 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -757,6 +757,11 @@ void cWorld::InitialiseGeneratorDefaults(cIniFile & a_IniFile) a_IniFile.GetValueSet("Generator", "BottomLavaHeight", "30"); break; } + case dimNotSet: + { + assert(!"Dimension not set"); + break; + } } } @@ -772,6 +777,7 @@ void cWorld::InitialiseAndLoadMobSpawningValues(cIniFile & a_IniFile) case dimOverworld: DefaultMonsters = "bat, cavespider, chicken, cow, creeper, enderman, horse, mooshroom, ocelot, pig, sheep, silverfish, skeleton, slime, spider, squid, wolf, zombie"; break; case dimNether: DefaultMonsters = "blaze, ghast, magmacube, skeleton, zombie, zombiepigman"; break; case dimEnd: DefaultMonsters = "enderman"; break; + case dimNotSet: assert(!"Dimension not set"); break; } m_bAnimals = a_IniFile.GetValueSetB("Monsters", "AnimalsOn", true); @@ -1130,7 +1136,7 @@ void cWorld::UpdateSkyDarkness(void) } else if (TempTime <= TIME_NIGHT_START) { - m_SkyDarkness = (TIME_NIGHT_START - TempTime) / TIME_SPAWN_DIVISOR; + m_SkyDarkness = static_cast((TIME_NIGHT_START - TempTime) / TIME_SPAWN_DIVISOR); } else if (TempTime <= TIME_NIGHT_END) { @@ -1138,7 +1144,7 @@ void cWorld::UpdateSkyDarkness(void) } else { - m_SkyDarkness = (TIME_SUNRISE - TempTime) / TIME_SPAWN_DIVISOR; + m_SkyDarkness = static_cast((TIME_SUNRISE - TempTime) / TIME_SPAWN_DIVISOR); } } -- cgit v1.2.3 From bd810b80a6df668cb6cb44519d8a533544163bfd Mon Sep 17 00:00:00 2001 From: worktycho Date: Mon, 8 Sep 2014 21:31:47 +0100 Subject: use the correct ASSERT --- src/World.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/World.cpp b/src/World.cpp index 1d0969dfa..b7045c7f4 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -759,7 +759,7 @@ void cWorld::InitialiseGeneratorDefaults(cIniFile & a_IniFile) } case dimNotSet: { - assert(!"Dimension not set"); + ASSERT(!"Dimension not set"); break; } } @@ -777,7 +777,7 @@ void cWorld::InitialiseAndLoadMobSpawningValues(cIniFile & a_IniFile) case dimOverworld: DefaultMonsters = "bat, cavespider, chicken, cow, creeper, enderman, horse, mooshroom, ocelot, pig, sheep, silverfish, skeleton, slime, spider, squid, wolf, zombie"; break; case dimNether: DefaultMonsters = "blaze, ghast, magmacube, skeleton, zombie, zombiepigman"; break; case dimEnd: DefaultMonsters = "enderman"; break; - case dimNotSet: assert(!"Dimension not set"); break; + case dimNotSet: ASSERT(!"Dimension not set"); break; } m_bAnimals = a_IniFile.GetValueSetB("Monsters", "AnimalsOn", true); -- cgit v1.2.3 From 1f0b6eeaf3cfff3e6bc27bf5f3a83be60722a3de Mon Sep 17 00:00:00 2001 From: worktycho Date: Tue, 9 Sep 2014 12:18:20 +0100 Subject: Actually set default --- src/World.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/World.cpp b/src/World.cpp index b7045c7f4..fdc0aebad 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -3329,6 +3329,7 @@ cFluidSimulator * cWorld::InitializeFluidSimulator(cIniFile & a_IniFile, const c if ((Falloff > 15) || (Falloff < 0)) { LOGWARNING("Falloff for %s simulator is out of range, assuming default of %d", a_FluidName, IsWater ? 1 : 2); + Falloff = IsWater ? 1 : 2; } if (NoCaseCompare(SimulatorName, "floody") == 0) -- cgit v1.2.3