From 518fa4a593993000385af04bea0e7f1417f8b900 Mon Sep 17 00:00:00 2001 From: Ludovic Marechal Date: Wed, 15 Mar 2023 20:22:50 +0100 Subject: [PATCH] Add an initialization protection of 6 seconds --- archipelago-client/Core.cpp | 31 +++++++++++++++++++------------ archipelago-client/Core.h | 4 +++- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/archipelago-client/Core.cpp b/archipelago-client/Core.cpp index 203497e..bc16e42 100644 --- a/archipelago-client/Core.cpp +++ b/archipelago-client/Core.cpp @@ -25,7 +25,7 @@ VOID CCore::Start() { while (true) { Core->Run(); - Sleep(2000); + Sleep(RUN_SLEEP); }; delete CoreStruct; @@ -72,15 +72,16 @@ BOOL CCore::CheckOldApFile() { } bool isInit = false; +int initProtectionDelay = 3; VOID CCore::Run() { ArchipelagoInterface->update(); - GameHook->updateRuntimeValues(); + if(GameHook->healthPointRead != 0 && GameHook->playTimeRead !=0) { - if (!isInit && ArchipelagoInterface->isConnected()) { + if (!isInit && ArchipelagoInterface->isConnected() && initProtectionDelay <= 0) { ReadConfigFiles(); CleanReceivedItemsList(); @@ -90,20 +91,26 @@ VOID CCore::Run() { Core->Panic("Failed to initialise GameHook", "...\\Randomiser\\Core\\Core.cpp", FE_InitFailed, 1); int3 } + printf("Mod initialized successfully\n"); isInit = true; } + if (isInit) { + GameHook->manageDeathLink(); - GameHook->manageDeathLink(); - - if (!ItemRandomiser->receivedItemsQueue.empty()) { - GameHook->giveItems(); - pLastReceivedIndex++; - } + if (!ItemRandomiser->receivedItemsQueue.empty()) { + GameHook->giveItems(); + pLastReceivedIndex++; + } - if (GameHook->isSoulOfCinderDefeated() && sendGoalStatus) { - sendGoalStatus = false; - ArchipelagoInterface->gameFinished(); + if (GameHook->isSoulOfCinderDefeated() && sendGoalStatus) { + sendGoalStatus = false; + ArchipelagoInterface->gameFinished(); + } + } else { + int secondsRemaining = (RUN_SLEEP / 1000) * initProtectionDelay; + printf("The mod will be initialized in %d seconds\n", secondsRemaining); + initProtectionDelay--; } } diff --git a/archipelago-client/Core.h b/archipelago-client/Core.h index 02ce334..839228d 100644 --- a/archipelago-client/Core.h +++ b/archipelago-client/Core.h @@ -36,7 +36,7 @@ #define AP_MissingValue 12 #define FE_MissingDLC 13 -#define VERSION "2.1.0" +#define VERSION "2.1.1" struct SCore; @@ -60,4 +60,6 @@ class CCore { BOOL sendGoalStatus = true; std::list pReceivedItems = { }; int pLastReceivedIndex = 0; + + static const int RUN_SLEEP = 2000; }; \ No newline at end of file