summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/Bindings.cpp3
-rw-r--r--source/Bindings.h2
-rw-r--r--source/WSSAnvil.cpp6
-rw-r--r--source/WSSAnvil.h2
-rw-r--r--source/WSSCompact.cpp27
-rw-r--r--source/WSSCompact.h10
-rw-r--r--source/WorldStorage.cpp28
-rw-r--r--source/WorldStorage.h50
-rw-r--r--source/cBlockEntity.h11
-rw-r--r--source/cChestEntity.cpp12
-rw-r--r--source/cChestEntity.h2
-rw-r--r--source/cEntity.h4
-rw-r--r--source/cFurnaceEntity.cpp15
-rw-r--r--source/cFurnaceEntity.h2
-rw-r--r--source/cSignEntity.cpp9
-rw-r--r--source/cSignEntity.h1
-rw-r--r--source/cWorld.cpp98
-rw-r--r--source/cWorld.h23
18 files changed, 258 insertions, 47 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 8e3c4bd96..e8d5da34b 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 03/11/12 17:55:41.
+** Generated automatically by tolua++-1.0.92 on 03/23/12 21:50:57.
*/
#ifndef __cplusplus
@@ -17574,6 +17574,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_ENT_LOOK",E_ENT_LOOK);
tolua_constant(tolua_S,"E_REL_ENT_MOVE_LOOK",E_REL_ENT_MOVE_LOOK);
tolua_constant(tolua_S,"E_ENT_TELEPORT",E_ENT_TELEPORT);
+ tolua_constant(tolua_S,"E_ENT_HEAD_LOOK",E_ENT_HEAD_LOOK);
tolua_constant(tolua_S,"E_ENT_STATUS",E_ENT_STATUS);
tolua_constant(tolua_S,"E_METADATA",E_METADATA);
tolua_constant(tolua_S,"E_PRE_CHUNK",E_PRE_CHUNK);
diff --git a/source/Bindings.h b/source/Bindings.h
index c100812cf..6f5fecd76 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 03/11/12 17:55:42.
+** Generated automatically by tolua++-1.0.92 on 03/23/12 21:50:57.
*/
/* Exported function */
diff --git a/source/WSSAnvil.cpp b/source/WSSAnvil.cpp
index 6520a7c95..cf0010362 100644
--- a/source/WSSAnvil.cpp
+++ b/source/WSSAnvil.cpp
@@ -111,7 +111,7 @@ cWSSAnvil::cMCAFile * cWSSAnvil::LoadMCAFile(const cChunkCoords & a_Chunk)
// Load it anew:
AString FileName;
- Printf(FileName, "%s/r.%d.%d.mca", m_World->GetName().c_str(), RegionX, RegionZ);
+ Printf(FileName, "%s/r.%d.%d.mca", m_WSI->WSIGetFolder().c_str(), RegionX, RegionZ);
cMCAFile * f = new cMCAFile(FileName, RegionX, RegionZ);
if (f == NULL)
{
@@ -282,7 +282,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, cNBTTag & a_NBT)
memset(ChunkData + cChunkDef::SkyLightOffset, 0xff, cChunkDef::NumBlocks / 2);
//*/
- m_World->ChunkDataLoaded(
+ m_WSI->WSIChunkDataLoaded(
a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ,
ChunkData,
ChunkData + cChunkDef::MetaOffset,
@@ -353,7 +353,7 @@ void cWSSAnvil::LoadChestFromNBT(cBlockEntityList & a_BlockEntities, const cNBTC
{
return; // Make it an empty chest
}
- std::auto_ptr<cChestEntity> Chest(new cChestEntity(x, y, z, m_World));
+ std::auto_ptr<cChestEntity> Chest(new cChestEntity(x, y, z));
const cNBTTags & ItemDefs = Items->GetChildren();
for (cNBTTags::const_iterator itr = ItemDefs.begin(); itr != ItemDefs.end(); ++itr)
{
diff --git a/source/WSSAnvil.h b/source/WSSAnvil.h
index 1052d0e5a..529a123fb 100644
--- a/source/WSSAnvil.h
+++ b/source/WSSAnvil.h
@@ -40,7 +40,7 @@ class cWSSAnvil :
public:
- cWSSAnvil(cWorld * a_World) : super(a_World) {}
+ cWSSAnvil(cWSInterface * a_WSI) : super(a_WSI) {}
virtual ~cWSSAnvil();
protected:
diff --git a/source/WSSCompact.cpp b/source/WSSCompact.cpp
index 8c27dba51..86c92e7ed 100644
--- a/source/WSSCompact.cpp
+++ b/source/WSSCompact.cpp
@@ -5,7 +5,6 @@
#include "Globals.h"
#include "WSSCompact.h"
-#include "cWorld.h"
#include "zlib.h"
#include <json/json.h>
#include "StringCompression.h"
@@ -68,7 +67,7 @@ bool cWSSCompact::LoadChunk(const cChunkCoords & a_Chunk)
return false;
}
- return LoadChunkFromData(a_Chunk, UncompressedSize, ChunkData, m_World);
+ return LoadChunkFromData(a_Chunk, UncompressedSize, ChunkData, m_WSI);
}
@@ -86,7 +85,7 @@ bool cWSSCompact::SaveChunk(const cChunkCoords & a_Chunk)
LOG("Cannot locate a proper PAK file for chunk [%d, %d]", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ);
return false;
}
- return f->SaveChunk(a_Chunk, m_World);
+ return f->SaveChunk(a_Chunk, m_WSI);
}
@@ -119,7 +118,7 @@ cWSSCompact::cPAKFile * cWSSCompact::LoadPAKFile(const cChunkCoords & a_Chunk)
// Load it anew:
AString FileName;
- Printf(FileName, "%s/X%i_Z%i.pak", m_World->GetName().c_str(), LayerX, LayerZ );
+ Printf(FileName, "%s/X%i_Z%i.pak", m_WSI->WSIGetFolder().c_str(), LayerX, LayerZ );
cPAKFile * f = new cPAKFile(FileName, LayerX, LayerZ);
if (f == NULL)
{
@@ -188,7 +187,7 @@ bool cWSSCompact::EraseChunkData(const cChunkCoords & a_Chunk)
-void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities, cWorld * a_World)
+void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities, cWSInterface * a_WSI)
{
// Load chests
Json::Value AllChests = a_Value.get("Chests", Json::nullValue);
@@ -197,7 +196,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
for (Json::Value::iterator itr = AllChests.begin(); itr != AllChests.end(); ++itr )
{
Json::Value & Chest = *itr;
- cChestEntity * ChestEntity = new cChestEntity(0,0,0, a_World);
+ cChestEntity * ChestEntity = new cChestEntity(0, 0, 0);
if (!ChestEntity->LoadFromJson( Chest ) )
{
LOGERROR("ERROR READING CHEST FROM JSON!" );
@@ -217,7 +216,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
for( Json::Value::iterator itr = AllFurnaces.begin(); itr != AllFurnaces.end(); ++itr )
{
Json::Value & Furnace = *itr;
- cFurnaceEntity * FurnaceEntity = new cFurnaceEntity(0,0,0, a_World);
+ cFurnaceEntity * FurnaceEntity = new cFurnaceEntity(0, 0, 0);
if( !FurnaceEntity->LoadFromJson( Furnace ) )
{
LOGERROR("ERROR READING FURNACE FROM JSON!" );
@@ -237,7 +236,7 @@ void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_En
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);
+ cSignEntity * SignEntity = new cSignEntity( E_BLOCK_SIGN_POST, 0, 0, 0);
if ( !SignEntity->LoadFromJson( Sign ) )
{
LOGERROR("ERROR READING SIGN FROM JSON!" );
@@ -382,7 +381,7 @@ bool cWSSCompact::cPAKFile::GetChunkData(const cChunkCoords & a_Chunk, int & a_U
-bool cWSSCompact::cPAKFile::SaveChunk(const cChunkCoords & a_Chunk, cWorld * a_World)
+bool cWSSCompact::cPAKFile::SaveChunk(const cChunkCoords & a_Chunk, cWSInterface * a_World)
{
if (!SaveChunkToData(a_Chunk, a_World))
{
@@ -681,7 +680,7 @@ void cWSSCompact::cPAKFile::UpdateChunk2To3()
-bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int & a_UncompressedSize, const AString & a_Data, cWorld * a_World)
+bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int & a_UncompressedSize, const AString & a_Data, cWSInterface * a_WSI)
{
// Crude data integrity check:
if (a_UncompressedSize < cChunkDef::BlockDataSize)
@@ -730,13 +729,13 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int & a_Uncomp
}
else
{
- LoadEntitiesFromJson(root, Entities, BlockEntities, a_World);
+ LoadEntitiesFromJson(root, Entities, BlockEntities, a_WSI);
}
}
BLOCKTYPE * BlockData = (BLOCKTYPE *)UncompressedData.data();
- a_World->ChunkDataLoaded(
+ a_WSI->WSIChunkDataLoaded(
a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ,
BlockData,
BlockData + cChunkDef::MetaOffset,
@@ -778,11 +777,11 @@ bool cWSSCompact::cPAKFile::EraseChunkData(const cChunkCoords & a_Chunk)
-bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld * a_World)
+bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWSInterface * a_WSI)
{
// Serialize the chunk:
cJsonChunkSerializer Serializer;
- if (!a_World->GetChunkData(a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ, Serializer))
+ if (!a_WSI->WSIGetChunkData(a_Chunk.m_ChunkX, a_Chunk.m_ChunkY, a_Chunk.m_ChunkZ, Serializer))
{
// Chunk not valid
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);
diff --git a/source/WSSCompact.h b/source/WSSCompact.h
index cd753ce9c..a50405d6d 100644
--- a/source/WSSCompact.h
+++ b/source/WSSCompact.h
@@ -22,7 +22,7 @@ class cWSSCompact :
public cWSSchema
{
public:
- cWSSCompact(cWorld * a_World) : cWSSchema(a_World) {}
+ cWSSCompact(cWSInterface * a_WSI) : cWSSchema(a_WSI) {}
virtual ~cWSSCompact();
protected:
@@ -42,7 +42,7 @@ protected:
bool SetChunkData(const cChunkCoords & a_Chunk, int a_UncompressedSize, const AString & a_Data);
bool EraseChunkData(const cChunkCoords & a_Chunk);
- bool SaveChunk(const cChunkCoords & a_Chunk, cWorld * a_World);
+ bool SaveChunk(const cChunkCoords & a_Chunk, cWSInterface * a_WSI);
int GetLayerX(void) const {return m_LayerX; }
int GetLayerZ(void) const {return m_LayerZ; }
@@ -68,7 +68,7 @@ protected:
char m_ChunkVersion;
char m_PakVersion;
- bool SaveChunkToData(const cChunkCoords & a_Chunk, cWorld * a_World); // Saves the chunk to m_DataContents, updates headers and m_NumDirty
+ bool SaveChunkToData(const cChunkCoords & a_Chunk, cWSInterface * a_WSI); // Saves the chunk to m_DataContents, updates headers and m_NumDirty
void SynchronizeFile(void); // Writes m_DataContents along with the headers to file, resets m_NumDirty
void UpdateChunk1To2(void); // Height from 128 to 256
@@ -93,9 +93,9 @@ protected:
bool EraseChunkData(const cChunkCoords & a_Chunk);
/// Loads the chunk from the data (no locking needed)
- bool LoadChunkFromData(const cChunkCoords & a_Chunk, int & a_UncompressedSize, const AString & a_Data, cWorld * a_World);
+ bool LoadChunkFromData(const cChunkCoords & a_Chunk, int & a_UncompressedSize, const AString & a_Data, cWSInterface * a_WSI);
- void LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities, cWorld * a_World);
+ void LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities, cWSInterface * a_WSI);
// cWSSchema overrides:
virtual bool LoadChunk(const cChunkCoords & a_Chunk) override;
diff --git a/source/WorldStorage.cpp b/source/WorldStorage.cpp
index e0e9e7c7b..5fc19ff59 100644
--- a/source/WorldStorage.cpp
+++ b/source/WorldStorage.cpp
@@ -24,7 +24,7 @@ class cWSSForgetful :
public cWSSchema
{
public:
- cWSSForgetful(cWorld * a_World) : cWSSchema(a_World) {}
+ cWSSForgetful(cWSInterface * a_WSI) : cWSSchema(a_WSI) {}
protected:
// cWSSchema overrides:
@@ -97,7 +97,7 @@ void cJsonChunkSerializer::BlockEntity(cBlockEntity * a_BlockEntity)
cWorldStorage::cWorldStorage(void) :
super("cWorldStorage"),
- m_World(NULL),
+ m_WSI(NULL),
m_SaveSchema(NULL)
{
}
@@ -120,9 +120,9 @@ cWorldStorage::~cWorldStorage()
-bool cWorldStorage::Start(cWorld * a_World, const AString & a_StorageSchemaName)
+bool cWorldStorage::Start(cWSInterface * a_WSI, const AString & a_StorageSchemaName)
{
- m_World = a_World;
+ m_WSI = a_WSI;
m_StorageSchemaName = a_StorageSchemaName;
InitSchemas();
@@ -266,9 +266,9 @@ void cWorldStorage::UnqueueSave(const cChunkCoords & a_Chunk)
void cWorldStorage::InitSchemas(void)
{
// The first schema added is considered the default
- m_Schemas.push_back(new cWSSCompact (m_World));
- m_Schemas.push_back(new cWSSAnvil (m_World));
- m_Schemas.push_back(new cWSSForgetful(m_World));
+ m_Schemas.push_back(new cWSSCompact (m_WSI));
+ m_Schemas.push_back(new cWSSAnvil (m_WSI));
+ m_Schemas.push_back(new cWSSForgetful(m_WSI));
// Add new schemas here
if (NoCaseCompare(m_StorageSchemaName, "default") == 0)
@@ -286,7 +286,7 @@ void cWorldStorage::InitSchemas(void)
} // for itr - m_Schemas[]
// Unknown schema selected, let the admin know:
- LOGWARNING("Unknown storage schema name \"%s\". Using default. Available schemas:", m_StorageSchemaName.c_str());
+ LOGWARNING("World \"%s\": Unknown storage schema name \"%s\". Using default. Available schemas:", m_WSI->WSIGetFolder().c_str(), m_StorageSchemaName.c_str());
for (cWSSchemaList::iterator itr = m_Schemas.begin(); itr != m_Schemas.end(); ++itr)
{
LOGWARNING("\t\"%s\"", (*itr)->GetName().c_str());
@@ -346,7 +346,7 @@ bool cWorldStorage::LoadOneChunk(void)
if (ToLoad.m_Generate)
{
// The chunk couldn't be loaded, generate it:
- m_World->GetGenerator().GenerateChunk(ToLoad.m_ChunkX, ToLoad.m_ChunkY, ToLoad.m_ChunkZ);
+ m_WSI->WSIGenerateChunk(ToLoad.m_ChunkX, ToLoad.m_ChunkY, ToLoad.m_ChunkZ);
}
else
{
@@ -376,12 +376,12 @@ bool cWorldStorage::SaveOneChunk(void)
}
HasMore = (m_SaveQueue.size() > 0);
}
- if (ShouldSave && m_World->IsChunkValid(Save.m_ChunkX, Save.m_ChunkY, Save.m_ChunkZ))
+ if (ShouldSave && m_WSI->WSIIsChunkValid(Save.m_ChunkX, Save.m_ChunkY, Save.m_ChunkZ))
{
- m_World->MarkChunkSaving(Save.m_ChunkX, Save.m_ChunkY, Save.m_ChunkZ);
+ m_WSI->WSIMarkChunkSaving(Save.m_ChunkX, Save.m_ChunkY, Save.m_ChunkZ);
if (m_SaveSchema->SaveChunk(Save))
{
- m_World->MarkChunkSaved(Save.m_ChunkX, Save.m_ChunkY, Save.m_ChunkZ);
+ m_WSI->WSIMarkChunkSaved(Save.m_ChunkX, Save.m_ChunkY, Save.m_ChunkZ);
}
else
{
@@ -397,7 +397,7 @@ bool cWorldStorage::SaveOneChunk(void)
bool cWorldStorage::LoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
- if (m_World->IsChunkValid(a_ChunkX, a_ChunkY, a_ChunkZ))
+ if (m_WSI->WSIIsChunkValid(a_ChunkX, a_ChunkY, a_ChunkZ))
{
// Already loaded (can happen, since the queue is async)
return true;
@@ -421,7 +421,7 @@ bool cWorldStorage::LoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
}
// Notify the chunk owner that the chunk failed to load (sets cChunk::m_HasLoadFailed to true):
- m_World->ChunkLoadFailed(a_ChunkX, a_ChunkY, a_ChunkZ);
+ m_WSI->WSIChunkLoadFailed(a_ChunkX, a_ChunkY, a_ChunkZ);
return false;
}
diff --git a/source/WorldStorage.h b/source/WorldStorage.h
index da78b69f2..047c358ba 100644
--- a/source/WorldStorage.h
+++ b/source/WorldStorage.h
@@ -22,8 +22,45 @@
-// fwd:
-class cWorld;
+/** Interface between cWorld and cWorldStorage, contains all calls into cWorld that cWorldStorage needs
+Defining this as an interface lets us re-use the cWorldStorage outside of MC-Server's main executable,
+for example for tools such as storage converters or chunk analytics
+*/
+class cWSInterface
+{
+public:
+ /// Asks the world if the chunk is fully valid
+ virtual bool WSIIsChunkValid(int a_ChunkX, int a_ChunkY, int a_ChunkZ) = 0;
+
+ /// Marks the chunk as being saved
+ virtual void WSIMarkChunkSaving(int a_ChunkX, int a_ChunkY, int a_ChunkZ) = 0;
+
+ /// Marks the chunk as having been saved (if there was no change since the last MarkSaving)
+ virtual void WSIMarkChunkSaved(int a_ChunkX, int a_ChunkY, int a_ChunkZ) = 0;
+
+ /// Marks the chunk as unable to load
+ virtual void WSIChunkLoadFailed(int a_ChunkX, int a_ChunkY, int a_ChunkZ) = 0;
+
+ /// Called when chunk generation has been specified for a chunk that cannot be loaded
+ virtual void WSIGenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) = 0;
+
+ /// Marks the chunk as having been saved (if there was no change since the last MarkSaving)
+ virtual bool WSIGetChunkData(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cChunkDataCallback & a_Callback) = 0;
+
+ /// Gets the folder where the world is saved
+ virtual AString WSIGetFolder(void) = 0;
+
+ virtual void WSIChunkDataLoaded(
+ int a_ChunkX, int a_ChunkY, int a_ChunkZ,
+ const BLOCKTYPE * a_BlockTypes,
+ const BLOCKTYPE * a_BlockMeta,
+ const BLOCKTYPE * a_BlockLight,
+ const BLOCKTYPE * a_BlockSkyLight,
+ const cChunkDef::HeightMap * a_HeightMap,
+ cEntityList & a_Entities,
+ cBlockEntityList & a_BlockEntities
+ ) = 0;
+} ;
@@ -33,7 +70,7 @@ class cWorld;
class cWSSchema abstract
{
public:
- cWSSchema(cWorld * a_World) : m_World(a_World) {}
+ cWSSchema(cWSInterface * a_WSI) : m_WSI(a_WSI) {}
virtual ~cWSSchema() {} // Force the descendants' destructors to be virtual
virtual bool LoadChunk(const cChunkCoords & a_Chunk) = 0;
@@ -42,7 +79,7 @@ public:
protected:
- cWorld * m_World;
+ cWSInterface * m_WSI;
} ;
typedef std::list<cWSSchema *> cWSSchemaList;
@@ -103,7 +140,7 @@ public:
void UnqueueLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
void UnqueueSave(const cChunkCoords & a_Chunk);
- bool Start(cWorld * a_World, const AString & a_StorageSchemaName); // Hide the cIsThread's Start() method, we need to provide args
+ bool Start(cWSInterface * a_WSI, const AString & a_StorageSchemaName); // Hide the cIsThread's Start() method, we need to provide args
void WaitForFinish(void);
void WaitForQueuesEmpty(void);
@@ -124,7 +161,8 @@ protected:
typedef std::list<sChunkLoad> sChunkLoadQueue;
- cWorld * m_World;
+ cWSInterface * m_WSI;
+
AString m_StorageSchemaName;
// Both queues are locked by the same CS
diff --git a/source/cBlockEntity.h b/source/cBlockEntity.h
index 3f0190c77..662a6c5eb 100644
--- a/source/cBlockEntity.h
+++ b/source/cBlockEntity.h
@@ -41,7 +41,17 @@ protected:
, m_BlockType( a_BlockType )
, m_World( a_World )
{}
+
+ cBlockEntity(ENUM_BLOCK_ID a_BlockType, int a_X, int a_Y, int a_Z)
+ : m_PosX( a_X )
+ , m_PosY( a_Y )
+ , m_PosZ( a_Z )
+ , m_BlockType( a_BlockType )
+ , m_World(NULL)
+ {}
+
public:
+
virtual ~cBlockEntity() {};
virtual void Destroy() {};
@@ -52,6 +62,7 @@ public:
ENUM_BLOCK_ID GetBlockType() { return m_BlockType; }
cWorld * GetWorld(void) const {return m_World; }
+ void SetWorld(cWorld * a_World) {m_World = a_World; }
virtual void SaveToJson (Json::Value & a_Value ) = 0;
diff --git a/source/cChestEntity.cpp b/source/cChestEntity.cpp
index f1a99b8c3..7961cee5b 100644
--- a/source/cChestEntity.cpp
+++ b/source/cChestEntity.cpp
@@ -34,6 +34,18 @@ cChestEntity::cChestEntity(int a_X, int a_Y, int a_Z, cWorld * a_World)
+cChestEntity::cChestEntity(int a_X, int a_Y, int a_Z)
+ : cBlockEntity( E_BLOCK_CHEST, a_X, a_Y, a_Z)
+ , m_TopChest( false )
+ , m_JoinedChest( NULL )
+{
+ m_Content = new cItem[ c_ChestHeight*c_ChestWidth ];
+}
+
+
+
+
+
cChestEntity::~cChestEntity()
{
if( GetWindow() )
diff --git a/source/cChestEntity.h b/source/cChestEntity.h
index 323eb0f8a..5223ad6eb 100644
--- a/source/cChestEntity.h
+++ b/source/cChestEntity.h
@@ -29,6 +29,8 @@ class cChestEntity :
{
public:
cChestEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
+ cChestEntity(int a_X, int a_Y, int a_Z);
+
virtual ~cChestEntity();
virtual void Destroy();
diff --git a/source/cEntity.h b/source/cEntity.h
index 1b26f46be..179af4b17 100644
--- a/source/cEntity.h
+++ b/source/cEntity.h
@@ -84,6 +84,9 @@ public: //tolua_export
int GetChunkY(void) const {return m_ChunkY; }
int GetChunkZ(void) const {return m_ChunkZ; }
+ // Can be used only once - to set the initial world after loading. Not to be used for moving to another world!
+ void SetWorld( cWorld* a_World ) { ASSERT(m_World == NULL); m_World = a_World; }
+
void SetPosX( const double & a_PosX ); //tolua_export
void SetPosY( const double & a_PosY ); //tolua_export
void SetPosZ( const double & a_PosZ ); //tolua_export
@@ -110,7 +113,6 @@ public: //tolua_export
protected:
virtual void Destroyed() {} // Called after the entity has been destroyed
- void SetWorld( cWorld* a_World ) { m_World = a_World; }
void MoveToCorrectChunk(bool a_bIgnoreOldChunk = false);
friend class cReferenceManager;
diff --git a/source/cFurnaceEntity.cpp b/source/cFurnaceEntity.cpp
index 389d4af54..63876ae19 100644
--- a/source/cFurnaceEntity.cpp
+++ b/source/cFurnaceEntity.cpp
@@ -36,6 +36,21 @@ cFurnaceEntity::cFurnaceEntity(int a_X, int a_Y, int a_Z, cWorld * a_World)
+cFurnaceEntity::cFurnaceEntity(int a_X, int a_Y, int a_Z)
+ : cBlockEntity( E_BLOCK_FURNACE, a_X, a_Y, a_Z)
+ , m_Items( new cItem[3] )
+ , m_CookingItem( 0 )
+ , m_CookTime( 0 )
+ , m_TimeCooked( 0 )
+ , m_BurnTime( 0 )
+ , m_TimeBurned( 0 )
+{
+}
+
+
+
+
+
cFurnaceEntity::~cFurnaceEntity()
{
// Tell window its owner is destroyed
diff --git a/source/cFurnaceEntity.h b/source/cFurnaceEntity.h
index 21cdb1e38..d72865c16 100644
--- a/source/cFurnaceEntity.h
+++ b/source/cFurnaceEntity.h
@@ -28,6 +28,8 @@ class cFurnaceEntity :
{
public:
cFurnaceEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
+ cFurnaceEntity(int a_X, int a_Y, int a_Z);
+
virtual ~cFurnaceEntity();
virtual void Destroy();
diff --git a/source/cSignEntity.cpp b/source/cSignEntity.cpp
index ca21d847b..92db18d91 100644
--- a/source/cSignEntity.cpp
+++ b/source/cSignEntity.cpp
@@ -25,6 +25,15 @@ cSignEntity::cSignEntity(ENUM_BLOCK_ID a_BlockType, int a_X, int a_Y, int a_Z, c
+cSignEntity::cSignEntity(ENUM_BLOCK_ID a_BlockType, int a_X, int a_Y, int a_Z)
+ : cBlockEntity(a_BlockType, a_X, a_Y, a_Z)
+{
+}
+
+
+
+
+
cSignEntity::~cSignEntity()
{
}
diff --git a/source/cSignEntity.h b/source/cSignEntity.h
index 5d9d11a9c..a8b0820dd 100644
--- a/source/cSignEntity.h
+++ b/source/cSignEntity.h
@@ -21,6 +21,7 @@ class cSignEntity :
{
public:
cSignEntity(ENUM_BLOCK_ID a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World);
+ cSignEntity(ENUM_BLOCK_ID a_BlockType, int a_X, int a_Y, int a_Z);
virtual ~cSignEntity();
OBSOLETE bool LoadFromFile(cFile & a_File); // deprecated format
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index 266d425e4..588640c03 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -1502,3 +1502,101 @@ int cWorld::GetNumChunks(void) const
+
+bool cWorld::WSIIsChunkValid(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
+{
+ return m_ChunkMap->IsChunkValid(a_ChunkX, a_ChunkY, a_ChunkZ);
+}
+
+
+
+
+
+void cWorld::WSIMarkChunkSaving(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
+{
+ m_ChunkMap->MarkChunkSaving(a_ChunkX, a_ChunkY, a_ChunkZ);
+}
+
+
+
+
+
+void cWorld::WSIMarkChunkSaved(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
+{
+ m_ChunkMap->MarkChunkSaved(a_ChunkX, a_ChunkY, a_ChunkZ);
+}
+
+
+
+
+
+void cWorld::WSIChunkLoadFailed(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
+{
+ ChunkLoadFailed(a_ChunkX, a_ChunkY, a_ChunkZ);
+}
+
+
+
+
+
+void cWorld::WSIGenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
+{
+ m_Generator.GenerateChunk(a_ChunkX, a_ChunkY, a_ChunkZ);
+}
+
+
+
+
+
+bool cWorld::WSIGetChunkData(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cChunkDataCallback & a_Callback)
+{
+ return m_ChunkMap->GetChunkData(a_ChunkX, a_ChunkY, a_ChunkZ, a_Callback);
+}
+
+
+
+
+
+AString cWorld::WSIGetFolder(void)
+{
+ return m_WorldName;
+}
+
+
+
+
+
+void cWorld::WSIChunkDataLoaded(
+ int a_ChunkX, int a_ChunkY, int a_ChunkZ,
+ const BLOCKTYPE * a_BlockTypes,
+ const BLOCKTYPE * a_BlockMeta,
+ const BLOCKTYPE * a_BlockLight,
+ const BLOCKTYPE * a_BlockSkyLight,
+ const cChunkDef::HeightMap * a_HeightMap,
+ cEntityList & a_Entities,
+ cBlockEntityList & a_BlockEntities
+)
+{
+ // Set all a_Entities' and a_BlockEntities' world to this:
+ for (cEntityList::iterator itr = a_Entities.begin(); itr != a_Entities.end(); ++itr)
+ {
+ (*itr)->SetWorld(this);
+ } // for itr - a_Entities[]
+ for (cBlockEntityList::iterator itr = a_BlockEntities.begin(); itr != a_BlockEntities.end(); ++itr)
+ {
+ (*itr)->SetWorld(this);
+ } // for itr - a_BlockEntities[]
+
+ m_ChunkMap->ChunkDataLoaded(
+ a_ChunkX, a_ChunkY, a_ChunkZ,
+ a_BlockTypes, a_BlockMeta, a_BlockLight, a_BlockSkyLight,
+ a_HeightMap,
+ a_Entities,
+ a_BlockEntities
+ );
+ m_ChunkSender.ChunkReady(a_ChunkX, a_ChunkY, a_ChunkZ);
+}
+
+
+
+
diff --git a/source/cWorld.h b/source/cWorld.h
index a8591af65..fd5f800fd 100644
--- a/source/cWorld.h
+++ b/source/cWorld.h
@@ -45,7 +45,8 @@ typedef cItemCallback<cEntity> cEntityCallback;
-class cWorld //tolua_export
+class cWorld : //tolua_export
+ public cWSInterface
{ //tolua_export
public:
@@ -257,6 +258,26 @@ public:
cWorldStorage & GetStorage (void) { return m_Storage; }
cChunkMap * GetChunkMap (void) { return m_ChunkMap; }
+protected:
+ // cWSInterface overrides:
+ virtual bool WSIIsChunkValid(int a_ChunkX, int a_ChunkY, int a_ChunkZ) override;
+ virtual void WSIMarkChunkSaving(int a_ChunkX, int a_ChunkY, int a_ChunkZ) override;
+ virtual void WSIMarkChunkSaved(int a_ChunkX, int a_ChunkY, int a_ChunkZ) override;
+ virtual void WSIChunkLoadFailed(int a_ChunkX, int a_ChunkY, int a_ChunkZ) override;
+ virtual void WSIGenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) override;
+ virtual bool WSIGetChunkData(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cChunkDataCallback & a_Callback) override;
+ virtual AString WSIGetFolder(void) override;
+ virtual void WSIChunkDataLoaded(
+ int a_ChunkX, int a_ChunkY, int a_ChunkZ,
+ const BLOCKTYPE * a_BlockTypes,
+ const BLOCKTYPE * a_BlockMeta,
+ const BLOCKTYPE * a_BlockLight,
+ const BLOCKTYPE * a_BlockSkyLight,
+ const cChunkDef::HeightMap * a_HeightMap,
+ cEntityList & a_Entities,
+ cBlockEntityList & a_BlockEntities
+ ) override;
+
private:
friend class cRoot;