Implement hook for archipelago
This commit is contained in:
@@ -69,3 +69,5 @@ DEFINE_HOOK(OnSetGameLanguage, ());
|
|||||||
DEFINE_HOOK(OnFileDropped, (std::string filePath));
|
DEFINE_HOOK(OnFileDropped, (std::string filePath));
|
||||||
DEFINE_HOOK(OnAssetAltChange, ());
|
DEFINE_HOOK(OnAssetAltChange, ());
|
||||||
DEFINE_HOOK(OnKaleidoUpdate, ());
|
DEFINE_HOOK(OnKaleidoUpdate, ());
|
||||||
|
|
||||||
|
DEFINE_HOOK(OnRandomizerItemGivenHooks, (uint32_t rc));
|
||||||
|
|||||||
@@ -301,3 +301,9 @@ void GameInteractor_RegisterOnAssetAltChange(void (*fn)(void)) {
|
|||||||
void GameInteractor_ExecuteOnKaleidoUpdate() {
|
void GameInteractor_ExecuteOnKaleidoUpdate() {
|
||||||
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnKaleidoUpdate>();
|
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnKaleidoUpdate>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mark: Randomizer
|
||||||
|
|
||||||
|
void GameInteractor_ExecuteOnRandomizerItemGivenHooks(uint32_t rc) {
|
||||||
|
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnRandomizerItemGivenHooks>(rc);
|
||||||
|
}
|
||||||
|
|||||||
@@ -81,6 +81,9 @@ void GameInteractor_RegisterOnAssetAltChange(void (*fn)(void));
|
|||||||
// Mark: - Pause Menu
|
// Mark: - Pause Menu
|
||||||
void GameInteractor_ExecuteOnKaleidoUpdate();
|
void GameInteractor_ExecuteOnKaleidoUpdate();
|
||||||
|
|
||||||
|
// Mark: - Randomizer
|
||||||
|
void GameInteractor_ExecuteOnRandomizerItemGivenHooks(uint32_t rc);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -346,6 +346,8 @@ void RandomizerOnPlayerUpdateForRCQueueHandler() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameInteractor_ExecuteOnRandomizerItemGivenHooks((uint32_t)rc);
|
||||||
|
|
||||||
randomizerQueuedChecks.pop();
|
randomizerQueuedChecks.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2408,6 +2410,9 @@ void RandomizerRegisterHooks() {
|
|||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnLoadGame>([](int32_t fileNum) {
|
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnLoadGame>([](int32_t fileNum) {
|
||||||
ShipInit::Init("IS_RANDO");
|
ShipInit::Init("IS_RANDO");
|
||||||
|
|
||||||
|
// Add condition around this to only fire when loading into an Archipelago save file
|
||||||
|
ShipInit::Init("IS_ARCHIPELAGO");
|
||||||
|
|
||||||
randomizerQueuedChecks = std::queue<RandomizerCheck>();
|
randomizerQueuedChecks = std::queue<RandomizerCheck>();
|
||||||
randomizerQueuedCheck = RC_UNKNOWN_CHECK;
|
randomizerQueuedCheck = RC_UNKNOWN_CHECK;
|
||||||
randomizerQueuedItemEntry = GET_ITEM_NONE;
|
randomizerQueuedItemEntry = GET_ITEM_NONE;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "soh/Enhancements/randomizer/randomizerTypes.h"
|
#include "soh/Enhancements/randomizer/randomizerTypes.h"
|
||||||
#include "soh/Enhancements/randomizer/static_data.h"
|
#include "soh/Enhancements/randomizer/static_data.h"
|
||||||
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
||||||
|
#include "soh/ShipInit.hpp"
|
||||||
|
|
||||||
ArchipelagoClient::ArchipelagoClient() {
|
ArchipelagoClient::ArchipelagoClient() {
|
||||||
std::string uuid = ap_get_uuid("uuid");
|
std::string uuid = ap_get_uuid("uuid");
|
||||||
@@ -199,3 +200,20 @@ const char* ArchipelagoClient::GetConnectionStatus() {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Implement this properly once we have some kind of indication within a save file wether the player is in a normal
|
||||||
|
// rando save or an archipelago one.
|
||||||
|
#define IS_ARCHIPELAGO true
|
||||||
|
|
||||||
|
void RegisterArchipelago() {
|
||||||
|
COND_HOOK(GameInteractor::OnRandomizerItemGivenHooks, IS_ARCHIPELAGO,
|
||||||
|
[](uint32_t rc) {
|
||||||
|
if (rc == RC_ARCHIPELAGO_RECIEVED_ITEM) {
|
||||||
|
// Update lastReceivedIndex
|
||||||
|
} else {
|
||||||
|
ArchipelagoClient::GetInstance().CheckLocation((RandomizerCheck)rc);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static RegisterShipInitFunc initFunc(RegisterArchipelago, { "IS_ARCHIPELAGO" });
|
||||||
|
|||||||
Reference in New Issue
Block a user