fix(items): safe cast in _try_return_to_chest, typed chest state param, object_states reset

- Replace unsafe direct cast in HoldableItem._try_return_to_chest() with guarded as-cast
- Type set_chest_state() parameter as Array[String] to match RoomChest._get_spawned_ids()
- Add else-branch in apply_save_data() to reset _object_states when key absent
- Rename test_save_data_has_version_two to test_save_data_has_version_three
This commit is contained in:
Steven Wroblewski
2026-05-09 01:12:29 +02:00
parent 96ec053331
commit 87db92955a
3 changed files with 8 additions and 3 deletions
+3 -1
View File
@@ -63,7 +63,7 @@ func get_chest_state(chest_id: String) -> Array:
return _chest_states.get(chest_id, [])
func set_chest_state(chest_id: String, spawned_item_ids: Array) -> void:
func set_chest_state(chest_id: String, spawned_item_ids: Array[String]) -> void:
_chest_states[chest_id] = spawned_item_ids
state_changed.emit()
@@ -108,6 +108,8 @@ func apply_save_data(data: Dictionary) -> void:
_character_held_items = {}
if data.has("object_states"):
_object_states = data["object_states"]
else:
_object_states = {}
if data.has("current_room"):
current_room = data["current_room"]
if data.has("music_volume"):