fix: improve id handling, filter out bloodweb

This commit is contained in:
2026-03-20 20:33:55 -03:00
parent 96746626bd
commit e492b8ea3b
+23 -19
View File
@@ -301,45 +301,49 @@ int main()
std::lock_guard<std::mutex> lock(g_dataMutex);
if (!g_allObjectIds.empty())
{
Log::info("Merging catalog items into real inventory response");
Log::info("Merging catalog and dumped items into real inventory response");
size_t closePos = data.rfind("]}");
if (closePos != std::string::npos)
{
uint64_t now = time(nullptr);
std::string injected;
injected.reserve(g_allObjectIds.size() * 60);
injected.reserve((g_allObjectIds.size() + g_stackableItems.size()) * 80);
std::unordered_set<std::string> handledIds;
auto injectItem = [&](const std::string& id, int qty) {
if (id.empty()) return;
if (handledIds.count(id)) return;
std::string searchPat = "\"objectId\":\"" + id + "\"";
if (data.find(searchPat) != std::string::npos)
std::unordered_set<std::string> seenIds;
size_t pos = 0;
while ((pos = data.find("\"objectId\":\"", pos)) != std::string::npos)
{
pos += 12;
size_t end = data.find("\"", pos);
if (end != std::string::npos)
{
handledIds.insert(id);
return;
seenIds.insert(data.substr(pos, end - pos));
pos = end;
}
}
injected += ",{\"lastUpdateAt\":" + std::to_string(now) +
",\"quantity\":" + std::to_string(qty) + ",\"objectId\":\"" + id + "\"}";
handledIds.insert(id);
auto injectItem = [&](const std::string& id, int qty) {
if (id.empty() || seenIds.count(id)) return;
injected += std::format(",{{\"lastUpdateAt\":{},\"quantity\":{},\"objectId\":\"{}\"}}", now, qty, id);
seenIds.insert(id);
};
for (const auto& id : g_allObjectIds)
injectItem(id, 1);
for (const auto& id : g_allObjectIds) injectItem(id, 1);
for (const auto& id : g_stackableItems) injectItem(id, 100);
for (const auto& id : g_uniqueItems) injectItem(id, 1);
for (const auto& id : g_perks) injectItem(id, 3);
if (!injected.empty()) data.insert(closePos, injected);
Log::info("Injected {} catalog items into global inventory",
injected.empty() ? 0 : std::count(injected.begin(), injected.end(), '{'));
Log::info("Injected {} items into global inventory",
std::count(injected.begin(), injected.end(), '{'));
}
}
else
Log::warning("No catalog data available to inject into global inventory yet!");
}
else if (url.find("api/v1/dbd-character-data/get-all") != std::string::npos)
else if (url.find("api/v1/dbd-character-data/") != std::string::npos && url.find("/bloodweb") == std::string::npos)
{
std::vector<std::string> localStackable;
std::vector<std::string> localUnique;