Skip to content

Commit

Permalink
Change transform field to an enum
Browse files Browse the repository at this point in the history
We use the YOCTON_ENUM_TRY_INDEX mechanism so that integer index values
are still valid.
  • Loading branch information
fragglet committed Nov 26, 2024
1 parent a548e6a commit 926a2d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions maps/original.sop
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ level {
type: TARGET
x: 685
orient: 3
transform: 6
transform: MIRROR
territory_l: 0
territory_r: 0
faction: PLAYER3
Expand Down Expand Up @@ -1582,7 +1582,7 @@ level {
type: TARGET
x: 1550
orient: 3
transform: 6
transform: MIRROR
territory_l: 0
territory_r: 0
faction: PLAYER2
Expand Down Expand Up @@ -1665,7 +1665,7 @@ level {
type: TARGET
x: 2279
orient: 3
transform: 6
transform: MIRROR
territory_l: 0
territory_r: 0
faction: PLAYER4
Expand Down
8 changes: 7 additions & 1 deletion src/swgames.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ static const char *obtype_names[] = {
"FLOCK", "BIRD", "OX", "MISSILE", "STARBURST", "BALLOON", NULL,
};

static const char *transform_names[] = {
"NONE", "ROTATE90", "ROTATE180", "ROTATE270",
"FLIP", "FLIP_ROTATE90", "MIRROR", "MIRROR_ROTATE90",
YOCTON_ENUM_TRY_INDEX,
};

static const char *faction_names[] = {
"NONE", "PLAYER1", "PLAYER2", "PLAYER3", "PLAYER4", "PLAYER5",
"PLAYER6", "PLAYER7", "PLAYER8", NULL,
Expand Down Expand Up @@ -301,7 +307,7 @@ static void AddObject(original_ob_t *ob, struct yocton_object *yo)
YOCTON_VAR_INT(p, "orient", int, ob->orient);
YOCTON_VAR_INT(p, "territory_l", int, ob->territory_l);
YOCTON_VAR_INT(p, "territory_r", int, ob->territory_r);
YOCTON_VAR_INT(p, "transform", transform_t, ob->transform);
YOCTON_VAR_ENUM(p, "transform", ob->transform, transform_names);
YOCTON_VAR_ENUM(p, "type", ob->type, obtype_names);
YOCTON_VAR_ENUM(p, "faction", ob->faction, faction_names);

Expand Down

0 comments on commit 926a2d9

Please sign in to comment.