2012-02-13 16:47:03 -05:00
|
|
|
|
|
|
|
// WSSCompact.cpp
|
|
|
|
|
|
|
|
// Interfaces to the cWSSCompact class representing the "compact" storage schema (PAK-files)
|
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
#include "WSSCompact.h"
|
|
|
|
#include "cWorld.h"
|
|
|
|
#include "zlib.h"
|
|
|
|
#include <json/json.h>
|
2012-02-16 08:42:35 -05:00
|
|
|
#include "StringCompression.h"
|
|
|
|
#include "cChestEntity.h"
|
|
|
|
#include "cSignEntity.h"
|
|
|
|
#include "cFurnaceEntity.h"
|
|
|
|
#include "BlockID.h"
|
2012-02-13 16:47:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
/// The chunk header, as stored in the file:
|
|
|
|
struct cWSSCompact::sChunkHeader
|
|
|
|
{
|
|
|
|
int m_ChunkX;
|
|
|
|
int m_ChunkZ;
|
|
|
|
int m_CompressedSize;
|
|
|
|
int m_UncompressedSize;
|
|
|
|
} ;
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The maximum number of PAK files that are cached
|
|
|
|
const int MAX_PAK_FILES = 16;
|
|
|
|
|
|
|
|
/// The maximum number of unsaved chunks before the cPAKFile saves them to disk
|
|
|
|
const int MAX_DIRTY_CHUNKS = 16;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// cWSSCompact:
|
|
|
|
|
|
|
|
cWSSCompact::~cWSSCompact()
|
|
|
|
{
|
|
|
|
for (cPAKFiles::iterator itr = m_PAKFiles.begin(); itr != m_PAKFiles.end(); ++itr)
|
|
|
|
{
|
|
|
|
delete *itr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-16 08:42:35 -05:00
|
|
|
bool cWSSCompact::LoadChunk(const cChunkCoords & a_Chunk)
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
2012-02-28 05:45:53 -05:00
|
|
|
AString ChunkData;
|
|
|
|
int UncompressedSize = 0;
|
|
|
|
if (!GetChunkData(a_Chunk, UncompressedSize, ChunkData))
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
2012-02-28 05:45:53 -05:00
|
|
|
// The reason for failure is already printed in GetChunkData()
|
2012-02-13 16:47:03 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-02-28 05:45:53 -05:00
|
|
|
return LoadChunkFromData(a_Chunk, UncompressedSize, ChunkData, m_World);
|
2012-02-13 16:47:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-16 08:42:35 -05:00
|
|
|
bool cWSSCompact::SaveChunk(const cChunkCoords & a_Chunk)
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
2012-02-28 05:45:53 -05:00
|
|
|
cCSLock Lock(m_CS);
|
|
|
|
|
2012-02-13 16:47:03 -05:00
|
|
|
cPAKFile * f = LoadPAKFile(a_Chunk);
|
|
|
|
if (f == NULL)
|
|
|
|
{
|
|
|
|
// For some reason we couldn't locate the file
|
2012-02-17 06:40:14 -05:00
|
|
|
LOG("Cannot locate a proper PAK file for chunk [%d, %d]", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ);
|
2012-02-13 16:47:03 -05:00
|
|
|
return false;
|
|
|
|
}
|
2012-02-16 08:42:35 -05:00
|
|
|
return f->SaveChunk(a_Chunk, m_World);
|
2012-02-13 16:47:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-16 08:42:35 -05:00
|
|
|
cWSSCompact::cPAKFile * cWSSCompact::LoadPAKFile(const cChunkCoords & a_Chunk)
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
2012-02-28 05:45:53 -05:00
|
|
|
// ASSUMES that m_CS has been locked
|
|
|
|
|
2012-02-13 16:47:03 -05:00
|
|
|
// We need to retain this weird conversion code, because some edge chunks are in the wrong PAK file
|
2012-02-16 08:42:35 -05:00
|
|
|
const int LayerX = (int)(floorf((float)a_Chunk.m_ChunkX / 32.0f));
|
|
|
|
const int LayerZ = (int)(floorf((float)a_Chunk.m_ChunkZ / 32.0f));
|
2012-02-13 16:47:03 -05:00
|
|
|
|
|
|
|
// Is it already cached?
|
|
|
|
for (cPAKFiles::iterator itr = m_PAKFiles.begin(); itr != m_PAKFiles.end(); ++itr)
|
|
|
|
{
|
|
|
|
if (((*itr) != NULL) && ((*itr)->GetLayerX() == LayerX) && ((*itr)->GetLayerZ() == LayerZ))
|
|
|
|
{
|
|
|
|
// Move the file to front and return it:
|
|
|
|
cPAKFile * f = *itr;
|
|
|
|
if (itr != m_PAKFiles.begin())
|
|
|
|
{
|
|
|
|
m_PAKFiles.erase(itr);
|
|
|
|
m_PAKFiles.push_front(f);
|
|
|
|
}
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load it anew:
|
|
|
|
AString FileName;
|
|
|
|
Printf(FileName, "%s/X%i_Z%i.pak", m_World->GetName().c_str(), LayerX, LayerZ );
|
|
|
|
cPAKFile * f = new cPAKFile(FileName, LayerX, LayerZ);
|
|
|
|
if (f == NULL)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
m_PAKFiles.push_front(f);
|
|
|
|
|
|
|
|
// If there are too many PAK files cached, delete the last one used:
|
|
|
|
if (m_PAKFiles.size() > MAX_PAK_FILES)
|
|
|
|
{
|
|
|
|
delete m_PAKFiles.back();
|
|
|
|
m_PAKFiles.pop_back();
|
|
|
|
}
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-28 05:45:53 -05:00
|
|
|
bool cWSSCompact::GetChunkData(const cChunkCoords & a_Chunk, int & a_UncompressedSize, AString & a_Data)
|
|
|
|
{
|
|
|
|
cCSLock Lock(m_CS);
|
|
|
|
cPAKFile * f = LoadPAKFile(a_Chunk);
|
|
|
|
if (f == NULL)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return f->GetChunkData(a_Chunk, a_UncompressedSize, a_Data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
// TODO: Rewrite saving to use the same principles as loading
|
|
|
|
bool cWSSCompact::SetChunkData(const cChunkCoords & a_Chunk, int a_UncompressedSize, const AString & a_Data)
|
|
|
|
{
|
|
|
|
cCSLock Lock(m_CS);
|
|
|
|
cPAKFile * f = LoadPAKFile(a_Chunk);
|
|
|
|
if (f == NULL)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return f->SetChunkData(a_Chunk, a_UncompressedSize, a_Data);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool cWSSCompact::EraseChunkData(const cChunkCoords & a_Chunk)
|
|
|
|
{
|
|
|
|
cCSLock Lock(m_CS);
|
|
|
|
cPAKFile * f = LoadPAKFile(a_Chunk);
|
|
|
|
if (f == NULL)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return f->EraseChunkData(a_Chunk);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities, cWorld * a_World)
|
|
|
|
{
|
|
|
|
// Load chests
|
|
|
|
Json::Value AllChests = a_Value.get("Chests", Json::nullValue);
|
|
|
|
if (!AllChests.empty())
|
|
|
|
{
|
|
|
|
for (Json::Value::iterator itr = AllChests.begin(); itr != AllChests.end(); ++itr )
|
|
|
|
{
|
|
|
|
Json::Value & Chest = *itr;
|
|
|
|
cChestEntity * ChestEntity = new cChestEntity(0,0,0, a_World);
|
|
|
|
if (!ChestEntity->LoadFromJson( Chest ) )
|
|
|
|
{
|
|
|
|
LOGERROR("ERROR READING CHEST FROM JSON!" );
|
|
|
|
delete ChestEntity;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
a_BlockEntities.push_back( ChestEntity );
|
|
|
|
}
|
|
|
|
} // for itr - AllChests[]
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load furnaces
|
|
|
|
Json::Value AllFurnaces = a_Value.get("Furnaces", Json::nullValue);
|
|
|
|
if( !AllFurnaces.empty() )
|
|
|
|
{
|
|
|
|
for( Json::Value::iterator itr = AllFurnaces.begin(); itr != AllFurnaces.end(); ++itr )
|
|
|
|
{
|
|
|
|
Json::Value & Furnace = *itr;
|
|
|
|
cFurnaceEntity * FurnaceEntity = new cFurnaceEntity(0,0,0, a_World);
|
|
|
|
if( !FurnaceEntity->LoadFromJson( Furnace ) )
|
|
|
|
{
|
|
|
|
LOGERROR("ERROR READING FURNACE FROM JSON!" );
|
|
|
|
delete FurnaceEntity;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
a_BlockEntities.push_back( FurnaceEntity );
|
|
|
|
}
|
|
|
|
} // for itr - AllFurnaces[]
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load signs
|
|
|
|
Json::Value AllSigns = a_Value.get("Signs", Json::nullValue);
|
|
|
|
if( !AllSigns.empty() )
|
|
|
|
{
|
|
|
|
for( Json::Value::iterator itr = AllSigns.begin(); itr != AllSigns.end(); ++itr )
|
|
|
|
{
|
|
|
|
Json::Value & Sign = *itr;
|
|
|
|
cSignEntity * SignEntity = new cSignEntity( E_BLOCK_SIGN_POST, 0,0,0, a_World);
|
|
|
|
if ( !SignEntity->LoadFromJson( Sign ) )
|
|
|
|
{
|
|
|
|
LOGERROR("ERROR READING SIGN FROM JSON!" );
|
|
|
|
delete SignEntity;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
a_BlockEntities.push_back( SignEntity );
|
|
|
|
}
|
|
|
|
} // for itr - AllSigns[]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-13 16:47:03 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// cWSSCompact::cPAKFile
|
|
|
|
|
|
|
|
#define READ(Var) \
|
|
|
|
if (f.Read(&Var, sizeof(Var)) != sizeof(Var)) \
|
|
|
|
{ \
|
|
|
|
LOGERROR("ERROR READING %s FROM FILE %s (line %d); file offset %d", #Var, m_FileName.c_str(), __LINE__, f.Tell()); \
|
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
|
|
|
cWSSCompact::cPAKFile::cPAKFile(const AString & a_FileName, int a_LayerX, int a_LayerZ) :
|
|
|
|
m_FileName(a_FileName),
|
|
|
|
m_LayerX(a_LayerX),
|
|
|
|
m_LayerZ(a_LayerZ),
|
2012-03-04 10:59:10 -05:00
|
|
|
m_NumDirty(0),
|
2012-03-07 15:03:44 -05:00
|
|
|
m_ChunkVersion( CHUNK_VERSION ), // Init with latest version
|
|
|
|
m_PakVersion( PAK_VERSION )
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
|
|
|
cFile f;
|
|
|
|
if (!f.Open(m_FileName, cFile::fmRead))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read headers:
|
2012-03-04 10:59:10 -05:00
|
|
|
READ(m_PakVersion);
|
|
|
|
if (m_PakVersion != 1)
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
2012-03-04 10:59:10 -05:00
|
|
|
LOGERROR("File \"%s\" is in an unknown pak format (%d)", m_FileName.c_str(), m_PakVersion);
|
2012-02-13 16:47:03 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-04 10:59:10 -05:00
|
|
|
READ(m_ChunkVersion);
|
|
|
|
switch( m_ChunkVersion )
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
m_ChunkSize.Set(16, 128, 16);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
m_ChunkSize.Set(16, 256, 16);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
LOGERROR("File \"%s\" is in an unknown chunk format (%d)", m_FileName.c_str(), m_ChunkVersion);
|
2012-02-13 16:47:03 -05:00
|
|
|
return;
|
2012-03-04 10:59:10 -05:00
|
|
|
};
|
2012-02-13 16:47:03 -05:00
|
|
|
|
|
|
|
short NumChunks = 0;
|
|
|
|
READ(NumChunks);
|
|
|
|
|
|
|
|
// Read chunk headers:
|
|
|
|
for (int i = 0; i < NumChunks; i++)
|
|
|
|
{
|
|
|
|
sChunkHeader * Header = new sChunkHeader;
|
|
|
|
READ(*Header);
|
|
|
|
m_ChunkHeaders.push_back(Header);
|
|
|
|
} // for i - chunk headers
|
|
|
|
|
|
|
|
// Read chunk data:
|
|
|
|
if (f.ReadRestOfFile(m_DataContents) == -1)
|
|
|
|
{
|
|
|
|
LOGERROR("Cannot read file \"%s\" contents", m_FileName.c_str());
|
|
|
|
return;
|
|
|
|
}
|
2012-03-04 10:59:10 -05:00
|
|
|
|
|
|
|
if( m_ChunkVersion == 1 ) // Convert chunks to version 2
|
|
|
|
{
|
|
|
|
UpdateChunk1To2();
|
|
|
|
}
|
2012-03-10 17:10:15 -05:00
|
|
|
#if AXIS_ORDER == AXIS_ORDER_XZY
|
|
|
|
if( m_ChunkVersion == 2 ) // Convert chunks to version 3
|
|
|
|
{
|
|
|
|
UpdateChunk2To3();
|
|
|
|
}
|
|
|
|
#endif
|
2012-02-13 16:47:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cWSSCompact::cPAKFile::~cPAKFile()
|
|
|
|
{
|
|
|
|
if (m_NumDirty > 0)
|
|
|
|
{
|
|
|
|
SynchronizeFile();
|
|
|
|
}
|
|
|
|
for (sChunkHeaders::iterator itr = m_ChunkHeaders.begin(); itr != m_ChunkHeaders.end(); ++itr)
|
|
|
|
{
|
|
|
|
delete *itr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-28 05:45:53 -05:00
|
|
|
bool cWSSCompact::cPAKFile::GetChunkData(const cChunkCoords & a_Chunk, int & a_UncompressedSize, AString & a_Data)
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
2012-02-16 08:42:35 -05:00
|
|
|
int ChunkX = a_Chunk.m_ChunkX;
|
|
|
|
int ChunkZ = a_Chunk.m_ChunkZ;
|
2012-02-13 16:47:03 -05:00
|
|
|
sChunkHeader * Header = NULL;
|
|
|
|
int Offset = 0;
|
|
|
|
for (sChunkHeaders::iterator itr = m_ChunkHeaders.begin(); itr != m_ChunkHeaders.end(); ++itr)
|
|
|
|
{
|
|
|
|
if (((*itr)->m_ChunkX == ChunkX) && ((*itr)->m_ChunkZ == ChunkZ))
|
|
|
|
{
|
|
|
|
Header = *itr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Offset += (*itr)->m_CompressedSize;
|
|
|
|
}
|
|
|
|
if ((Header == NULL) || (Offset + Header->m_CompressedSize > (int)m_DataContents.size()))
|
|
|
|
{
|
|
|
|
// Chunk not found / data invalid
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-02-28 05:45:53 -05:00
|
|
|
a_UncompressedSize = Header->m_UncompressedSize;
|
|
|
|
a_Data.assign(m_DataContents, Offset, Header->m_CompressedSize);
|
|
|
|
return true;
|
2012-02-13 16:47:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-16 08:42:35 -05:00
|
|
|
bool cWSSCompact::cPAKFile::SaveChunk(const cChunkCoords & a_Chunk, cWorld * a_World)
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
2012-02-16 08:42:35 -05:00
|
|
|
if (!SaveChunkToData(a_Chunk, a_World))
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (m_NumDirty > MAX_DIRTY_CHUNKS)
|
|
|
|
{
|
|
|
|
SynchronizeFile();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-04 10:59:10 -05:00
|
|
|
void cWSSCompact::cPAKFile::UpdateChunk1To2()
|
|
|
|
{
|
|
|
|
int Offset = 0;
|
|
|
|
AString NewDataContents;
|
2012-03-04 11:18:32 -05:00
|
|
|
int ChunksConverted = 0;
|
2012-03-04 10:59:10 -05:00
|
|
|
for (sChunkHeaders::iterator itr = m_ChunkHeaders.begin(); itr != m_ChunkHeaders.end(); ++itr)
|
|
|
|
{
|
|
|
|
sChunkHeader * Header = *itr;
|
|
|
|
|
2012-03-04 11:18:32 -05:00
|
|
|
if( ChunksConverted % 32 == 0 )
|
|
|
|
{
|
2012-03-05 12:00:35 -05:00
|
|
|
LOGINFO("Updating \"%s\" version 1 to version 2: %d %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() );
|
2012-03-04 11:18:32 -05:00
|
|
|
}
|
|
|
|
ChunksConverted++;
|
2012-03-04 10:59:10 -05:00
|
|
|
|
|
|
|
AString Data;
|
|
|
|
int UncompressedSize = Header->m_UncompressedSize;
|
|
|
|
Data.assign(m_DataContents, Offset, Header->m_CompressedSize);
|
|
|
|
Offset += Header->m_CompressedSize;
|
|
|
|
|
|
|
|
// Crude data integrity check:
|
|
|
|
int ExpectedSize = (16*128*16)*2 + (16*128*16)/2; // For version 1
|
|
|
|
if (UncompressedSize < ExpectedSize)
|
|
|
|
{
|
|
|
|
LOGWARNING("Chunk [%d, %d] has too short decompressed data (%d bytes out of %d needed), erasing",
|
|
|
|
Header->m_ChunkX, Header->m_ChunkZ,
|
|
|
|
UncompressedSize, ExpectedSize
|
|
|
|
);
|
|
|
|
Offset += Header->m_CompressedSize;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Decompress the data:
|
|
|
|
AString UncompressedData;
|
|
|
|
{
|
|
|
|
int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, UncompressedSize);
|
|
|
|
if (errorcode != Z_OK)
|
|
|
|
{
|
|
|
|
LOGERROR("Error %d decompressing data for chunk [%d, %d]",
|
|
|
|
errorcode,
|
|
|
|
Header->m_ChunkX, Header->m_ChunkZ
|
|
|
|
);
|
|
|
|
Offset += Header->m_CompressedSize;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UncompressedSize != (int)UncompressedData.size())
|
|
|
|
{
|
|
|
|
LOGWARNING("Uncompressed data size differs (exp %d bytes, got %d) for chunk [%d, %d]",
|
|
|
|
UncompressedSize, UncompressedData.size(),
|
|
|
|
Header->m_ChunkX, Header->m_ChunkZ
|
|
|
|
);
|
|
|
|
Offset += Header->m_CompressedSize;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Old version is 128 blocks high with YZX axis order
|
2012-03-05 12:00:35 -05:00
|
|
|
char ConvertedData[cChunk::c_BlockDataSize];
|
|
|
|
int Index = 0;
|
2012-03-04 10:59:10 -05:00
|
|
|
unsigned int InChunkOffset = 0;
|
|
|
|
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z )
|
|
|
|
{
|
|
|
|
for( int y = 0; y < 128; ++y )
|
|
|
|
{
|
2012-03-05 12:00:35 -05:00
|
|
|
ConvertedData[Index++] = UncompressedData[y + z * 128 + x * 128 * 16 + InChunkOffset];
|
2012-03-04 10:59:10 -05:00
|
|
|
}
|
|
|
|
// Add 128 empty blocks after an old y column
|
2012-03-05 12:00:35 -05:00
|
|
|
memset(ConvertedData + Index, E_BLOCK_AIR, 128);
|
|
|
|
Index += 128;
|
2012-03-04 10:59:10 -05:00
|
|
|
}
|
2012-03-05 12:00:35 -05:00
|
|
|
InChunkOffset += (16 * 128 * 16);
|
2012-03-04 10:59:10 -05:00
|
|
|
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Metadata
|
|
|
|
{
|
|
|
|
for( int y = 0; y < 64; ++y )
|
|
|
|
{
|
2012-03-05 12:00:35 -05:00
|
|
|
ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset];
|
2012-03-04 10:59:10 -05:00
|
|
|
}
|
2012-03-05 12:00:35 -05:00
|
|
|
memset(ConvertedData + Index, 0, 64);
|
|
|
|
Index += 64;
|
2012-03-04 10:59:10 -05:00
|
|
|
}
|
2012-03-05 12:00:35 -05:00
|
|
|
InChunkOffset += (16 * 128 * 16) / 2;
|
2012-03-04 10:59:10 -05:00
|
|
|
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Block light
|
|
|
|
{
|
|
|
|
for( int y = 0; y < 64; ++y )
|
|
|
|
{
|
2012-03-05 12:00:35 -05:00
|
|
|
ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset];
|
2012-03-04 10:59:10 -05:00
|
|
|
}
|
2012-03-05 12:00:35 -05:00
|
|
|
memset(ConvertedData + Index, 0, 64);
|
|
|
|
Index += 64;
|
2012-03-04 10:59:10 -05:00
|
|
|
}
|
|
|
|
InChunkOffset += (16*128*16)/2;
|
|
|
|
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) // Sky light
|
|
|
|
{
|
|
|
|
for( int y = 0; y < 64; ++y )
|
|
|
|
{
|
2012-03-05 12:00:35 -05:00
|
|
|
ConvertedData[Index++] = UncompressedData[y + z * 64 + x * 64 * 16 + InChunkOffset];
|
2012-03-04 10:59:10 -05:00
|
|
|
}
|
2012-03-05 12:00:35 -05:00
|
|
|
memset(ConvertedData + Index, 0, 64);
|
|
|
|
Index += 64;
|
2012-03-04 10:59:10 -05:00
|
|
|
}
|
2012-03-05 12:00:35 -05:00
|
|
|
InChunkOffset += (16 * 128 * 16) / 2;
|
|
|
|
|
|
|
|
AString Converted(ConvertedData, ARRAYCOUNT(ConvertedData));
|
|
|
|
|
2012-03-04 10:59:10 -05:00
|
|
|
// Add JSON data afterwards
|
2012-03-05 12:00:35 -05:00
|
|
|
if (UncompressedData.size() > InChunkOffset)
|
2012-03-04 10:59:10 -05:00
|
|
|
{
|
2012-03-05 12:00:35 -05:00
|
|
|
Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end() );
|
2012-03-04 10:59:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Re-compress data
|
|
|
|
AString CompressedData;
|
|
|
|
{
|
2012-03-05 12:00:35 -05:00
|
|
|
int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData);
|
2012-03-04 10:59:10 -05:00
|
|
|
if (errorcode != Z_OK)
|
|
|
|
{
|
|
|
|
LOGERROR("Error %d compressing data for chunk [%d, %d]",
|
|
|
|
errorcode,
|
|
|
|
Header->m_ChunkX, Header->m_ChunkZ
|
2012-03-05 12:00:35 -05:00
|
|
|
);
|
2012-03-04 10:59:10 -05:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-05 12:00:35 -05:00
|
|
|
// Save into file's cache
|
|
|
|
Header->m_UncompressedSize = Converted.size();
|
2012-03-04 10:59:10 -05:00
|
|
|
Header->m_CompressedSize = CompressedData.size();
|
|
|
|
NewDataContents.append( CompressedData );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Done converting
|
|
|
|
m_DataContents = NewDataContents;
|
|
|
|
m_ChunkVersion = 2;
|
2012-03-05 12:00:35 -05:00
|
|
|
SynchronizeFile();
|
|
|
|
|
2012-03-05 11:43:06 -05:00
|
|
|
LOGINFO("Updated \"%s\" version 1 to version 2", m_FileName.c_str() );
|
2012-03-04 10:59:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-10 17:10:15 -05:00
|
|
|
void cWSSCompact::cPAKFile::UpdateChunk2To3()
|
|
|
|
{
|
|
|
|
int Offset = 0;
|
|
|
|
AString NewDataContents;
|
|
|
|
int ChunksConverted = 0;
|
|
|
|
for (sChunkHeaders::iterator itr = m_ChunkHeaders.begin(); itr != m_ChunkHeaders.end(); ++itr)
|
|
|
|
{
|
|
|
|
sChunkHeader * Header = *itr;
|
|
|
|
|
|
|
|
if( ChunksConverted % 32 == 0 )
|
|
|
|
{
|
|
|
|
LOGINFO("Updating \"%s\" version 2 to version 3: %d %%", m_FileName.c_str(), (ChunksConverted * 100) / m_ChunkHeaders.size() );
|
|
|
|
}
|
|
|
|
ChunksConverted++;
|
|
|
|
|
|
|
|
AString Data;
|
|
|
|
int UncompressedSize = Header->m_UncompressedSize;
|
|
|
|
Data.assign(m_DataContents, Offset, Header->m_CompressedSize);
|
|
|
|
Offset += Header->m_CompressedSize;
|
|
|
|
|
|
|
|
// Crude data integrity check:
|
|
|
|
int ExpectedSize = (16*256*16)*2 + (16*256*16)/2; // For version 2
|
|
|
|
if (UncompressedSize < ExpectedSize)
|
|
|
|
{
|
|
|
|
LOGWARNING("Chunk [%d, %d] has too short decompressed data (%d bytes out of %d needed), erasing",
|
|
|
|
Header->m_ChunkX, Header->m_ChunkZ,
|
|
|
|
UncompressedSize, ExpectedSize
|
|
|
|
);
|
|
|
|
Offset += Header->m_CompressedSize;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Decompress the data:
|
|
|
|
AString UncompressedData;
|
|
|
|
{
|
|
|
|
int errorcode = UncompressString(Data.data(), Data.size(), UncompressedData, UncompressedSize);
|
|
|
|
if (errorcode != Z_OK)
|
|
|
|
{
|
|
|
|
LOGERROR("Error %d decompressing data for chunk [%d, %d]",
|
|
|
|
errorcode,
|
|
|
|
Header->m_ChunkX, Header->m_ChunkZ
|
|
|
|
);
|
|
|
|
Offset += Header->m_CompressedSize;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UncompressedSize != (int)UncompressedData.size())
|
|
|
|
{
|
|
|
|
LOGWARNING("Uncompressed data size differs (exp %d bytes, got %d) for chunk [%d, %d]",
|
|
|
|
UncompressedSize, UncompressedData.size(),
|
|
|
|
Header->m_ChunkX, Header->m_ChunkZ
|
|
|
|
);
|
|
|
|
Offset += Header->m_CompressedSize;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::auto_ptr<char> ConvertedData(new char[ ExpectedSize ]);
|
|
|
|
memset( ConvertedData.get(), 0, ExpectedSize );
|
|
|
|
|
|
|
|
// Cannot use cChunk::MakeIndex because it might change again?????????
|
|
|
|
// For compatibility, use what we know is current
|
|
|
|
#define MAKE_2_INDEX( x, y, z ) ( y + (z * 256) + (x * 256 * 16) )
|
|
|
|
#define MAKE_3_INDEX( x, y, z ) ( x + (z * 16) + (y * 16 * 16) )
|
|
|
|
|
|
|
|
unsigned int InChunkOffset = 0;
|
|
|
|
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y ) // YZX Loop order is important, in 1.1 Y was first then Z then X
|
|
|
|
{
|
|
|
|
ConvertedData.get()[ MAKE_3_INDEX(x, y, z) ] = UncompressedData[InChunkOffset];
|
|
|
|
++InChunkOffset;
|
|
|
|
} // for y, z, x
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int index2 = 0;
|
|
|
|
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y )
|
|
|
|
{
|
|
|
|
ConvertedData.get()[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4);
|
|
|
|
++index2;
|
|
|
|
}
|
|
|
|
InChunkOffset += index2/2;
|
|
|
|
index2 = 0;
|
|
|
|
|
|
|
|
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y )
|
|
|
|
{
|
|
|
|
ConvertedData.get()[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4);
|
|
|
|
++index2;
|
|
|
|
}
|
|
|
|
InChunkOffset += index2/2;
|
|
|
|
index2 = 0;
|
|
|
|
|
|
|
|
for( int x = 0; x < 16; ++x ) for( int z = 0; z < 16; ++z ) for( int y = 0; y < 256; ++y )
|
|
|
|
{
|
|
|
|
ConvertedData.get()[ InChunkOffset + MAKE_3_INDEX(x, y, z)/2 ] |= ( (UncompressedData[ InChunkOffset + index2/2 ] >> ((index2&1)*4) ) & 0x0f ) << ((x&1)*4);
|
|
|
|
++index2;
|
|
|
|
}
|
|
|
|
InChunkOffset += index2/2;
|
|
|
|
index2 = 0;
|
|
|
|
|
|
|
|
AString Converted(ConvertedData.get(), ExpectedSize);
|
|
|
|
|
|
|
|
// Add JSON data afterwards
|
|
|
|
if (UncompressedData.size() > InChunkOffset)
|
|
|
|
{
|
|
|
|
Converted.append( UncompressedData.begin() + InChunkOffset, UncompressedData.end() );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Re-compress data
|
|
|
|
AString CompressedData;
|
|
|
|
{
|
|
|
|
int errorcode = CompressString(Converted.data(), Converted.size(), CompressedData);
|
|
|
|
if (errorcode != Z_OK)
|
|
|
|
{
|
|
|
|
LOGERROR("Error %d compressing data for chunk [%d, %d]",
|
|
|
|
errorcode,
|
|
|
|
Header->m_ChunkX, Header->m_ChunkZ
|
|
|
|
);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save into file's cache
|
|
|
|
Header->m_UncompressedSize = Converted.size();
|
|
|
|
Header->m_CompressedSize = CompressedData.size();
|
|
|
|
NewDataContents.append( CompressedData );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Done converting
|
|
|
|
m_DataContents = NewDataContents;
|
|
|
|
m_ChunkVersion = 3;
|
|
|
|
SynchronizeFile();
|
|
|
|
|
|
|
|
LOGINFO("Updated \"%s\" version 2 to version 3", m_FileName.c_str() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-28 05:45:53 -05:00
|
|
|
bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int & a_UncompressedSize, const AString & a_Data, cWorld * a_World)
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
2012-02-16 08:42:35 -05:00
|
|
|
// Crude data integrity check:
|
2012-02-28 05:45:53 -05:00
|
|
|
if (a_UncompressedSize < cChunk::c_BlockDataSize)
|
2012-02-16 08:42:35 -05:00
|
|
|
{
|
2012-02-28 05:45:53 -05:00
|
|
|
LOGWARNING("Chunk [%d, %d] has too short decompressed data (%d bytes out of %d needed), erasing",
|
2012-02-16 08:42:35 -05:00
|
|
|
a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ,
|
2012-02-28 05:45:53 -05:00
|
|
|
a_UncompressedSize, cChunk::c_BlockDataSize
|
2012-02-16 08:42:35 -05:00
|
|
|
);
|
2012-02-28 05:45:53 -05:00
|
|
|
EraseChunkData(a_Chunk);
|
2012-02-16 08:42:35 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-02-13 16:47:03 -05:00
|
|
|
// Decompress the data:
|
2012-02-16 08:42:35 -05:00
|
|
|
AString UncompressedData;
|
2012-02-28 05:45:53 -05:00
|
|
|
int errorcode = UncompressString(a_Data.data(), a_Data.size(), UncompressedData, a_UncompressedSize);
|
2012-02-13 16:47:03 -05:00
|
|
|
if (errorcode != Z_OK)
|
|
|
|
{
|
2012-02-28 05:45:53 -05:00
|
|
|
LOGERROR("Error %d decompressing data for chunk [%d, %d]",
|
2012-02-13 16:47:03 -05:00
|
|
|
errorcode,
|
2012-02-28 05:45:53 -05:00
|
|
|
a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ
|
2012-02-13 16:47:03 -05:00
|
|
|
);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-02-28 05:45:53 -05:00
|
|
|
if (a_UncompressedSize != (int)UncompressedData.size())
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
2012-02-28 05:45:53 -05:00
|
|
|
LOGWARNING("Uncompressed data size differs (exp %d bytes, got %d) for chunk [%d, %d]",
|
|
|
|
a_UncompressedSize, UncompressedData.size(),
|
|
|
|
a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ
|
2012-02-13 16:47:03 -05:00
|
|
|
);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-02-16 08:42:35 -05:00
|
|
|
cEntityList Entities;
|
|
|
|
cBlockEntityList BlockEntities;
|
|
|
|
|
2012-02-28 05:45:53 -05:00
|
|
|
if (a_UncompressedSize > cChunk::c_BlockDataSize)
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
|
|
|
Json::Value root; // will contain the root value after parsing.
|
|
|
|
Json::Reader reader;
|
2012-02-16 08:42:35 -05:00
|
|
|
if ( !reader.parse( UncompressedData.data() + cChunk::c_BlockDataSize, root, false ) )
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
2012-02-28 05:45:53 -05:00
|
|
|
LOGERROR("Failed to parse trailing JSON in chunk [%d, %d]!",
|
|
|
|
a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ
|
|
|
|
);
|
2012-02-13 16:47:03 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-16 08:42:35 -05:00
|
|
|
LoadEntitiesFromJson(root, Entities, BlockEntities, a_World);
|
2012-02-13 16:47:03 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-17 12:56:25 -05:00
|
|
|
a_World->ChunkDataLoaded(a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ, UncompressedData.data(), Entities, BlockEntities);
|
2012-02-16 08:42:35 -05:00
|
|
|
|
2012-02-13 16:47:03 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-28 05:45:53 -05:00
|
|
|
bool cWSSCompact::cPAKFile::EraseChunkData(const cChunkCoords & a_Chunk)
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
2012-02-16 08:42:35 -05:00
|
|
|
int ChunkX = a_Chunk.m_ChunkX;
|
|
|
|
int ChunkZ = a_Chunk.m_ChunkZ;
|
2012-02-13 16:47:03 -05:00
|
|
|
int Offset = 0;
|
|
|
|
for (sChunkHeaders::iterator itr = m_ChunkHeaders.begin(); itr != m_ChunkHeaders.end(); ++itr)
|
|
|
|
{
|
|
|
|
if (((*itr)->m_ChunkX == ChunkX) && ((*itr)->m_ChunkZ == ChunkZ))
|
|
|
|
{
|
|
|
|
m_DataContents.erase(Offset, (*itr)->m_CompressedSize);
|
|
|
|
delete *itr;
|
|
|
|
itr = m_ChunkHeaders.erase(itr);
|
2012-02-28 05:45:53 -05:00
|
|
|
return true;
|
2012-02-13 16:47:03 -05:00
|
|
|
}
|
|
|
|
Offset += (*itr)->m_CompressedSize;
|
|
|
|
}
|
2012-02-28 05:45:53 -05:00
|
|
|
|
|
|
|
return false;
|
2012-02-13 16:47:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-16 08:42:35 -05:00
|
|
|
bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld * a_World)
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
|
|
|
// Serialize the chunk:
|
2012-02-16 08:42:35 -05:00
|
|
|
cJsonChunkSerializer Serializer;
|
2012-03-09 08:42:28 -05:00
|
|
|
a_World->GetChunkData(a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ, Serializer);
|
2012-02-16 08:42:35 -05:00
|
|
|
if (Serializer.GetBlockData().empty())
|
|
|
|
{
|
|
|
|
// Chunk not valid
|
2012-02-17 12:56:25 -05:00
|
|
|
LOG("cWSSCompact: Trying to save chunk [%d, %d, %d] that has no data, ignoring request.", a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ);
|
2012-02-16 08:42:35 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-02-13 16:47:03 -05:00
|
|
|
AString Data;
|
2012-02-16 08:42:35 -05:00
|
|
|
std::swap(Serializer.GetBlockData(), Data);
|
|
|
|
if (Serializer.HasJsonData())
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
|
|
|
AString JsonData;
|
|
|
|
Json::StyledWriter writer;
|
2012-02-16 08:42:35 -05:00
|
|
|
JsonData = writer.write(Serializer.GetRoot());
|
2012-02-13 16:47:03 -05:00
|
|
|
Data.append(JsonData);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compress the data:
|
2012-02-16 08:42:35 -05:00
|
|
|
AString CompressedData;
|
|
|
|
int errorcode = CompressString(Data.data(), Data.size(), CompressedData);
|
2012-02-13 16:47:03 -05:00
|
|
|
if ( errorcode != Z_OK )
|
|
|
|
{
|
2012-02-17 12:56:25 -05:00
|
|
|
LOGERROR("Error %i compressing data for chunk [%d, %d, %d]", errorcode, a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ);
|
2012-02-13 16:47:03 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-02-16 08:42:35 -05:00
|
|
|
// Erase any existing data for the chunk:
|
2012-02-28 05:45:53 -05:00
|
|
|
EraseChunkData(a_Chunk);
|
2012-02-16 08:42:35 -05:00
|
|
|
|
2012-02-13 16:47:03 -05:00
|
|
|
// Save the header:
|
|
|
|
sChunkHeader * Header = new sChunkHeader;
|
|
|
|
if (Header == NULL)
|
|
|
|
{
|
2012-02-17 12:56:25 -05:00
|
|
|
LOGWARNING("Cannot create a new chunk header to save chunk [%d, %d, %d]", a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ);
|
2012-02-13 16:47:03 -05:00
|
|
|
return false;
|
|
|
|
}
|
2012-02-16 08:42:35 -05:00
|
|
|
Header->m_CompressedSize = (int)CompressedData.size();
|
|
|
|
Header->m_ChunkX = a_Chunk.m_ChunkX;
|
|
|
|
Header->m_ChunkZ = a_Chunk.m_ChunkZ;
|
|
|
|
Header->m_UncompressedSize = (int)Data.size();
|
2012-02-13 16:47:03 -05:00
|
|
|
m_ChunkHeaders.push_back(Header);
|
|
|
|
|
2012-02-16 08:42:35 -05:00
|
|
|
m_DataContents.append(CompressedData.data(), CompressedData.size());
|
2012-02-13 16:47:03 -05:00
|
|
|
|
|
|
|
m_NumDirty++;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define WRITE(Var) \
|
|
|
|
if (f.Write(&Var, sizeof(Var)) != sizeof(Var)) \
|
|
|
|
{ \
|
|
|
|
LOGERROR("cWSSCompact: ERROR writing %s to file \"%s\" (line %d); file offset %d", #Var, m_FileName.c_str(), __LINE__, f.Tell()); \
|
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
|
|
|
void cWSSCompact::cPAKFile::SynchronizeFile(void)
|
|
|
|
{
|
|
|
|
cFile f;
|
|
|
|
if (!f.Open(m_FileName, cFile::fmWrite))
|
|
|
|
{
|
|
|
|
LOGERROR("Cannot open PAK file \"%s\" for writing", m_FileName.c_str());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-04 10:59:10 -05:00
|
|
|
WRITE(m_PakVersion);
|
|
|
|
WRITE(m_ChunkVersion);
|
2012-02-13 16:47:03 -05:00
|
|
|
short NumChunks = (short)m_ChunkHeaders.size();
|
|
|
|
WRITE(NumChunks);
|
|
|
|
for (sChunkHeaders::iterator itr = m_ChunkHeaders.begin(); itr != m_ChunkHeaders.end(); ++itr)
|
|
|
|
{
|
|
|
|
WRITE(**itr);
|
|
|
|
}
|
2012-02-16 08:42:35 -05:00
|
|
|
if (f.Write(m_DataContents.data(), m_DataContents.size()) != (int)m_DataContents.size())
|
2012-02-13 16:47:03 -05:00
|
|
|
{
|
|
|
|
LOGERROR("cWSSCompact: ERROR writing chunk contents to file \"%s\" (line %d); file offset %d", m_FileName.c_str(), __LINE__, f.Tell());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_NumDirty = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|