feat: add DLC unlocking
This commit is contained in:
@@ -121,6 +121,27 @@ void Spoofer::loadData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
dlcs
|
||||||
|
*/
|
||||||
|
std::ifstream dlcFile(utils::getExePath() + "dlcs.json");
|
||||||
|
if (dlcFile.is_open())
|
||||||
|
{
|
||||||
|
std::stringstream buff;
|
||||||
|
buff << dlcFile.rdbuf();
|
||||||
|
json doc = json::parse(buff.str(), nullptr, false);
|
||||||
|
if (doc.is_discarded())
|
||||||
|
Log::error("Failed to parse dlcs.json");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (const auto& dlc : doc)
|
||||||
|
{
|
||||||
|
if (dlc.contains("grdk")) _dlcListGRDK.insert(dlc["grdk"].get<std::string>());
|
||||||
|
if (dlc.contains("egs")) _dlcListEGS.insert(dlc["egs"].get<std::string>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Log::verbose("Finished loading data");
|
Log::verbose("Finished loading data");
|
||||||
|
|
||||||
Log::verbose("Items - {} camper", _camperItemIds.size());
|
Log::verbose("Items - {} camper", _camperItemIds.size());
|
||||||
@@ -131,6 +152,7 @@ void Spoofer::loadData()
|
|||||||
|
|
||||||
Log::verbose("Catalog - {} outfits | {} items", _catalogOutfitIds.size(), _catalogItemIds.size());
|
Log::verbose("Catalog - {} outfits | {} items", _catalogOutfitIds.size(), _catalogItemIds.size());
|
||||||
Log::verbose("Characters - {}", _characterList.size());
|
Log::verbose("Characters - {}", _characterList.size());
|
||||||
|
Log::verbose("DLCs - GRDK {} - EGS: {}", _dlcListGRDK.size(), _dlcListEGS.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spoofer::loadConfig()
|
void Spoofer::loadConfig()
|
||||||
@@ -658,6 +680,66 @@ void Spoofer::onBloodweb(std::string& body, std::string& respHeaders)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Spoofer::onUpdateEntitlements(const std::string& url, std::string& body)
|
||||||
|
{
|
||||||
|
if (!_config.spoofCharacterOwnership) return;
|
||||||
|
|
||||||
|
json js = json::parse(body, nullptr, false);
|
||||||
|
if (js.is_discarded()) return Log::error("JSON parse error for get-update-entitlements");
|
||||||
|
|
||||||
|
if (js.contains("entitlements"))
|
||||||
|
{
|
||||||
|
auto& jsonList = js["entitlements"];
|
||||||
|
|
||||||
|
std::unordered_set<std::string>* list = nullptr;
|
||||||
|
|
||||||
|
if (url.starts_with("https://grdk.live.bhvrdbd.com/"))
|
||||||
|
list = &_dlcListGRDK;
|
||||||
|
else if (url.starts_with("https://egs.live.bhvrdbd.com/"))
|
||||||
|
list = &_dlcListEGS;
|
||||||
|
else
|
||||||
|
return Log::error("Invalid url?");
|
||||||
|
|
||||||
|
if (list == nullptr) return;
|
||||||
|
for (const std::string& dlcId : *list)
|
||||||
|
{
|
||||||
|
if (std::find(jsonList.begin(), jsonList.end(), dlcId) == jsonList.end()) jsonList.push_back(dlcId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body = js.dump();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spoofer::onUpdateEntitlementsClient(const std::string& url, std::string& body)
|
||||||
|
{
|
||||||
|
if (!_config.spoofCharacterOwnership) return;
|
||||||
|
|
||||||
|
json js = json::parse(body, nullptr, false);
|
||||||
|
if (js.is_discarded()) return Log::error("JSON parse error for get-update-entitlements");
|
||||||
|
|
||||||
|
if (js.contains("clientEntitlementIds"))
|
||||||
|
{
|
||||||
|
auto& jsonList = js["clientEntitlementIds"];
|
||||||
|
|
||||||
|
std::unordered_set<std::string>* list = nullptr;
|
||||||
|
|
||||||
|
if (url.starts_with("https://grdk.live.bhvrdbd.com/"))
|
||||||
|
list = &_dlcListGRDK;
|
||||||
|
else if (url.starts_with("https://egs.live.bhvrdbd.com/"))
|
||||||
|
list = &_dlcListEGS;
|
||||||
|
else
|
||||||
|
return Log::error("Invalid url?");
|
||||||
|
|
||||||
|
if (list == nullptr) return;
|
||||||
|
for (const std::string& dlcId : *list)
|
||||||
|
{
|
||||||
|
if (std::find(jsonList.begin(), jsonList.end(), dlcId) == jsonList.end()) jsonList.push_back(dlcId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body = js.dump();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
event handlers
|
event handlers
|
||||||
*/
|
*/
|
||||||
@@ -676,6 +758,8 @@ void Spoofer::serverResponseHandler(const std::string& url, std::string& body, s
|
|||||||
if (url.find("api/v1/dbd-character-data/bloodweb") != std::string::npos ||
|
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)
|
url.find("api/v1/dbd-character-data/bulk-spending-bloodweb") != std::string::npos)
|
||||||
return onBloodweb(body, respHeaders);
|
return onBloodweb(body, respHeaders);
|
||||||
|
|
||||||
|
if (url.ends_with("api/v1/owned-products/get-update-entitlements")) return onUpdateEntitlements(url, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spoofer::clientRequestHandler(const std::string& url, std::string& body, std::string& /*reqHeaders*/)
|
void Spoofer::clientRequestHandler(const std::string& url, std::string& body, std::string& /*reqHeaders*/)
|
||||||
@@ -687,4 +771,6 @@ void Spoofer::clientRequestHandler(const std::string& url, std::string& body, st
|
|||||||
if (url.find("api/v1/dbd-character-data/bloodweb") != std::string::npos ||
|
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)
|
url.find("api/v1/dbd-character-data/bulk-spending-bloodweb") != std::string::npos)
|
||||||
return onBloodwebClient(body);
|
return onBloodwebClient(body);
|
||||||
|
|
||||||
|
if (url.ends_with("api/v1/owned-products/get-update-entitlements")) return onUpdateEntitlementsClient(url, body);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,12 +40,16 @@ class Spoofer
|
|||||||
void generateBloodweb(nlohmann::json& data);
|
void generateBloodweb(nlohmann::json& data);
|
||||||
void modifyCharacterData(nlohmann::json& js);
|
void modifyCharacterData(nlohmann::json& js);
|
||||||
|
|
||||||
void onGetAllClient(std::string& body);
|
|
||||||
void onGetAll(std::string& body);
|
void onGetAll(std::string& body);
|
||||||
void onInventoryAll(std::string& body);
|
void onInventoryAll(std::string& body);
|
||||||
void onMessageList(std::string& body);
|
void onMessageList(std::string& body);
|
||||||
void onBloodwebClient(std::string& body);
|
|
||||||
void onBloodweb(std::string& body, std::string& respHeaders);
|
void onBloodweb(std::string& body, std::string& respHeaders);
|
||||||
|
void onGameConfigs(std::string& body);
|
||||||
|
void onUpdateEntitlements(const std::string& url, std::string& body);
|
||||||
|
|
||||||
|
void onGetAllClient(std::string& body);
|
||||||
|
void onBloodwebClient(std::string& body);
|
||||||
|
void onUpdateEntitlementsClient(const std::string& url, std::string& body);
|
||||||
|
|
||||||
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(const std::string& url, std::string& body, std::string& reqHeaders);
|
void clientRequestHandler(const std::string& url, std::string& body, std::string& reqHeaders);
|
||||||
@@ -70,6 +74,9 @@ class Spoofer
|
|||||||
std::unordered_set<std::string> _unownedCharacters;
|
std::unordered_set<std::string> _unownedCharacters;
|
||||||
std::unordered_set<std::string> _characterList;
|
std::unordered_set<std::string> _characterList;
|
||||||
|
|
||||||
|
std::unordered_set<std::string> _dlcListGRDK;
|
||||||
|
std::unordered_set<std::string> _dlcListEGS;
|
||||||
|
|
||||||
std::string _lastBloodWebChar = "";
|
std::string _lastBloodWebChar = "";
|
||||||
std::mutex _mtx;
|
std::mutex _mtx;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user