mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-07-07 04:22:53 +00:00
Fix budget growing too much
We were using += instead of =, meaning the budget always grew, rather than growing while there was still space. As a result, computers were never correctly rate limited. Further more, if a computer went into a deficit, we would continue to increase the budget by a negative amount, exponentially decreasing until overflowing! Yes, this is a very embarrassing mistake. I'd been aware that rate limiting wasn't working as expected for a while, I hadn't realised the problem would be this stupid.
This commit is contained in:
parent
b9fd690ecb
commit
8fafec4915
@ -134,7 +134,7 @@ public final class MainThread
|
|||||||
// Of course, we'll go over the MAX_TICK_TIME most of the time, but eventually that overrun will accumulate
|
// Of course, we'll go over the MAX_TICK_TIME most of the time, but eventually that overrun will accumulate
|
||||||
// and we'll skip a whole tick - bringing the average back down again.
|
// and we'll skip a whole tick - bringing the average back down again.
|
||||||
currentTick++;
|
currentTick++;
|
||||||
budget += Math.min( budget + ComputerCraft.maxMainGlobalTime, ComputerCraft.maxMainGlobalTime );
|
budget = Math.min( budget + ComputerCraft.maxMainGlobalTime, ComputerCraft.maxMainGlobalTime );
|
||||||
canExecute = budget > 0;
|
canExecute = budget > 0;
|
||||||
|
|
||||||
// Cool down any warm computers.
|
// Cool down any warm computers.
|
||||||
|
@ -224,7 +224,7 @@ final class MainThreadExecutor implements IWorkMonitor
|
|||||||
{
|
{
|
||||||
state = State.COOLING;
|
state = State.COOLING;
|
||||||
currentTick = MainThread.currentTick();
|
currentTick = MainThread.currentTick();
|
||||||
budget += Math.min( budget + ComputerCraft.maxMainComputerTime, ComputerCraft.maxMainComputerTime );
|
budget = Math.min( budget + ComputerCraft.maxMainComputerTime, ComputerCraft.maxMainComputerTime );
|
||||||
if( budget < ComputerCraft.maxMainComputerTime ) return false;
|
if( budget < ComputerCraft.maxMainComputerTime ) return false;
|
||||||
|
|
||||||
state = State.COOL;
|
state = State.COOL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user