Skip to content

Commit

Permalink
fix world unloading in cia release
Browse files Browse the repository at this point in the history
  • Loading branch information
RSDuck committed Oct 28, 2017
1 parent 1145284 commit 3e6d83a
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ void exitHandler() {

bool showDebugInfo = false; // muss noch besser gemacht werden, vlt. über eine Options Struktur wo auch andere Einstellungen drinne sind

void releaseWorld(ChunkWorker* chunkWorker, SaveManager* savemgr, World* world) {
for (int i = 0; i < CHUNKCACHE_SIZE; i++) {
for (int j = 0; j < CHUNKCACHE_SIZE; j++) {
World_UnloadChunk(world, world->chunkCache[i][j]);
}
}
ChunkWorker_Finish(&chunkWorker);
World_Reset(world);

SaveManager_Unload(&savemgr);
}

int main() {
GameState gamestate = GameState_SelectWorld;

Expand Down Expand Up @@ -114,15 +126,8 @@ int main() {
if (gamestate == GameState_SelectWorld)
break;
else if (gamestate == GameState_Playing) {
for (int i = 0; i < CHUNKCACHE_SIZE; i++) {
for (int j = 0; j < CHUNKCACHE_SIZE; j++) {
World_UnloadChunk(world, world->chunkCache[i][j]);
}
}
ChunkWorker_Finish(&chunkWorker);
World_Reset(world);
releaseWorld(&chunkWorker, &savemgr, world);

SaveManager_Unload(&savemgr);
gamestate = GameState_SelectWorld;

WorldSelect_ScanWorlds();
Expand Down Expand Up @@ -205,6 +210,8 @@ int main() {
Gui_InputData(inputData);
}

if (gamestate == GameState_Playing) releaseWorld(&chunkWorker, &savemgr, world);

ChunkWorker_Deinit(&chunkWorker);

SaveManager_Deinit(&savemgr);
Expand Down

0 comments on commit 3e6d83a

Please sign in to comment.