summaryrefslogtreecommitdiff
path: root/unix.c
diff options
context:
space:
mode:
authorludde <ludde@openttd.org>2005-07-15 20:29:06 +0000
committerludde <ludde@openttd.org>2005-07-15 20:29:06 +0000
commitfd0cee74182900b6cdcf679e0fbdd16f0cf59466 (patch)
tree4082dbe36cd4d476e1d16f70a88eaa90adb7523f /unix.c
parentac4f823b547f77781dc6738882a3da601a17dc9b (diff)
downloadopenttd-fd0cee74182900b6cdcf679e0fbdd16f0cf59466.tar.xz
(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
Diffstat (limited to 'unix.c')
-rw-r--r--unix.c47
1 files changed, 47 insertions, 0 deletions
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 <devices/timer.h>
+# include <dos/dos.h>
+
+ 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 */
+