[1546] in Coldmud discussion meeting

root meeting help first first in chain previous in chain previous next next in chain last in chain last

Re: 1.1.8 Win32 genesis binaries

daemon@ATHENA.MIT.EDU (Sun Jan 23 02:40:39 2000 )

From: "Jon A. Lambert" <jlsysinc@ix.netcom.com>
To: <coldstuff@cold.org>
Date: Sun, 23 Jan 2000 02:35:10 -0500
Reply-To: coldstuff@cold.org

>Psyclone wrote:
>>
>>mtime() always returns 0. Also a library issue -- Win32 apparently
>>doesn't have a function to return microseconds.
>
>
>Hmm.. I'll have a look around.
>

Sorry I don't have the current source handy, but ...    

Not sure where you need it but this will pull out current millisecs (~=microsecs?).

  timeb z;
  ftime(&z);    // needs  #include <sys\timeb.h>
  cout << z.millitm;

Of course if you are just fetching ticks to seed some random function
  long x = clock();   is faster...

Or if you are trying to measure time intervals to the millisec:

   long start = clock();
   somefunction();
   long end = clock();
   cout << (end - start) / CLK_TCK << endl;

>>ctime() and friends throw when given numbers < 18000. Borland (what I
>>used to compile genesis) has a broken time utility which causes genesis
>>to crash when these functions are given low numbers.
>>

This check will resolve the problem without having to throw an error and
should work in whatever timezone you set up in.  

Somewhere after this :
 tval = (num_args) ? args[0].u.val : time(NULL);

Insert the following:
#ifdef _BORLANDC_
  if (tval < _timezome) tval = _timezone;
#endif

Before calling:
ctime(tval);


--
--*     Jon A. Lambert - TychoMUD Email: jlsysinc@nospam.ix.netcom.com     *--
--*     Mud Server Developer's Page <http://jlsysinc.home.netcom.com>      *--
--* "No Free man shall ever be debarred the use of arms." Thomas Jefferson *--