fix qport

This commit is contained in:
Bill Currie 2001-11-27 04:50:41 +00:00
parent c4646b9685
commit 4689350283
3 changed files with 17 additions and 1 deletions

View file

@ -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

View file

@ -54,6 +54,7 @@ static const char rcsid[] =
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
@ -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;
}

View file

@ -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);
}