From fd0cee74182900b6cdcf679e0fbdd16f0cf59466 Mon Sep 17 00:00:00 2001 From: ludde Date: Fri, 15 Jul 2005 20:29:06 +0000 Subject: (svn r2583) Move OS specific code out of misc.c Added support for Mersenne Twister random number generator (not implemented in network yet) Wrap player randoms around #ifdef --- unix.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'unix.c') diff --git a/unix.c b/unix.c index c2b81b3d7..f40783247 100644 --- a/unix.c +++ b/unix.c @@ -474,6 +474,7 @@ int CDECL main(int argc, char* argv[]) #endif _random_seeds[0][1] = _random_seeds[0][0] = time(NULL); + SeedMT(_random_seeds[0][1]); signal(SIGPIPE, SIG_IGN); @@ -581,3 +582,49 @@ void JoinOTTDThread(void) pthread_join(thread1, NULL); } + + + +#ifdef ENABLE_NETWORK + +// multi os compatible sleep function + +#ifdef __AMIGA__ +// usleep() implementation +# include +# include + + extern struct Device *TimerBase = NULL; + extern struct MsgPort *TimerPort = NULL; + extern struct timerequest *TimerRequest = NULL; +#endif // __AMIGA__ + +void CSleep(int milliseconds) +{ + #if !defined(__BEOS__) && !defined(__AMIGA__) + usleep(milliseconds * 1000); + #endif + #ifdef __BEOS__ + snooze(milliseconds * 1000); + #endif + #if defined(__AMIGA__) + { + ULONG signals; + ULONG TimerSigBit = 1 << TimerPort->mp_SigBit; + + // send IORequest + TimerRequest->tr_node.io_Command = TR_ADDREQUEST; + TimerRequest->tr_time.tv_secs = (milliseconds * 1000) / 1000000; + TimerRequest->tr_time.tv_micro = (milliseconds * 1000) % 1000000; + SendIO((struct IORequest *)TimerRequest); + + if (!((signals = Wait(TimerSigBit | SIGBREAKF_CTRL_C)) & TimerSigBit) ) { + AbortIO((struct IORequest *)TimerRequest); + } + WaitIO((struct IORequest *)TimerRequest); + } + #endif // __AMIGA__ +} + +#endif /* ENABLE_NETWORK */ + -- cgit v1.2.3-54-g00ecf