feat: send characters on /get-all request
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "spoofing.h"
|
||||
#include "spoofing.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <string>
|
||||
@@ -101,6 +101,26 @@ void Spoofer::loadData()
|
||||
Log::verbose("Loaded customizations.json");
|
||||
}
|
||||
|
||||
/*
|
||||
characters
|
||||
*/
|
||||
std::ifstream characterFile(utils::getExePath() + "characters.json");
|
||||
if (characterFile.is_open())
|
||||
{
|
||||
std::stringstream buff;
|
||||
buff << characterFile.rdbuf();
|
||||
json doc = json::parse(buff.str(), nullptr, false);
|
||||
if (doc.is_discarded())
|
||||
Log::error("Failed to parse characters.json");
|
||||
else
|
||||
{
|
||||
for (const auto& character : doc)
|
||||
{
|
||||
if (character.is_string()) _characterList.insert(character.get<std::string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log::verbose("Finished loading data");
|
||||
|
||||
Log::verbose("Items - {} camper", _camperItemIds.size());
|
||||
@@ -110,6 +130,7 @@ void Spoofer::loadData()
|
||||
Log::verbose("Perks - {} camper | {} slasher ", _camperPerkIds.size(), _slasherPerkIds.size());
|
||||
|
||||
Log::verbose("Catalog - {} outfits | {} items", _catalogOutfitIds.size(), _catalogItemIds.size());
|
||||
Log::verbose("Characters - {}", _characterList.size());
|
||||
}
|
||||
|
||||
void Spoofer::loadConfig()
|
||||
@@ -382,6 +403,30 @@ void Spoofer::modifyCharacterData(json& js)
|
||||
#endif
|
||||
}
|
||||
|
||||
void Spoofer::onGetAllClient(std::string& body)
|
||||
{
|
||||
if (!_config.spoofCharacterOwnership) return;
|
||||
|
||||
json doc = json::parse(body, nullptr, false);
|
||||
if (doc.is_discarded()) return Log::error("JSON parse error for dbd-inventories/all (client)");
|
||||
|
||||
if (doc.contains("ownedCharacters") && doc["ownedCharacters"].is_array())
|
||||
{
|
||||
auto& jsonList = doc["ownedCharacters"];
|
||||
|
||||
for (const std::string& charName : _characterList)
|
||||
{
|
||||
if (charName == "K25") continue;
|
||||
|
||||
if (std::find(jsonList.begin(), jsonList.end(), charName) == jsonList.end())
|
||||
jsonList.push_back(charName);
|
||||
}
|
||||
|
||||
body = doc.dump();
|
||||
Log::verbose("{}", body);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
endpoint handlers
|
||||
*/
|
||||
@@ -632,16 +677,13 @@ void Spoofer::serverResponseHandler(const std::string& url, std::string& body, s
|
||||
return onBloodweb(body, respHeaders);
|
||||
}
|
||||
|
||||
void Spoofer::clientRequestHandler(std::string& url, const std::string& body, std::string& /*reqHeaders*/)
|
||||
void Spoofer::clientRequestHandler(const std::string& url, std::string& body, std::string& /*reqHeaders*/)
|
||||
{
|
||||
if (url.find("bhvrdbd.com") == std::string::npos) return;
|
||||
std::lock_guard<std::mutex> lock(_mtx);
|
||||
|
||||
if (url.find("api/v1/dbd-character-data/get-all") != std::string::npos) return onGetAllClient(body);
|
||||
if (url.find("api/v1/dbd-character-data/bloodweb") != std::string::npos ||
|
||||
url.find("api/v1/dbd-character-data/bulk-spending-bloodweb") != std::string::npos)
|
||||
{
|
||||
json req = json::parse(body, nullptr, false);
|
||||
if (req.is_discarded()) return Log::error("JSON parse error for bloodweb request handler");
|
||||
if (req.contains("characterName")) this->_lastBloodWebChar = req["characterName"];
|
||||
return onBloodwebClient(body);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ class Spoofer
|
||||
void generateBloodweb(nlohmann::json& data);
|
||||
void modifyCharacterData(nlohmann::json& js);
|
||||
|
||||
void onGetAllClient(std::string& body);
|
||||
void onGetAll(std::string& body);
|
||||
void onInventoryAll(std::string& body);
|
||||
void onMessageList(std::string& body);
|
||||
@@ -63,6 +64,7 @@ class Spoofer
|
||||
std::unordered_set<std::string> _catalogItemIds;
|
||||
|
||||
std::unordered_set<std::string> _unownedCharacters;
|
||||
std::unordered_set<std::string> _characterList;
|
||||
|
||||
std::string _lastBloodWebChar = "";
|
||||
std::mutex _mtx;
|
||||
|
||||
Reference in New Issue
Block a user