summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Bindings/ManualBindings.cpp32
-rw-r--r--src/MobSpawner.cpp3
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp17
3 files changed, 46 insertions, 6 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 24e3f0052..30bce6525 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -165,6 +165,14 @@ static AString GetLogMessage(lua_State * tolua_S)
static int tolua_LOG(lua_State * tolua_S)
{
+ // If there's no param, spit out an error message instead of crashing:
+ if (lua_isnil(tolua_S, 1))
+ {
+ LOGWARNING("Attempting to LOG a nil value!");
+ cLuaState::LogStackTrace(tolua_S);
+ return 0;
+ }
+
// If the param is a cCompositeChat, read the log level from it:
cLogger::eLogLevel LogLevel = cLogger::llRegular;
tolua_Error err;
@@ -184,6 +192,14 @@ static int tolua_LOG(lua_State * tolua_S)
static int tolua_LOGINFO(lua_State * tolua_S)
{
+ // If there's no param, spit out an error message instead of crashing:
+ if (lua_isnil(tolua_S, 1))
+ {
+ LOGWARNING("Attempting to LOGINFO a nil value!");
+ cLuaState::LogStackTrace(tolua_S);
+ return 0;
+ }
+
cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S).c_str(), cLogger::llInfo);
return 0;
}
@@ -194,6 +210,14 @@ static int tolua_LOGINFO(lua_State * tolua_S)
static int tolua_LOGWARN(lua_State * tolua_S)
{
+ // If there's no param, spit out an error message instead of crashing:
+ if (lua_isnil(tolua_S, 1))
+ {
+ LOGWARNING("Attempting to LOGWARN a nil value!");
+ cLuaState::LogStackTrace(tolua_S);
+ return 0;
+ }
+
cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S).c_str(), cLogger::llWarning);
return 0;
}
@@ -204,6 +228,14 @@ static int tolua_LOGWARN(lua_State * tolua_S)
static int tolua_LOGERROR(lua_State * tolua_S)
{
+ // If there's no param, spit out an error message instead of crashing:
+ if (lua_isnil(tolua_S, 1))
+ {
+ LOGWARNING("Attempting to LOGERROR a nil value!");
+ cLuaState::LogStackTrace(tolua_S);
+ return 0;
+ }
+
cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S).c_str(), cLogger::llError);
return 0;
}
diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp
index 0a32d17ef..541135996 100644
--- a/src/MobSpawner.cpp
+++ b/src/MobSpawner.cpp
@@ -110,7 +110,8 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
if (allowedMobsSize > 0)
{
std::set<eMonsterType>::iterator itr = allowedMobs.begin();
- int iRandom = m_Random.NextInt((int)allowedMobsSize, a_Biome);
+ static int Counter = 0;
+ int iRandom = m_Random.NextInt((int)allowedMobsSize, Counter++);
for (int i = 0; i < iRandom; i++)
{
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index ae82db346..cc8b8d3f5 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -1007,21 +1007,28 @@ cBlockEntity * cWSSAnvil::LoadFlowerPotFromNBT(const cParsedNBT & a_NBT, int a_T
}
std::unique_ptr<cFlowerPotEntity> FlowerPot(new cFlowerPotEntity(a_BlockX, a_BlockY, a_BlockZ, m_World));
- short ItemType = 0, ItemData = 0;
+ cItem Item;
int currentLine = a_NBT.FindChildByName(a_TagIdx, "Item");
if (currentLine >= 0)
{
- ItemType = (short) a_NBT.GetInt(currentLine);
+ if (a_NBT.GetType(currentLine) == TAG_String)
+ {
+ StringToItem(a_NBT.GetString(currentLine), Item);
+ }
+ else if (a_NBT.GetType(currentLine) == TAG_Int)
+ {
+ Item.m_ItemType = (short) a_NBT.GetInt(currentLine);
+ }
}
currentLine = a_NBT.FindChildByName(a_TagIdx, "Data");
- if (currentLine >= 0)
+ if ((currentLine >= 0) && (a_NBT.GetType(currentLine) == TAG_Int))
{
- ItemData = (short) a_NBT.GetInt(currentLine);
+ Item.m_ItemDamage = (short) a_NBT.GetInt(currentLine);
}
- FlowerPot->SetItem(cItem(ItemType, 1, ItemData));
+ FlowerPot->SetItem(Item);
return FlowerPot.release();
}