1
0

Anvil saver pads data to 4K boundaries.

Fixes #524.
This commit is contained in:
madmaxoft 2014-05-01 18:00:10 +02:00
parent ab2dfb44fa
commit 772b57ca04

View File

@ -2672,6 +2672,11 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri
return false;
}
// 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));
// Store the header:
ChunkSize = (a_Data.size() + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size *up* to nearest 4KB sector, make it a sector number
ASSERT(ChunkSize < 256);