From 5e3624eb29c6078b7fd489808951260759dec541 Mon Sep 17 00:00:00 2001 From: autocommit Date: Sat, 6 Jun 2026 23:56:40 -0700 Subject: [PATCH] =?UTF-8?q?fix(climate):=20=F0=9F=90=9B=20Prevent=20crashe?= =?UTF-8?q?s=20in=20ecological=20event=20spawning=20by=20adding=20null/abs?= =?UTF-8?q?ent=20checks=20for=20resource=20configurations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- .../engine/src/modules/climate/ecological_event_utils.gd | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/game/engine/src/modules/climate/ecological_event_utils.gd b/src/game/engine/src/modules/climate/ecological_event_utils.gd index 98625dfc..c0333f4d 100644 --- a/src/game/engine/src/modules/climate/ecological_event_utils.gd +++ b/src/game/engine/src/modules/climate/ecological_event_utils.gd @@ -91,7 +91,13 @@ static func spawn_resource(tile: Variant, cfg: Dictionary) -> void: spawn_resource_weighted(tile, table) return - var resource_id: String = cfg.get("spawns_resource", "") + # `Dictionary.get(key, default)` only returns `default` when the key is + # ABSENT — a config with an explicit `"spawns_resource": null` returns + # `null` (Nil), which crashes a direct assignment to a typed `String`. + # Guard the null/absent case → no-spawn, matching `resource_terrain` below. + var resource_id: String = "" + if cfg.get("spawns_resource") != null: + resource_id = str(cfg["spawns_resource"]) if resource_id == "" or resource_id == "null": return var resource_terrain: Variant = cfg.get("resource_terrain", null)