Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion soh/soh/Network/Archipelago/Archipelago.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ bool ArchipelagoClient::StartClient() {
ResetQueue();
SynchSentLocations();
SynchReceivedLocations();
if (gPlayState != nullptr) {
ArchipelagoClient::SetDataStorage("scene", gPlayState->sceneNum);
}
}
});

Expand Down Expand Up @@ -531,6 +534,21 @@ void ArchipelagoClient::ResetQueue() {
std::swap(receiveQueue, empty);
}

void ArchipelagoClient::OnSceneInit(uint16_t sceneNum) {
if (!ArchipelagoClient::IsConnected())
return;
if (gPlayState == nullptr)
return;
ArchipelagoClient::SetDataStorage("scene", sceneNum);
}

void ArchipelagoClient::SetDataStorage(const std::string& key, const nlohmann::json& value) const {
std::string full_key =
std::format("oot_soh_{}_{}_{}", key, apClient->get_team_number(), apClient->get_player_number());
std::list<APClient::DataStorageOperation> operations = { { "replace", value } };
apClient->Set(full_key, 0, false, operations);
}

bool ArchipelagoClient::slotMatch(const std::string& slotName, const std::string& roomHash) {
if (apClient == nullptr) {
return false;
Expand Down Expand Up @@ -796,6 +814,10 @@ void RegisterArchipelago() {

COND_HOOK(GameInteractor::OnPlayerDeath, IS_ARCHIPELAGO,
[]() { ArchipelagoClient::GetInstance().SendDeathLink(); });
}

COND_HOOK(GameInteractor::OnSceneInit, IS_ARCHIPELAGO,
[](int16_t sceneNum) { ArchipelagoClient::GetInstance().OnSceneInit(sceneNum);
});
}

static RegisterShipInitFunc initFunc(RegisterArchipelago, { "IS_ARCHIPELAGO" });
4 changes: 4 additions & 0 deletions soh/soh/Network/Archipelago/Archipelago.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class ArchipelagoClient {
void Poll();
void ResetQueue();

void OnSceneInit(uint16_t sceneNum);

void SetDataStorage(const std::string& key, const nlohmann::json& value) const;

bool slotMatch(const std::string& slotName, const std::string& roomHash);

std::unique_ptr<APClient> apClient;
Expand Down