summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage/WSSAnvil.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2015-03-09 22:39:11 +0100
committerHowaner <franzi.moos@googlemail.com>2015-03-09 22:39:11 +0100
commita96c21fc0d4326ffda93cc78c5dfcfc4bd034e24 (patch)
tree38dba8f86163283d90d1d6d9d2fa420cb4e99231 /src/WorldStorage/WSSAnvil.cpp
parentReadded old comment (diff)
parentFixed client kick/crash if many block changes happend (diff)
downloadcuberite-a96c21fc0d4326ffda93cc78c5dfcfc4bd034e24.tar
cuberite-a96c21fc0d4326ffda93cc78c5dfcfc4bd034e24.tar.gz
cuberite-a96c21fc0d4326ffda93cc78c5dfcfc4bd034e24.tar.bz2
cuberite-a96c21fc0d4326ffda93cc78c5dfcfc4bd034e24.tar.lz
cuberite-a96c21fc0d4326ffda93cc78c5dfcfc4bd034e24.tar.xz
cuberite-a96c21fc0d4326ffda93cc78c5dfcfc4bd034e24.tar.zst
cuberite-a96c21fc0d4326ffda93cc78c5dfcfc4bd034e24.zip
Diffstat (limited to 'src/WorldStorage/WSSAnvil.cpp')
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index a76e9461a..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();
}
@@ -3136,8 +3143,11 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri
// Add padding to 4K boundary:
size_t BytesWritten = a_Data.size() + MCA_CHUNK_HEADER_LENGTH;
- static const char Padding[4095] = {0};
- m_File.Write(Padding, 4096 - (BytesWritten % 4096));
+ if (BytesWritten % 4096 != 0)
+ {
+ static const char Padding[4095] = {0};
+ m_File.Write(Padding, 4096 - (BytesWritten % 4096));
+ }
// Store the header:
ChunkSize = ((u_long)a_Data.size() + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size *up* to nearest 4KB sector, make it a sector number