feat: send characters on /get-all request
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
[
|
||||
"Ace",
|
||||
"Adam",
|
||||
"Ash",
|
||||
"Bear",
|
||||
"Bill",
|
||||
"Bob",
|
||||
"Cannibal",
|
||||
"Chuckles",
|
||||
"Claudette",
|
||||
"Clown",
|
||||
"Demogorgon",
|
||||
"Dwight",
|
||||
"Eric",
|
||||
"Feng",
|
||||
"Ghostface",
|
||||
"Gunslinger",
|
||||
"HillBilly",
|
||||
"Jake",
|
||||
"Jane",
|
||||
"Jeff",
|
||||
"K20",
|
||||
"K21",
|
||||
"K22",
|
||||
"K23",
|
||||
"K24",
|
||||
"K25",
|
||||
"K26",
|
||||
"K27",
|
||||
"K28",
|
||||
"K29",
|
||||
"K30",
|
||||
"K31",
|
||||
"K32",
|
||||
"K33",
|
||||
"K34",
|
||||
"K35",
|
||||
"K36",
|
||||
"K37",
|
||||
"K38",
|
||||
"K39",
|
||||
"K40",
|
||||
"K41",
|
||||
"K42",
|
||||
"Kate",
|
||||
"Killer07",
|
||||
"Laurie",
|
||||
"Legion",
|
||||
"Meg",
|
||||
"Nancy",
|
||||
"Nea",
|
||||
"Nightmare",
|
||||
"Nurse",
|
||||
"Oni",
|
||||
"Pig",
|
||||
"Plague",
|
||||
"Quentin",
|
||||
"S22",
|
||||
"S23",
|
||||
"S24",
|
||||
"S25",
|
||||
"S26",
|
||||
"S27",
|
||||
"S28",
|
||||
"S29",
|
||||
"S30",
|
||||
"S31",
|
||||
"S32",
|
||||
"S33",
|
||||
"S34",
|
||||
"S35",
|
||||
"S36",
|
||||
"S37",
|
||||
"S38",
|
||||
"S39",
|
||||
"S40",
|
||||
"S41",
|
||||
"S42",
|
||||
"S43",
|
||||
"S44",
|
||||
"S45",
|
||||
"S46",
|
||||
"S47",
|
||||
"S48",
|
||||
"S49",
|
||||
"S50",
|
||||
"S51",
|
||||
"Shape",
|
||||
"Smoke",
|
||||
"Spirit",
|
||||
"Steve",
|
||||
"Witch",
|
||||
"Yui",
|
||||
"Zarina"
|
||||
]
|
||||
@@ -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