From 05f4f6349fd9e65cccb96e7b46cf65d0802ed52d Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 20 Oct 2024 19:08:11 +0100 Subject: [PATCH] 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. --- pattern.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pattern.c b/pattern.c index b7bde77..8dba168 100644 --- a/pattern.c +++ b/pattern.c @@ -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 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); /* @@ -2070,6 +2074,8 @@ static void game_print(drawing *dr, const game_state *state, const game_ui *ui, TOCOORD(h, y) + TILE_SIZE/2, TILE_SIZE/12, ink, ink); } + + game_free_drawstate(dr, ds); } #ifdef COMBINED