2026-02-02 12:24:50 -08:00
|
|
|
#include "pipeline/asset_manager.hpp"
|
|
|
|
|
#include "core/logger.hpp"
|
2026-02-08 23:15:26 -08:00
|
|
|
#include "core/memory_monitor.hpp"
|
2026-02-02 12:24:50 -08:00
|
|
|
#include <algorithm>
|
2026-02-12 16:12:10 -08:00
|
|
|
#include <cstdlib>
|
2026-02-12 20:32:14 -08:00
|
|
|
#include <filesystem>
|
2026-02-13 00:10:01 -08:00
|
|
|
#include <fstream>
|
2026-02-12 16:12:10 -08:00
|
|
|
#include <limits>
|
2026-02-02 12:24:50 -08:00
|
|
|
|
2026-02-12 20:32:14 -08:00
|
|
|
#include "stb_image.h"
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
namespace wowee {
|
|
|
|
|
namespace pipeline {
|
|
|
|
|
|
2026-02-12 16:12:10 -08:00
|
|
|
namespace {
|
|
|
|
|
size_t parseEnvSizeMB(const char* name) {
|
|
|
|
|
const char* v = std::getenv(name);
|
|
|
|
|
if (!v || !*v) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
char* end = nullptr;
|
|
|
|
|
unsigned long long mb = std::strtoull(v, &end, 10);
|
|
|
|
|
if (end == v || mb == 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
if (mb > (std::numeric_limits<size_t>::max() / (1024ull * 1024ull))) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return static_cast<size_t>(mb);
|
|
|
|
|
}
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
AssetManager::AssetManager() = default;
|
|
|
|
|
AssetManager::~AssetManager() {
|
|
|
|
|
shutdown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AssetManager::initialize(const std::string& dataPath_) {
|
|
|
|
|
if (initialized) {
|
|
|
|
|
LOG_WARNING("AssetManager already initialized");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dataPath = dataPath_;
|
|
|
|
|
LOG_INFO("Initializing asset manager with data path: ", dataPath);
|
|
|
|
|
|
2026-02-12 20:32:14 -08:00
|
|
|
setupFileCacheBudget();
|
|
|
|
|
|
|
|
|
|
std::string manifestPath = dataPath + "/manifest.json";
|
|
|
|
|
if (!std::filesystem::exists(manifestPath)) {
|
|
|
|
|
LOG_ERROR("manifest.json not found in: ", dataPath);
|
|
|
|
|
LOG_ERROR("Run asset_extract to extract MPQ archives first");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!manifest_.load(manifestPath)) {
|
|
|
|
|
LOG_ERROR("Failed to load manifest");
|
2026-02-02 12:24:50 -08:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-12 20:32:14 -08:00
|
|
|
initialized = true;
|
|
|
|
|
LOG_INFO("Asset manager initialized: ", manifest_.getEntryCount(),
|
|
|
|
|
" files indexed (file cache: ", fileCacheBudget / (1024 * 1024), " MB)");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AssetManager::setupFileCacheBudget() {
|
2026-02-08 23:15:26 -08:00
|
|
|
auto& memMonitor = core::MemoryMonitor::getInstance();
|
|
|
|
|
size_t recommendedBudget = memMonitor.getRecommendedCacheBudget();
|
2026-02-12 20:32:14 -08:00
|
|
|
size_t dynamicBudget = (recommendedBudget * 3) / 4;
|
2026-02-12 16:12:10 -08:00
|
|
|
|
|
|
|
|
const size_t envFixedMB = parseEnvSizeMB("WOWEE_FILE_CACHE_MB");
|
|
|
|
|
const size_t envMaxMB = parseEnvSizeMB("WOWEE_FILE_CACHE_MAX_MB");
|
|
|
|
|
|
2026-02-12 20:32:14 -08:00
|
|
|
const size_t minBudgetBytes = 256ull * 1024ull * 1024ull;
|
|
|
|
|
const size_t defaultMaxBudgetBytes = 32768ull * 1024ull * 1024ull;
|
2026-02-12 16:12:10 -08:00
|
|
|
const size_t maxBudgetBytes = (envMaxMB > 0)
|
|
|
|
|
? (envMaxMB * 1024ull * 1024ull)
|
|
|
|
|
: defaultMaxBudgetBytes;
|
|
|
|
|
|
|
|
|
|
if (envFixedMB > 0) {
|
|
|
|
|
fileCacheBudget = envFixedMB * 1024ull * 1024ull;
|
|
|
|
|
if (fileCacheBudget < minBudgetBytes) {
|
|
|
|
|
fileCacheBudget = minBudgetBytes;
|
|
|
|
|
}
|
|
|
|
|
LOG_WARNING("Asset file cache fixed via WOWEE_FILE_CACHE_MB=", envFixedMB,
|
|
|
|
|
" (effective ", fileCacheBudget / (1024 * 1024), " MB)");
|
|
|
|
|
} else {
|
|
|
|
|
fileCacheBudget = std::clamp(dynamicBudget, minBudgetBytes, maxBudgetBytes);
|
|
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AssetManager::shutdown() {
|
|
|
|
|
if (!initialized) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG_INFO("Shutting down asset manager");
|
|
|
|
|
|
2026-02-08 22:37:29 -08:00
|
|
|
if (fileCacheHits + fileCacheMisses > 0) {
|
|
|
|
|
float hitRate = (float)fileCacheHits / (fileCacheHits + fileCacheMisses) * 100.0f;
|
|
|
|
|
LOG_INFO("File cache stats: ", fileCacheHits, " hits, ", fileCacheMisses, " misses (",
|
|
|
|
|
(int)hitRate, "% hit rate), ", fileCacheTotalBytes / 1024 / 1024, " MB cached");
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
clearCache();
|
2026-02-12 22:56:36 -08:00
|
|
|
overlayLayers_.clear();
|
2026-02-02 12:24:50 -08:00
|
|
|
initialized = false;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-12 22:56:36 -08:00
|
|
|
bool AssetManager::addOverlayManifest(const std::string& manifestPath, int priority, const std::string& id) {
|
|
|
|
|
// Check for duplicate
|
|
|
|
|
for (const auto& layer : overlayLayers_) {
|
|
|
|
|
if (layer.id == id) {
|
|
|
|
|
LOG_WARNING("Overlay '", id, "' already loaded, skipping");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ManifestLayer layer;
|
|
|
|
|
layer.priority = priority;
|
|
|
|
|
layer.id = id;
|
|
|
|
|
|
|
|
|
|
if (!layer.manifest.load(manifestPath)) {
|
|
|
|
|
LOG_ERROR("Failed to load overlay manifest: ", manifestPath);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
overlayLayers_.push_back(std::move(layer));
|
|
|
|
|
|
|
|
|
|
// Sort by priority descending (highest priority first)
|
|
|
|
|
std::sort(overlayLayers_.begin(), overlayLayers_.end(),
|
|
|
|
|
[](const ManifestLayer& a, const ManifestLayer& b) {
|
|
|
|
|
return a.priority > b.priority;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
LOG_INFO("Added overlay '", id, "' (priority ", priority, ", ",
|
|
|
|
|
overlayLayers_.back().manifest.getEntryCount(), " files) from ", manifestPath);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AssetManager::removeOverlay(const std::string& id) {
|
|
|
|
|
auto it = std::remove_if(overlayLayers_.begin(), overlayLayers_.end(),
|
|
|
|
|
[&id](const ManifestLayer& layer) { return layer.id == id; });
|
|
|
|
|
if (it != overlayLayers_.end()) {
|
|
|
|
|
overlayLayers_.erase(it, overlayLayers_.end());
|
|
|
|
|
// Clear file cache since overlay removal changes file resolution
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> lock(cacheMutex);
|
|
|
|
|
fileCache.clear();
|
|
|
|
|
fileCacheTotalBytes = 0;
|
|
|
|
|
}
|
|
|
|
|
LOG_INFO("Removed overlay '", id, "', file cache cleared");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> AssetManager::getOverlayIds() const {
|
|
|
|
|
std::vector<std::string> ids;
|
|
|
|
|
ids.reserve(overlayLayers_.size());
|
|
|
|
|
for (const auto& layer : overlayLayers_) {
|
|
|
|
|
ids.push_back(layer.id);
|
|
|
|
|
}
|
|
|
|
|
return ids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string AssetManager::resolveLayeredPath(const std::string& normalizedPath) const {
|
|
|
|
|
// Check overlay manifests first (sorted by priority desc)
|
|
|
|
|
for (const auto& layer : overlayLayers_) {
|
|
|
|
|
std::string fsPath = layer.manifest.resolveFilesystemPath(normalizedPath);
|
|
|
|
|
if (!fsPath.empty()) {
|
|
|
|
|
return fsPath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Fall back to base manifest
|
|
|
|
|
return manifest_.resolveFilesystemPath(normalizedPath);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
BLPImage AssetManager::loadTexture(const std::string& path) {
|
|
|
|
|
if (!initialized) {
|
|
|
|
|
LOG_ERROR("AssetManager not initialized");
|
|
|
|
|
return BLPImage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string normalizedPath = normalizePath(path);
|
|
|
|
|
|
|
|
|
|
LOG_DEBUG("Loading texture: ", normalizedPath);
|
|
|
|
|
|
2026-02-12 20:32:14 -08:00
|
|
|
// Check for PNG override
|
|
|
|
|
BLPImage pngImage = tryLoadPngOverride(normalizedPath);
|
|
|
|
|
if (pngImage.isValid()) {
|
|
|
|
|
return pngImage;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-11 18:25:04 -08:00
|
|
|
std::vector<uint8_t> blpData = readFile(normalizedPath);
|
2026-02-02 12:24:50 -08:00
|
|
|
if (blpData.empty()) {
|
|
|
|
|
LOG_WARNING("Texture not found: ", normalizedPath);
|
|
|
|
|
return BLPImage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLPImage image = BLPLoader::load(blpData);
|
|
|
|
|
if (!image.isValid()) {
|
|
|
|
|
LOG_ERROR("Failed to load texture: ", normalizedPath);
|
|
|
|
|
return BLPImage();
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-11 22:27:02 -08:00
|
|
|
LOG_DEBUG("Loaded texture: ", normalizedPath, " (", image.width, "x", image.height, ")");
|
2026-02-02 12:24:50 -08:00
|
|
|
return image;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-12 20:32:14 -08:00
|
|
|
BLPImage AssetManager::tryLoadPngOverride(const std::string& normalizedPath) const {
|
|
|
|
|
if (normalizedPath.size() < 4) return BLPImage();
|
|
|
|
|
|
|
|
|
|
std::string ext = normalizedPath.substr(normalizedPath.size() - 4);
|
|
|
|
|
if (ext != ".blp") return BLPImage();
|
|
|
|
|
|
2026-02-12 22:56:36 -08:00
|
|
|
std::string fsPath = resolveLayeredPath(normalizedPath);
|
2026-02-12 20:32:14 -08:00
|
|
|
if (fsPath.empty()) return BLPImage();
|
|
|
|
|
|
|
|
|
|
// Replace .blp/.BLP extension with .png
|
|
|
|
|
std::string pngPath = fsPath.substr(0, fsPath.size() - 4) + ".png";
|
|
|
|
|
if (!LooseFileReader::fileExists(pngPath)) {
|
|
|
|
|
return BLPImage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int w, h, channels;
|
|
|
|
|
unsigned char* pixels = stbi_load(pngPath.c_str(), &w, &h, &channels, 4);
|
|
|
|
|
if (!pixels) {
|
|
|
|
|
LOG_WARNING("PNG override exists but failed to load: ", pngPath);
|
|
|
|
|
return BLPImage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLPImage image;
|
|
|
|
|
image.width = w;
|
|
|
|
|
image.height = h;
|
|
|
|
|
image.channels = 4;
|
|
|
|
|
image.format = BLPFormat::BLP2;
|
|
|
|
|
image.compression = BLPCompression::ARGB8888;
|
|
|
|
|
image.data.assign(pixels, pixels + (w * h * 4));
|
|
|
|
|
stbi_image_free(pixels);
|
|
|
|
|
|
|
|
|
|
LOG_INFO("PNG override loaded: ", pngPath, " (", w, "x", h, ")");
|
|
|
|
|
return image;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-13 00:10:01 -08:00
|
|
|
void AssetManager::setExpansionDataPath(const std::string& path) {
|
|
|
|
|
expansionDataPath_ = path;
|
|
|
|
|
LOG_INFO("Expansion data path for CSV DBCs: ", expansionDataPath_);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
std::shared_ptr<DBCFile> AssetManager::loadDBC(const std::string& name) {
|
|
|
|
|
if (!initialized) {
|
|
|
|
|
LOG_ERROR("AssetManager not initialized");
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto it = dbcCache.find(name);
|
|
|
|
|
if (it != dbcCache.end()) {
|
|
|
|
|
LOG_DEBUG("DBC already loaded (cached): ", name);
|
|
|
|
|
return it->second;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG_DEBUG("Loading DBC: ", name);
|
|
|
|
|
|
2026-02-13 00:10:01 -08:00
|
|
|
std::vector<uint8_t> dbcData;
|
|
|
|
|
|
|
|
|
|
// Try expansion-specific CSV first (e.g. Data/expansions/wotlk/db/Spell.csv)
|
|
|
|
|
if (!expansionDataPath_.empty()) {
|
|
|
|
|
// Derive CSV name from DBC name: "Spell.dbc" -> "Spell.csv"
|
|
|
|
|
std::string baseName = name;
|
|
|
|
|
auto dot = baseName.rfind('.');
|
|
|
|
|
if (dot != std::string::npos) {
|
|
|
|
|
baseName = baseName.substr(0, dot);
|
|
|
|
|
}
|
|
|
|
|
std::string csvPath = expansionDataPath_ + "/db/" + baseName + ".csv";
|
|
|
|
|
if (std::filesystem::exists(csvPath)) {
|
|
|
|
|
std::ifstream f(csvPath, std::ios::binary | std::ios::ate);
|
|
|
|
|
if (f) {
|
|
|
|
|
auto size = f.tellg();
|
|
|
|
|
if (size > 0) {
|
|
|
|
|
f.seekg(0);
|
|
|
|
|
dbcData.resize(static_cast<size_t>(size));
|
|
|
|
|
f.read(reinterpret_cast<char*>(dbcData.data()), size);
|
|
|
|
|
LOG_DEBUG("Found CSV DBC: ", csvPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
|
2026-02-13 00:10:01 -08:00
|
|
|
// Fall back to manifest (binary DBC from extracted MPQs)
|
2026-02-02 12:24:50 -08:00
|
|
|
if (dbcData.empty()) {
|
2026-02-13 00:10:01 -08:00
|
|
|
std::string dbcPath = "DBFilesClient\\" + name;
|
|
|
|
|
dbcData = readFile(dbcPath);
|
|
|
|
|
if (dbcData.empty()) {
|
|
|
|
|
LOG_WARNING("DBC not found: ", name);
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto dbc = std::make_shared<DBCFile>();
|
|
|
|
|
if (!dbc->load(dbcData)) {
|
2026-02-13 00:10:01 -08:00
|
|
|
LOG_ERROR("Failed to load DBC: ", name);
|
2026-02-02 12:24:50 -08:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbcCache[name] = dbc;
|
|
|
|
|
|
|
|
|
|
LOG_INFO("Loaded DBC: ", name, " (", dbc->getRecordCount(), " records)");
|
|
|
|
|
return dbc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<DBCFile> AssetManager::getDBC(const std::string& name) const {
|
|
|
|
|
auto it = dbcCache.find(name);
|
|
|
|
|
if (it != dbcCache.end()) {
|
|
|
|
|
return it->second;
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AssetManager::fileExists(const std::string& path) const {
|
|
|
|
|
if (!initialized) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2026-02-12 22:56:36 -08:00
|
|
|
std::string normalized = normalizePath(path);
|
|
|
|
|
// Check overlay manifests first
|
|
|
|
|
for (const auto& layer : overlayLayers_) {
|
|
|
|
|
if (layer.manifest.hasEntry(normalized)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return manifest_.hasEntry(normalized);
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<uint8_t> AssetManager::readFile(const std::string& path) const {
|
|
|
|
|
if (!initialized) {
|
2026-02-12 20:32:14 -08:00
|
|
|
return {};
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
|
2026-02-08 22:37:29 -08:00
|
|
|
std::string normalized = normalizePath(path);
|
2026-02-12 20:32:14 -08:00
|
|
|
|
|
|
|
|
// Check cache first
|
2026-02-11 19:28:15 -08:00
|
|
|
{
|
|
|
|
|
std::lock_guard<std::mutex> cacheLock(cacheMutex);
|
|
|
|
|
auto it = fileCache.find(normalized);
|
|
|
|
|
if (it != fileCache.end()) {
|
|
|
|
|
it->second.lastAccessTime = ++fileCacheAccessCounter;
|
|
|
|
|
fileCacheHits++;
|
|
|
|
|
return it->second.data;
|
|
|
|
|
}
|
2026-02-08 22:37:29 -08:00
|
|
|
}
|
|
|
|
|
|
2026-02-12 22:56:36 -08:00
|
|
|
// Read from filesystem using layered resolution (overlays first, then base)
|
|
|
|
|
std::string fsPath = resolveLayeredPath(normalized);
|
2026-02-12 20:32:14 -08:00
|
|
|
if (fsPath.empty()) {
|
|
|
|
|
return {};
|
2026-02-11 19:28:15 -08:00
|
|
|
}
|
2026-02-12 20:32:14 -08:00
|
|
|
|
|
|
|
|
auto data = LooseFileReader::readFile(fsPath);
|
2026-02-08 22:37:29 -08:00
|
|
|
if (data.empty()) {
|
2026-02-12 20:32:14 -08:00
|
|
|
LOG_WARNING("Manifest entry exists but file unreadable: ", fsPath);
|
|
|
|
|
return data;
|
2026-02-08 22:37:29 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add to cache if within budget
|
|
|
|
|
size_t fileSize = data.size();
|
2026-02-12 20:32:14 -08:00
|
|
|
if (fileSize > 0 && fileSize < fileCacheBudget / 2) {
|
2026-02-11 19:28:15 -08:00
|
|
|
std::lock_guard<std::mutex> cacheLock(cacheMutex);
|
2026-02-08 22:37:29 -08:00
|
|
|
// Evict old entries if needed (LRU)
|
2026-02-08 23:15:26 -08:00
|
|
|
while (fileCacheTotalBytes + fileSize > fileCacheBudget && !fileCache.empty()) {
|
2026-02-08 22:37:29 -08:00
|
|
|
auto lru = fileCache.begin();
|
|
|
|
|
for (auto it = fileCache.begin(); it != fileCache.end(); ++it) {
|
|
|
|
|
if (it->second.lastAccessTime < lru->second.lastAccessTime) {
|
|
|
|
|
lru = it;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fileCacheTotalBytes -= lru->second.data.size();
|
|
|
|
|
fileCache.erase(lru);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CachedFile cached;
|
|
|
|
|
cached.data = data;
|
|
|
|
|
cached.lastAccessTime = ++fileCacheAccessCounter;
|
|
|
|
|
fileCache[normalized] = std::move(cached);
|
|
|
|
|
fileCacheTotalBytes += fileSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return data;
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
|
2026-02-12 02:27:59 -08:00
|
|
|
std::vector<uint8_t> AssetManager::readFileOptional(const std::string& path) const {
|
|
|
|
|
if (!initialized) {
|
2026-02-12 20:32:14 -08:00
|
|
|
return {};
|
2026-02-12 02:27:59 -08:00
|
|
|
}
|
|
|
|
|
if (!fileExists(path)) {
|
2026-02-12 20:32:14 -08:00
|
|
|
return {};
|
2026-02-12 02:27:59 -08:00
|
|
|
}
|
|
|
|
|
return readFile(path);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-13 16:53:28 -08:00
|
|
|
void AssetManager::clearDBCCache() {
|
|
|
|
|
std::lock_guard<std::mutex> lock(cacheMutex);
|
|
|
|
|
dbcCache.clear();
|
|
|
|
|
LOG_INFO("Cleared DBC cache");
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
void AssetManager::clearCache() {
|
2026-02-12 20:32:14 -08:00
|
|
|
std::lock_guard<std::mutex> lock(cacheMutex);
|
2026-02-02 12:24:50 -08:00
|
|
|
dbcCache.clear();
|
2026-02-08 22:37:29 -08:00
|
|
|
fileCache.clear();
|
|
|
|
|
fileCacheTotalBytes = 0;
|
|
|
|
|
fileCacheAccessCounter = 0;
|
|
|
|
|
LOG_INFO("Cleared asset cache (DBC + file cache)");
|
2026-02-02 12:24:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string AssetManager::normalizePath(const std::string& path) const {
|
|
|
|
|
std::string normalized = path;
|
|
|
|
|
std::replace(normalized.begin(), normalized.end(), '/', '\\');
|
2026-02-11 19:28:15 -08:00
|
|
|
std::transform(normalized.begin(), normalized.end(), normalized.begin(),
|
|
|
|
|
[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
2026-02-02 12:24:50 -08:00
|
|
|
return normalized;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace pipeline
|
|
|
|
|
} // namespace wowee
|