Kelsidavis-WoWee/tools/asset_extract/extractor.hpp
Kelsi Davis 2343b768ce
Some checks are pending
Build / Build (arm64) (push) Waiting to run
Build / Build (x86-64) (push) Waiting to run
Build / Build (macOS arm64) (push) Waiting to run
Build / Build (windows-arm64) (push) Waiting to run
Build / Build (windows-x86-64) (push) Waiting to run
Security / CodeQL (C/C++) (push) Waiting to run
Security / Semgrep (push) Waiting to run
Security / Sanitizer Build (ASan/UBSan) (push) Waiting to run
fix: warden mmap on macOS, add external listfile support to asset extractor
Drop PROT_EXEC from warden module mmap when using Unicorn emulation
(not needed — module image is copied into emulator address space). Use
MAP_JIT on macOS for the native fallback path.

Add --listfile option to asset_extract and SFileAddListFileEntries
support for resolving unnamed MPQ hash table entries from external
listfiles.
2026-04-04 01:16:28 -07:00

63 lines
2.3 KiB
C++

#pragma once
#include <string>
#include <vector>
#include <atomic>
#include <cstdint>
namespace wowee {
namespace tools {
/**
* Extraction pipeline: MPQ archives → loose files + manifest
*/
class Extractor {
public:
struct Options {
std::string mpqDir; // Path to WoW Data directory
std::string outputDir; // Output directory for extracted assets
std::string expansion; // "classic", "tbc", "wotlk", or "" for auto-detect
std::string locale; // "enUS", "deDE", etc., or "" for auto-detect
int threads = 0; // 0 = auto-detect
bool verify = false; // CRC32 verify after extraction
bool verbose = false; // Verbose logging
bool generateDbcCsv = false; // Convert selected DBFilesClient/*.dbc to CSV for committing
bool skipDbcExtraction = false; // Extract visual assets only (recommended when CSV DBCs are in repo)
bool onlyUsedDbcs = false; // Extract only the DBC files wowee uses (implies DBFilesClient/*.dbc filter)
std::string dbcCsvOutputDir; // When set, write CSVs into this directory instead of outputDir/expansions/<exp>/db
std::string referenceManifest; // If set, only extract files NOT in this manifest (delta extraction)
std::string listFile; // External listfile for MPQ enumeration (resolves unnamed hash entries)
};
struct Stats {
std::atomic<uint64_t> filesExtracted{0};
std::atomic<uint64_t> bytesExtracted{0};
std::atomic<uint64_t> filesSkipped{0};
std::atomic<uint64_t> filesFailed{0};
};
/**
* Auto-detect expansion from files in mpqDir.
* @return "classic", "tbc", "wotlk", or "" if unknown
*/
static std::string detectExpansion(const std::string& mpqDir);
/**
* Auto-detect locale by scanning for locale subdirectories.
* @return locale string like "enUS", or "" if none found
*/
static std::string detectLocale(const std::string& mpqDir);
/**
* Run the extraction pipeline
* @return true on success
*/
static bool run(const Options& opts);
private:
static bool enumerateFiles(const Options& opts,
std::vector<std::string>& outFiles);
};
} // namespace tools
} // namespace wowee