Skip to content

Commit d2751e6

Browse files
committed
making customCommands robust on units sharing [https://trello.com/c/tg1OcR80/], 3.0.2
1 parent e95a81c commit d2751e6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

customCommands.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ customCommands = {
184184
-- @argument unitID [number] Spring unitID
185185
-- @argument unitDefID [number] Spring unitDefID
186186
-- @argument teamID [number] Spring teamID
187-
-- @argument builderID [number] Spring unitID of builder of given unit
188-
["UnitIncomming"] = function(unitID, unitDefID, teamID, builderID)
187+
["UnitIncomming"] = function(unitID, unitDefID, teamID)
189188
unitName = UnitDefs[unitDefID].name
190189
for internalCmdName, cmdDesc in pairs(customCommandsDescriptions) do
191190
if (customCommandsNameToTeamID[internalCmdName] == teamID) then -- if ownded by proper team
@@ -198,6 +197,11 @@ customCommands = {
198197
Spring.EditUnitCmdDesc(unitID, index, cmdDesc)
199198
end
200199
end
200+
else -- for taken units remove invalid commands (owned only by donator)
201+
local index = Spring.FindUnitCmdDesc(unitID, cmdDesc.id)
202+
if (index ~= nil) then
203+
Spring.RemoveUnitCmdDesc(unitID, index)
204+
end
201205
end
202206
end
203207
end,

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
customCommands 3.0.1
1+
customCommands 3.0.2
22
===
33

44
This module allows you to

0 commit comments

Comments
 (0)