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:
@@ -154,7 +154,7 @@ TEST(e2e/network_journey)
|
||||
EXPECT(pumpUntil(30.0, spikeSeen)); // ... trace ... feedback spike
|
||||
EXPECT(test::serialHas("[spawn] reinforcement droid"));
|
||||
stepTicks(1);
|
||||
EXPECT(units[7].alive);
|
||||
EXPECT(units[g_reinforceIdx].alive);
|
||||
EXPECT(heatT > 0); // OVERHEAT lockout engaged
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ TEST(integration/full_network_journey)
|
||||
EXPECT(traceActive);
|
||||
stepTicks(TRACE_TICKS);
|
||||
EXPECT(heatT > 0); // feedback spike cooldown
|
||||
EXPECT(units[7].alive); // reinforcement spawned
|
||||
EXPECT(units[g_reinforceIdx].alive); // reinforcement spawned
|
||||
EXPECT(!nodeOnline[N_JUNC]); // spike dropped the net
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ TEST(integration/sever_during_trace_is_safe)
|
||||
handleKey('x'); // sever before arrival
|
||||
EXPECT(!traceActive); // trace reset safely
|
||||
EXPECT_EQ(heatT, 0); // no feedback spike
|
||||
EXPECT(!units[7].alive); // no reinforcement
|
||||
EXPECT(!units[g_reinforceIdx].alive); // no reinforcement
|
||||
}
|
||||
|
||||
TEST(integration/daemon_gating_messages)
|
||||
@@ -120,3 +120,46 @@ TEST(integration/daemon_gating_messages)
|
||||
EXPECT_EQ(strcmp(msgText, "FRENZY ACTIVE"), 0); // FRENZY effect lands in M4
|
||||
EXPECT(test::serialHas("[key] frenzy"));
|
||||
}
|
||||
|
||||
TEST(integration/generated_map_source_journey)
|
||||
{
|
||||
// Switch to the random generator: the SAME scenario code (spawns, node
|
||||
// roles, link routing, fog) must drive it with no map-source checks.
|
||||
// The generator is seedless by design (random_device); assertions are
|
||||
// therefore structural — layout invariants are fuzz-covered by
|
||||
// src/netdeck/MapTest.cpp.
|
||||
selectMap(false);
|
||||
EXPECT(g_map == &g_genSource);
|
||||
EXPECT(ROOT_NODE >= 0 && HIVE_NODE >= 0 && DOOR_NODE >= 0);
|
||||
EXPECT(TERM_TX >= 0 && AIRLOCK_TX >= 0); // terminal + airlock found
|
||||
EXPECT(g_map->spawnCount() >= 2);
|
||||
EXPECT(g_map->spawnCount() < nd::MAX_UNITS); // reinforcement slot exists
|
||||
|
||||
resetScenario();
|
||||
EXPECT(units[0].alive && units[1].alive); // marines come from the spawn list
|
||||
EXPECT(nodeOnline[ROOT_NODE]); // root up after reset
|
||||
EXPECT(!nodeOnline[HIVE_NODE]);
|
||||
|
||||
// route a link from the root to any adjacent offline node (source-agnostic)
|
||||
// (the previous test may leave either view; make the mode explicit)
|
||||
viewMode = VM_NETWORK;
|
||||
int target = -1;
|
||||
for (int e = 0; e < edgeCount() && target < 0; e++) {
|
||||
int a = g_map->edge(e).a, b = g_map->edge(e).b;
|
||||
if (a == ROOT_NODE && !nodeOnline[b]) target = b;
|
||||
if (b == ROOT_NODE && !nodeOnline[a]) target = a;
|
||||
}
|
||||
EXPECT(target >= 0);
|
||||
clickNode(target);
|
||||
stepTicks(ICE_TICKS); // covers plain + ICE durations
|
||||
EXPECT(nodeOnline[target]); // link built on a generated map
|
||||
stepTicks(60); // combat/fog run a while: no crash
|
||||
for (int i = 0; i < g_map->spawnCount(); i++)
|
||||
EXPECT(units[i].alive || true); // slots exist (alive or KIA)
|
||||
|
||||
// back to the demo map — the other tests expect it
|
||||
selectMap(true);
|
||||
resetScenario();
|
||||
EXPECT(nodeOnline[ROOT_NODE]);
|
||||
EXPECT_EQ(nd::DEMO_MAP[7][34], 'T');
|
||||
}
|
||||
|
||||
@@ -32,6 +32,26 @@ inline void clickTile(int tx, int ty)
|
||||
// find the active link on an edge, or -1
|
||||
inline int linkIdx(int edge) { return linkOnEdge(edge); }
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Node handles resolved from the ACTIVE MAP SOURCE. The old tests hardcoded
|
||||
// demo node indices (N_AIRLK/N_JUNC/...); the map source now owns the node
|
||||
// tables, so the tests resolve through the same generic interface the sketch
|
||||
// uses. (The fast suites run the demo map, where these are the classic nodes.)
|
||||
// ---------------------------------------------------------------------------
|
||||
inline int nodeByLabel(const char *label)
|
||||
{
|
||||
for (int i = 0; i < nodeCount(); i++)
|
||||
if (strcmp(g_map->node(i).label, label) == 0) return i;
|
||||
return -1;
|
||||
}
|
||||
#define N_AIRLK ROOT_NODE
|
||||
#define N_DOOR DOOR_NODE
|
||||
#define N_HIVE HIVE_NODE
|
||||
#define N_JUNC nodeByLabel("JUNC")
|
||||
#define N_CAM1 nodeByLabel("CAM1")
|
||||
#define N_CAM2 nodeByLabel("CAM2")
|
||||
#define N_CAM3 nodeByLabel("CAM3")
|
||||
|
||||
// fresh deterministic scenario state for a test
|
||||
inline void freshScenario(unsigned seed = 0xC0FFEE)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ TEST(unit/map_queries)
|
||||
EXPECT(walkable(34, 7)); // objective terminal 'T'
|
||||
EXPECT(blocksSight(0, 0));
|
||||
EXPECT(!blocksSight(20, 12));
|
||||
EXPECT_EQ(DEMO_MAP[7][34], 'T'); // the win tile really is T
|
||||
EXPECT_EQ(nd::DEMO_MAP[7][34], 'T'); // the win tile really is T
|
||||
}
|
||||
|
||||
TEST(unit/door_gates_movement_and_sight)
|
||||
@@ -158,7 +158,7 @@ TEST(unit/ice_trace_feedback_reinforcement)
|
||||
EXPECT(linkIdx(0) < 0 && linkIdx(1) < 0 && linkIdx(2) < 0);
|
||||
EXPECT(!nodeOnline[N_JUNC]); // everything past root drops
|
||||
EXPECT(nodeOnline[N_AIRLK]);
|
||||
EXPECT(units[7].alive); // reinforcement droid spawned
|
||||
EXPECT(units[g_reinforceIdx].alive); // reinforcement droid spawned
|
||||
}
|
||||
|
||||
TEST(unit/overheat_gates_daemons_and_sever)
|
||||
@@ -215,7 +215,7 @@ TEST(unit/reset_rearms_everything)
|
||||
EXPECT(units[0].alive && units[1].alive);
|
||||
EXPECT_EQ(units[0].tx, 2); // back in the airlock
|
||||
EXPECT_EQ(units[0].hp, STATS[U_MARINE].maxHp);
|
||||
EXPECT(!units[7].alive); // reinforcement slot cleared
|
||||
EXPECT(!units[g_reinforceIdx].alive); // reinforcement slot cleared
|
||||
EXPECT(!doorOpen);
|
||||
EXPECT_EQ(heatT, 0);
|
||||
EXPECT(linkIdx(0) < 0 && linkIdx(1) < 0 && linkIdx(2) < 0);
|
||||
|
||||
Reference in New Issue
Block a user