1
0

WorldStorage: Removed unused callback parameters

This commit is contained in:
Tiger Wang 2020-08-28 21:36:46 +01:00
parent 071aee6c79
commit da9158937d
3 changed files with 13 additions and 50 deletions

View File

@ -629,27 +629,6 @@ public:
/** Provides storage for a set of chunk coords together with a callback.
Used for chunk queues that notify about processed items. */
class cChunkCoordsWithCallback
{
public:
cChunkCoordsWithCallback(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback):
m_ChunkX(a_ChunkX),
m_ChunkZ(a_ChunkZ),
m_Callback(a_Callback)
{
}
int m_ChunkX;
int m_ChunkZ;
cChunkCoordCallback * m_Callback;
};
/** Generic template that can store any kind of data together with a triplet of 3 coords */ /** Generic template that can store any kind of data together with a triplet of 3 coords */
template <typename X> class cCoordWithData template <typename X> class cCoordWithData
{ {

View File

@ -138,13 +138,13 @@ size_t cWorldStorage::GetSaveQueueLength(void)
void cWorldStorage::QueueLoadChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback) void cWorldStorage::QueueLoadChunk(int a_ChunkX, int a_ChunkZ)
{ {
ASSERT((a_ChunkX > -0x08000000) && (a_ChunkX < 0x08000000)); ASSERT((a_ChunkX > -0x08000000) && (a_ChunkX < 0x08000000));
ASSERT((a_ChunkZ > -0x08000000) && (a_ChunkZ < 0x08000000)); ASSERT((a_ChunkZ > -0x08000000) && (a_ChunkZ < 0x08000000));
ASSERT(m_World->IsChunkQueued(a_ChunkX, a_ChunkZ)); ASSERT(m_World->IsChunkQueued(a_ChunkX, a_ChunkZ));
m_LoadQueue.EnqueueItem(cChunkCoordsWithCallback(a_ChunkX, a_ChunkZ, a_Callback)); m_LoadQueue.EnqueueItem({ a_ChunkX, a_ChunkZ });
m_Event.Set(); m_Event.Set();
} }
@ -152,11 +152,11 @@ void cWorldStorage::QueueLoadChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallba
void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback) void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkZ)
{ {
ASSERT(m_World->IsChunkValid(a_ChunkX, a_ChunkZ)); ASSERT(m_World->IsChunkValid(a_ChunkX, a_ChunkZ));
m_SaveQueue.EnqueueItem(cChunkCoordsWithCallback(a_ChunkX, a_ChunkZ, a_Callback)); m_SaveQueue.EnqueueItem({ a_ChunkX, a_ChunkZ });
m_Event.Set(); m_Event.Set();
} }
@ -227,7 +227,7 @@ void cWorldStorage::Execute(void)
bool cWorldStorage::LoadOneChunk(void) bool cWorldStorage::LoadOneChunk(void)
{ {
// Dequeue an item, bail out if there's none left: // Dequeue an item, bail out if there's none left:
cChunkCoordsWithCallback ToLoad(0, 0, nullptr); cChunkCoords ToLoad(0, 0);
bool ShouldLoad = m_LoadQueue.TryDequeueItem(ToLoad); bool ShouldLoad = m_LoadQueue.TryDequeueItem(ToLoad);
if (!ShouldLoad) if (!ShouldLoad)
{ {
@ -235,14 +235,7 @@ bool cWorldStorage::LoadOneChunk(void)
} }
// Load the chunk: // Load the chunk:
bool res = LoadChunk(ToLoad.m_ChunkX, ToLoad.m_ChunkZ); return LoadChunk(ToLoad.m_ChunkX, ToLoad.m_ChunkZ);
// Call the callback, if specified:
if (ToLoad.m_Callback != nullptr)
{
ToLoad.m_Callback->Call({ToLoad.m_ChunkX, ToLoad.m_ChunkZ}, res);
}
return res;
} }
@ -252,7 +245,7 @@ bool cWorldStorage::LoadOneChunk(void)
bool cWorldStorage::SaveOneChunk(void) bool cWorldStorage::SaveOneChunk(void)
{ {
// Dequeue one chunk to save: // Dequeue one chunk to save:
cChunkCoordsWithCallback ToSave(0, 0, nullptr); cChunkCoords ToSave(0, 0);
bool ShouldSave = m_SaveQueue.TryDequeueItem(ToSave); bool ShouldSave = m_SaveQueue.TryDequeueItem(ToSave);
if (!ShouldSave) if (!ShouldSave)
{ {
@ -271,11 +264,6 @@ bool cWorldStorage::SaveOneChunk(void)
} }
} }
// Call the callback, if specified:
if (ToSave.m_Callback != nullptr)
{
ToSave.m_Callback->Call({ToSave.m_ChunkX, ToSave.m_ChunkZ}, Status);
}
return true; return true;
} }

View File

@ -22,8 +22,6 @@
// fwd: // fwd:
class cWorld; class cWorld;
typedef cQueue<cChunkCoordsWithCallback> cChunkCoordsQueue;
@ -61,13 +59,11 @@ public:
cWorldStorage(); cWorldStorage();
virtual ~cWorldStorage() override; virtual ~cWorldStorage() override;
/** Queues a chunk to be loaded, asynchronously. /** Queues a chunk to be loaded, asynchronously. */
The callback, if specified, will be called with the result of the load operation. */ void QueueLoadChunk(int a_ChunkX, int a_ChunkZ);
void QueueLoadChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback = nullptr);
/** Queues a chunk to be saved, asynchronously. /** Queues a chunk to be saved, asynchronously. */
The callback, if specified, will be called with the result of the save operation. */ void QueueSaveChunk(int a_ChunkX, int a_ChunkZ);
void QueueSaveChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback = nullptr);
/** Initializes the storage schemas, ready to be started. */ /** Initializes the storage schemas, ready to be started. */
void Initialize(cWorld & a_World, const AString & a_StorageSchemaName, int a_StorageCompressionFactor); void Initialize(cWorld & a_World, const AString & a_StorageSchemaName, int a_StorageCompressionFactor);
@ -84,8 +80,8 @@ protected:
cWorld * m_World; cWorld * m_World;
AString m_StorageSchemaName; AString m_StorageSchemaName;
cChunkCoordsQueue m_LoadQueue; cQueue<cChunkCoords> m_LoadQueue;
cChunkCoordsQueue m_SaveQueue; cQueue<cChunkCoords> m_SaveQueue;
/** All the storage schemas (all used for loading) */ /** All the storage schemas (all used for loading) */
cWSSchemaList m_Schemas; cWSSchemaList m_Schemas;