From 1995ed9824d55c499b3dda3adff5cb887b179ca2 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 10:43:13 -0700 Subject: [PATCH] feat(runtime): pick up JSON DBC sidecars from --emit-json-dbc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AssetManager::loadDBC now probes for a .json sidecar in the same directory as the binary DBC the manifest resolves to. asset_extract --emit-json-dbc writes that sidecar on extraction, so the runtime client transparently falls back to it when the binary DBC is absent (e.g. open-format-only extraction for end-to-end format testing). Order: binary DBC > JSON sidecar > custom_zones JSON > CSV > error. Servers (AzerothCore/TrinityCore) only read the binary DBC, so this change is invisible to them — the wowee runtime is the only consumer that tries the JSON path. The PNG sidecar pickup (tryLoadPngOverride) was already in place from prior work — this completes the symmetric runtime-side wiring for both BLP→PNG and DBC→JSON open-format outputs. --- src/pipeline/asset_manager.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/pipeline/asset_manager.cpp b/src/pipeline/asset_manager.cpp index 95e90370..d3cdef8e 100644 --- a/src/pipeline/asset_manager.cpp +++ b/src/pipeline/asset_manager.cpp @@ -304,12 +304,37 @@ std::shared_ptr AssetManager::loadDBC(const std::string& name) { std::vector dbcData; - // Try binary DBC from extracted MPQs first (preferred source) + // Try binary DBC from extracted MPQs first (preferred source). + std::string dbcPath = "DBFilesClient\\" + name; { - std::string dbcPath = "DBFilesClient\\" + name; dbcData = readFile(dbcPath); } + // If asset_extract was run with --emit-json-dbc, the DBC's directory + // also contains a JSON sidecar. Use it when the binary is missing + // (lets users run with PNG/JSON-only extractions for testing the + // open-format end-to-end path). Server-mode never reads via this + // code path, so private-server compat is unaffected. + if (dbcData.empty()) { + std::string normalizedDbc = normalizePath(dbcPath); + std::string fsPath = resolveFile(normalizedDbc); + if (!fsPath.empty() && fsPath.size() >= 4) { + std::string sidecar = fsPath.substr(0, fsPath.size() - 4) + ".json"; + if (std::filesystem::exists(sidecar)) { + std::ifstream jf(sidecar, std::ios::binary | std::ios::ate); + if (jf) { + auto sz = jf.tellg(); + if (sz > 0) { + dbcData.resize(static_cast(sz)); + jf.seekg(0); + jf.read(reinterpret_cast(dbcData.data()), sz); + LOG_INFO("Loading JSON DBC sidecar: ", sidecar); + } + } + } + } + } + // Try Data/db/ directory (pre-extracted binary DBCs shared across expansions) if (dbcData.empty()) { // dataPath is expansion-specific (e.g. Data/expansions/wotlk/); go up to Data/