carenalgas / popochiu

Godot plugin to make point-and-click adventure games, inspired by tools like Adventure Game Studio and PowerQuest.
https://carenalgas.github.io/popochiu/
MIT License
207 stars 19 forks source link

Issue when changing to a room with a missing hotspot #320

Closed balloonpopper closed 3 weeks ago

balloonpopper commented 4 weeks ago

Bug description

As discussed here on Discord : https://discordapp.com/channels/970008012553068583/970133408737005588/1300088547868414003 When changing rooms to a room with a broken hotspot (i.e. you've deleted the hotspot but not the files on the filesystem relating to the hotspot), the game breaks and "Cannot call method 'get_script' on a null value" is displayed. Error is on popochui_resources.gd:474, from i_room.gd:270, from popochui_room.gd:109

When you change rooms, the code in i_room.gd searches through all the hotspots in your room. If a hotspot has been deleted but the files still exist on the filesystem, the error happens. The strange thing about it is that the room you start the game from is not evaluated.

Steps to reproduce

In both scenarios, room 1 is the default game start room. Hotspots are broken by creating a hotspot, deleting the hotspot, but leaving the files on the filesystem.

Scenario 1 : I break a hotspot in room 1. If I start the game from room 1 (F5 or F6), I can go between room 1 and 2 as many times as I like and it won't break. If I start the game from room 2 (F6) and change to room 1, it breaks.

Scenario 2 : I break the a hotspot in room 2 instead. If I start the game from room 2 (F6), I can go between room 2 and room 1 as many times as I like and it won't break. If I start the game from room 1 (F5 or F6), when I go to room 2 it breaks.

Expected vs observed behavior

The engine should print a debug error about a missing hotspot but continue, instead it breaks.

Environment information (please complete):

Additional information

The code below (null check on the last 2 lines) fixes the problem, but I'm not submitting it as a pull request as it appears to be more of a mask for the problem than a fix. The package maintainers may decide it's sufficient to fix the problem though.

i_room.gd : line 259

    for type in PopochiuResources.ROOM_CHILDREN:
        print("RS = "+str(rooms_states[room.script_name][type]))
        for script_name in rooms_states[room.script_name][type]:
            var node: Node2D = current.callv(
                "get_" + type.trim_suffix("s"),
                [(script_name as String).to_pascal_case()]
            )
            if node == null:
                continue
mapedorr commented 3 weeks ago

Thanks for the deatiled info, I'll take a look. I have a question: when you delete the room, do you use the Remove option in the Hotspot's menu in the Room tab? Or do you delete it directly from the Hotspots node in the tree?

balloonpopper commented 3 weeks ago

When I delete the hotspot I delete it using the remove option in the hotspot menu (but don't select the checkbox to delete the files for the hotspot)