GodotModding / godot-mod-loader

A general purpose mod loader for GDScript based Godot Games [3.x/4.x]
https://discord.godotmodding.com
Creative Commons Zero v1.0 Universal
365 stars 29 forks source link

fix: :bug: fixed super fixing #425

Closed KANAjetzt closed 4 days ago

KANAjetzt commented 5 days ago

With the changes from #420, we need to start the search for closing_paren_index at func_def_end - 1.

But this needs a deeper look. based on my debugging, it seems there’s more wrong with how we’re processing that part.

Some print debugging

``` text on func_def_end: ) -> method_name: _ready closing_paren_index: -1 func_def_end: 83 --- extends Portal @export var label_level_name_override := "New Game" func _ready() -> void: super() label_level_name.text = label_level_name_override func _on_hit_detector_body_entered(body: Node3D) -> void: super(body) Global.reset_game() No matching closing parenthesis text on func_def_end: body method_name: _on_hit_detector_body_entered closing_paren_index: -1 func_def_end: 210 --- extends Portal @export var label_level_name_override := "New Game" func vanilla_4007268940__ready() -> void: super() label_level_name.text = label_level_name_override func _on_hit_detector_body_entered(body: Node3D) -> void: super(body) Global.reset_game() No matching closing parenthesis ``` - I think `text on func_def_end` should always start with `)`. It looks like the result is shifted for the second method, and if this pattern continues, things will start to break again.

For now, this should be enough to keep things moving.

KANAjetzt commented 4 days ago

Oh right - in the morning everything seems clearer 😄 So I change it in get_closing_paren_index() then.

static func get_closing_paren_index(opening_paren_index: int, text: String) -> int:
    # Use a stack counter to match parentheses
    var stack := 0
    var closing_paren_index := opening_paren_index - 1 # Shift the index back by one to start before the opening parentheses.
        [...]
Qubus0 commented 4 days ago

nono, where it is is completely correct. that is a thing specific to using get_closing_paren_index right after match_func_with_whitespace. though that's the only way we use it currently since we do -1 in both fix_method_super and get_function_parameters

KANAjetzt commented 4 days ago

ok got it now 😄 then I add the comment where we call get_closing_paren_index() in fix_method_super() and get_function_parameters()