1
0
Fork 0

WSSAnvil: Fixed chunk data padding.

When the chunk data fit perfectly into the old space, an extra 4 KiB of padding zeroes were written, overwriting the next chunk.
Fixes #1730.
This commit is contained in:
Mattes D 2015-02-08 12:24:15 +01:00
parent 5ee5a691b7
commit a939e2ded9
1 changed files with 5 additions and 2 deletions

View File

@ -3136,8 +3136,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