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:
12
dominosa.c
12
dominosa.c
@ -169,18 +169,14 @@ static config_item *game_configure(const game_params *params)
|
||||
ret[0].name = "Maximum number on dominoes";
|
||||
ret[0].type = C_STRING;
|
||||
sprintf(buf, "%d", params->n);
|
||||
ret[0].sval = dupstr(buf);
|
||||
ret[0].ival = 0;
|
||||
ret[0].u.string.sval = dupstr(buf);
|
||||
|
||||
ret[1].name = "Ensure unique solution";
|
||||
ret[1].type = C_BOOLEAN;
|
||||
ret[1].sval = NULL;
|
||||
ret[1].ival = params->unique;
|
||||
ret[1].u.boolean.bval = params->unique;
|
||||
|
||||
ret[2].name = NULL;
|
||||
ret[2].type = C_END;
|
||||
ret[2].sval = NULL;
|
||||
ret[2].ival = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -189,8 +185,8 @@ static game_params *custom_params(const config_item *cfg)
|
||||
{
|
||||
game_params *ret = snew(game_params);
|
||||
|
||||
ret->n = atoi(cfg[0].sval);
|
||||
ret->unique = cfg[1].ival;
|
||||
ret->n = atoi(cfg[0].u.string.sval);
|
||||
ret->unique = cfg[1].u.boolean.bval;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user