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("Items - {} camper", _camperItemIds.size());
|
||||
@@ -131,6 +152,7 @@ void Spoofer::loadData()
|
||||
|
||||
Log::verbose("Catalog - {} outfits | {} items", _catalogOutfitIds.size(), _catalogItemIds.size());
|
||||
Log::verbose("Characters - {}", _characterList.size());
|
||||
Log::verbose("DLCs - GRDK {} - EGS: {}", _dlcListGRDK.size(), _dlcListEGS.size());
|
||||
}
|
||||
|
||||
void Spoofer::loadConfig()
|
||||
@@ -658,6 +680,66 @@ void Spoofer::onBloodweb(std::string& body, std::string& respHeaders)
|
||||
#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
|
||||
*/
|
||||
@@ -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 ||
|
||||
url.find("api/v1/dbd-character-data/bulk-spending-bloodweb") != std::string::npos)
|
||||
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*/)
|
||||
@@ -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 ||
|
||||
url.find("api/v1/dbd-character-data/bulk-spending-bloodweb") != std::string::npos)
|
||||
return onBloodwebClient(body);
|
||||
|
||||
if (url.ends_with("api/v1/owned-products/get-update-entitlements")) return onUpdateEntitlementsClient(url, body);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user