Revert "Project modernization (#630)"
This code was not tested and breaks in Release builds, reverting to restore
functionality of the nightly. All in-game menus do not work and generating
a world crashes.
This reverts commit a9be52c41a.
This commit is contained in:
@@ -71,7 +71,7 @@ bool ServerChunkCache::hasChunk(int x, int z)
|
||||
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return true;
|
||||
int idx = ix * XZSIZE + iz;
|
||||
LevelChunk *lc = cache[idx];
|
||||
if( lc == nullptr ) return false;
|
||||
if( lc == NULL ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -148,13 +148,13 @@ LevelChunk *ServerChunkCache::create(int x, int z, bool asyncPostProcess) // 4J
|
||||
LevelChunk *chunk = cache[idx];
|
||||
LevelChunk *lastChunk = chunk;
|
||||
|
||||
if( ( chunk == nullptr ) || ( chunk->x != x ) || ( chunk->z != z ) )
|
||||
if( ( chunk == NULL ) || ( chunk->x != x ) || ( chunk->z != z ) )
|
||||
{
|
||||
EnterCriticalSection(&m_csLoadCreate);
|
||||
chunk = load(x, z);
|
||||
if (chunk == nullptr)
|
||||
if (chunk == NULL)
|
||||
{
|
||||
if (source == nullptr)
|
||||
if (source == NULL)
|
||||
{
|
||||
chunk = emptyChunk;
|
||||
}
|
||||
@@ -163,7 +163,7 @@ LevelChunk *ServerChunkCache::create(int x, int z, bool asyncPostProcess) // 4J
|
||||
chunk = source->getChunk(x, z);
|
||||
}
|
||||
}
|
||||
if (chunk != nullptr)
|
||||
if (chunk != NULL)
|
||||
{
|
||||
chunk->load();
|
||||
}
|
||||
@@ -320,7 +320,7 @@ void ServerChunkCache::overwriteLevelChunkFromSource(int x, int z)
|
||||
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) assert(0);
|
||||
int idx = ix * XZSIZE + iz;
|
||||
|
||||
LevelChunk *chunk = nullptr;
|
||||
LevelChunk *chunk = NULL;
|
||||
chunk = source->getChunk(x, z);
|
||||
assert(chunk);
|
||||
if(chunk)
|
||||
@@ -389,22 +389,22 @@ void ServerChunkCache::dontDrop(int x, int z)
|
||||
|
||||
LevelChunk *ServerChunkCache::load(int x, int z)
|
||||
{
|
||||
if (storage == nullptr) return nullptr;
|
||||
if (storage == NULL) return NULL;
|
||||
|
||||
LevelChunk *levelChunk = nullptr;
|
||||
LevelChunk *levelChunk = NULL;
|
||||
|
||||
#ifdef _LARGE_WORLDS
|
||||
int ix = x + XZOFFSET;
|
||||
int iz = z + XZOFFSET;
|
||||
int idx = ix * XZSIZE + iz;
|
||||
levelChunk = m_unloadedCache[idx];
|
||||
m_unloadedCache[idx] = nullptr;
|
||||
if(levelChunk == nullptr)
|
||||
m_unloadedCache[idx] = NULL;
|
||||
if(levelChunk == NULL)
|
||||
#endif
|
||||
{
|
||||
levelChunk = storage->load(level, x, z);
|
||||
}
|
||||
if (levelChunk != nullptr)
|
||||
if (levelChunk != NULL)
|
||||
{
|
||||
levelChunk->lastSaveTime = level->getGameTime();
|
||||
}
|
||||
@@ -413,14 +413,14 @@ LevelChunk *ServerChunkCache::load(int x, int z)
|
||||
|
||||
void ServerChunkCache::saveEntities(LevelChunk *levelChunk)
|
||||
{
|
||||
if (storage == nullptr) return;
|
||||
if (storage == NULL) return;
|
||||
|
||||
storage->saveEntities(level, levelChunk);
|
||||
}
|
||||
|
||||
void ServerChunkCache::save(LevelChunk *levelChunk)
|
||||
{
|
||||
if (storage == nullptr) return;
|
||||
if (storage == NULL) return;
|
||||
|
||||
levelChunk->lastSaveTime = level->getGameTime();
|
||||
storage->save(level, levelChunk);
|
||||
@@ -542,7 +542,7 @@ void ServerChunkCache::postProcess(ChunkSource *parent, int x, int z )
|
||||
LevelChunk *chunk = getChunk(x, z);
|
||||
if ( (chunk->terrainPopulated & LevelChunk::sTerrainPopulatedFromHere) == 0 )
|
||||
{
|
||||
if (source != nullptr)
|
||||
if (source != NULL)
|
||||
{
|
||||
PIXBeginNamedEvent(0,"Main post processing");
|
||||
source->postProcess(parent, x, z);
|
||||
@@ -659,7 +659,7 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener)
|
||||
}
|
||||
|
||||
// 4J - added this to support progressListener
|
||||
if (progressListener != nullptr)
|
||||
if (progressListener != NULL)
|
||||
{
|
||||
if (++cc % 10 == 0)
|
||||
{
|
||||
@@ -679,19 +679,19 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener)
|
||||
|
||||
vector<LevelChunk *> sortedChunkList;
|
||||
|
||||
for( size_t i = 0; i < m_loadedChunkList.size(); i++ )
|
||||
for( int i = 0; i < m_loadedChunkList.size(); i++ )
|
||||
{
|
||||
if( ( m_loadedChunkList[i]->x < 0 ) && ( m_loadedChunkList[i]->z < 0 ) ) sortedChunkList.push_back(m_loadedChunkList[i]);
|
||||
}
|
||||
for( size_t i = 0; i < m_loadedChunkList.size(); i++ )
|
||||
for( int i = 0; i < m_loadedChunkList.size(); i++ )
|
||||
{
|
||||
if( ( m_loadedChunkList[i]->x >= 0 ) && ( m_loadedChunkList[i]->z < 0 ) ) sortedChunkList.push_back(m_loadedChunkList[i]);
|
||||
}
|
||||
for( size_t i = 0; i < m_loadedChunkList.size(); i++ )
|
||||
for( int i = 0; i < m_loadedChunkList.size(); i++ )
|
||||
{
|
||||
if( ( m_loadedChunkList[i]->x >= 0 ) && ( m_loadedChunkList[i]->z >= 0 ) ) sortedChunkList.push_back(m_loadedChunkList[i]);
|
||||
}
|
||||
for( size_t i = 0; i < m_loadedChunkList.size(); i++ )
|
||||
for( int i = 0; i < m_loadedChunkList.size(); i++ )
|
||||
{
|
||||
if( ( m_loadedChunkList[i]->x < 0 ) && ( m_loadedChunkList[i]->z >= 0 ) ) sortedChunkList.push_back(m_loadedChunkList[i]);
|
||||
}
|
||||
@@ -712,7 +712,7 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener)
|
||||
}
|
||||
|
||||
// 4J - added this to support progressListener
|
||||
if (progressListener != nullptr)
|
||||
if (progressListener != NULL)
|
||||
{
|
||||
if (++cc % 10 == 0)
|
||||
{
|
||||
@@ -741,21 +741,21 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener)
|
||||
|
||||
for(unsigned int i = 0; i < 3; ++i)
|
||||
{
|
||||
saveThreads[i] = nullptr;
|
||||
saveThreads[i] = NULL;
|
||||
|
||||
threadData[i].cache = this;
|
||||
|
||||
wakeEvent[i] = new C4JThread::Event(); //CreateEvent(nullptr,FALSE,FALSE,nullptr);
|
||||
wakeEvent[i] = new C4JThread::Event(); //CreateEvent(NULL,FALSE,FALSE,NULL);
|
||||
threadData[i].wakeEvent = wakeEvent[i];
|
||||
|
||||
notificationEvent[i] = new C4JThread::Event(); //CreateEvent(nullptr,FALSE,FALSE,nullptr);
|
||||
notificationEvent[i] = new C4JThread::Event(); //CreateEvent(NULL,FALSE,FALSE,NULL);
|
||||
threadData[i].notificationEvent = notificationEvent[i];
|
||||
|
||||
if(i==0) threadData[i].useSharedThreadStorage = true;
|
||||
else threadData[i].useSharedThreadStorage = false;
|
||||
}
|
||||
|
||||
LevelChunk *chunk = nullptr;
|
||||
LevelChunk *chunk = NULL;
|
||||
byte workingThreads;
|
||||
bool chunkSet = false;
|
||||
|
||||
@@ -764,19 +764,19 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener)
|
||||
|
||||
vector<LevelChunk *> sortedChunkList;
|
||||
|
||||
for( size_t i = 0; i < m_loadedChunkList.size(); i++ )
|
||||
for( int i = 0; i < m_loadedChunkList.size(); i++ )
|
||||
{
|
||||
if( ( m_loadedChunkList[i]->x < 0 ) && ( m_loadedChunkList[i]->z < 0 ) ) sortedChunkList.push_back(m_loadedChunkList[i]);
|
||||
}
|
||||
for( size_t i = 0; i < m_loadedChunkList.size(); i++ )
|
||||
for( int i = 0; i < m_loadedChunkList.size(); i++ )
|
||||
{
|
||||
if( ( m_loadedChunkList[i]->x >= 0 ) && ( m_loadedChunkList[i]->z < 0 ) ) sortedChunkList.push_back(m_loadedChunkList[i]);
|
||||
}
|
||||
for( size_t i = 0; i < m_loadedChunkList.size(); i++ )
|
||||
for( int i = 0; i < m_loadedChunkList.size(); i++ )
|
||||
{
|
||||
if( ( m_loadedChunkList[i]->x >= 0 ) && ( m_loadedChunkList[i]->z >= 0 ) ) sortedChunkList.push_back(m_loadedChunkList[i]);
|
||||
}
|
||||
for( size_t i = 0; i < m_loadedChunkList.size(); i++ )
|
||||
for( int i = 0; i < m_loadedChunkList.size(); i++ )
|
||||
{
|
||||
if( ( m_loadedChunkList[i]->x < 0 ) && ( m_loadedChunkList[i]->z >= 0 ) ) sortedChunkList.push_back(m_loadedChunkList[i]);
|
||||
}
|
||||
@@ -804,13 +804,13 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener)
|
||||
|
||||
//app.DebugPrintf("Chunk to save set for thread %d\n", j);
|
||||
|
||||
if(saveThreads[j] == nullptr)
|
||||
if(saveThreads[j] == NULL)
|
||||
{
|
||||
char threadName[256];
|
||||
sprintf(threadName,"Save thread %d\n",j);
|
||||
SetThreadName(threadId[j], threadName);
|
||||
|
||||
//saveThreads[j] = CreateThread(nullptr,0,runSaveThreadProc,&threadData[j],CREATE_SUSPENDED,&threadId[j]);
|
||||
//saveThreads[j] = CreateThread(NULL,0,runSaveThreadProc,&threadData[j],CREATE_SUSPENDED,&threadId[j]);
|
||||
saveThreads[j] = new C4JThread(runSaveThreadProc,(void *)&threadData[j],threadName);
|
||||
|
||||
|
||||
@@ -836,7 +836,7 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener)
|
||||
}
|
||||
|
||||
// 4J - added this to support progressListener
|
||||
if (progressListener != nullptr)
|
||||
if (progressListener != NULL)
|
||||
{
|
||||
if (count > 0 && ++cc % 10 == 0)
|
||||
{
|
||||
@@ -850,7 +850,7 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener)
|
||||
|
||||
if( !chunkSet )
|
||||
{
|
||||
threadData[j].chunkToSave = nullptr;
|
||||
threadData[j].chunkToSave = NULL;
|
||||
//app.DebugPrintf("No chunk to save set for thread %d\n",j);
|
||||
}
|
||||
}
|
||||
@@ -882,13 +882,13 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener)
|
||||
unsigned char validThreads = 0;
|
||||
for(unsigned int i = 0; i < 3; ++i)
|
||||
{
|
||||
//app.DebugPrintf("Settings chunk to nullptr for save thread %d\n", i);
|
||||
threadData[i].chunkToSave = nullptr;
|
||||
//app.DebugPrintf("Settings chunk to NULL for save thread %d\n", i);
|
||||
threadData[i].chunkToSave = NULL;
|
||||
|
||||
//app.DebugPrintf("Setting wake event for save thread %d\n",i);
|
||||
threadData[i].wakeEvent->Set(); //SetEvent(threadData[i].wakeEvent);
|
||||
|
||||
if(saveThreads[i] != nullptr) ++validThreads;
|
||||
if(saveThreads[i] != NULL) ++validThreads;
|
||||
}
|
||||
|
||||
//WaitForMultipleObjects(validThreads,saveThreads,TRUE,INFINITE);
|
||||
@@ -910,7 +910,7 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener)
|
||||
|
||||
if (force)
|
||||
{
|
||||
if (storage == nullptr)
|
||||
if (storage == NULL)
|
||||
{
|
||||
LeaveCriticalSection(&m_csLoadCreate);
|
||||
return true;
|
||||
@@ -955,14 +955,14 @@ bool ServerChunkCache::tick()
|
||||
int iz = chunk->z + XZOFFSET;
|
||||
int idx = ix * XZSIZE + iz;
|
||||
m_unloadedCache[idx] = chunk;
|
||||
cache[idx] = nullptr;
|
||||
cache[idx] = NULL;
|
||||
}
|
||||
}
|
||||
m_toDrop.pop_front();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (storage != nullptr) storage->tick();
|
||||
if (storage != NULL) storage->tick();
|
||||
}
|
||||
|
||||
return source->tick();
|
||||
@@ -995,7 +995,7 @@ void ServerChunkCache::recreateLogicStructuresForChunk(int chunkX, int chunkZ)
|
||||
|
||||
int ServerChunkCache::runSaveThreadProc(LPVOID lpParam)
|
||||
{
|
||||
SaveThreadData *params = static_cast<SaveThreadData *>(lpParam);
|
||||
SaveThreadData *params = (SaveThreadData *)lpParam;
|
||||
|
||||
if(params->useSharedThreadStorage)
|
||||
{
|
||||
@@ -1013,7 +1013,7 @@ int ServerChunkCache::runSaveThreadProc(LPVOID lpParam)
|
||||
|
||||
//app.DebugPrintf("Save thread has started\n");
|
||||
|
||||
while(params->chunkToSave != nullptr)
|
||||
while(params->chunkToSave != NULL)
|
||||
{
|
||||
PIXBeginNamedEvent(0,"Saving entities");
|
||||
//app.DebugPrintf("Save thread has started processing a chunk\n");
|
||||
|
||||
Reference in New Issue
Block a user