style: move bloodweb fix to its own fn

This commit is contained in:
2026-04-29 11:54:53 -03:00
parent 27b8d3b880
commit ef0d19e659
2 changed files with 26 additions and 17 deletions
+24 -17
View File
@@ -283,6 +283,29 @@ int Spoofer::getRandomQuantity()
return dist(gen); 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) void Spoofer::generateBloodweb(nlohmann::json& js)
{ {
if (!js.is_object()) js = json::object(); if (!js.is_object()) js = json::object();
@@ -654,23 +677,7 @@ void Spoofer::onBloodweb(std::string& body, std::string& respHeaders)
bloodweb fixup for perks 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 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 (_config.spoofInventory) fixBloodweb(doc);
{
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;
}
}
}
}
/* /*
prevent bloodweb reqs from overriding inventory values prevent bloodweb reqs from overriding inventory values
+2
View File
@@ -37,7 +37,9 @@ class Spoofer
std::string getRandomItem(); std::string getRandomItem();
int getRandomQuantity(); int getRandomQuantity();
void fixBloodweb(nlohmann::json& data);
void generateBloodweb(nlohmann::json& data); void generateBloodweb(nlohmann::json& data);
void modifyCharacterData(nlohmann::json& js); void modifyCharacterData(nlohmann::json& js);
void onGetAll(std::string& body); void onGetAll(std::string& body);