Pattern: fix crash when printing.

The mostly-unpopulated game_drawstate created in game_print for the
sake of the TILE_SIZE macro was being passed to a subroutine which
expected another field of it to be filled in.

Rather than continue filling in one field at a time, let's just make a
complete one.
This commit is contained in:
Simon Tatham
2024-10-20 19:08:11 +01:00
parent 182b3d9e27
commit 05f4f6349f

View File

@ -2025,8 +2025,12 @@ static void game_print(drawing *dr, const game_state *state, const game_ui *ui,
int ink = print_mono_colour(dr, 0); int ink = print_mono_colour(dr, 0);
int x, y, i; int x, y, i;
/* Ick: fake up `ds->tilesize' for macro expansion purposes */ /*
game_drawstate ads, *ds = &ads; * Make a game_drawstate, so that the TILE_SIZE macro will work in
* this function, and so that draw_numbers can use it to format
* the text for numeric clues.
*/
game_drawstate *ds = game_new_drawstate(dr, state);
game_set_size(dr, ds, NULL, tilesize); game_set_size(dr, ds, NULL, tilesize);
/* /*
@ -2070,6 +2074,8 @@ static void game_print(drawing *dr, const game_state *state, const game_ui *ui,
TOCOORD(h, y) + TILE_SIZE/2, TOCOORD(h, y) + TILE_SIZE/2,
TILE_SIZE/12, ink, ink); TILE_SIZE/12, ink, ink);
} }
game_free_drawstate(dr, ds);
} }
#ifdef COMBINED #ifdef COMBINED