1
0

Merge pull request #1399 from mc-server/warnings

Warnings
This commit is contained in:
Mattes D 2014-09-09 14:32:58 +02:00
commit feb408424c
3 changed files with 29 additions and 17 deletions

View File

@ -17,7 +17,7 @@ class cWorldInterface
public: public:
virtual ~cWorldInterface() {} virtual ~cWorldInterface() {}
virtual Int64 GetTimeOfDay(void) const = 0; virtual int GetTimeOfDay(void) const = 0;
virtual Int64 GetWorldAge(void) const = 0; virtual Int64 GetWorldAge(void) const = 0;
virtual eDimension GetDimension(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 */ /** 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<cPlayer> & a_Callback) = 0; virtual bool ForEachPlayer(cItemCallback<cPlayer> & 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. */ /** 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; virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) = 0;

View File

@ -757,6 +757,11 @@ void cWorld::InitialiseGeneratorDefaults(cIniFile & a_IniFile)
a_IniFile.GetValueSet("Generator", "BottomLavaHeight", "30"); a_IniFile.GetValueSet("Generator", "BottomLavaHeight", "30");
break; 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 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 dimNether: DefaultMonsters = "blaze, ghast, magmacube, skeleton, zombie, zombiepigman"; break;
case dimEnd: DefaultMonsters = "enderman"; break; case dimEnd: DefaultMonsters = "enderman"; break;
case dimNotSet: ASSERT(!"Dimension not set"); break;
} }
m_bAnimals = a_IniFile.GetValueSetB("Monsters", "AnimalsOn", true); m_bAnimals = a_IniFile.GetValueSetB("Monsters", "AnimalsOn", true);
@ -876,7 +882,7 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec)
m_TimeOfDaySecs -= 1200.0; m_TimeOfDaySecs -= 1200.0;
} }
m_TimeOfDay = (Int64)(m_TimeOfDaySecs * 20.0); m_TimeOfDay = static_cast<int>(m_TimeOfDaySecs * 20.0);
// Updates the sky darkness based on current time of day // Updates the sky darkness based on current time of day
UpdateSkyDarkness(); UpdateSkyDarkness();
@ -1130,7 +1136,7 @@ void cWorld::UpdateSkyDarkness(void)
} }
else if (TempTime <= TIME_NIGHT_START) else if (TempTime <= TIME_NIGHT_START)
{ {
m_SkyDarkness = (TIME_NIGHT_START - TempTime) / TIME_SPAWN_DIVISOR; m_SkyDarkness = static_cast<NIBBLETYPE>((TIME_NIGHT_START - TempTime) / TIME_SPAWN_DIVISOR);
} }
else if (TempTime <= TIME_NIGHT_END) else if (TempTime <= TIME_NIGHT_END)
{ {
@ -1138,7 +1144,7 @@ void cWorld::UpdateSkyDarkness(void)
} }
else else
{ {
m_SkyDarkness = (TIME_SUNRISE - TempTime) / TIME_SPAWN_DIVISOR; m_SkyDarkness = static_cast<NIBBLETYPE>((TIME_SUNRISE - TempTime) / TIME_SPAWN_DIVISOR);
} }
} }
@ -1592,9 +1598,9 @@ bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsBy
MTRand r1; MTRand r1;
for (int i = 0; i < 60; i++) for (int i = 0; i < 60; i++)
{ {
int OfsX = (r1.randInt(3) + r1.randInt(3) + r1.randInt(3) + r1.randInt(3)) / 2 - 3; int OfsX = static_cast<int>(r1.randInt(3) + r1.randInt(3) + r1.randInt(3) + r1.randInt(3)) / 2 - 3;
int OfsY = r1.randInt(3) + r1.randInt(3) - 3; int OfsY = static_cast<int>(r1.randInt(3) + r1.randInt(3)) - 3;
int OfsZ = (r1.randInt(3) + r1.randInt(3) + r1.randInt(3) + r1.randInt(3)) / 2 - 3; int OfsZ = static_cast<int>(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); BLOCKTYPE Ground = GetBlock(a_BlockX + OfsX, a_BlockY + OfsY, a_BlockZ + OfsZ);
if (Ground != E_BLOCK_GRASS) if (Ground != E_BLOCK_GRASS)
{ {
@ -2844,7 +2850,7 @@ bool cWorld::SetCommandBlockCommand(int a_BlockX, int a_BlockY, int a_BlockZ, co
{ {
AString m_Command; AString m_Command;
public: 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 virtual bool Item(cCommandBlockEntity * a_CommandBlock) override
{ {
@ -3320,19 +3326,25 @@ cFluidSimulator * cWorld::InitializeFluidSimulator(cIniFile & a_IniFile, const c
int TickDelay = a_IniFile.GetValueSetI(SimulatorSectionName, "TickDelay", IsWater ? 5 : 30); int TickDelay = a_IniFile.GetValueSetI(SimulatorSectionName, "TickDelay", IsWater ? 5 : 30);
int NumNeighborsForSource = a_IniFile.GetValueSetI(SimulatorSectionName, "NumNeighborsForSource", IsWater ? 2 : -1); 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);
Falloff = IsWater ? 1 : 2;
}
if (NoCaseCompare(SimulatorName, "floody") == 0) 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<NIBBLETYPE>(Falloff), TickDelay, NumNeighborsForSource);
} }
else if (NoCaseCompare(SimulatorName, "vanilla") == 0) 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<NIBBLETYPE>(Falloff), TickDelay, NumNeighborsForSource);
} }
else else
{ {
// The simulator name doesn't match anything we have, issue a warning: // 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()); 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<NIBBLETYPE>(Falloff), TickDelay, NumNeighborsForSource);
} }
} }
@ -3442,9 +3454,9 @@ void cWorld::cTaskSendBlockToAllPlayers::Run(cWorld & a_World)
public cPlayerListCallback public cPlayerListCallback
{ {
public: public:
cPlayerCallback(std::vector<Vector3i> & a_SendQueue, cWorld & a_World) : cPlayerCallback(std::vector<Vector3i> & a_SendQueue, cWorld & a_CallbackWorld) :
m_SendQueue(a_SendQueue), m_SendQueue(a_SendQueue),
m_World(a_World) m_World(a_CallbackWorld)
{ {
} }

View File

@ -157,14 +157,14 @@ public:
} }
virtual Int64 GetWorldAge (void) const override { return m_WorldAge; } 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) void SetTicksUntilWeatherChange(int a_WeatherInterval)
{ {
m_WeatherInterval = 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_TimeOfDay = a_TimeOfDay;
m_TimeOfDaySecs = (double)a_TimeOfDay / 20.0; 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_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. 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_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_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_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 Int64 m_LastSave; // The last WorldAge (in ticks) in which save-all was triggerred