From a00e019b75d115261ecc9c666106da28834a7f69 Mon Sep 17 00:00:00 2001 From: Martin Haye Date: Wed, 18 Jan 2017 08:21:01 -0800 Subject: [PATCH] Got game-exist check working. --- Platform/Apple/virtual/src/plasma/diskops.pla | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Platform/Apple/virtual/src/plasma/diskops.pla b/Platform/Apple/virtual/src/plasma/diskops.pla index 187d8d13..acb21a0a 100644 --- a/Platform/Apple/virtual/src/plasma/diskops.pla +++ b/Platform/Apple/virtual/src/plasma/diskops.pla @@ -212,7 +212,7 @@ end /////////////////////////////////////////////////////////////////////////////////////////////////// def _rwGame(cmd) while TRUE - if callProRWTS(cmd | RWTS_OPENDIR, "GAME.1.SAVE", LOAD_SAVE_BUF, HEAP_SIZE) == 0 + if callProRWTS(cmd | RWTS_OPENDIR, @game1_filename, LOAD_SAVE_BUF, HEAP_SIZE) == 0 break fin textHome() @@ -272,6 +272,7 @@ def newGame() initHeap(0) // initially empty heap global = getGlobals() global->b_curAvatar = 0 + mmgr(START_LOAD, 1) // players module and new game module both in partition 1 playersModule = mmgr(QUEUE_LOAD, MOD_GEN_PLAYERS<<8 | RES_TYPE_MODULE) newGameModule = mmgr(QUEUE_LOAD, MOD_GS_NEW_GAME<<8 | RES_TYPE_MODULE) mmgr(FINISH_LOAD, 0) @@ -281,7 +282,18 @@ end /////////////////////////////////////////////////////////////////////////////////////////////////// def gameExists() - return FALSE // FIXME + word p_loaded + + // Load first part of save game into mem... 1 block should be plenty to verify it's real. + if callProRWTS(RWTS_READ | RWTS_OPENDIR, @game1_filename, LOAD_SAVE_BUF, 512) == 0 + // If heap size is reasonable, assume it's a real save game. (Hash will be checked if the + // user chooses to actually load the game) + p_loaded = LOAD_SAVE_BUF + if p_loaded=>w_heapSize >= 100 and p_loaded=>w_heapSize <= HEAP_SIZE + return TRUE + fin + fin + return FALSE end ///////////////////////////////////////////////////////////////////////////////////////////////////