LCEMP v1.1.0, bugfixes, multithreading server, local leaderboard, performance fixes, and more

This commit is contained in:
NOTPIES
2026-04-20 18:56:39 -04:00
parent fadeee4192
commit 7e7668c7fa
88 changed files with 4825 additions and 634 deletions

View File

@@ -76,6 +76,7 @@ Chunk LevelRenderer::permaChunk[MAX_CONCURRENT_CHUNK_REBUILDS];
C4JThread *LevelRenderer::rebuildThreads[MAX_CHUNK_REBUILD_THREADS];
C4JThread::EventArray *LevelRenderer::s_rebuildCompleteEvents;
C4JThread::Event *LevelRenderer::s_activationEventA[MAX_CHUNK_REBUILD_THREADS];
volatile bool LevelRenderer::s_rebuildThreadsTerminate = false;
// This defines the maximum size of renderable level, must be big enough to cope with actual size of level + view distance at each side
// so that we can render the "infinite" sea at the edges. Currently defined as:
@@ -3589,6 +3590,12 @@ void LevelRenderer::DestroyedTileManager::tick()
#ifdef _LARGE_WORLDS
void LevelRenderer::staticCtor()
{
if (s_rebuildCompleteEvents != NULL)
{
return;
}
s_rebuildThreadsTerminate = false;
s_rebuildCompleteEvents = new C4JThread::EventArray(MAX_CHUNK_REBUILD_THREADS);
char threadName[256];
for(unsigned int i = 0; i < MAX_CHUNK_REBUILD_THREADS; ++i)
@@ -3614,6 +3621,46 @@ void LevelRenderer::staticCtor()
}
}
void LevelRenderer::shutdownRebuildThreads()
{
if (s_rebuildCompleteEvents == NULL)
{
return;
}
s_rebuildThreadsTerminate = true;
for (unsigned int i = 0; i < MAX_CHUNK_REBUILD_THREADS; ++i)
{
if (s_activationEventA[i] != NULL)
{
s_activationEventA[i]->Set();
}
}
for (unsigned int i = 0; i < MAX_CHUNK_REBUILD_THREADS; ++i)
{
if (rebuildThreads[i] != NULL)
{
rebuildThreads[i]->WaitForCompletion(INFINITE);
delete rebuildThreads[i];
rebuildThreads[i] = NULL;
}
}
for (unsigned int i = 0; i < MAX_CHUNK_REBUILD_THREADS; ++i)
{
if (s_activationEventA[i] != NULL)
{
delete s_activationEventA[i];
s_activationEventA[i] = NULL;
}
}
delete s_rebuildCompleteEvents;
s_rebuildCompleteEvents = NULL;
}
int LevelRenderer::rebuildChunkThreadProc(LPVOID lpParam)
{
Vec3::CreateNewThreadStorage();
@@ -3630,6 +3677,11 @@ int LevelRenderer::rebuildChunkThreadProc(LPVOID lpParam)
{
s_activationEventA[index]->WaitForSignal(INFINITE);
if (s_rebuildThreadsTerminate)
{
break;
}
//app.DebugPrintf("Rebuilding permaChunk %d\n", index + 1);
permaChunk[index + 1].rebuild();