feat: add config

This commit is contained in:
2026-04-11 10:41:45 -03:00
parent 83ac8615ba
commit 0300ced79c
2 changed files with 156 additions and 82 deletions
+68 -4
View File
@@ -39,6 +39,7 @@ void Spoofer::init(Proxy* proxy)
{ {
registerListeners(proxy); registerListeners(proxy);
loadData(); loadData();
loadConfig();
} }
void Spoofer::registerListeners(Proxy* proxy) void Spoofer::registerListeners(Proxy* proxy)
@@ -90,6 +91,37 @@ void Spoofer::loadData()
LOADDATA("perks.json", Perks, _camperPerkIds, _slasherPerkIds, "Perks won't be added"); LOADDATA("perks.json", Perks, _camperPerkIds, _slasherPerkIds, "Perks won't be added");
} }
void Spoofer::loadConfig()
{
std::string configPath = utils::getExePath() + "config.json";
std::ifstream configFile(configPath);
if (configFile.is_open())
{
try
{
json configJson = json::parse(configFile);
_config.spoofCharacterOwnership = configJson.value("spoofCharacterOwnership", false);
_config.spoofInventory = configJson.value("spoofInventory", true);
_config.spoofCustomization = configJson.value("spoofCustomization", true);
Log::info("Loaded config: Ownership={}, Inventory={}, Customization={}", _config.spoofCharacterOwnership,
_config.spoofInventory, _config.spoofCustomization);
}
catch (...)
{
Log::error("Failed to parse config.json, using defaults");
}
}
else
{
Log::info("config.json not found, using default settings");
json defaultConfig = {
{"spoofCharacterOwnership", true}, {"spoofInventory", true}, {"spoofCustomization", true}};
std::ofstream out(configPath);
out << defaultConfig.dump(4);
}
}
/* /*
data parsing data parsing
*/ */
@@ -241,10 +273,12 @@ void Spoofer::modifyCharacterData(json& js)
} }
std::string name = js["characterName"]; std::string name = js["characterName"];
bool slasher = isSlasher(js["characterName"]);
if (_config.spoofCharacterOwnership)
{
bool needsSpoofing = false; bool needsSpoofing = false;
if (js.value("isEntitled", true) == false)
if (js.value("isEntitled", false) == false)
{ {
_unownedCharacters.insert(name); _unownedCharacters.insert(name);
js["isEntitled"] = true; js["isEntitled"] = true;
@@ -269,10 +303,20 @@ void Spoofer::modifyCharacterData(json& js)
if (js.contains("bloodWebData")) generateBloodweb(js["bloodWebData"]); if (js.contains("bloodWebData")) generateBloodweb(js["bloodWebData"]);
} }
}
else
{
if (js.value("isEntitled", false) == false) return;
}
/* /*
item spoofing item spoofing
*/ */
if (_config.spoofInventory)
{
bool slasher = isSlasher(js["characterName"]);
if (js.contains("characterItems") && js["characterItems"].is_array()) if (js.contains("characterItems") && js["characterItems"].is_array())
{ {
std::unordered_set<std::string> existingItemIds; std::unordered_set<std::string> existingItemIds;
@@ -318,6 +362,7 @@ void Spoofer::modifyCharacterData(json& js)
appendItems(_slasherPerkIds, true); appendItems(_slasherPerkIds, true);
} }
} }
}
#ifdef _DEBUG #ifdef _DEBUG
Log::verbose("Spoofed data for character {}", name); Log::verbose("Spoofed data for character {}", name);
@@ -380,8 +425,24 @@ void Spoofer::onInventoryAll(std::string& body)
int quantity; int quantity;
}; };
std::vector<Category> categories = {{_camperPerkIds, 3}, {_slasherPerkIds, 3}, {_camperOfferingIds, -1}, std::vector<Category> categories;
{_slasherOfferingIds, -1}, {_catalogOutfitIds, 1}, {_catalogItemIds, 1}}; if (_config.spoofInventory)
{
categories.push_back({_camperPerkIds, 3});
categories.push_back({_slasherPerkIds, 3});
categories.push_back({_camperOfferingIds, -1});
categories.push_back({_slasherOfferingIds, -1});
categories.push_back({_camperItemIds, -1});
categories.push_back({_camperAddonIds, -1});
categories.push_back({_slasherAddonIds, -1});
}
if (_config.spoofCustomization)
{
categories.push_back({_catalogOutfitIds, 1});
categories.push_back({_catalogItemIds, 1});
}
for (auto& item : itemsArr) for (auto& item : itemsArr)
{ {
@@ -481,6 +542,8 @@ void Spoofer::onBloodweb(std::string& body, std::string& respHeaders)
json doc = json::parse(body, nullptr, false); json doc = json::parse(body, nullptr, false);
if (doc.is_discarded()) return Log::error("JSON parse error for bloodweb response"); if (doc.is_discarded()) return Log::error("JSON parse error for bloodweb response");
if (_config.spoofCharacterOwnership)
{
if (body.find("NotAllowedException") != std::string::npos && body.find("not owned") != std::string::npos) if (body.find("NotAllowedException") != std::string::npos && body.find("not owned") != std::string::npos)
{ {
Log::info("Spoofing bloodweb error for unowned character"); Log::info("Spoofing bloodweb error for unowned character");
@@ -512,6 +575,7 @@ void Spoofer::onBloodweb(std::string& body, std::string& respHeaders)
#endif #endif
return; return;
} }
}
modifyCharacterData(doc); modifyCharacterData(doc);
body = doc.dump(); body = doc.dump();
+10
View File
@@ -9,6 +9,13 @@
#include <nlohmann/json_fwd.hpp> #include <nlohmann/json_fwd.hpp>
struct SpooferConfig
{
bool spoofCharacterOwnership = false;
bool spoofInventory = false;
bool spoofCustomization = false;
};
class Spoofer class Spoofer
{ {
public: public:
@@ -17,6 +24,7 @@ class Spoofer
private: private:
void registerListeners(Proxy* proxy); void registerListeners(Proxy* proxy);
void loadData(); void loadData();
void loadConfig();
bool parseCatalog(std::string data); bool parseCatalog(std::string data);
bool parseStackable(std::string data, std::unordered_set<std::string>& camperSet, bool parseStackable(std::string data, std::unordered_set<std::string>& camperSet,
@@ -37,6 +45,8 @@ class Spoofer
void serverResponseHandler(const std::string& url, std::string& body, std::string& respHeaders); void serverResponseHandler(const std::string& url, std::string& body, std::string& respHeaders);
void clientRequestHandler(std::string& url, const std::string& body, std::string& reqHeaders); void clientRequestHandler(std::string& url, const std::string& body, std::string& reqHeaders);
SpooferConfig _config;
std::unordered_set<std::string> _camperItemIds; std::unordered_set<std::string> _camperItemIds;
std::unordered_set<std::string> _slasherPowerIds; std::unordered_set<std::string> _slasherPowerIds;