Author Topic: A Blockland Glitch I'd only like to share.  (Read 2950 times)

I've posted this before, but the post must have been lost in the Great Coding Help Culling of 2015.

Blockland stores time in a 32-bit signed integer.  The maximum positive value this data type can store is 2,147,483,647.  Now, last time I made a very broad, sweeping statement that all of the ways you could get the simtime used this value at their core.  I don't actually know if this is true, but it would amaze me if it were not.  For one thing, it would mean that $Sim::Time would rapidly build up inaccuracies and deviate wildly from the correct value.

Assuming, however, that it is true, and every possible way you can get the simtime uses the same 32-bit integer at their core, then all of them will eventually overflow at the same time as the game passes 2147483647 milliseconds of uptime.  With some basic arithmetic, we know that this occurs after:

24 days, 20 hours, 31 minutes, 23 seconds, and 647 milliseconds.


After this period, any scripts or code that use getSimTime() or $Sim::Time and aren't designed to be Ragnarok-proofed against simtime suddenly jumping to -2147483648 milliseconds will probably experience glitches.  These can range from momentary bizarreness at the discontinuity, or extremely long-lived glitches that last until the simtime reaches a value of 0 milliseconds again, after 24 days, 20 hours, 31 minutes, 23 seconds, and 648 milliseconds.  In theory, at this point, all of the problems would stop occurring for another 2147483647 milliseconds.

In theory, anyway.  I don't think anyone's ever hosted a server for 50 continuous days without restart.  If anyone wants to try, go for it; I'd be interested to see if the problems actually did stop or if they continued indefinitely.

i just realized

this is the aot master server glitch all over again

this is the aot master server glitch all over again

Yes.  Same root cause, different symptoms.

Hold on--tell me if I'm crazy here--but why doesn't BL just have a host-only command to reset the value to 0? Wouldn't that fix this?

Or better, a periodic check(10m) for sim time to be negative, and if it is, reset it to 0. This seems like a really simple and elegant solution to the problem.
« Last Edit: May 31, 2016, 09:18:05 PM by superdupercoolguy »

Hold on--tell me if I'm crazy here--but why doesn't BL just have a host-only command to reset the value to 0? Wouldn't that fix this?

Or better, a periodic check(10m) for sim time to be negative, and if it is, reset it to 0. This seems like a really simple and elegant solution to the problem.
$Sim::Time can't just be reset to zero (you can briefly set it to 0 but it'll continue counting on afterwards like it was never set to zero), and also there would be no need to check even every 10 minutes if it was negative if this was possible, but only every ~24 days just before it overflows.

$Sim::Time can't just be reset to zero (you can briefly set it to 0 but it'll continue counting on afterwards like it was never set to zero), and also there would be no need to check even every 10 minutes if it was negative if this was possible, but only every ~24 days just before it overflows.

I'm talking something that Badspot would have to implement.

The problem with the entire checking thing, now that I think about it, is that you're adding more things to process every second. I think the best solution would be to just have a command to reset it.

Then again, Badspot doesn't update BL so it doesn't matter

resetting it wouldn't do any good, it'll still forget up scripts n stuff

resetting it wouldn't do any good, it'll still forget up scripts n stuff
For example...

obj.lastSomethingTime = 2147001234
sim time was reset to 0
Code: [Select]
if(getSimTime()-1000 > obj.lastSomethingTime)
{
dostuff();
obj.lastSomethingTime = getSimTime();
}
if(<some relatively low number>-1000 > 2147001234)
this will return false, preventing whatever this check is for from working for a very long time.

« Last Edit: June 01, 2016, 12:46:13 PM by Meta_KnightX »

Lovely,
Petition to make dostuff(); an actual console command

Petition to make dostuff(); an actual console command
or you could just make it an actual console command.

Code: [Select]
function dostuff(%del)
{
for(%x=0;%x<$stuffList;%x++)
schedule(0,0,$stuffList[%x]);
if(%del)
DeleteVariables($stuffList*);
}