Maintain timer sort invariants when changing period

See: https://github.com/OpenTTD/OpenTTD/issues/12509
This commit is contained in:
Jonathan G Rennison
2024-04-20 15:09:49 +01:00
parent 674642f9cc
commit 33baceaef7
2 changed files with 16 additions and 2 deletions

View File

@@ -99,7 +99,7 @@ public:
*/
void SetInterval(const TPeriod interval, bool reset = true)
{
this->period = interval;
TimerManager<TTimerType>::ChangeRegisteredTimerPeriod(*this, interval);
if (reset) this->storage = {};
}
@@ -151,7 +151,7 @@ public:
*/
void Reset(const TPeriod timeout)
{
this->period = timeout;
TimerManager<TTimerType>::ChangeRegisteredTimerPeriod(*this, timeout);
this->fired = false;
this->storage = {};
}