mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
Use a proper union in struct config_item.
This allows me to use different types for the mutable, dynamically allocated string value in a C_STRING control and the fixed constant list of option names in a C_CHOICES.
This commit is contained in:
19
unequal.c
19
unequal.c
@ -218,24 +218,21 @@ static config_item *game_configure(const game_params *params)
|
||||
|
||||
ret[0].name = "Mode";
|
||||
ret[0].type = C_CHOICES;
|
||||
ret[0].sval = ":Unequal:Adjacent";
|
||||
ret[0].ival = params->adjacent;
|
||||
ret[0].u.choices.choicenames = ":Unequal:Adjacent";
|
||||
ret[0].u.choices.selected = params->adjacent;
|
||||
|
||||
ret[1].name = "Size (s*s)";
|
||||
ret[1].type = C_STRING;
|
||||
sprintf(buf, "%d", params->order);
|
||||
ret[1].sval = dupstr(buf);
|
||||
ret[1].ival = 0;
|
||||
ret[1].u.string.sval = dupstr(buf);
|
||||
|
||||
ret[2].name = "Difficulty";
|
||||
ret[2].type = C_CHOICES;
|
||||
ret[2].sval = DIFFCONFIG;
|
||||
ret[2].ival = params->diff;
|
||||
ret[2].u.choices.choicenames = DIFFCONFIG;
|
||||
ret[2].u.choices.selected = params->diff;
|
||||
|
||||
ret[3].name = NULL;
|
||||
ret[3].type = C_END;
|
||||
ret[3].sval = NULL;
|
||||
ret[3].ival = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -244,9 +241,9 @@ static game_params *custom_params(const config_item *cfg)
|
||||
{
|
||||
game_params *ret = snew(game_params);
|
||||
|
||||
ret->adjacent = cfg[0].ival;
|
||||
ret->order = atoi(cfg[1].sval);
|
||||
ret->diff = cfg[2].ival;
|
||||
ret->adjacent = cfg[0].u.choices.selected;
|
||||
ret->order = atoi(cfg[1].u.string.sval);
|
||||
ret->diff = cfg[2].u.choices.selected;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user