From 3bc90b293c8655a3a85f3a92ea55749c17332916 Mon Sep 17 00:00:00 2001 From: Caladius Date: Mon, 4 May 2026 15:51:36 -0400 Subject: [PATCH 1/4] Test adding Name to Payload --- soh/soh/Network/Anchor/Packets/GiveItem.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/soh/soh/Network/Anchor/Packets/GiveItem.cpp b/soh/soh/Network/Anchor/Packets/GiveItem.cpp index f957eef0226..51b54e6cbc8 100644 --- a/soh/soh/Network/Anchor/Packets/GiveItem.cpp +++ b/soh/soh/Network/Anchor/Packets/GiveItem.cpp @@ -37,6 +37,7 @@ void Anchor::SendPacket_GiveItem(u16 modId, s16 getItemId) { nlohmann::json payload; payload["type"] = GIVE_ITEM; payload["targetTeamId"] = CVarGetString(CVAR_REMOTE_ANCHOR("TeamId"), "default"); + payload["name"] = CVarGetString(CVAR_REMOTE_ANCHOR("Name"), ""); payload["addToQueue"] = true; payload["modId"] = modId; payload["getItemId"] = getItemId; @@ -73,6 +74,7 @@ void Anchor::HandlePacket_GiveItem(nlohmann::json payload) { } else { Randomizer_Item_Give(gPlayState, getItemEntry); } + Notification::Emit({ .prefix = payload["name"], .message = std::to_string(getItemEntry.itemId) }); } // Full heal if getting a heart container or piece From e97823173985efd7a1a4e49fce375509ac5c60ef Mon Sep 17 00:00:00 2001 From: Caladius Date: Thu, 7 May 2026 10:40:50 -0400 Subject: [PATCH 2/4] Update to file report. --- soh/soh/Network/Anchor/Packets/GiveItem.cpp | 38 ++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/soh/soh/Network/Anchor/Packets/GiveItem.cpp b/soh/soh/Network/Anchor/Packets/GiveItem.cpp index 51b54e6cbc8..67ac62144d8 100644 --- a/soh/soh/Network/Anchor/Packets/GiveItem.cpp +++ b/soh/soh/Network/Anchor/Packets/GiveItem.cpp @@ -8,6 +8,9 @@ #include "soh/Enhancements/item-tables/ItemTableManager.h" #include "soh/OTRGlobals.h" +#include +#include + extern "C" { #include "functions.h" extern PlayState* gPlayState; @@ -74,9 +77,42 @@ void Anchor::HandlePacket_GiveItem(nlohmann::json payload) { } else { Randomizer_Item_Give(gPlayState, getItemEntry); } - Notification::Emit({ .prefix = payload["name"], .message = std::to_string(getItemEntry.itemId) }); } + if (getItemEntry.modIndex == MOD_RANDOMIZER) { + if (getItemEntry.getItemId == RG_TRIFORCE_PIECE) { + Notification::Emit({ .prefix = payload["name"], .message = "Triforce Piece" }); + + std::string filename = Ship::Context::GetPathRelativeToAppDirectory("cheesehunt.json"); + nlohmann::json saveFile; + std::ifstream inputFile(filename); + if (inputFile.is_open()) { + inputFile >> saveFile; + inputFile.close(); + } + + if (saveFile.contains(payload["name"])) { + int32_t currentCount = saveFile[payload["name"]]["count"].get(); + currentCount++; + + saveFile[payload["name"]]["count"] = currentCount; + } else { + saveFile[payload["name"]]["count"] = 1; + } + + std::ofstream outputFile(filename); + if (outputFile.is_open()) { + outputFile << saveFile.dump(4); + outputFile.close(); + } + + //j["player"] = nlohmann::json::object(); + //j["player"]["name"] = payload["name"]; + //j["player"]["count"] = 1; + } + } + + // Full heal if getting a heart container or piece if (getItemEntry.gid == GID_HEART_CONTAINER || getItemEntry.gid == GID_HEART_PIECE) { gSaveContext.healthAccumulator = 0x140; From 8192676c275920f5f50c37e4a64bfc6cc867ed43 Mon Sep 17 00:00:00 2001 From: Caladius Date: Thu, 7 May 2026 12:38:11 -0400 Subject: [PATCH 3/4] linux fix maybe --- soh/soh/Network/Anchor/Packets/GiveItem.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/soh/soh/Network/Anchor/Packets/GiveItem.cpp b/soh/soh/Network/Anchor/Packets/GiveItem.cpp index 67ac62144d8..946ce6cdbd3 100644 --- a/soh/soh/Network/Anchor/Packets/GiveItem.cpp +++ b/soh/soh/Network/Anchor/Packets/GiveItem.cpp @@ -91,13 +91,14 @@ void Anchor::HandlePacket_GiveItem(nlohmann::json payload) { inputFile.close(); } - if (saveFile.contains(payload["name"])) { - int32_t currentCount = saveFile[payload["name"]]["count"].get(); + std::string playerName = payload["name"].get(); + if (saveFile.contains(playerName)) { + int32_t currentCount = saveFile[playerName]["count"].get(); currentCount++; - saveFile[payload["name"]]["count"] = currentCount; + saveFile[playerName]["count"] = currentCount; } else { - saveFile[payload["name"]]["count"] = 1; + saveFile[playerName]["count"] = 1; } std::ofstream outputFile(filename); @@ -105,10 +106,6 @@ void Anchor::HandlePacket_GiveItem(nlohmann::json payload) { outputFile << saveFile.dump(4); outputFile.close(); } - - //j["player"] = nlohmann::json::object(); - //j["player"]["name"] = payload["name"]; - //j["player"]["count"] = 1; } } From c4d721061c42724e764000b6b546b18bb76a7b3d Mon Sep 17 00:00:00 2001 From: Caladius Date: Thu, 7 May 2026 12:39:27 -0400 Subject: [PATCH 4/4] clang --- soh/soh/Network/Anchor/Packets/GiveItem.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/soh/soh/Network/Anchor/Packets/GiveItem.cpp b/soh/soh/Network/Anchor/Packets/GiveItem.cpp index 946ce6cdbd3..814637551ab 100644 --- a/soh/soh/Network/Anchor/Packets/GiveItem.cpp +++ b/soh/soh/Network/Anchor/Packets/GiveItem.cpp @@ -82,7 +82,7 @@ void Anchor::HandlePacket_GiveItem(nlohmann::json payload) { if (getItemEntry.modIndex == MOD_RANDOMIZER) { if (getItemEntry.getItemId == RG_TRIFORCE_PIECE) { Notification::Emit({ .prefix = payload["name"], .message = "Triforce Piece" }); - + std::string filename = Ship::Context::GetPathRelativeToAppDirectory("cheesehunt.json"); nlohmann::json saveFile; std::ifstream inputFile(filename); @@ -108,7 +108,6 @@ void Anchor::HandlePacket_GiveItem(nlohmann::json payload) { } } } - // Full heal if getting a heart container or piece if (getItemEntry.gid == GID_HEART_CONTAINER || getItemEntry.gid == GID_HEART_PIECE) {