Zero-K icon indicating copy to clipboard operation
Zero-K copied to clipboard

Wait command after some actions

Open N0U opened this issue 10 years ago • 1 comments

Somehow after some commands cons (and probably other units) get CMD.WAIT command. After they finish building anything they don't get WAIT command. I made this widget for testing:

function gadget:GetInfo()
  return {
    name      = "List orders",
    desc      = "List add orders for selected unit",
    author    = "banana_Ai",
    date      = "1 May 2016",
    license   = "GNU GPL, v2 or later",
    layer     = 0,
    enabled   = true,
  }
end


local echo=Spring.Echo

local function echoCommand(cmdID,cmdParams)
    local text="\tID "..tostring(cmdID)
    text=text.." params"
    for _,p in ipairs(cmdParams) do
        text=text.." "..tostring(p)
    end
    echo(text)
end

local function echoAllCommands(unitID)
    echo("\tUnit "..unitID)
    local cmds=Spring.GetUnitCommands(unitID)
    for _,cmd in ipairs(cmds) do
        echoCommand(cmd.id,cmd.params)
    end
end

function gadget:UnitCommand(unitID, unitDefID, unitTeam, cmdID, cmdOpts, cmdParams)
    echo("Command added")
    echoAllCommands(unitID)
    echoCommand(cmdID,cmdParams)
end

function gadget:UnitCmdDone(unitID, unitDefID, unitTeam, cmdID, cmdOpts, cmdParams)
    echo("Command is done")
    echoAllCommands(unitID)
end

I gave order commander to move

[f=0000107] Command added
[f=0000107]     Unit 4734
[f=0000107]     ID 10 params 855.05902099609 132.30780029297 511.00045776367
[f=0000107] Command added
[f=0000107]     Unit 4734
[f=0000107]     ID 10 params 855.05902099609 132.30780029297 511.00045776367
[f=0000107]     ID 70 params 1.2000000476837
[f=0000226] Command is done
[f=0000226]     Unit 4734
[f=0000226]     ID 70 params 1.2000000476837
[f=0000226] Command is done
[f=0000226]     Unit 4734
[f=0000240] Command added
[f=0000240]     Unit 4734
[f=0000240]     ID 5 params
[f=0000240] Command added
[f=0000240]     Unit 4734
[f=0000240]     ID 5 params
[f=0000240]     ID 5 params

After I pressed W to order it to wait

[f=0000314] Command added
[f=0000314]     Unit 4734
[f=0000314]     ID 5 params

Now I pressed W to cancel wait order

[f=0000405] Command added
[f=0000405]     Unit 4734
[f=0000405]     ID 5 params
[f=0000405]     ID 5 params

As Sprung told me, I changed my widget to a gadget and disable UI.

