2021-03-11, 11:18 PM
The wiki is sort of correct, but the solution is very very wrong. You just need to use a subtraction.
While the code might look like this before:
The solution is amazingly simple - just rearrange the formula
That will totally account for all wrap-around and negative numbers (I'm not going to prove it mathematically here though).
While the code might look like this before:
Code:
if (newTime < oldTime 2000)
{
// Flooding.
}
The solution is amazingly simple - just rearrange the formula
Code:
if (newTime - oldTime < 2000)
{
// Flooding.
}
That will totally account for all wrap-around and negative numbers (I'm not going to prove it mathematically here though).