mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-10 19:13:52 +00:00
57th open format — replaces LFGDungeons.dbc plus the AzerothCore-style dungeon-finder reward tables. Defines the dungeons / raids that the Dungeon Finder / Raid Browser presents to players, with their level brackets, group-size requirements, role requirements (tank / heal / DPS), and queue-completion rewards. 4 difficulty levels (Normal / Heroic / Mythic / Hardmode — the latter for Ulduar-style toggleable boss difficulty), 4 expansion gates (Classic / TBC / WotLK / TurtleWoW), and 3 role-requirement bits (Tank / Heal / DPS — typically all three for queue-formed groups). Cross-references with prior formats — mapId points at WMS.mapId (the instance map), queueRewardItemId points at WIT.itemId (the random reward bag), firstClearAchievement points at WACH.achievementId. CLI: --gen-lfg (3 classic 5-mans Ragefire/Wailing/Deadmines with real WoW mapIds + level brackets), --gen-lfg-heroic (5 WotLK 80-level heroic 5-mans with emblem rewards + real first-clear achievement IDs from Halls of Lightning through Old Kingdom), --gen-lfg-raid (3 raid entries — Naxx-25, Ulduar-25 Hardmode, ToC-25 Mythic), --info-wlfg, --validate-wlfg with --json variants. Validator catches id+name+mapId required, difficulty 0..3, expansion 0..3, minLevel<=maxLevel, recommended-level outside range warning, unusual groupSize warning (5/10/25/40 are canonical), and zero role mask (queue can't form a balanced group). Format graph: 56 → 57 binary formats. CLI flag count: 804 → 811.
259 lines
9.5 KiB
C++
259 lines
9.5 KiB
C++
#include "cli_lfg_catalog.hpp"
|
|
#include "cli_arg_parse.hpp"
|
|
#include "cli_box_emitter.hpp"
|
|
|
|
#include "pipeline/wowee_lfg.hpp"
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include <cstdint>
|
|
#include <cstdio>
|
|
#include <cstring>
|
|
#include <fstream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace wowee {
|
|
namespace editor {
|
|
namespace cli {
|
|
|
|
namespace {
|
|
|
|
std::string stripWlfgExt(std::string base) {
|
|
stripExt(base, ".wlfg");
|
|
return base;
|
|
}
|
|
|
|
bool saveOrError(const wowee::pipeline::WoweeLFGDungeon& c,
|
|
const std::string& base, const char* cmd) {
|
|
if (!wowee::pipeline::WoweeLFGDungeonLoader::save(c, base)) {
|
|
std::fprintf(stderr, "%s: failed to save %s.wlfg\n",
|
|
cmd, base.c_str());
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void printGenSummary(const wowee::pipeline::WoweeLFGDungeon& c,
|
|
const std::string& base) {
|
|
std::printf("Wrote %s.wlfg\n", base.c_str());
|
|
std::printf(" catalog : %s\n", c.name.c_str());
|
|
std::printf(" dungeons : %zu\n", c.entries.size());
|
|
}
|
|
|
|
int handleGenStarter(int& i, int argc, char** argv) {
|
|
std::string base = argv[++i];
|
|
std::string name = "StarterLFG";
|
|
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
|
base = stripWlfgExt(base);
|
|
auto c = wowee::pipeline::WoweeLFGDungeonLoader::makeStarter(name);
|
|
if (!saveOrError(c, base, "gen-lfg")) return 1;
|
|
printGenSummary(c, base);
|
|
return 0;
|
|
}
|
|
|
|
int handleGenHeroic(int& i, int argc, char** argv) {
|
|
std::string base = argv[++i];
|
|
std::string name = "HeroicLFG";
|
|
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
|
base = stripWlfgExt(base);
|
|
auto c = wowee::pipeline::WoweeLFGDungeonLoader::makeHeroic(name);
|
|
if (!saveOrError(c, base, "gen-lfg-heroic")) return 1;
|
|
printGenSummary(c, base);
|
|
return 0;
|
|
}
|
|
|
|
int handleGenRaid(int& i, int argc, char** argv) {
|
|
std::string base = argv[++i];
|
|
std::string name = "RaidLFG";
|
|
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
|
base = stripWlfgExt(base);
|
|
auto c = wowee::pipeline::WoweeLFGDungeonLoader::makeRaid(name);
|
|
if (!saveOrError(c, base, "gen-lfg-raid")) return 1;
|
|
printGenSummary(c, base);
|
|
return 0;
|
|
}
|
|
|
|
int handleInfo(int& i, int argc, char** argv) {
|
|
std::string base = argv[++i];
|
|
bool jsonOut = consumeJsonFlag(i, argc, argv);
|
|
base = stripWlfgExt(base);
|
|
if (!wowee::pipeline::WoweeLFGDungeonLoader::exists(base)) {
|
|
std::fprintf(stderr, "WLFG not found: %s.wlfg\n", base.c_str());
|
|
return 1;
|
|
}
|
|
auto c = wowee::pipeline::WoweeLFGDungeonLoader::load(base);
|
|
if (jsonOut) {
|
|
nlohmann::json j;
|
|
j["wlfg"] = base + ".wlfg";
|
|
j["name"] = c.name;
|
|
j["count"] = c.entries.size();
|
|
nlohmann::json arr = nlohmann::json::array();
|
|
for (const auto& e : c.entries) {
|
|
arr.push_back({
|
|
{"dungeonId", e.dungeonId},
|
|
{"name", e.name},
|
|
{"description", e.description},
|
|
{"mapId", e.mapId},
|
|
{"minLevel", e.minLevel},
|
|
{"maxLevel", e.maxLevel},
|
|
{"recommendedLevel", e.recommendedLevel},
|
|
{"minGearLevel", e.minGearLevel},
|
|
{"difficulty", e.difficulty},
|
|
{"difficultyName", wowee::pipeline::WoweeLFGDungeon::difficultyName(e.difficulty)},
|
|
{"groupSize", e.groupSize},
|
|
{"requiredRolesMask", e.requiredRolesMask},
|
|
{"expansionRequired", e.expansionRequired},
|
|
{"expansionRequiredName", wowee::pipeline::WoweeLFGDungeon::expansionRequiredName(e.expansionRequired)},
|
|
{"queueRewardItemId", e.queueRewardItemId},
|
|
{"queueRewardEmblemCount", e.queueRewardEmblemCount},
|
|
{"firstClearAchievement", e.firstClearAchievement},
|
|
});
|
|
}
|
|
j["entries"] = arr;
|
|
std::printf("%s\n", j.dump(2).c_str());
|
|
return 0;
|
|
}
|
|
std::printf("WLFG: %s.wlfg\n", base.c_str());
|
|
std::printf(" catalog : %s\n", c.name.c_str());
|
|
std::printf(" dungeons : %zu\n", c.entries.size());
|
|
if (c.entries.empty()) return 0;
|
|
std::printf(" id map levels ilvl diff group roles exp emblem ach name\n");
|
|
for (const auto& e : c.entries) {
|
|
std::printf(" %4u %4u %3u-%3u %3u %-9s %3u 0x%02x %-7s %3u %5u %s\n",
|
|
e.dungeonId, e.mapId,
|
|
e.minLevel, e.maxLevel, e.minGearLevel,
|
|
wowee::pipeline::WoweeLFGDungeon::difficultyName(e.difficulty),
|
|
e.groupSize, e.requiredRolesMask,
|
|
wowee::pipeline::WoweeLFGDungeon::expansionRequiredName(e.expansionRequired),
|
|
e.queueRewardEmblemCount,
|
|
e.firstClearAchievement,
|
|
e.name.c_str());
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int handleValidate(int& i, int argc, char** argv) {
|
|
std::string base = argv[++i];
|
|
bool jsonOut = consumeJsonFlag(i, argc, argv);
|
|
base = stripWlfgExt(base);
|
|
if (!wowee::pipeline::WoweeLFGDungeonLoader::exists(base)) {
|
|
std::fprintf(stderr,
|
|
"validate-wlfg: WLFG not found: %s.wlfg\n", base.c_str());
|
|
return 1;
|
|
}
|
|
auto c = wowee::pipeline::WoweeLFGDungeonLoader::load(base);
|
|
std::vector<std::string> errors;
|
|
std::vector<std::string> warnings;
|
|
if (c.entries.empty()) {
|
|
warnings.push_back("catalog has zero entries");
|
|
}
|
|
std::vector<uint32_t> idsSeen;
|
|
for (size_t k = 0; k < c.entries.size(); ++k) {
|
|
const auto& e = c.entries[k];
|
|
std::string ctx = "entry " + std::to_string(k) +
|
|
" (id=" + std::to_string(e.dungeonId);
|
|
if (!e.name.empty()) ctx += " " + e.name;
|
|
ctx += ")";
|
|
if (e.dungeonId == 0)
|
|
errors.push_back(ctx + ": dungeonId is 0");
|
|
if (e.name.empty())
|
|
errors.push_back(ctx + ": name is empty");
|
|
if (e.mapId == 0)
|
|
errors.push_back(ctx +
|
|
": mapId is 0 (dungeon has no instance map)");
|
|
if (e.difficulty > wowee::pipeline::WoweeLFGDungeon::Hardmode) {
|
|
errors.push_back(ctx + ": difficulty " +
|
|
std::to_string(e.difficulty) + " not in 0..3");
|
|
}
|
|
if (e.expansionRequired > wowee::pipeline::WoweeLFGDungeon::TurtleWoW) {
|
|
errors.push_back(ctx + ": expansionRequired " +
|
|
std::to_string(e.expansionRequired) + " not in 0..3");
|
|
}
|
|
if (e.minLevel > e.maxLevel) {
|
|
errors.push_back(ctx + ": minLevel " +
|
|
std::to_string(e.minLevel) + " > maxLevel " +
|
|
std::to_string(e.maxLevel));
|
|
}
|
|
if (e.recommendedLevel != 0 &&
|
|
(e.recommendedLevel < e.minLevel ||
|
|
e.recommendedLevel > e.maxLevel)) {
|
|
warnings.push_back(ctx + ": recommendedLevel " +
|
|
std::to_string(e.recommendedLevel) +
|
|
" outside [" + std::to_string(e.minLevel) +
|
|
", " + std::to_string(e.maxLevel) + "]");
|
|
}
|
|
// Common group sizes: 5 (dungeon), 10/25 (raid),
|
|
// 40 (vanilla raid). Other values are unusual but
|
|
// not technically wrong.
|
|
if (e.groupSize != 5 && e.groupSize != 10 &&
|
|
e.groupSize != 25 && e.groupSize != 40) {
|
|
warnings.push_back(ctx + ": groupSize " +
|
|
std::to_string(e.groupSize) +
|
|
" is unusual (5 / 10 / 25 / 40 are canonical)");
|
|
}
|
|
if (e.requiredRolesMask == 0) {
|
|
errors.push_back(ctx +
|
|
": requiredRolesMask=0 (no role requirement — "
|
|
"queue won't form a balanced group)");
|
|
}
|
|
for (uint32_t prev : idsSeen) {
|
|
if (prev == e.dungeonId) {
|
|
errors.push_back(ctx + ": duplicate dungeonId");
|
|
break;
|
|
}
|
|
}
|
|
idsSeen.push_back(e.dungeonId);
|
|
}
|
|
bool ok = errors.empty();
|
|
if (jsonOut) {
|
|
nlohmann::json j;
|
|
j["wlfg"] = base + ".wlfg";
|
|
j["ok"] = ok;
|
|
j["errors"] = errors;
|
|
j["warnings"] = warnings;
|
|
std::printf("%s\n", j.dump(2).c_str());
|
|
return ok ? 0 : 1;
|
|
}
|
|
std::printf("validate-wlfg: %s.wlfg\n", base.c_str());
|
|
if (ok && warnings.empty()) {
|
|
std::printf(" OK — %zu dungeons, all dungeonIds unique, all level ranges valid\n",
|
|
c.entries.size());
|
|
return 0;
|
|
}
|
|
if (!warnings.empty()) {
|
|
std::printf(" warnings (%zu):\n", warnings.size());
|
|
for (const auto& w : warnings)
|
|
std::printf(" - %s\n", w.c_str());
|
|
}
|
|
if (!errors.empty()) {
|
|
std::printf(" ERRORS (%zu):\n", errors.size());
|
|
for (const auto& e : errors)
|
|
std::printf(" - %s\n", e.c_str());
|
|
}
|
|
return ok ? 0 : 1;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
bool handleLFGCatalog(int& i, int argc, char** argv, int& outRc) {
|
|
if (std::strcmp(argv[i], "--gen-lfg") == 0 && i + 1 < argc) {
|
|
outRc = handleGenStarter(i, argc, argv); return true;
|
|
}
|
|
if (std::strcmp(argv[i], "--gen-lfg-heroic") == 0 && i + 1 < argc) {
|
|
outRc = handleGenHeroic(i, argc, argv); return true;
|
|
}
|
|
if (std::strcmp(argv[i], "--gen-lfg-raid") == 0 && i + 1 < argc) {
|
|
outRc = handleGenRaid(i, argc, argv); return true;
|
|
}
|
|
if (std::strcmp(argv[i], "--info-wlfg") == 0 && i + 1 < argc) {
|
|
outRc = handleInfo(i, argc, argv); return true;
|
|
}
|
|
if (std::strcmp(argv[i], "--validate-wlfg") == 0 && i + 1 < argc) {
|
|
outRc = handleValidate(i, argc, argv); return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
} // namespace cli
|
|
} // namespace editor
|
|
} // namespace wowee
|