From 4689350283fda6628214cdffa58813c5e0100a71 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 27 Nov 2001 04:50:41 +0000 Subject: [PATCH] fix qport --- include/QF/sys.h | 2 ++ libs/util/sys.c | 13 +++++++++++++ qw/source/net_chan.c | 3 ++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/QF/sys.h b/include/QF/sys.h index 559c7fcd4..bbb2c5bf8 100644 --- a/include/QF/sys.h +++ b/include/QF/sys.h @@ -60,6 +60,8 @@ double Sys_DoubleTime (void); const char *Sys_ConsoleInput (void); void Sys_Sleep (void); + +int Sys_TimeID (void); // called to yield for a little bit so as // not to hog cpu when paused or debugging diff --git a/libs/util/sys.c b/libs/util/sys.c index 3aaf6b44f..29ae2d23a 100644 --- a/libs/util/sys.c +++ b/libs/util/sys.c @@ -54,6 +54,7 @@ static const char rcsid[] = #include #include #include +#include #include #include #include @@ -352,3 +353,15 @@ Sys_RegisterShutdown (void (*func) (void)) p->next = shutdown_list; shutdown_list = p; } + +int +Sys_TimeID (void) //FIXME I need a new name, one that doesn't make me feel 3 feet thick +{ + int val; +#ifdef _WIN32 + val = ((int) (timeGetTime () * 1000) * time (NULL)) & 0xffff; +#else + val = ((int) (getpid () + getuid () * 1000) * time (NULL)) & 0xffff; +#endif + return val; +} diff --git a/qw/source/net_chan.c b/qw/source/net_chan.c index 0f863127c..3341700d2 100644 --- a/qw/source/net_chan.c +++ b/qw/source/net_chan.c @@ -46,6 +46,7 @@ static const char rcsid[] = #include "QF/console.h" #include "QF/cvar.h" #include "QF/msg.h" +#include "QF/sys.h" #include "client.h" #include "compat.h" @@ -111,7 +112,7 @@ Netchan_Init (void) int port; // pick a port value that should be nice and random - port = rand () * (65536.0 / RAND_MAX); + port = Sys_TimeID (); Cvar_SetValue (qport, port); }