#include #include #include #include "ok_types.h" #include "ok_map.h" #include "ok_unit.h" static int run_smoke(void) { OkWorld w; ok_map_init(&w, 42); int a = ok_unit_spawn(&w, OK_FACTION_A, OK_UNIT_SCOUT, 1, 1); int b = ok_unit_spawn(&w, OK_FACTION_B, OK_UNIT_SCOUT, OK_WORLD_W - 2, OK_WORLD_H - 2); if (a < 0 || b < 0) { fprintf(stderr, "spawn failed\n"); return 2; } for (int t = 0; t < 40; t++) ok_world_tick(&w); if (ok_world_alive_count(&w, OK_FACTION_A) < 1 || ok_world_alive_count(&w, OK_FACTION_B) < 1) { fprintf(stderr, "units died\n"); return 3; } if (w.units[a].x == 1 && w.units[a].y == 1) { fprintf(stderr, "unit A did not move\n"); return 4; } printf("openkknd2: headless smoke test passed (ticks=%d units=%d resA=%d resB=%d)\n", w.tick, w.unit_count, w.resources_a, w.resources_b); return 0; } int main(int argc, char *argv[]) { int headless = 0, smoke = 0; for (int i = 1; i < argc; i++) { if (strcmp(argv[i], "--headless") == 0) headless = 1; else if (strcmp(argv[i], "--smoke") == 0) smoke = 1; } if (headless && smoke) return run_smoke(); printf("openkknd2 - original open post-apoc RTS scaffold (not KKnD)\n"); printf("Usage: %s --headless --smoke\n", argv[0]); return headless ? 0 : 1; }