summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-01-26 14:43:54 +0100
committermadmaxoft <github@xoft.cz>2014-01-26 17:56:11 +0100
commit61848ff5a0866a8e14f81c12ab85088dfe460708 (patch)
treed404ed6c8aa94d9316b37659578a62f49451680d
parentFixed Byte-order reading. (diff)
downloadcuberite-61848ff5a0866a8e14f81c12ab85088dfe460708.tar
cuberite-61848ff5a0866a8e14f81c12ab85088dfe460708.tar.gz
cuberite-61848ff5a0866a8e14f81c12ab85088dfe460708.tar.bz2
cuberite-61848ff5a0866a8e14f81c12ab85088dfe460708.tar.lz
cuberite-61848ff5a0866a8e14f81c12ab85088dfe460708.tar.xz
cuberite-61848ff5a0866a8e14f81c12ab85088dfe460708.tar.zst
cuberite-61848ff5a0866a8e14f81c12ab85088dfe460708.zip
-rw-r--r--src/WorldStorage/WSSAnvil.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index e2a882f65..a0f9136d8 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -611,12 +611,18 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con
bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_TagIdx)
{
- int ID = a_NBT.FindChildByName(a_TagIdx, "id");
- if ((ID < 0) || (a_NBT.GetType(ID) != TAG_Short))
+ int Type = a_NBT.FindChildByName(a_TagIdx, "id");
+ if ((Type < 0) || (a_NBT.GetType(Type) != TAG_Short))
{
return false;
}
- a_Item.m_ItemType = (ENUM_ITEM_ID)(a_NBT.GetShort(ID));
+ a_Item.m_ItemType = a_NBT.GetShort(Type);
+ if (a_Item.m_ItemType < 0)
+ {
+ LOGD("Encountered an item with negative type (%d). Replacing with an empty item.", a_NBT.GetShort(Type));
+ a_Item.Empty();
+ return true;
+ }
int Damage = a_NBT.FindChildByName(a_TagIdx, "Damage");
if ((Damage < 0) || (a_NBT.GetType(Damage) != TAG_Short))