Skip to content

Commit

Permalink
Add an initialization protection of 6 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
Marechal-L committed Mar 15, 2023
1 parent a2037bf commit 518fa4a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
31 changes: 19 additions & 12 deletions archipelago-client/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ VOID CCore::Start() {

while (true) {
Core->Run();
Sleep(2000);
Sleep(RUN_SLEEP);
};

delete CoreStruct;
Expand Down Expand Up @@ -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();

Expand All @@ -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--;
}
}

Expand Down
4 changes: 3 additions & 1 deletion archipelago-client/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define AP_MissingValue 12
#define FE_MissingDLC 13

#define VERSION "2.1.0"
#define VERSION "2.1.1"


struct SCore;
Expand All @@ -60,4 +60,6 @@ class CCore {
BOOL sendGoalStatus = true;
std::list<std::string> pReceivedItems = { };
int pLastReceivedIndex = 0;

static const int RUN_SLEEP = 2000;
};

0 comments on commit 518fa4a

Please sign in to comment.