From 64f8960b78cc9b614ae5cc9cb0f51ce1c3620357 Mon Sep 17 00:00:00 2001 From: orcutt989 <5608027+orcutt989@users.noreply.github.com> Date: Sat, 12 Sep 2026 22:48:28 -0400 Subject: [PATCH] Fix crash (0xC0000005) when a NULL city pointer is passed to City_has_improvement --- changelog.txt | 1 + injected_code.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/changelog.txt b/changelog.txt index c98fe0bd..5d450124 100644 --- a/changelog.txt +++ b/changelog.txt @@ -11,6 +11,7 @@ - Fix some ways areas revealed by recon can stay permanently revealed - Can happen when the unit that performed recon was destroyed before the start of its next turn (this is a base game bug) - Can happen when a unit has performed multiple recon missions in one turn (possible if charge_one_move_for_recon_and_interception option is active) +- Fix crash (0xC0000005) when a NULL city pointer is passed to City_has_improvement * RELEASE 28 PREVIEW 1 - Allow for custom combat bonuses or maluses to be applied based on unit type, combat role (attack, defense, or bombard), terrain, city/district, and experience level diff --git a/injected_code.c b/injected_code.c index f098880a..9b8578d6 100644 --- a/injected_code.c +++ b/injected_code.c @@ -16288,6 +16288,9 @@ show_map_specific_text (int tile_x, int tile_y, char const * text, bool pause) bool __fastcall patch_City_has_improvement (City * this, int edx, int improv_id, bool include_auto_improvements) { + if (this == NULL) + return false; + bool tr = City_has_improvement (this, __, improv_id, include_auto_improvements); // Check if the improvement is provided for free by another human player's wonder if we're in a hotseat game and the config option is on