Require games to accept new_ui(NULL) if they have preferences.

This will be necessary in the next commit, so that the midend can make
a game_ui out of nothing in order to store preferences in it.

The only game actually affected by this requirement is Pearl, which
has a preference (GUI style) and also allocates space based on the
game_state's grid size to store the coordinates of a path being
dragged, so if there is no game_state, it can't do the latter - which
is OK, because it also won't be expected to.
This commit is contained in:
Simon Tatham
2023-04-22 10:51:37 +01:00
parent d13ece698f
commit ea6be8f0af
2 changed files with 16 additions and 5 deletions

View File

@ -1897,10 +1897,9 @@ static void legacy_prefs_override(struct game_ui *ui_out)
static game_ui *new_ui(const game_state *state)
{
game_ui *ui = snew(game_ui);
int sz = state->shared->sz;
ui->ndragcoords = -1;
ui->dragcoords = snewn(sz, int);
ui->dragcoords = state ? snewn(state->shared->sz, int) : NULL;
ui->cursor_active = getenv_bool("PUZZLES_SHOW_CURSOR", false);
ui->curx = ui->cury = 0;