diff --git a/CMakeLists.txt b/CMakeLists.txt index bb3ad938..377502ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -722,6 +722,7 @@ set(WOWEE_SOURCES src/pipeline/wowee_guild_bank.cpp src/pipeline/wowee_quest_graph.cpp src/pipeline/wowee_crafting_recipes.cpp + src/pipeline/wowee_world_locations.cpp src/pipeline/custom_zone_discovery.cpp src/pipeline/dbc_layout.cpp @@ -1607,6 +1608,7 @@ add_executable(wowee_editor tools/editor/cli_guild_bank_catalog.cpp tools/editor/cli_quest_graph_catalog.cpp tools/editor/cli_crafting_recipes_catalog.cpp + tools/editor/cli_world_locations_catalog.cpp tools/editor/cli_catalog_pluck.cpp tools/editor/cli_catalog_find.cpp tools/editor/cli_catalog_by_name.cpp @@ -1811,6 +1813,7 @@ add_executable(wowee_editor src/pipeline/wowee_guild_bank.cpp src/pipeline/wowee_quest_graph.cpp src/pipeline/wowee_crafting_recipes.cpp + src/pipeline/wowee_world_locations.cpp src/pipeline/custom_zone_discovery.cpp src/pipeline/terrain_mesh.cpp diff --git a/include/pipeline/wowee_world_locations.hpp b/include/pipeline/wowee_world_locations.hpp new file mode 100644 index 00000000..19ec9062 --- /dev/null +++ b/include/pipeline/wowee_world_locations.hpp @@ -0,0 +1,156 @@ +#pragma once + +#include +#include +#include + +namespace wowee { +namespace pipeline { + +// Wowee Open World Locations catalog (.wloc) — +// novel unified replacement for the half-dozen +// proprietary location tables vanilla WoW +// scattered across AreaPOI.dbc (zone-discovery +// landmarks), gameobject_template.spawn rows +// (herb/mineral/fishing nodes), creature_template +// rare-spawn entries, and AreaTrigger.dbc (zone +// boundary teleports). Each WLOC entry binds one +// world coord (mapId, x, y, z) to its kind (POI / +// RareSpawn / HerbNode / MineralVein / FishingSpot +// / AreaTrigger / PortalLanding), respawn timer, +// gathering-skill gate, and on-discovery XP. +// +// Cross-references with previously-added formats: +// WMS: mapId references the WMS map catalog. +// WSKL: requiredSkillId references the WSKL +// skill catalog (Herbalism=182, +// Mining=186, Fishing=356). +// WPRT: PortalLanding-kind locations are +// referenced as destination coords by +// WPRT mage portal entries. +// +// Binary layout (little-endian): +// magic[4] = "WLOC" +// version (uint32) = current 1 +// nameLen + name (catalog label) +// entryCount (uint32) +// entries (each): +// locationId (uint32) +// nameLen + name +// mapId (uint32) +// areaId (uint32) +// x (float) +// y (float) +// z (float) +// locKind (uint8) — 0=POI / +// 1=RareSpawn / +// 2=HerbNode / +// 3=MineralVein / +// 4=FishingSpot / +// 5=AreaTrigger / +// 6=PortalLanding +// iconIndex (uint8) +// factionAccess (uint8) — 0=Both / +// 1=Alliance / +// 2=Horde / +// 3=Neutral +// pad0 (uint8) +// respawnSec (uint32) — 0 = static +// (POI / Trigger / +// Portal land) +// discoverableXp (uint32) — XP on first +// discovery (POI +// only) +// requiredSkillId (uint16) — 0 if not gather- +// gated +// requiredSkillLevel (uint16) — gathering skill +// minimum +struct WoweeWorldLocations { + enum LocKind : uint8_t { + POI = 0, + RareSpawn = 1, + HerbNode = 2, + MineralVein = 3, + FishingSpot = 4, + AreaTrigger = 5, + PortalLanding = 6, + }; + + enum FactionAccess : uint8_t { + Both = 0, + Alliance = 1, + Horde = 2, + Neutral = 3, + }; + + struct Entry { + uint32_t locationId = 0; + std::string name; + uint32_t mapId = 0; + uint32_t areaId = 0; + float x = 0.f; + float y = 0.f; + float z = 0.f; + uint8_t locKind = POI; + uint8_t iconIndex = 0; + uint8_t factionAccess = Both; + uint8_t pad0 = 0; + uint32_t respawnSec = 0; + uint32_t discoverableXp = 0; + uint16_t requiredSkillId = 0; + uint16_t requiredSkillLevel = 0; + }; + + std::string name; + std::vector entries; + + bool isValid() const { return !entries.empty(); } + + const Entry* findById(uint32_t locationId) const; + + // Returns all locations on a map (used by the + // world-map UI to populate per-map markers). + std::vector findByMap(uint32_t mapId) const; + + // Returns all locations of a single kind on a + // map. Used by the herbalism-tracking UI to + // show only HerbNode markers without polluting + // with POIs. + std::vector findByMapAndKind(uint32_t mapId, + uint8_t kind) const; +}; + +class WoweeWorldLocationsLoader { +public: + static bool save(const WoweeWorldLocations& cat, + const std::string& basePath); + static WoweeWorldLocations load(const std::string& basePath); + static bool exists(const std::string& basePath); + + // Preset emitters used by --gen-loc* variants. + // + // makeAlliancePOIs — 4 Alliance POIs + // (Stormwind / Ironforge + // / Goldshire / Sentinel + // Hill) with discoverable + // XP and POI-kind iconry. + // makeHerbalismNodes — 5 herb nodes (Peacebloom + // / Silverleaf / + // Briarthorn / Mageroyal + // / Stranglekelp) with + // required Herbalism skill + // 1..125 + 600s (10min) + // respawn. + // makeRareSpawns — 4 vanilla rare-elites + // (Mor'Ladim / Princess + // Tempestria / Foreman + // Rigger / Lord Sakrasis) + // with 1800..7200s (30- + // 120min) respawn. + static WoweeWorldLocations makeAlliancePOIs(const std::string& catalogName); + static WoweeWorldLocations makeHerbalismNodes(const std::string& catalogName); + static WoweeWorldLocations makeRareSpawns(const std::string& catalogName); +}; + +} // namespace pipeline +} // namespace wowee diff --git a/src/pipeline/wowee_world_locations.cpp b/src/pipeline/wowee_world_locations.cpp new file mode 100644 index 00000000..8e0f4e2f --- /dev/null +++ b/src/pipeline/wowee_world_locations.cpp @@ -0,0 +1,295 @@ +#include "pipeline/wowee_world_locations.hpp" + +#include +#include +#include + +namespace wowee { +namespace pipeline { + +namespace { + +constexpr char kMagic[4] = {'W', 'L', 'O', 'C'}; +constexpr uint32_t kVersion = 1; + +template +void writePOD(std::ofstream& os, const T& v) { + os.write(reinterpret_cast(&v), sizeof(T)); +} + +template +bool readPOD(std::ifstream& is, T& v) { + is.read(reinterpret_cast(&v), sizeof(T)); + return is.gcount() == static_cast(sizeof(T)); +} + +void writeStr(std::ofstream& os, const std::string& s) { + uint32_t n = static_cast(s.size()); + writePOD(os, n); + if (n > 0) os.write(s.data(), n); +} + +bool readStr(std::ifstream& is, std::string& s) { + uint32_t n = 0; + if (!readPOD(is, n)) return false; + if (n > (1u << 20)) return false; + s.resize(n); + if (n > 0) { + is.read(s.data(), n); + if (is.gcount() != static_cast(n)) { + s.clear(); + return false; + } + } + return true; +} + +std::string normalizePath(std::string base) { + if (base.size() < 5 || base.substr(base.size() - 5) != ".wloc") { + base += ".wloc"; + } + return base; +} + +} // namespace + +const WoweeWorldLocations::Entry* +WoweeWorldLocations::findById(uint32_t locationId) const { + for (const auto& e : entries) + if (e.locationId == locationId) return &e; + return nullptr; +} + +std::vector +WoweeWorldLocations::findByMap(uint32_t mapId) const { + std::vector out; + for (const auto& e : entries) + if (e.mapId == mapId) out.push_back(&e); + return out; +} + +std::vector +WoweeWorldLocations::findByMapAndKind(uint32_t mapId, + uint8_t kind) const { + std::vector out; + for (const auto& e : entries) + if (e.mapId == mapId && e.locKind == kind) + out.push_back(&e); + return out; +} + +bool WoweeWorldLocationsLoader::save( + const WoweeWorldLocations& cat, + const std::string& basePath) { + std::ofstream os(normalizePath(basePath), std::ios::binary); + if (!os) return false; + os.write(kMagic, 4); + writePOD(os, kVersion); + writeStr(os, cat.name); + uint32_t entryCount = static_cast(cat.entries.size()); + writePOD(os, entryCount); + for (const auto& e : cat.entries) { + writePOD(os, e.locationId); + writeStr(os, e.name); + writePOD(os, e.mapId); + writePOD(os, e.areaId); + writePOD(os, e.x); + writePOD(os, e.y); + writePOD(os, e.z); + writePOD(os, e.locKind); + writePOD(os, e.iconIndex); + writePOD(os, e.factionAccess); + writePOD(os, e.pad0); + writePOD(os, e.respawnSec); + writePOD(os, e.discoverableXp); + writePOD(os, e.requiredSkillId); + writePOD(os, e.requiredSkillLevel); + } + return os.good(); +} + +WoweeWorldLocations WoweeWorldLocationsLoader::load( + const std::string& basePath) { + WoweeWorldLocations out; + std::ifstream is(normalizePath(basePath), std::ios::binary); + if (!is) return out; + char magic[4]; + is.read(magic, 4); + if (std::memcmp(magic, kMagic, 4) != 0) return out; + uint32_t version = 0; + if (!readPOD(is, version) || version != kVersion) return out; + if (!readStr(is, out.name)) return out; + uint32_t entryCount = 0; + if (!readPOD(is, entryCount)) return out; + if (entryCount > (1u << 20)) return out; + out.entries.resize(entryCount); + for (auto& e : out.entries) { + if (!readPOD(is, e.locationId)) { + out.entries.clear(); return out; + } + if (!readStr(is, e.name)) { + out.entries.clear(); return out; + } + if (!readPOD(is, e.mapId) || + !readPOD(is, e.areaId) || + !readPOD(is, e.x) || + !readPOD(is, e.y) || + !readPOD(is, e.z) || + !readPOD(is, e.locKind) || + !readPOD(is, e.iconIndex) || + !readPOD(is, e.factionAccess) || + !readPOD(is, e.pad0) || + !readPOD(is, e.respawnSec) || + !readPOD(is, e.discoverableXp) || + !readPOD(is, e.requiredSkillId) || + !readPOD(is, e.requiredSkillLevel)) { + out.entries.clear(); return out; + } + } + return out; +} + +bool WoweeWorldLocationsLoader::exists( + const std::string& basePath) { + std::ifstream is(normalizePath(basePath), std::ios::binary); + return is.good(); +} + +namespace { + +WoweeWorldLocations::Entry makeLoc(uint32_t locationId, + const char* name, + uint32_t mapId, + uint32_t areaId, + float x, float y, float z, + uint8_t locKind, + uint8_t iconIndex, + uint8_t factionAccess, + uint32_t respawnSec, + uint32_t discoverableXp, + uint16_t requiredSkillId, + uint16_t requiredSkillLevel) { + WoweeWorldLocations::Entry e; + e.locationId = locationId; e.name = name; + e.mapId = mapId; e.areaId = areaId; + e.x = x; e.y = y; e.z = z; + e.locKind = locKind; + e.iconIndex = iconIndex; + e.factionAccess = factionAccess; + e.respawnSec = respawnSec; + e.discoverableXp = discoverableXp; + e.requiredSkillId = requiredSkillId; + e.requiredSkillLevel = requiredSkillLevel; + return e; +} + +} // namespace + +WoweeWorldLocations WoweeWorldLocationsLoader::makeAlliancePOIs( + const std::string& catalogName) { + using L = WoweeWorldLocations; + WoweeWorldLocations c; + c.name = catalogName; + // Stormwind: areaId 1519, Eastern Kingdoms map=0. + c.entries.push_back(makeLoc( + 1, "Stormwind City", 0, 1519, + -8836.f, 626.f, 94.f, + L::POI, 12, L::Alliance, + 0, 100, 0, 0)); + // Ironforge: areaId 1537. + c.entries.push_back(makeLoc( + 2, "Ironforge", 0, 1537, + -4925.f, -956.f, 502.f, + L::POI, 12, L::Alliance, + 0, 100, 0, 0)); + // Goldshire: areaId 87, lower XP (small village). + c.entries.push_back(makeLoc( + 3, "Goldshire", 0, 87, + -9460.f, 53.f, 56.f, + L::POI, 12, L::Alliance, + 0, 50, 0, 0)); + // Sentinel Hill: Westfall area 957. + c.entries.push_back(makeLoc( + 4, "Sentinel Hill", 0, 957, + -10620.f, 1067.f, 53.f, + L::POI, 12, L::Alliance, + 0, 80, 0, 0)); + return c; +} + +WoweeWorldLocations WoweeWorldLocationsLoader::makeHerbalismNodes( + const std::string& catalogName) { + using L = WoweeWorldLocations; + WoweeWorldLocations c; + c.name = catalogName; + // Peacebloom: skill 1 (lowest), Elwynn area=12. + // 600s respawn typical for herb nodes. + c.entries.push_back(makeLoc( + 100, "Peacebloom Patch", 0, 12, + -9020.f, 130.f, 75.f, + L::HerbNode, 5, L::Both, + 600, 0, 182 /* Herbalism */, 1)); + // Silverleaf: skill 1, same zone. + c.entries.push_back(makeLoc( + 101, "Silverleaf Patch", 0, 12, + -8860.f, 200.f, 78.f, + L::HerbNode, 5, L::Both, + 600, 0, 182, 1)); + // Briarthorn: skill 70, Westfall area=40. + c.entries.push_back(makeLoc( + 102, "Briarthorn Bush", 0, 40, + -10510.f, 950.f, 50.f, + L::HerbNode, 5, L::Both, + 600, 0, 182, 70)); + // Mageroyal: skill 50, Westfall. + c.entries.push_back(makeLoc( + 103, "Mageroyal Patch", 0, 40, + -10780.f, 1130.f, 51.f, + L::HerbNode, 5, L::Both, + 600, 0, 182, 50)); + // Stranglekelp: skill 85, fishing-coast in + // Westfall. + c.entries.push_back(makeLoc( + 104, "Stranglekelp Cluster", 0, 40, + -11050.f, 1700.f, 4.f, + L::HerbNode, 5, L::Both, + 600, 0, 182, 85)); + return c; +} + +WoweeWorldLocations WoweeWorldLocationsLoader::makeRareSpawns( + const std::string& catalogName) { + using L = WoweeWorldLocations; + WoweeWorldLocations c; + c.name = catalogName; + // Mor'Ladim: Duskwood (area=10), 30..120min spawn + // (1800..7200s; using 3600 = 1hr midpoint). + c.entries.push_back(makeLoc( + 200, "Mor'Ladim", 0, 10, + -10770.f, -1700.f, 50.f, + L::RareSpawn, 6, L::Both, + 3600, 0, 0, 0)); + // Princess Tempestria: Winterspring elemental + // rare (area=618), Kalimdor map=1. + c.entries.push_back(makeLoc( + 201, "Princess Tempestria", 1, 618, + 6020.f, -4450.f, 800.f, + L::RareSpawn, 6, L::Both, + 7200, 0, 0, 0)); + // Foreman Rigger: Stranglethorn (area=33). + c.entries.push_back(makeLoc( + 202, "Foreman Rigger", 0, 33, + -13620.f, 870.f, 44.f, + L::RareSpawn, 6, L::Both, + 1800, 0, 0, 0)); + // Lord Sakrasis: STV satyr camp. + c.entries.push_back(makeLoc( + 203, "Lord Sakrasis", 0, 33, + -12230.f, 90.f, 9.f, + L::RareSpawn, 6, L::Both, + 3600, 0, 0, 0)); + return c; +} + +} // namespace pipeline +} // namespace wowee diff --git a/tools/editor/cli_arg_required.cpp b/tools/editor/cli_arg_required.cpp index 1a11de78..786d2df2 100644 --- a/tools/editor/cli_arg_required.cpp +++ b/tools/editor/cli_arg_required.cpp @@ -410,6 +410,8 @@ const char* const kArgRequired[] = { "--gen-cra-alchemy", "--gen-cra-engineering", "--gen-cra-blacksmithing", "--info-wcra", "--validate-wcra", "--export-wcra-json", "--import-wcra-json", + "--gen-loc-poi", "--gen-loc-herb", "--gen-loc-rare", + "--info-wloc", "--validate-wloc", "--gen-weather-temperate", "--gen-weather-arctic", "--gen-weather-desert", "--gen-weather-stormy", "--gen-zone-atmosphere", diff --git a/tools/editor/cli_dispatch.cpp b/tools/editor/cli_dispatch.cpp index e696b8b4..b12222ef 100644 --- a/tools/editor/cli_dispatch.cpp +++ b/tools/editor/cli_dispatch.cpp @@ -178,6 +178,7 @@ #include "cli_guild_bank_catalog.hpp" #include "cli_quest_graph_catalog.hpp" #include "cli_crafting_recipes_catalog.hpp" +#include "cli_world_locations_catalog.hpp" #include "cli_catalog_pluck.hpp" #include "cli_catalog_find.hpp" #include "cli_catalog_by_name.hpp" @@ -401,6 +402,7 @@ constexpr DispatchFn kDispatchTable[] = { handleGuildBankCatalog, handleQuestGraphCatalog, handleCraftingRecipesCatalog, + handleWorldLocationsCatalog, handleCatalogPluck, handleCatalogFind, handleCatalogByName, diff --git a/tools/editor/cli_format_table.cpp b/tools/editor/cli_format_table.cpp index cbf0f4a5..21622a70 100644 --- a/tools/editor/cli_format_table.cpp +++ b/tools/editor/cli_format_table.cpp @@ -136,6 +136,7 @@ constexpr FormatMagicEntry kFormats[] = { {{'W','G','B','K'}, ".wgbk", "guild", "--info-wgbk", "Guild bank tabs catalog"}, {{'W','Q','G','R'}, ".wqgr", "quests", "--info-wqgr", "Quest graph catalog"}, {{'W','C','R','A'}, ".wcra", "crafting", "--info-wcra", "Crafting recipe catalog"}, + {{'W','L','O','C'}, ".wloc", "world", "--info-wloc", "World locations catalog"}, {{'W','F','A','C'}, ".wfac", "factions", nullptr, "Faction catalog"}, {{'W','L','C','K'}, ".wlck", "locks", nullptr, "Lock catalog"}, {{'W','S','K','L'}, ".wskl", "skills", nullptr, "Skill catalog"}, diff --git a/tools/editor/cli_help.cpp b/tools/editor/cli_help.cpp index 8d7bbffc..0f1ae6d7 100644 --- a/tools/editor/cli_help.cpp +++ b/tools/editor/cli_help.cpp @@ -2629,6 +2629,16 @@ void printUsage(const char* argv0) { std::printf(" Export binary .wcra to a human-editable JSON sidecar (defaults to .wcra.json; tradeSkillName is informational; reagents emitted as JSON object array of {itemId,count})\n"); std::printf(" --import-wcra-json [out-base]\n"); std::printf(" Import a .wcra.json sidecar back into binary .wcra (tradeSkillId int authoritative, tradeSkillName ignored; reagents accept JSON object array — round-trips per-recipe variable-length reagent lists byte-identical)\n"); + std::printf(" --gen-loc-poi [name]\n"); + std::printf(" Emit .wloc 4 Alliance POIs (Stormwind/Ironforge/Goldshire/Sentinel Hill) with discoverable XP and POI-kind iconry\n"); + std::printf(" --gen-loc-herb [name]\n"); + std::printf(" Emit .wloc 5 Elwynn/Westfall herb nodes (Peacebloom/Silverleaf skill 1 to Stranglekelp skill 85) with 600s respawn and Herbalism (skillId 182) gating\n"); + std::printf(" --gen-loc-rare [name]\n"); + std::printf(" Emit .wloc 4 vanilla rare-elite spawns (Mor'Ladim 1hr / Princess Tempestria 2hr / Foreman Rigger 30min / Lord Sakrasis 1hr) with realistic respawn timers\n"); + std::printf(" --info-wloc [--json]\n"); + std::printf(" Print WLOC entries (id / mapId / areaId / locKindName / factionAccessName / respawnSec / discoverableXp / requiredSkill / level / name)\n"); + std::printf(" --validate-wloc [--json]\n"); + std::printf(" Static checks: id+name required, locKind 0..6, factionAccess 0..3, no duplicate locationIds, spawnable kinds (Rare/Herb/Mineral/Fishing) MUST have respawnSec > 0 (else entity spawns once and never returns); warns on discoverableXp set with non-POI kind (XP would never award), requiredSkillId set with non-gather kind (skill check would never fire), and gather kind with skill > 0 but level = 0 (every player satisfies — verify intentional)\n"); std::printf(" --catalog-pluck [--json]\n"); std::printf(" Extract one entry by id from any registered catalog format. Auto-detects magic, dispatches to the per-format --info-* handler internally, then prints just the matching entry. Primary-key field is auto-detected (first *Id field, or first numeric)\n"); std::printf(" --catalog-find [--magic ] [--json]\n"); diff --git a/tools/editor/cli_list_formats.cpp b/tools/editor/cli_list_formats.cpp index 61d33baf..207eaf66 100644 --- a/tools/editor/cli_list_formats.cpp +++ b/tools/editor/cli_list_formats.cpp @@ -158,6 +158,7 @@ constexpr FormatRow kFormats[] = { {"WGBK", ".wgbk", "guild", "(absent in vanilla, TBC GuildBankTab)","Guild bank tabs catalog (per-rank withdrawal limits)"}, {"WQGR", ".wqgr", "quests", "QuestRelations.dbc + per-quest scripts","Quest graph catalog (chain prereq DAG + cycle detection)"}, {"WCRA", ".wcra", "crafting", "SpellReagents.dbc + Spell.dbc effect-24","Crafting recipe catalog (trade-skill recipe expansion)"}, + {"WLOC", ".wloc", "world", "AreaPOI + GO spawns + AreaTrigger.dbc","World locations catalog (POI/RareSpawn/HerbNode/MineralVein/FishingSpot/Trigger/PortalLand)"}, // Additional pipeline catalogs without the alternating // gen/info/validate CLI surface (loaded by the engine diff --git a/tools/editor/cli_world_locations_catalog.cpp b/tools/editor/cli_world_locations_catalog.cpp new file mode 100644 index 00000000..a9aa8671 --- /dev/null +++ b/tools/editor/cli_world_locations_catalog.cpp @@ -0,0 +1,326 @@ +#include "cli_world_locations_catalog.hpp" +#include "cli_arg_parse.hpp" +#include "cli_box_emitter.hpp" + +#include "pipeline/wowee_world_locations.hpp" +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace wowee { +namespace editor { +namespace cli { + +namespace { + +std::string stripWlocExt(std::string base) { + stripExt(base, ".wloc"); + return base; +} + +const char* locKindName(uint8_t k) { + using L = wowee::pipeline::WoweeWorldLocations; + switch (k) { + case L::POI: return "poi"; + case L::RareSpawn: return "rarespawn"; + case L::HerbNode: return "herbnode"; + case L::MineralVein: return "mineralvein"; + case L::FishingSpot: return "fishingspot"; + case L::AreaTrigger: return "areatrigger"; + case L::PortalLanding: return "portallanding"; + default: return "?"; + } +} + +const char* factionAccessName(uint8_t f) { + using L = wowee::pipeline::WoweeWorldLocations; + switch (f) { + case L::Both: return "both"; + case L::Alliance: return "alliance"; + case L::Horde: return "horde"; + case L::Neutral: return "neutral"; + default: return "?"; + } +} + +const char* skillIdName(uint16_t s) { + switch (s) { + case 0: return "-"; + case 182: return "Herbalism"; + case 186: return "Mining"; + case 356: return "Fishing"; + default: return "?"; + } +} + +bool saveOrError(const wowee::pipeline::WoweeWorldLocations& c, + const std::string& base, const char* cmd) { + if (!wowee::pipeline::WoweeWorldLocationsLoader::save(c, base)) { + std::fprintf(stderr, "%s: failed to save %s.wloc\n", + cmd, base.c_str()); + return false; + } + return true; +} + +void printGenSummary(const wowee::pipeline::WoweeWorldLocations& c, + const std::string& base) { + std::printf("Wrote %s.wloc\n", base.c_str()); + std::printf(" catalog : %s\n", c.name.c_str()); + std::printf(" locations: %zu\n", c.entries.size()); +} + +int handleGenAlliancePOIs(int& i, int argc, char** argv) { + std::string base = argv[++i]; + std::string name = "AlliancePOIs"; + if (parseOptArg(i, argc, argv)) name = argv[++i]; + base = stripWlocExt(base); + auto c = wowee::pipeline::WoweeWorldLocationsLoader:: + makeAlliancePOIs(name); + if (!saveOrError(c, base, "gen-loc-poi")) return 1; + printGenSummary(c, base); + return 0; +} + +int handleGenHerbalism(int& i, int argc, char** argv) { + std::string base = argv[++i]; + std::string name = "HerbalismNodes"; + if (parseOptArg(i, argc, argv)) name = argv[++i]; + base = stripWlocExt(base); + auto c = wowee::pipeline::WoweeWorldLocationsLoader:: + makeHerbalismNodes(name); + if (!saveOrError(c, base, "gen-loc-herb")) return 1; + printGenSummary(c, base); + return 0; +} + +int handleGenRareSpawns(int& i, int argc, char** argv) { + std::string base = argv[++i]; + std::string name = "RareSpawns"; + if (parseOptArg(i, argc, argv)) name = argv[++i]; + base = stripWlocExt(base); + auto c = wowee::pipeline::WoweeWorldLocationsLoader:: + makeRareSpawns(name); + if (!saveOrError(c, base, "gen-loc-rare")) 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 = stripWlocExt(base); + if (!wowee::pipeline::WoweeWorldLocationsLoader::exists(base)) { + std::fprintf(stderr, "WLOC not found: %s.wloc\n", + base.c_str()); + return 1; + } + auto c = wowee::pipeline::WoweeWorldLocationsLoader::load(base); + if (jsonOut) { + nlohmann::json j; + j["wloc"] = base + ".wloc"; + j["name"] = c.name; + j["count"] = c.entries.size(); + nlohmann::json arr = nlohmann::json::array(); + for (const auto& e : c.entries) { + arr.push_back({ + {"locationId", e.locationId}, + {"name", e.name}, + {"mapId", e.mapId}, + {"areaId", e.areaId}, + {"x", e.x}, + {"y", e.y}, + {"z", e.z}, + {"locKind", e.locKind}, + {"locKindName", locKindName(e.locKind)}, + {"iconIndex", e.iconIndex}, + {"factionAccess", e.factionAccess}, + {"factionAccessName", + factionAccessName(e.factionAccess)}, + {"respawnSec", e.respawnSec}, + {"discoverableXp", e.discoverableXp}, + {"requiredSkillId", e.requiredSkillId}, + {"requiredSkillName", + skillIdName(e.requiredSkillId)}, + {"requiredSkillLevel", e.requiredSkillLevel}, + }); + } + j["entries"] = arr; + std::printf("%s\n", j.dump(2).c_str()); + return 0; + } + std::printf("WLOC: %s.wloc\n", base.c_str()); + std::printf(" catalog : %s\n", c.name.c_str()); + std::printf(" locations: %zu\n", c.entries.size()); + if (c.entries.empty()) return 0; + std::printf(" id map area kind fact respawn xp skill lvl name\n"); + for (const auto& e : c.entries) { + std::printf(" %4u %3u %4u %-13s %-8s %7us %4u %-12s %3u %s\n", + e.locationId, e.mapId, e.areaId, + locKindName(e.locKind), + factionAccessName(e.factionAccess), + e.respawnSec, e.discoverableXp, + skillIdName(e.requiredSkillId), + e.requiredSkillLevel, + 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 = stripWlocExt(base); + if (!wowee::pipeline::WoweeWorldLocationsLoader::exists(base)) { + std::fprintf(stderr, + "validate-wloc: WLOC not found: %s.wloc\n", + base.c_str()); + return 1; + } + auto c = wowee::pipeline::WoweeWorldLocationsLoader::load(base); + std::vector errors; + std::vector warnings; + if (c.entries.empty()) { + warnings.push_back("catalog has zero entries"); + } + using L = wowee::pipeline::WoweeWorldLocations; + std::set 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.locationId); + if (!e.name.empty()) ctx += " " + e.name; + ctx += ")"; + if (e.locationId == 0) + errors.push_back(ctx + ": locationId is 0"); + if (e.name.empty()) + errors.push_back(ctx + ": name is empty"); + if (e.locKind > 6) { + errors.push_back(ctx + ": locKind " + + std::to_string(e.locKind) + + " out of range (0..6)"); + } + if (e.factionAccess > 3) { + errors.push_back(ctx + ": factionAccess " + + std::to_string(e.factionAccess) + + " out of range (0..3)"); + } + // Spawnable kinds REQUIRE respawnSec > 0 + // (otherwise they spawn once and never come + // back). Static kinds don't. + bool spawnable = + e.locKind == L::RareSpawn || + e.locKind == L::HerbNode || + e.locKind == L::MineralVein || + e.locKind == L::FishingSpot; + if (spawnable && e.respawnSec == 0) { + errors.push_back(ctx + + ": spawnable kind (" + + std::string(locKindName(e.locKind)) + + ") with respawnSec=0 — entity would " + "spawn once and never come back"); + } + // discoverableXp only meaningful for POI kind. + if (e.discoverableXp > 0 && e.locKind != L::POI) { + warnings.push_back(ctx + + ": discoverableXp=" + + std::to_string(e.discoverableXp) + + " set but locKind is not POI — XP " + "would never be awarded (the discovery " + "flow only fires for POIs)"); + } + // requiredSkill only meaningful for gather- + // kinds. + bool gatherKind = + e.locKind == L::HerbNode || + e.locKind == L::MineralVein || + e.locKind == L::FishingSpot; + if (e.requiredSkillId != 0 && !gatherKind) { + warnings.push_back(ctx + + ": requiredSkillId=" + + std::to_string(e.requiredSkillId) + + " set but locKind is not a gather " + "kind — skill check will never fire"); + } + // Gather kinds with zero requiredSkillLevel + // BUT non-zero skillId is suspicious — usually + // a typo. + if (gatherKind && e.requiredSkillId != 0 && + e.requiredSkillLevel == 0) { + warnings.push_back(ctx + + ": gather kind with requiredSkillId=" + + std::to_string(e.requiredSkillId) + + " but requiredSkillLevel=0 — every " + "player satisfies; verify intentional"); + } + if (!idsSeen.insert(e.locationId).second) { + errors.push_back(ctx + ": duplicate locationId"); + } + } + bool ok = errors.empty(); + if (jsonOut) { + nlohmann::json j; + j["wloc"] = base + ".wloc"; + 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-wloc: %s.wloc\n", base.c_str()); + if (ok && warnings.empty()) { + std::printf(" OK — %zu locations, all locationIds " + "unique, locKind 0..6, factionAccess " + "0..3, all spawnable kinds (Rare/Herb/" + "Mineral/Fishing) have respawnSec > 0\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 handleWorldLocationsCatalog(int& i, int argc, char** argv, + int& outRc) { + if (std::strcmp(argv[i], "--gen-loc-poi") == 0 && + i + 1 < argc) { + outRc = handleGenAlliancePOIs(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--gen-loc-herb") == 0 && + i + 1 < argc) { + outRc = handleGenHerbalism(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--gen-loc-rare") == 0 && + i + 1 < argc) { + outRc = handleGenRareSpawns(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--info-wloc") == 0 && i + 1 < argc) { + outRc = handleInfo(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--validate-wloc") == 0 && + i + 1 < argc) { + outRc = handleValidate(i, argc, argv); return true; + } + return false; +} + +} // namespace cli +} // namespace editor +} // namespace wowee diff --git a/tools/editor/cli_world_locations_catalog.hpp b/tools/editor/cli_world_locations_catalog.hpp new file mode 100644 index 00000000..6dbd7871 --- /dev/null +++ b/tools/editor/cli_world_locations_catalog.hpp @@ -0,0 +1,12 @@ +#pragma once + +namespace wowee { +namespace editor { +namespace cli { + +bool handleWorldLocationsCatalog(int& i, int argc, char** argv, + int& outRc); + +} // namespace cli +} // namespace editor +} // namespace wowee