TTT-2 / TTT2

Trouble in Terrorist Town 2 for Garry's Mod (gmod)
https://steamcommunity.com/sharedfiles/filedetails/?id=1357204556
178 stars 74 forks source link

Language selection error #1068

Closed mexikoedi closed 1 year ago

mexikoedi commented 1 year ago

Your version of TTT2 (mandatory)

Describe the bug (mandatory)

If you switch the language in the F1 menu to another language and then switch back to another language you will receive the following error in the console: [TTT2 (Base) - v0.11.7b] lua/includes/modules/cvars.lua:48: attempt to call local 'callback' (a nil value)

  1. unknown - lua/includes/modules/cvars.lua:48
    1. SetString - [C]:-1
    2. SetConVarValues - gamemodes/terrortown/gamemode/client/cl_vskin/vgui/dcombobox_ttt2.lua:398
      1. ChooseOptionID - gamemodes/terrortown/gamemode/client/cl_vskin/vgui/dcombobox_ttt2.lua:188
      2. ChooseOptionValue - gamemodes/terrortown/gamemode/client/cl_vskin/vgui/dcombobox_ttt2.lua:197
      3. SetValue - gamemodes/terrortown/gamemode/client/cl_vskin/vgui/dcombobox_ttt2.lua:336
      4. DoClick - gamemodes/terrortown/gamemode/client/cl_vskin/vgui/dcombobox_ttt2.lua:307
        1. OnMouseReleased - lua/vgui/dlabel.lua:237
        2. unknown - lua/vgui/dmenuoption.lua:76

The language completion rate is also bugged. For example English is 100 % complete then you change to another language and back to English and you will see something different like 81.7 % or 45.8 % ... .

To reproduce

Steps to reproduce the behaviour:

  1. Go to the F1 menu
  2. Click on Language
  3. Select a different language
  4. Switch back to another language
  5. See error and weird completion rate

Expected behaviour

It should not create an error and the completion rate should be correct.

Context (please provide as much as you can)

Tested with TTT2 Base, ULX, ULIB, ULX for TTT2 and some TTT2 roles installed.

TimGoll commented 1 year ago

yes, the language selection has a few minor bugs that we have to fix

NickCloudAT commented 1 year ago

Not sure if I'm correct, but it seems like the game can't keep track of the callback function created here: https://github.com/TTT-2/TTT2/blob/master/gamemodes/terrortown/gamemode/client/cl_vskin/vgui/dcombobox_ttt2.lua#L343

If I take out those two line here: https://github.com/TTT-2/TTT2/blob/master/lua/terrortown/menus/gamemode/language/language.lua#L31 https://github.com/TTT-2/TTT2/blob/master/lua/terrortown/menus/gamemode/language/language.lua#L32

The error disappears after changing the language once. It then only comes back if I go back one menu (so main menu) and then go into the language menu again and select a language. The error then only happens once though.

NickCloudAT commented 1 year ago

Soo.. after digging through it I'm now pretty sure that the game doesn't keep track of the functions correctly.. I made a "draft" in a branch which would fix both issues: https://github.com/NickCloudAT/TTT2/commit/752492aae0ba0aefcbc3a2144cbac76e4d6b805e

It still contains debug messages and is not fletched out though.. but works.

Spanospy commented 1 year ago

Adding a comment to say that this error message can be replicated with an addon's convar combobox!