Skip to content

Commit

Permalink
Fix MissionCommand bugs
Browse files Browse the repository at this point in the history
Fix Command bugs for Coalition and Group level mission commands.
  • Loading branch information
rurounijones committed Mar 6, 2022
1 parent 6e0ef67 commit 1ea5ed7
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lua/DCS-gRPC/methods/mission.lua
Original file line number Diff line number Diff line change
Expand Up @@ -463,19 +463,22 @@ end

GRPC.methods.addCoalitionCommand = function(params)
return GRPC.success({
path = missionCommands.addCommandForCoalition(params.coalition, params.name, params.path,
-- Decrement coalition for non zero-indexed gRPC enum
path = missionCommands.addCommandForCoalition(params.coalition - 1, params.name, params.path,
coalitionCommandCallback, params)
})
end

GRPC.methods.addCoalitionCommandSubMenu = function(params)
return GRPC.success({
path = missionCommands.addSubMenuForCoalition(params.coalition, params.name, params.path)
-- Decrement coalition for non zero-indexed gRPC enum
path = missionCommands.addSubMenuForCoalition(params.coalition - 1, params.name, params.path)
})
end

GRPC.methods.removeCoalitionCommandItem = function(params)
missionCommands.removeItemForCoalition(params.coalition, params.path)
-- Decrement coalition for non zero-indexed gRPC enum
missionCommands.removeItemForCoalition(params.coalition - 1, params.path)
return GRPC.success(nil)
end

Expand All @@ -494,35 +497,35 @@ local function groupCommandCallback(params)
})
end

GRPC.methods.addCoalitionCommand = function(params)
GRPC.methods.addGroupCommand = function(params)
local group = Group.getByName(params.groupName)
if group == nil then
return GRPC.errorNotFound("group does not exist")
end

return GRPC.success({
path = missionCommands.addCommandForCoalition(group:getID(), params.name, params.path,
path = missionCommands.addCommandForGroup(group:getID(), params.name, params.path,
groupCommandCallback, params.details)
})
end

GRPC.methods.addCoalitionCommandSubMenu = function(params)
GRPC.methods.addGroupCommandSubMenu = function(params)
local group = Group.getByName(params.groupName)
if group == nil then
return GRPC.errorNotFound("group does not exist")
end

return GRPC.success({
path = missionCommands.addSubMenuForCoalition(group:getID(), params.name, params.path)
path = missionCommands.addSubMenuForGroup(group:getID(), params.name, params.path)
})
end

GRPC.methods.removeCoalitionCommandItem = function(params)
GRPC.methods.removeGroupCommandItem = function(params)
local group = Group.getByName(params.groupName)
if group == nil then
return GRPC.errorNotFound("group does not exist")
end

missionCommands.removeItemForCoalition(group:getID(), params.path)
missionCommands.removeItemForGroup(group:getID(), params.path)
return GRPC.success(nil)
end

0 comments on commit 1ea5ed7

Please sign in to comment.