Extract map-specific data into a generic MapSource interface
One interface (nd_mapsource.h) now owns everything map-specific: tiles, rooms/doors/cameras, the network graph (nodes + edges with roles replacing the hardcoded N_AIRLK/N_DOOR/N_HIVE indices) and the entity spawn list. The scenario populates its structures once via selectMap() and never checks which map is active. - DemoMapSource: self-contained demo grid (moved out of the sketch), demo node/edge/spawn tables - GenMapSource: adapts the random MapGenerator — now with L-corridors for guaranteed connectivity, doors that lead somewhere, airlock pad, terminal and crates (never on corridor tiles); network graph derived from the room chain, marine-first spawn list with droid patrols - NetDeck.ino: all source branching removed; red trace follows the real active-link path (BFS HIVE->ROOT); reinforcement spawns near the blast door - Tests: MapTest validates 50 generated runs + demo via the interface with an airlock flood-fill; new generated-map integration journey; test node handles resolve through the source (no hardcoded indices)
This commit is contained in:
@@ -148,6 +148,54 @@ or press the advantage at the blast door. The frenzy timer decrements each
|
||||
shared coordinate space so that a network link to the Droid Hive node directly
|
||||
controls local droid behavior.
|
||||
-->
|
||||
### Map sources: generic MapSource interface (this change)
|
||||
|
||||
All map-specific data now lives behind one interface (`nd_mapsource.h`), so
|
||||
the scenario populates its structures **once** (`selectMap()` →
|
||||
`resetScenario()`) and never checks which map is active — the demo floorplan
|
||||
and the random `MapGenerator` are interchangeable:
|
||||
|
||||
- **`nd_mapsource.h`** (new): `MapSource` abstract interface exposing tiles,
|
||||
rooms/doors/cameras, the network graph (`NetNodeDef`/`NetEdgeDef` with
|
||||
**roles** `NR_ROOT/NR_DOOR/NR_HIVE/NR_CAMERA` replacing the old hardcoded
|
||||
`N_AIRLK/N_DOOR/N_HIVE` indices), and the entity spawn list
|
||||
(`UnitSpawn`, marines first — slots 0/1 are the squad). Shared helpers:
|
||||
role lookups (`rootNode()/hiveNode()/doorNode()`) and `findTile()` for the
|
||||
`'A'`/`'T'` anchor tiles. Pool bounds `MAX_NODES`/`MAX_EDGES`.
|
||||
- **`nd_demomap.h`** (rewritten): self-contained `DemoMapSource` — the real
|
||||
24x40 demo grid (moved out of the sketch; the stale 19x38 array is gone),
|
||||
demo node/edge/spawn tables, blast door + room regions. `isDemo()` and the
|
||||
`setMapRows()` workaround were dropped as unnecessary.
|
||||
- **`nd_mapgen.h`** (reworked): the generator now produces playable maps —
|
||||
solid hull, carved rooms, **L-corridors between room centers** (full
|
||||
walkable connectivity; corridor tiles recorded so crates never block a
|
||||
link), doors only on walls that lead somewhere (with a deterministic
|
||||
fallback so every room gets one), airlock pad `'A'` + objective terminal
|
||||
`'T'` in the hive room, cover crates, and no unit letters written into the
|
||||
tile grid (the old code wrote `'T'` for turrets — clashing with the
|
||||
terminal). `GenMapSource` adapts the result to the interface: network graph
|
||||
derived from the room chain (AIRLK root online, HIVE on the hive room,
|
||||
DOOR node pinned to the hive door tile) and a marine-first spawn list with
|
||||
droid patrol endpoints (spawn tile ↔ room center).
|
||||
- **`NetDeck.ino`**: every map-source branch removed (`g_useDemoMap` is gone);
|
||||
node/edge tables, spawn placement, terminal/airlock anchors, reinforcement
|
||||
spawn point (near the blast door, hive side) and the win tile all come from
|
||||
the active source. The red trace now follows the actual active-link path
|
||||
(BFS HIVE→ROOT) instead of the hardcoded HIVE→JUNC→AIRLK segments; the
|
||||
reinforcement droid uses the first slot after the spawn list.
|
||||
- **Tests**: `MapTest.cpp` (standalone, also compiled into the firmware as
|
||||
before) now validates 50 generated runs + the demo source through the
|
||||
interface: room count, marine-first spawns, role nodes, graph connectivity
|
||||
from the root, and a **flood-fill from the airlock** proving the terminal
|
||||
and every spawn are reachable. New integration journey
|
||||
`generated_map_source_journey` switches the running scenario to
|
||||
`GenMapSource`, routes a link and steps combat, then restores the demo map.
|
||||
Test node handles resolve via the source (`nodeByLabel` / role globals) —
|
||||
no hardcoded indices left in the tests.
|
||||
- Verified: `make netdeck` (both targets), `make netdeck-test` — 28 unit +
|
||||
8 integration + 4 E2E journeys, 0 failures; plus a 2000-run generator fuzz
|
||||
(all maps flood-connected, all role nodes present).
|
||||
|
||||
### Headless test structure
|
||||
|
||||
Tests live in `emulator/tests/` (see its README): **unit** +
|
||||
|
||||
Reference in New Issue
Block a user