From 13b1592592d06eca7e7917cf33d687b205de982a Mon Sep 17 00:00:00 2001 From: metzner Date: Mon, 18 Jul 2022 11:10:55 +0200 Subject: [PATCH] Many more fixes, yay --- Source/Archipelago/APRandomizer.cpp | 28 +++++++++++++++++++++++++--- Source/Archipelago/APRandomizer.h | 3 +-- Source/Archipelago/APWatchdog.cpp | 1 - Source/Archipelago/DoorSevers.h | 6 +++++- Source/Memory.h | 9 ++++++++- 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/Source/Archipelago/APRandomizer.cpp b/Source/Archipelago/APRandomizer.cpp index 9547c60f..61638aad 100644 --- a/Source/Archipelago/APRandomizer.cpp +++ b/Source/Archipelago/APRandomizer.cpp @@ -93,6 +93,7 @@ bool APRandomizer::Connect(HWND& messageBoxHandle, std::string& server, std::str int locationId = val; panelIdToLocationId.insert({ panelId, locationId }); + panelIdToLocationIdReverse.insert({ locationId, panelId }); } if (slotData.contains("item_id_to_door_hexes")) { @@ -150,12 +151,33 @@ bool APRandomizer::Connect(HWND& messageBoxHandle, std::string& server, std::str std::string player = ap->get_player_alias(receiver); std::string itemName = ap->get_item_name(item.item); + std::string locationName = ap->get_location_name(item.location); if (!receiving) { - async->queueMessage("Sent " + itemName + " to " + player + "."); + bool hint = false; + + for (auto textNode : msg) { + if (textNode.text.find("[Hint]") != std::string::npos) { + hint = true; + } + } + + if (hint) { + async->queueMessage("Hint: " + itemName + " for " + player + " is on " + locationName + "."); + } + else { + int location = item.location; + + if (panelIdToLocationIdReverse.count(location) && !_memory->ReadPanelData(panelIdToLocationIdReverse[location], SOLVED)) { + async->queueMessage("(Collect) Sent " + itemName + " to " + player + "."); + } + else + { + panelLocker->SetItemReward(findResult->first, item); + async->queueMessage("Sent " + itemName + " to " + player + "."); + } + } } - - panelLocker->SetItemReward(findResult->first, item); }); ap->set_data_package_changed_handler([&](const nlohmann::json& data) { diff --git a/Source/Archipelago/APRandomizer.h b/Source/Archipelago/APRandomizer.h index f9a684bd..6aef58de 100644 --- a/Source/Archipelago/APRandomizer.h +++ b/Source/Archipelago/APRandomizer.h @@ -50,6 +50,7 @@ class APRandomizer { private: std::map panelIdToLocationId; std::map> itemIdToDoorSet; + std::map panelIdToLocationIdReverse; std::set allDoors; std::shared_ptr _memory; @@ -61,8 +62,6 @@ class APRandomizer { void PreventSnipes(); - void MakeEarlyUTM(); - void setPuzzleLocks(HWND loadingHandle); std::string buildUri(std::string& server); diff --git a/Source/Archipelago/APWatchdog.cpp b/Source/Archipelago/APWatchdog.cpp index bcc97c1c..c5c80412 100644 --- a/Source/Archipelago/APWatchdog.cpp +++ b/Source/Archipelago/APWatchdog.cpp @@ -79,7 +79,6 @@ void APWatchdog::CheckSolvedPanels() { continue; } - else if (ReadPanelData(panelId, SOLVED)) { solvedLocations.push_back(locationId); diff --git a/Source/Archipelago/DoorSevers.h b/Source/Archipelago/DoorSevers.h index ae709c66..fabd5c01 100644 --- a/Source/Archipelago/DoorSevers.h +++ b/Source/Archipelago/DoorSevers.h @@ -139,7 +139,7 @@ inline std::map> severTargetsById = { {0x0C309, {{0x0288C, PANEL, TARGET}}}, // Treehouse Entry Door 1 {0x0C310, {{0x02886, PANEL, TARGET}, {0x02886, PANEL, MOUNT_PARENT_ID}}}, // Treehouse Entry Door 2 {0x0A181, {{0x0A182, PANEL, TARGET}}}, // Treehouse Entry Door 3 - {0x0C323, {{0x034FC, PRESSURE_PLATE, PRESSURE_PLATE_TARGET}, {0x334DB, PANEL, TARGET}, {0x334DC, PANEL, TARGET}, {0x2700B, PANEL, ENTITY_NAME}, {0x17CBC, PANEL, ENTITY_NAME}} }, // Treehouse Timed Door + {0x0C323, {{0x034FC, PRESSURE_PLATE, PRESSURE_PLATE_TARGET}, {0x2700B, PANEL, TARGET}, {0x17CBC, PANEL, TARGET}, {0x2700B, PANEL, ENTITY_NAME}, {0x17CBC, PANEL, ENTITY_NAME}} }, // Treehouse Timed Door {0x0C32D, {{0x037FF, PANEL, TARGET}}}, // Treehouse Draw Bridge {0x09E54, {{0x09EAF, PANEL, TARGET}, {0x09F6E, PANEL, TARGET}, {0x09E6B, PANEL, TARGET}, {0x09E7B, PANEL, TARGET}} }, // Mountain Door to 2nd Layer @@ -601,4 +601,8 @@ std::set knownIrrelevantCollisions = { // We will still update these collis 0x2d740, 0x2d741, 0x2d743, + 0x0360b, + 0x02886, + 0x035c4, + 0x0360c, }; \ No newline at end of file diff --git a/Source/Memory.h b/Source/Memory.h index 808e2bbb..ced11aa7 100644 --- a/Source/Memory.h +++ b/Source/Memory.h @@ -108,7 +108,14 @@ class Memory template T ReadPanelData(int panel, int offset) { - return ReadData({ GLOBALS, 0x18, panel * 8, offset }, 1)[0]; + std::vector result = ReadData({ GLOBALS, 0x18, panel * 8, offset }, 1); + + if (result.size() == 0) { + std::exception e; + throw e; + } + + return result[0]; } template