From c54bf40ef96806bf836db205f79e60d016b7eee9 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Fri, 22 Sep 2017 17:16:47 +0100 Subject: cWorld Threads: Seperate initialization and thread start. Prevents nullptr dereferences before Start has been called. --- src/WorldStorage/WorldStorage.cpp | 6 ++---- src/WorldStorage/WorldStorage.h | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src/WorldStorage') diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index 29fe78d4f..7be710c29 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -60,13 +60,11 @@ cWorldStorage::~cWorldStorage() -bool cWorldStorage::Start(cWorld * a_World, const AString & a_StorageSchemaName, int a_StorageCompressionFactor) +void cWorldStorage::Initialize(cWorld & a_World, const AString & a_StorageSchemaName, int a_StorageCompressionFactor) { - m_World = a_World; + m_World = &a_World; m_StorageSchemaName = a_StorageSchemaName; InitSchemas(a_StorageCompressionFactor); - - return super::Start(); } diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index 5b8a1b8ba..a7d3bb1d4 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -69,7 +69,8 @@ public: The callback, if specified, will be called with the result of the save operation. */ void QueueSaveChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback = nullptr); - bool Start(cWorld * a_World, const AString & a_StorageSchemaName, int a_StorageCompressionFactor); // Hide the cIsThread's Start() method, we need to provide args + /** Initializes the storage schemas, ready to be started. */ + void Initialize(cWorld & a_World, const AString & a_StorageSchemaName, int a_StorageCompressionFactor); void Stop(void); // Hide the cIsThread's Stop() method, we need to signal the event void WaitForFinish(void); void WaitForLoadQueueEmpty(void); -- cgit v1.2.3