Added opening of local checks when synchinc locations

This commit is contained in:
Jerom Venneker
2025-05-26 20:51:49 +02:00
parent 603c163167
commit f6359f1008
6 changed files with 26 additions and 8 deletions

View File

@@ -71,4 +71,5 @@ DEFINE_HOOK(OnAssetAltChange, ());
DEFINE_HOOK(OnKaleidoUpdate, ());
DEFINE_HOOK(OnRandomizerItemGivenHooks, (uint32_t rc));
DEFINE_HOOK(OnArchipelagoItemRecieved, (uint32_t rc));
DEFINE_HOOK(OnArchipelagoItemRecieved, (uint32_t rg));
DEFINE_HOOK(OnRandomizerExternalCheck, (uint32_t rc));

View File

@@ -309,6 +309,10 @@ void GameInteractor_ExecuteOnRandomizerItemGivenHooks(uint32_t rc) {
}
// MARK: Archipelago
void GameInteractor_ExecuteOnArchipelagoItemRecieved(uint32_t rc) {
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnArchipelagoItemRecieved>(rc);
void GameInteractor_ExecuteOnArchipelagoItemRecieved(uint32_t rg) {
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnArchipelagoItemRecieved>(rg);
}
void GameInteractor_ExecuteOnRandomizerExternalCheck(uint32_t rc) {
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnRandomizerExternalCheck>(rc);
}

View File

@@ -85,7 +85,8 @@ void GameInteractor_ExecuteOnKaleidoUpdate();
void GameInteractor_ExecuteOnRandomizerItemGivenHooks(uint32_t rc);
// Mark: - Archipelago
void GameInteractor_ExecuteOnArchipelagoItemRecieved(uint32_t rc);
void GameInteractor_ExecuteOnArchipelagoItemRecieved(uint32_t rg);
void GameInteractor_ExecuteOnRandomizerExternalCheck(uint32_t rc);
#ifdef __cplusplus
}

View File

@@ -286,6 +286,10 @@ void RandomizerOnSceneFlagSetHandler(int16_t sceneNum, int16_t flagType, int16_t
randomizerQueuedChecks.push(rc);
}
void RandomizerOnExternalCheckHandler(uint32_t randomizerCheck) {
randomizerQueuedChecks.push(static_cast<RandomizerCheck>(randomizerCheck));
}
static Vec3f spawnPos = { 0.0f, -999.0f, 0.0f };
void RandomizerOnPlayerUpdateForRCQueueHandler() {
@@ -2525,9 +2529,8 @@ void RandomizerRegisterHooks() {
onCuccoOrChickenHatchHook = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnCuccoOrChickenHatch>(
RandomizerOnCuccoOrChickenHatch);
// TODO Implement propeerly when we can read what kind of game we're playing from the save file
COND_HOOK(GameInteractor::OnArchipelagoItemRecieved, IS_ARCHIPELAGO, ArchipelagoOnRecieveItem);
COND_HOOK(GameInteractor::OnRandomizerExternalCheck, IS_ARCHIPELAGO, RandomizerOnExternalCheckHandler)
if (RAND_GET_OPTION(RSK_FISHSANITY) != RO_FISHSANITY_OFF) {
OTRGlobals::Instance->gRandoContext->GetFishsanity()->InitializeFromSave();

View File

@@ -109,7 +109,9 @@ bool ArchipelagoClient::StartClient() {
}); // todo maybe move these functions to a lambda, since they don't have to be static anymore
apClient->set_location_checked_handler([&](const std::list<int64_t> locations) {
// todo implement me
for(const int64_t apLoc : locations) {
QueueExternalCheck(apLoc);
}
});
return true;
@@ -171,10 +173,16 @@ void ArchipelagoClient::SynchSentLocations() {
void ArchipelagoClient::SynchRecievedLocations() {
// Open checks that have been found previously but went unsaved
for(const int64_t apLoc : apClient->get_checked_locations()) {
// TODO call location checked function to open any unopened checks.
QueueExternalCheck(apLoc);
}
}
void ArchipelagoClient::QueueExternalCheck(const int64_t apLocation) {
const std::string checkName = apClient->get_location_name(apLocation, AP_Client_consts::AP_GAME_NAME);
const uint32_t RC = static_cast<uint32_t>(Rando::StaticData::locationNameToEnum[checkName]);
GameInteractor_ExecuteOnRandomizerExternalCheck(RC);
}
bool ArchipelagoClient::IsConnected() {
return apClient->get_state() == APClient::State::SLOT_CONNECTED;
}

View File

@@ -49,6 +49,7 @@ class ArchipelagoClient{
void OnItemReceived(const ApItem apItem);
void QueueItem(const ApItem item);
void QueueExternalCheck(int64_t apLocation);
void SendGameWon();