fix(editor): batch convert CLI has visible output and proper exit codes
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

- --convert-m2 and --convert-wmo now print progress and results to
  stdout (was LOG_INFO to log file only, invisible to user)
- Failures return exit code 1 (was always 0, breaking scripting)
- Success output shows vertex/bone counts (M2) or group count (WMO)
- Error messages go to stderr for proper pipe handling
This commit is contained in:
Kelsi 2026-05-05 16:57:06 -07:00
parent 1337a963a0
commit fde1fa8129

View file

@ -62,8 +62,7 @@ int main(int argc, char* argv[]) {
for (int i = 1; i < argc; i++) {
if (std::strcmp(argv[i], "--convert-m2") == 0 && i + 1 < argc) {
std::string m2Path = argv[++i];
LOG_INFO("Batch convert mode: M2→WOM for ", m2Path);
// Need data path for asset loading
std::printf("Converting M2→WOM: %s\n", m2Path.c_str());
if (dataPath.empty()) dataPath = "Data";
wowee::pipeline::AssetManager am;
if (am.initialize(dataPath)) {
@ -73,11 +72,17 @@ int main(int argc, char* argv[]) {
auto dot = outPath.rfind('.');
if (dot != std::string::npos) outPath = outPath.substr(0, dot);
wowee::pipeline::WoweeModelLoader::save(wom, "output/models/" + outPath);
LOG_INFO("Converted: ", m2Path, " → output/models/", outPath, ".wom");
std::printf("OK: output/models/%s.wom (%zu verts, %zu bones)\n",
outPath.c_str(), wom.vertices.size(), wom.bones.size());
} else {
LOG_ERROR("Failed to convert: ", m2Path);
std::fprintf(stderr, "FAILED: %s\n", m2Path.c_str());
am.shutdown();
return 1;
}
am.shutdown();
} else {
std::fprintf(stderr, "FAILED: cannot initialize asset manager\n");
return 1;
}
return 0;
}
@ -87,7 +92,7 @@ int main(int argc, char* argv[]) {
for (int i = 1; i < argc; i++) {
if (std::strcmp(argv[i], "--convert-wmo") == 0 && i + 1 < argc) {
std::string wmoPath = argv[++i];
LOG_INFO("Batch convert mode: WMO→WOB for ", wmoPath);
std::printf("Converting WMO→WOB: %s\n", wmoPath.c_str());
if (dataPath.empty()) dataPath = "Data";
wowee::pipeline::AssetManager am;
if (am.initialize(dataPath)) {
@ -110,14 +115,22 @@ int main(int argc, char* argv[]) {
auto dot = outPath.rfind('.');
if (dot != std::string::npos) outPath = outPath.substr(0, dot);
wowee::pipeline::WoweeBuildingLoader::save(wob, "output/buildings/" + outPath);
LOG_INFO("Converted: ", wmoPath, " → output/buildings/", outPath, ".wob");
std::printf("OK: output/buildings/%s.wob (%zu groups)\n",
outPath.c_str(), wob.groups.size());
} else {
LOG_ERROR("Failed to convert: ", wmoPath);
std::fprintf(stderr, "FAILED: %s\n", wmoPath.c_str());
am.shutdown();
return 1;
}
} else {
LOG_ERROR("WMO file not found: ", wmoPath);
std::fprintf(stderr, "FAILED: file not found: %s\n", wmoPath.c_str());
am.shutdown();
return 1;
}
am.shutdown();
} else {
std::fprintf(stderr, "FAILED: cannot initialize asset manager\n");
return 1;
}
return 0;
}