Files
Addison Bair 623bc8ced5 StageKit: stage and instrument any scenario on the real engine, with no retail assets
tools/stagekit writes a scenario's map in code (a floor in a box, props, players' starts) and plays it headless, a tick a frame, the same every time. Every player is logged each second and tests check what happened: walking, an obstacle, an elevator ridden up and down. 20 tests, about 2 s, CI-safe.
2026-10-16 16:26:08 +00:00

54 lines
1.3 KiB
C

/*
MAIN.C
StageKit (README.md): writes a scenario's map, in code.
usage: stagekit --list
stagekit <scenario> <map file>
*/
/* ---------- headers */
#include "stagekit.h"
/* ---------- globals */
extern struct stagekit_scenario const scenario_walk;
extern struct stagekit_scenario const scenario_obstacle;
extern struct stagekit_scenario const scenario_elevator;
static struct stagekit_scenario const *const scenarios[] = { &scenario_walk, &scenario_obstacle, &scenario_elevator };
/* ---------- public code */
int main(
int argc,
char **argv)
{
struct stage stage = { 0 };
struct stagekit_scenario const *scenario = NULL;
long tag_count;
unsigned long index;
if (argc == 2 && !strcmp(argv[1], "--list"))
{
for (index = 0; index < NUMBEROF(scenarios); index++)
printf("%-12s %s\n", scenarios[index]->name, scenarios[index]->description);
return 0;
}
for (index = 0; argc == 3 && index < NUMBEROF(scenarios); index++)
{
if (!strcmp(scenarios[index]->name, argv[1]))
scenario = scenarios[index];
}
if (!scenario)
{
fprintf(stderr, "usage: stagekit --list\n stagekit <scenario> <map file>\n");
return 2;
}
stage_build(&stage, scenario);
cache_write(argv[2], &tag_count);
printf("stagekit: %s: %s, %ld tags\n", scenario->name, argv[2], tag_count);
return 0;
}