Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The problem identified by the stack trace below is caused by the json library changing the key type to a string for both the _priority and _intel tables. Since LUA differentiates between a number and string when looking up a key in a table you can actually have a table construction like the following; { 1 = 1234, "1" = 789, } This will result in two different values being returned depending on if you asked for the key `"1"` or `1`. The solution is to turn these table keys back into numbers when reading in the state file. Stack trace: 2020-05-01 22:45:15.811 ERROR SCRIPTING: DCT|Theater: protected call - [string "C:\Saved Games\DCS.openbeta\Mods\tech\DCT\lua\dct\Asset.lua"]:149: attempt to index field '?' (a nil value) stack traceback: [string "C:\Saved Games\DCS.openbeta\Mods\tech\DCT\lua\dct\Theater.lua"]:338: in function <[string "C:\Saved Games\DCS.openbeta\Mods\tech\DCT\lua\dct\Theater.lua"]:336> [string "C:\Saved Games\DCS.openbeta\Mods\tech\DCT\lua\dct\Asset.lua"]:149: in function 'getPriority' [string "C:\Saved Games\DCS.openbeta\Mods\tech\DCT\lua\dct\ai\Commander.lua"]:25: in function 'heapsort_tgtlist' [string "C:\Saved Games\DCS.openbeta\Mods\tech\DCT\lua\dct\ai\Commander.lua"]:191: in function 'requestMission' [string "C:\Saved Games\DCS.openbeta\Mods\tech\DCT\lua\dct\ui\cmds.lua"]:171: in function '_execute' [string "C:\Saved Games\DCS.openbeta\Mods\tech\DCT\lua\dct\ui\cmds.lua"]:48: in function 'execute' [string "C:\Saved Games\DCS.openbeta\Mods\tech\DCT\lua\dct\Theater.lua"]:318: in function '_exec' [string "C:\Saved Games\DCS.openbeta\Mods\tech\DCT\lua\dct\Theater.lua"]:341: in function <[string "C:\Saved Games\DCS.openbeta\Mods\tech\DCT\lua\dct\Theater.lua"]:340> [C]: in function 'xpcall' [string "C:\Saved Games\DCS.openbeta\Mods\tech\DCT\lua\dct\Theater.lua"]:344: in function <[string "C:\Saved Games\DCS.openbeta\Mods\tech\DCT\lua\dct\Theater.lua"]:335> Finally, add a unit-test to catch this issue in the future by triggering a user command after the state file has been read back in. Closes: #74 Fixes: 942e4c4 ("asset: use composition to represent different asset types")
- Loading branch information