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);