From c115e7b2d6d10bb540d63bc4411a4a42a76e1513 Mon Sep 17 00:00:00 2001 From: Tiger Jove Date: Wed, 21 Jan 2026 15:09:59 +0100 Subject: [PATCH] fix: room identification and save games were getting tangled up --- .../transition/code/subway_sequence.gd | 4 +--- .../volunteer_room/shared_flat.gd | 3 +-- src/base-environments/youth_room/youth_room.gd | 5 +++++ src/dev-util/bug_button.gd | 2 +- src/dev-util/room_template.gd | 6 ------ src/dev-util/savegame.gd | 14 +++++++++----- src/logic-scenes/card_picker/card_picker.gd | 2 -- 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/base-environments/transition/code/subway_sequence.gd b/src/base-environments/transition/code/subway_sequence.gd index 76ba653..eefb172 100644 --- a/src/base-environments/transition/code/subway_sequence.gd +++ b/src/base-environments/transition/code/subway_sequence.gd @@ -4,8 +4,8 @@ class_name SubwaySequence @export var all_stations: Dictionary[Station.id, Station] @export var all_lines: Dictionary[TrainLine.id, TrainLine] func _ready() -> void: - super._ready() id = State.rooms.TRANSITION + super._ready() func start_room(): @@ -18,9 +18,7 @@ func start_room(): func pull_save_state(save: SaveGame) -> void: - #FIXME save.sequences_enabled = Scenes.enabled_sequences - save.current_room = State.rooms.ADULTHOOD save_game = save # Call parent to restore player position diff --git a/src/base-environments/volunteer_room/shared_flat.gd b/src/base-environments/volunteer_room/shared_flat.gd index 95ee246..e4420a3 100644 --- a/src/base-environments/volunteer_room/shared_flat.gd +++ b/src/base-environments/volunteer_room/shared_flat.gd @@ -4,8 +4,8 @@ extends RoomTemplate @onready var player: PlayerController = %PlayerController func _ready(): - super._ready() id = State.rooms.ADULTHOOD + super._ready() func get_ready() -> void: @@ -14,7 +14,6 @@ func get_ready() -> void: Scenes.scene_finished.connect(_on_scene_finished) card_picker.cards_picked.connect(card_board.populate_board) save_game = State.save_game - save_game.current_room = State.rooms.ADULTHOOD Scenes.completed_sequences = save_game.mementos_complete Scenes.started_sequences = save_game.mementos_complete Scenes.enabled_sequences = save_game.sequences_enabled diff --git a/src/base-environments/youth_room/youth_room.gd b/src/base-environments/youth_room/youth_room.gd index 5230f15..dff1196 100644 --- a/src/base-environments/youth_room/youth_room.gd +++ b/src/base-environments/youth_room/youth_room.gd @@ -7,6 +7,11 @@ extends RoomTemplate @onready var card_picker: CardPicker = %Picker @onready var ui: Control = %UI +func _ready() -> void: + id = State.rooms.YOUTH + super._ready() # UwU, superclass _ready is not called by Godot automatically... + + func start_room(): super.start_room() diff --git a/src/dev-util/bug_button.gd b/src/dev-util/bug_button.gd index 63e3616..d95d13e 100644 --- a/src/dev-util/bug_button.gd +++ b/src/dev-util/bug_button.gd @@ -19,7 +19,7 @@ func create_bug_report(): Current Focus: %s Current Scene: %s Mementos: %s - """ % [OS.get_name(), OS.get_video_adapter_driver_info(), Scenes.current_sequence, State.current_room, Scenes.completed_sequences] + """ % [OS.get_name(), OS.get_video_adapter_driver_info(), Scenes.current_sequence, State.room, Scenes.completed_sequences] #debug_text = debug_text.replace(" ", "%20").replace("\n", "%0A").replace("\t", "") diff --git a/src/dev-util/room_template.gd b/src/dev-util/room_template.gd index e59a819..396a68f 100644 --- a/src/dev-util/room_template.gd +++ b/src/dev-util/room_template.gd @@ -12,24 +12,18 @@ signal proceed(next_scene_path: String) func _ready() -> void: State.room = self - State.current_room = id if not State.save_game: push_warning("Room initialised without a SaveGame. Creating proxy save.") State.save_game = ResourceLoader.load("res://dev-util/debug_save.tres") save_game = State.save_game - save_game.current_room = id - save_game.player_position = %PlayerController.global_position if not Main.normal_boot: push_warning("------- DEBUG MODE --------") play.call_deferred() -func disable()-> void: - push_warning("Room disabling is deprecated / unter reconstruction") - func get_ready(): prints("----------", "GET_READY", self.name, "--------------") pass diff --git a/src/dev-util/savegame.gd b/src/dev-util/savegame.gd index dfa9729..7c06d6d 100644 --- a/src/dev-util/savegame.gd +++ b/src/dev-util/savegame.gd @@ -134,11 +134,15 @@ func save_to_file(screen_shot: Texture2D) -> void: push_warning("SaveGame: DEBUG save skipped (intentional).") return - if current_room == State.rooms.NULL: - push_warning("SaveGame: Not saving empty savegame.") - return + assert(State.room, "Trying to save while not in a room.") + assert(State.room.id != State.rooms.NULL, "Trying to save in a room that's not correctly initialized.") - print_debug("SaveGame: Saving to file: %s" % file_name) + # Save game can track the room it is in by itself; + # and we should never save before having successfully entered a room. + current_room = State.room.id + + prints("-----------", "SAVE POINT", State.room, "-----------") + print("SaveGame: Saving to file: %s" % file_name) # Capture current state capture_player_state() @@ -184,7 +188,7 @@ func _validate_board_state() -> bool: if not position is Vector2: push_error("Save %s: Corrupted board positions" % unique_save_name) return false - + # Validate attachments (sticky must exist, card must exist) for sticky_name in board_attachments.keys(): var card_name := board_attachments[sticky_name] diff --git a/src/logic-scenes/card_picker/card_picker.gd b/src/logic-scenes/card_picker/card_picker.gd index e0f4ea3..299bbef 100644 --- a/src/logic-scenes/card_picker/card_picker.gd +++ b/src/logic-scenes/card_picker/card_picker.gd @@ -230,6 +230,4 @@ func pick_cards(id: Scenes.id): await cards_picked hide() - await get_tree().process_frame - State.room.save_room()