Skip to content

Commit

Permalink
hooks: fix concatenate error when player occupies special role slot
Browse files Browse the repository at this point in the history
It issue occurs when a player occupies a special role slot. This causes
the slot id to be set in the player object but the groupName field
is nil, which results in the concatenation error. The solution is
to test if the player is in a special role slot.

2021-02-02 00:32:03.259 ERROR   [DCT-HOOKS]: call to hook failed; [string "C:\Users\<user>\Saved Games\DCS.openbeta\Scripts/Hooks//dct-hook.lua"]:555: attempt to concatenate local 'grpname' (a nil value)
stack traceback:
    [string "C:\Users\<user>\Saved Games\DCS.openbeta\Scripts/Hooks//dct-hook.lua"]:602: in function 'dct_call_hook'
    [string "C:\Users\<user>\Saved Games\DCS.openbeta\Scripts/Hooks//dct-hook.lua"]:639: in function <[string "C:\Users\<user>\Saved Games\DCS.openbeta\Scripts/Hooks//dct-hook.lua"]:638>
    [C]: in function 'pcall'
    [string "MissionEditor/loadUserScripts.lua"]:129: in function <[string "MissionEditor/loadUserScripts.lua"]:124>
    (tail call): ?
  • Loading branch information
jtoppins committed Feb 2, 2021
1 parent 1907c9a commit 2c76beb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion hooks/dct-hook.lua
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,15 @@ function DCTHooks:kickPlayerFromSlot(player)
if player.slot == nil then
return
end
local slot = self.slots[player.slot]
if not slot or special_unit_role_types[slot.role] ~= nil then
return
end

local grpname = self.slots[player.slot].groupName
local grpname = slot.groupName
if not grpname then
return
end
local kick = do_rpc("server", rpc_get_flag(grpname.."_kick"), "number")
if kick ~= 1 then
return
Expand Down

0 comments on commit 2c76beb

Please sign in to comment.