feat: add config
This commit is contained in:
@@ -39,6 +39,7 @@ void Spoofer::init(Proxy* proxy)
|
||||
{
|
||||
registerListeners(proxy);
|
||||
loadData();
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
void Spoofer::registerListeners(Proxy* proxy)
|
||||
@@ -90,6 +91,37 @@ void Spoofer::loadData()
|
||||
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
|
||||
*/
|
||||
@@ -241,10 +273,12 @@ void Spoofer::modifyCharacterData(json& js)
|
||||
}
|
||||
|
||||
std::string name = js["characterName"];
|
||||
bool slasher = isSlasher(js["characterName"]);
|
||||
|
||||
if (_config.spoofCharacterOwnership)
|
||||
{
|
||||
bool needsSpoofing = false;
|
||||
if (js.value("isEntitled", true) == false)
|
||||
|
||||
if (js.value("isEntitled", false) == false)
|
||||
{
|
||||
_unownedCharacters.insert(name);
|
||||
js["isEntitled"] = true;
|
||||
@@ -269,10 +303,20 @@ void Spoofer::modifyCharacterData(json& js)
|
||||
|
||||
if (js.contains("bloodWebData")) generateBloodweb(js["bloodWebData"]);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
if (js.value("isEntitled", false) == false) return;
|
||||
}
|
||||
|
||||
/*
|
||||
item spoofing
|
||||
*/
|
||||
if (_config.spoofInventory)
|
||||
{
|
||||
bool slasher = isSlasher(js["characterName"]);
|
||||
|
||||
if (js.contains("characterItems") && js["characterItems"].is_array())
|
||||
{
|
||||
std::unordered_set<std::string> existingItemIds;
|
||||
@@ -318,6 +362,7 @@ void Spoofer::modifyCharacterData(json& js)
|
||||
appendItems(_slasherPerkIds, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
Log::verbose("Spoofed data for character {}", name);
|
||||
@@ -380,8 +425,24 @@ void Spoofer::onInventoryAll(std::string& body)
|
||||
int quantity;
|
||||
};
|
||||
|
||||
std::vector<Category> categories = {{_camperPerkIds, 3}, {_slasherPerkIds, 3}, {_camperOfferingIds, -1},
|
||||
{_slasherOfferingIds, -1}, {_catalogOutfitIds, 1}, {_catalogItemIds, 1}};
|
||||
std::vector<Category> categories;
|
||||
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)
|
||||
{
|
||||
@@ -481,6 +542,8 @@ void Spoofer::onBloodweb(std::string& body, std::string& respHeaders)
|
||||
json doc = json::parse(body, nullptr, false);
|
||||
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)
|
||||
{
|
||||
Log::info("Spoofing bloodweb error for unowned character");
|
||||
@@ -512,6 +575,7 @@ void Spoofer::onBloodweb(std::string& body, std::string& respHeaders)
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
modifyCharacterData(doc);
|
||||
body = doc.dump();
|
||||
|
||||
@@ -9,6 +9,13 @@
|
||||
|
||||
#include <nlohmann/json_fwd.hpp>
|
||||
|
||||
struct SpooferConfig
|
||||
{
|
||||
bool spoofCharacterOwnership = false;
|
||||
bool spoofInventory = false;
|
||||
bool spoofCustomization = false;
|
||||
};
|
||||
|
||||
class Spoofer
|
||||
{
|
||||
public:
|
||||
@@ -17,6 +24,7 @@ class Spoofer
|
||||
private:
|
||||
void registerListeners(Proxy* proxy);
|
||||
void loadData();
|
||||
void loadConfig();
|
||||
|
||||
bool parseCatalog(std::string data);
|
||||
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 clientRequestHandler(std::string& url, const std::string& body, std::string& reqHeaders);
|
||||
|
||||
SpooferConfig _config;
|
||||
|
||||
std::unordered_set<std::string> _camperItemIds;
|
||||
std::unordered_set<std::string> _slasherPowerIds;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user