Skip to content

Commit a6f03a0

Browse files
committed
Improve buffer by setting a time limit on commands.
Only turn buffer off when its empty.
1 parent 29657f8 commit a6f03a0

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

LuaMenu/widgets/api_command_buffering.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ function widget:Update()
5757
return
5858
end
5959

60-
lobby.bufferCommandsEnabled = false
6160
local repetitions = 1
62-
while repetitions <= CMD_PER_UPDATE and lobby:ProcessBuffer() do
61+
local startTime = Spring.GetTimer()
62+
while Spring.DiffTimers(Spring.GetTimer(), startTime) < 0.05 and repetitions <= CMD_PER_UPDATE and lobby:ProcessBuffer() do
6363
repetitions = repetitions + 1
6464
end
65+
lobby.bufferCommandsEnabled = lobby.commandsInBuffer and (lobby.commandsInBuffer > 0)
6566
end

libs/liblobby/lobby/interface_shared.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,12 @@ function Interface:ProcessBuffer()
9494
self.bufferExecutionPos = self.bufferExecutionPos + 1
9595
local command = self.commandBuffer[self.bufferExecutionPos]
9696
if not self.commandBuffer[self.bufferExecutionPos + 1] then
97+
-- Reset buffer pointers because external widgets read (self.commandsInBuffer > 0)
98+
-- to set self.bufferCommandsEnabled.
9799
self:CommandReceived(command)
98100
self.commandBuffer = false
101+
self.commandsInBuffer = 0
102+
self.bufferExecutionPos = 0
99103
return false
100104
end
101105
self:CommandReceived(command)

0 commit comments

Comments
 (0)