Kelsidavis-WoWee/include/pipeline/wowee_world_map.hpp
Kelsi db47f00657 feat(pipeline): add WOMX (Wowee World Map index) format
Novel open replacement for Blizzard's WDT (top-level world
definition table). The 9th open format added to the editor.

A WOMX file holds the manifest of which terrain tiles exist
within a world plus a tiny bit of map-level metadata. The
runtime consults it before attempting to load any individual
tile (so missing tiles produce a clean "no data" result
instead of a file-not-found error).

Format:
  • magic "WMPX", version 1, little-endian
  • mapName + worldType (continent/instance/battleground/arena)
  • gridSize 1..128 (typically 64 for continents)
  • defaultLightId / defaultWeatherId (atmosphere preset
    refs, 0 if none — wires into the WOL/WOW pair)
  • packed bitmap, 1 bit per tile, row-major
  • A 64x64 manifest is exactly 512 bytes of bitmap

API: WoweeWorldMapLoader::save / load / exists; presets
makeContinent (64x64 full), makeInstance (4x4 full),
makeArena (1x1 full).

CLI added (5 flags, 456 total now):
  --gen-world-map <base> [name]            (continent)
  --gen-world-map-instance <base> [name]   (4x4)
  --gen-world-map-arena <base> [name]      (1x1)
  --info-womx <base> [--json]
  --validate-womx <base> [--json]

Round-trip verified: continent + instance + arena presets
all save / load / re-validate to byte-identical state with
correct tile counts.
2026-05-09 14:38:05 -07:00

82 lines
2.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <cstdint>
#include <string>
#include <vector>
namespace wowee {
namespace pipeline {
// Wowee Open World Map index (.womx) — novel replacement for
// Blizzard's WDT (top-level world definition table). A WOMX file
// holds the manifest of which terrain tiles exist within a world,
// plus a tiny bit of map-level metadata. The runtime consults it
// before attempting to load any individual tile (so missing tiles
// produce a clean "no data" instead of a file-not-found error).
//
// The grid is a square of size N×N where N is typically 64 (the
// historical WoW value), but the format permits any N up to 128.
// Tile presence is stored as a packed bitmap (1 bit per tile,
// row-major), so a 64×64 manifest is only 512 bytes.
//
// Binary layout (little-endian):
// magic[4] = "WMPX"
// version (uint32) = current 1
// nameLen (uint32) + name bytes
// worldType (uint8) = 0=continent, 1=instance, 2=battleground, 3=arena
// gridSize (uint8) = N (1..128)
// pad[2]
// defaultLightId (uint32) -- 0 if no atmosphere preset
// defaultWeatherId (uint32) -- 0 if no atmosphere preset
// reserved[3] (uint32 each)
// bitmapBytes (uint32) = ceil(N*N/8)
// bitmap (bitmapBytes)
struct WoweeWorldMap {
enum WorldType : uint8_t {
Continent = 0,
Instance = 1,
Battleground = 2,
Arena = 3,
};
std::string name;
uint8_t worldType = Continent;
uint8_t gridSize = 64;
uint32_t defaultLightId = 0;
uint32_t defaultWeatherId = 0;
// Packed row-major bitmap: bit (y * gridSize + x) is set
// when a tile exists at column x, row y.
std::vector<uint8_t> tileBitmap;
bool isValid() const { return gridSize > 0 && gridSize <= 128; }
bool hasTile(uint32_t x, uint32_t y) const;
void setTile(uint32_t x, uint32_t y, bool present);
// Count of set bits in the bitmap (= number of present tiles).
uint32_t countTiles() const;
static const char* worldTypeName(uint8_t t);
};
class WoweeWorldMapLoader {
public:
static bool save(const WoweeWorldMap& map,
const std::string& basePath);
static WoweeWorldMap load(const std::string& basePath);
static bool exists(const std::string& basePath);
// Preset emitters used by --gen-world-map* variants.
//
// makeContinent — full 64×64 grid with all tiles present
// (continent-style world map, ~4.3 km²)
// makeInstance — small 4×4 grid for dungeon-scale worlds
// makeArena — 1×1 single-tile arena
static WoweeWorldMap makeContinent(const std::string& mapName);
static WoweeWorldMap makeInstance(const std::string& mapName);
static WoweeWorldMap makeArena(const std::string& mapName);
};
} // namespace pipeline
} // namespace wowee