Skip to content

Commit

Permalink
Many more fixes, yay
Browse files Browse the repository at this point in the history
  • Loading branch information
metzner committed Jul 18, 2022
1 parent b028cfc commit 13b1592
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
28 changes: 25 additions & 3 deletions Source/Archipelago/APRandomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down Expand Up @@ -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<int>(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) {
Expand Down
3 changes: 1 addition & 2 deletions Source/Archipelago/APRandomizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class APRandomizer {
private:
std::map<int, int> panelIdToLocationId;
std::map<int, std::set<int>> itemIdToDoorSet;
std::map<int, int> panelIdToLocationIdReverse;
std::set<int> allDoors;
std::shared_ptr<Memory> _memory;

Expand All @@ -61,8 +62,6 @@ class APRandomizer {

void PreventSnipes();

void MakeEarlyUTM();

void setPuzzleLocks(HWND loadingHandle);

std::string buildUri(std::string& server);
Expand Down
1 change: 0 additions & 1 deletion Source/Archipelago/APWatchdog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ void APWatchdog::CheckSolvedPanels() {
continue;
}


else if (ReadPanelData<int>(panelId, SOLVED))
{
solvedLocations.push_back(locationId);
Expand Down
6 changes: 5 additions & 1 deletion Source/Archipelago/DoorSevers.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ inline std::map<int, std::vector<Connection>> 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
Expand Down Expand Up @@ -601,4 +601,8 @@ std::set<int> knownIrrelevantCollisions = { // We will still update these collis
0x2d740,
0x2d741,
0x2d743,
0x0360b,
0x02886,
0x035c4,
0x0360c,
};
9 changes: 8 additions & 1 deletion Source/Memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,14 @@ class Memory

template <class T>
T ReadPanelData(int panel, int offset) {
return ReadData<T>({ GLOBALS, 0x18, panel * 8, offset }, 1)[0];
std::vector<T> result = ReadData<T>({ GLOBALS, 0x18, panel * 8, offset }, 1);

if (result.size() == 0) {
std::exception e;
throw e;
}

return result[0];
}

template <class T>
Expand Down

0 comments on commit 13b1592

Please sign in to comment.