From 9a3b6aff943fb16a3e94faaff2517f2b841240f3 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sun, 1 Dec 2024 16:27:13 +0100 Subject: fix crash --- src/scenes/world_map.c | 1 + src/world.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/scenes/world_map.c b/src/scenes/world_map.c index 2640d47..70be8c3 100644 --- a/src/scenes/world_map.c +++ b/src/scenes/world_map.c @@ -1180,6 +1180,7 @@ static void world_map_draw_bank(platform_window* window) sprintf(txt, "LOAN: 150K at $%.0f/month. %d days left.", _active_world->bank_info.loan3.monthly_payment, _active_world->bank_info.loan3.days_left); renderer->render_text(fnt_big, btn_row_x + textpad, btn_row_y + textpad + txt_offset, txt, COLOR_TEXT); + txt_offset += fnt_big->px_h + textpad; } if (txt_offset == 0) { diff --git a/src/world.c b/src/world.c index 6d62b09..111b3a3 100644 --- a/src/world.c +++ b/src/world.c @@ -1216,11 +1216,14 @@ static world_location* get_random_owned_location(world* world) s32 rand_nr = get_random_number(0, count); + count = 0; for (s32 i = 0; i < world->locations.length; i++) { world_location* location = array_at(&world->locations, i); if (!location->is_owned) continue; - if (i == rand_nr) return location; + count++; + + if (count == rand_nr) return location; } return 0; } -- cgit v1.2.3-70-g09d2