From ef0d19e659f92fa5185a1808b3864232838e4bb2 Mon Sep 17 00:00:00 2001 From: neru Date: Wed, 29 Apr 2026 11:54:53 -0300 Subject: [PATCH] style: move bloodweb fix to its own fn --- src/unlocker/spoofing.cpp | 41 +++++++++++++++++++++++---------------- src/unlocker/spoofing.h | 2 ++ 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/unlocker/spoofing.cpp b/src/unlocker/spoofing.cpp index 651ec98..ad8a69b 100644 --- a/src/unlocker/spoofing.cpp +++ b/src/unlocker/spoofing.cpp @@ -283,6 +283,29 @@ int Spoofer::getRandomQuantity() return dist(gen); } +void Spoofer::fixBloodweb(nlohmann::json& js) +{ + if (!js.contains("bloodWebData") || !js["bloodWebData"].is_object()) return; + + auto& bloodWebData = js["bloodWebData"]; + + if (!bloodWebData.contains("paths") || !bloodWebData.contains("ringData")) return; + + for (auto& ring : js["bloodWebData"]["ringData"]) + { + if (!ring.contains("nodeData")) continue; + for (auto& node : ring["nodeData"]) + { + if (!node.contains("contentId")) continue; + std::string contentId = node["contentId"]; + if (_camperPerkIds.contains(contentId) || _slasherPerkIds.contains(contentId)) + node["contentId"] = PLACEHOLDER_ITEMID; + } + } + + Log::verbose("Fixed bloodweb request"); +} + void Spoofer::generateBloodweb(nlohmann::json& js) { if (!js.is_object()) js = json::object(); @@ -654,23 +677,7 @@ void Spoofer::onBloodweb(std::string& body, std::string& respHeaders) bloodweb fixup for perks (if all perks are unlocked, the game will interpret bloodwebs with perks as invalid so perks will be replaced with PLACEHOLDER_ITEMID) */ - if (_config.spoofInventory) - { - if (doc.contains("bloodWebData") && doc["bloodWebData"].contains("ringData")) - { - for (auto& ring : doc["bloodWebData"]["ringData"]) - { - if (!ring.contains("nodeData")) continue; - for (auto& node : ring["nodeData"]) - { - if (!node.contains("contentId")) continue; - std::string contentId = node["contentId"]; - if (_camperPerkIds.contains(contentId) || _slasherPerkIds.contains(contentId)) - node["contentId"] = PLACEHOLDER_ITEMID; - } - } - } - } + if (_config.spoofInventory) fixBloodweb(doc); /* prevent bloodweb reqs from overriding inventory values diff --git a/src/unlocker/spoofing.h b/src/unlocker/spoofing.h index 97dbf2e..56226d6 100644 --- a/src/unlocker/spoofing.h +++ b/src/unlocker/spoofing.h @@ -37,7 +37,9 @@ class Spoofer std::string getRandomItem(); int getRandomQuantity(); + void fixBloodweb(nlohmann::json& data); void generateBloodweb(nlohmann::json& data); + void modifyCharacterData(nlohmann::json& js); void onGetAll(std::string& body);