Timestamps and Related Bugs

By: Brian Green                Date: May 27, 2006

Purpose:

This document details an old bug in the system dealing with timestamps and variable overflows.

Basics

The server provides timestamps to the scripting system which uses it for various aspects of the game.  Unfortunately, due to Blakod's limitation on maximum integer size, this causes overflows on a regular basis and causes problems with the game.

Details

Getting a timestamp

The scripting system can get a timestamp from the server by calling the function GetTime().  Originally, this returned the normal system time, which is the number of seconds since 1970.  Unfortunately, due to the limitations on the maximum integer value able to be stored by Blakod, the value of the timestamp is too large to store in a script variable.

The solution

The temporary solution has been to adjust the values returned by the function to the script system.  This is accomplished in the file \blakston\blakserv\ccode.c on line 2045.  Currently we subtract the long integer value of 1148678128L, which puts timestamp 0 sometime in the month of May, 2006.  This fix will work until the new timestamp value overflows the maximum integer value, which will happen in approximiately 4 years and 3 months.

Likewise, the client has to recalculate timestamps passed to it.  Currently this only affecs globe posts and mail message timestamps.  This value is set in file \blakston\module\mailnews\newsread.c on line 372.   The value should match the one set in the server above.  This code goes into the mailnews.dll client file.

Systems affected by the bug

Currently, there are a few systems that use timestamps and that will be affected by this bug.  They include:
The following systems are also affected, but can be fixed by doing "send class user UpdateTimeValues" at the server console or admin window.
Adjusting the values above should fix all problems except for the timestamps on globe posts and mail messages.  Unfortunately, these will always have incorrect dates when the times are adjusted.

Note that existing mail messages on the client have their timestamps converted into dates when they are downloaded.

Future directions

Unfortunately, it is easy to forget that we currently have a temporary fix.  This means the bug will become active again and require the change of the variables mentioned above.  It would be nice to have a solution that does not require recompiling the server and  a client DLL.

A proposed solution: