From 8d78b5f8c698a31a363c3eff56428d418dc0f318 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 04:32:28 -0700 Subject: [PATCH] fix(content-pack): unpackZone now creates the zone subdirectory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit packZone stores files relative to the zone subdirectory (e.g. just 'MyZone_32_32.adt'), so unpacking to 'custom_zones/' produced files at 'custom_zones/MyZone_32_32.adt' — without the zone subdir the loader expects. Now reads the info JSON to extract the zone name and unpacks to 'custom_zones//' so imported zones load correctly. --- tools/editor/content_pack.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tools/editor/content_pack.cpp b/tools/editor/content_pack.cpp index 28559693..9ff7a09f 100644 --- a/tools/editor/content_pack.cpp +++ b/tools/editor/content_pack.cpp @@ -108,11 +108,21 @@ bool ContentPacker::unpackZone(const std::string& wcpPath, const std::string& de in.read(reinterpret_cast(&fileCount), 4); in.read(reinterpret_cast(&infoSize), 4); - // Skip info JSON - in.seekg(infoSize, std::ios::cur); + // Read the info JSON to extract the zone name. packZone stored files + // relative to the zone subdirectory (e.g. "MyZone_32_32.adt"), so we + // need to recreate that subdirectory under destDir for the loader to + // find the zone. + std::string infoJson(infoSize, '\0'); + in.read(infoJson.data(), infoSize); + std::string zoneName; + try { + auto info = nlohmann::json::parse(infoJson); + zoneName = info.value("name", ""); + } catch (...) {} namespace fs = std::filesystem; - fs::create_directories(destDir); + std::string zoneDir = zoneName.empty() ? destDir : destDir + "/" + zoneName; + fs::create_directories(zoneDir); for (uint32_t i = 0; i < fileCount; i++) { uint16_t pathLen; @@ -126,13 +136,13 @@ bool ContentPacker::unpackZone(const std::string& wcpPath, const std::string& de std::vector data(dataSize); in.read(data.data(), dataSize); - std::string fullPath = destDir + "/" + path; + std::string fullPath = zoneDir + "/" + path; fs::create_directories(fs::path(fullPath).parent_path()); std::ofstream fout(fullPath, std::ios::binary); fout.write(data.data(), dataSize); } - LOG_INFO("Content pack extracted to: ", destDir, " (", fileCount, " files)"); + LOG_INFO("Content pack extracted to: ", zoneDir, " (", fileCount, " files)"); return true; }