Skip to content

Commit 1eeee04

Browse files
committed
Revert "Make CMD_STOP_PRODUCTION preserve unit being built unless it's the only one in queue. (beyond-all-reason#4762)"
This reverts commit 8263814.
1 parent cf4be05 commit 1eeee04

File tree

1 file changed

+15
-31
lines changed

1 file changed

+15
-31
lines changed

luarules/gadgets/cmd_factory_stop_production.lua

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if gadgetHandler:IsSyncedCode() then
2929

3030
local CMD_WAIT = CMD.WAIT
3131
local EMPTY = {}
32-
local DEQUEUE_OPTS = CMD.OPT_RIGHT -- right: dequeue, ctrl+shift: 100
32+
local DEQUEUE_OPTS = { "right", "ctrl", "shift" } -- right: dequeue, ctrl+shift: 100
3333

3434
local stopProductionCmdDesc = {
3535
id = CMD_STOP_PRODUCTION,
@@ -50,21 +50,21 @@ if gadgetHandler:IsSyncedCode() then
5050

5151
local function orderDequeue(unitID, buildDefID, count)
5252
while count > 0 do
53-
local opts = DEQUEUE_OPTS
54-
if count >= 100 then
55-
count = count - 100
56-
opts = opts + CMD.OPT_SHIFT + CMD.OPT_CTRL
57-
elseif count >= 20 then
58-
count = count - 20
59-
opts = opts + CMD.OPT_CTRL
60-
elseif count >= 5 then
61-
count = count - 5
62-
opts = opts + CMD.OPT_SHIFT
63-
else
64-
count = count - 1
65-
end
53+
-- The commented code below might still be useful in some circumstance we need 'perfect' dequeue
54+
--
55+
-- if count >= 100 then
56+
count = count - 100
57+
-- elseif count >= 20 then
58+
-- opts = { "ctrl" }
59+
-- count = count - 20
60+
-- elseif count >= 5 then
61+
-- opts = { "shift" }
62+
-- count = count - 5
63+
-- else
64+
-- count = count - 1
65+
-- end
6666

67-
spGiveOrderToUnit(unitID, -buildDefID, EMPTY, opts)
67+
spGiveOrderToUnit(unitID, -buildDefID, EMPTY, DEQUEUE_OPTS)
6868
end
6969
end
7070

@@ -77,24 +77,8 @@ if gadgetHandler:IsSyncedCode() then
7777
-- As opposed to removing each build command individually
7878
local queue = spGetRealBuildQueue(unitID)
7979
if queue ~= nil then
80-
local total = 0
81-
for _, buildPair in ipairs(queue) do
82-
local _, count = next(buildPair, nil)
83-
total = total + count
84-
end
85-
local keepDefID
86-
if total > 1 then
87-
local firstCommand = Spring.GetFactoryCommands(unitID, 1)
88-
local firstID = firstCommand[1]['id']
89-
if firstID < 0 then
90-
keepDefID = -firstID
91-
end
92-
end
9380
for _, buildPair in ipairs(queue) do
9481
local buildUnitDefID, count = next(buildPair, nil)
95-
if keepDefID == buildUnitDefID then
96-
count = count - 1
97-
end
9882
orderDequeue(unitID, buildUnitDefID, count)
9983
end
10084
end

0 commit comments

Comments
 (0)