[f=0000000] Disabled LuaUI
[f=0000000] Command added
[f=0000000]     Unit 4734
[f=0000000]     ID 50 params 1
[f=0000000] Command added
[f=0000000]     Unit 4734
[f=0000000]     ID 50 params 1
[f=0000000] Command added
[f=0000000]     Unit 4734
[f=0000000]     ID 45 params 2
[f=0000000] Command added
[f=0000000]     Unit 4734
[f=0000000]     ID 45 params 2
[f=0000000] Command added
[f=0000000]     Unit 11555
[f=0000000]     ID 50 params 1
[f=0000000] Command added
[f=0000000]     Unit 11555
[f=0000000]     ID 50 params 1
[f=0000000] Command added
[f=0000000]     Unit 11555
[f=0000000]     ID 45 params 2
[f=0000000] Command added
[f=0000000]     Unit 11555
[f=0000000]     ID 45 params 2
[f=0000229] <banana_Ai> +M     -- Here I order my com to move
[f=0000279] Command added
[f=0000279]     Unit 4734
[f=0000279]     ID 10 params 857.70416259766 133.04742431641 467.08847045898
[f=0000279] Command added
[f=0000279]     Unit 4734
[f=0000279]     ID 10 params 857.70416259766 133.04742431641 467.08847045898
[f=0000279] Command added
[f=0000279]     Unit 4734
[f=0000279]     ID 10 params 857.70416259766 133.04742431641 467.08847045898
[f=0000279]     ID 70 params 1.2000000476837
[f=0000279] Command added
[f=0000279]     Unit 4734
[f=0000279]     ID 10 params 857.70416259766 133.04742431641 467.08847045898
[f=0000279]     ID 70 params 1.2000000476837
[f=0000346] Command is done
[f=0000346]     Unit 4734
[f=0000346]     ID 70 params 1.2000000476837
[f=0000346] Command is done
[f=0000346]     Unit 4734
[f=0000346]     ID 70 params 1.2000000476837
[f=0000346] Command is done
[f=0000346]     Unit 4734
[f=0000346] Command is done
[f=0000346]     Unit 4734
[f=0000363] Command added
[f=0000363]     Unit 4734
[f=0000363]     ID 5 params
[f=0000363] Command added
[f=0000363]     Unit 4734
[f=0000363]     ID 5 params
[f=0000363] Command added
[f=0000363]     Unit 4734
[f=0000363]     ID 5 params
[f=0000363]     ID 5 params
[f=0000363] Command added
[f=0000363]     Unit 4734
[f=0000363]     ID 5 params
[f=0000363]     ID 5 params
[f=0000525] <banana_Ai> +W  -- Here I ordered my com to wait
[f=0000542] Command added
[f=0000542]     Unit 4734
[f=0000542]     ID 5 params
[f=0000542] Command added
[f=0000542]     Unit 4734
[f=0000542]     ID 5 params
[f=0000625] <banana_Ai> -W  -- Here I ordered my com to wait again (so it will remove wait command)
[f=0000654] Command added
[f=0000654]     Unit 4734
[f=0000654]     ID 5 params
[f=0000654]     ID 5 params
[f=0000654] Command added
[f=0000654]     Unit 4734
[f=0000654]     ID 5 params
[f=0000654]     ID 5 params
[f=0001141] Command added
[f=0001141]     Unit 4734
[f=0001141]     ID -267 params 896 132.88571166992 464 0   -- Here I started to build defender
[f=0001141] Command added
[f=0001141]     Unit 4734
[f=0001141]     ID -267 params 896 132.88571166992 464 0
[f=0001141] Command added
[f=0001141]     Unit 3711
[f=0001141]     ID 45 params 2
[f=0001141] Command added
[f=0001141]     Unit 3711
[f=0001141]     ID 45 params 2
[f=0001141] Command added
[f=0001141]     Unit 4734
[f=0001141]     ID -267 params 896 132.88571166992 464 0
[f=0001141]     ID 70 params 1.2000000476837
[f=0001141] Command added
[f=0001141]     Unit 4734
[f=0001141]     ID -267 params 896 132.88571166992 464 0
[f=0001141]     ID 70 params 1.2000000476837
[f=0001352] Command is done
[f=0001352]     Unit 4734
[f=0001352]     ID 70 params 1.2000000476837
[f=0001352] Command is done
[f=0001352]     Unit 4734
[f=0001352]     ID 70 params 1.2000000476837
[f=0001352] Command is done
[f=0001352]     Unit 4734
[f=0001352] Command is done
[f=0001352]     Unit 4734   -- After that orders queue is empty

It seems that wait command is added after each command, but build. Wait bug is confirmed in ZK with luaui disabled and with luarules disabled (I tested them separately. I disabled ui and echoed commands via the gadget. Than launch again, disabled rules and echoed commands via the widget). Than I downloaded SpringTutorialGame and put my widget in it. This bug is confirmed in it.
So it is an engine bug. Wait bug appears on 99.0 engine, but not on 91.0.

N0U avatar Mar 01 '16 13:03 N0U

Fixed ZK-side https://github.com/ZeroK-RTS/Zero-K/pull/1312

sprunk avatar Mar 24 '16 14:03 sprunk