2000-05-14 17:08:28 +00:00
|
|
|
/*
|
2000-05-22 07:46:47 +00:00
|
|
|
sys_win.c
|
2000-05-14 17:08:28 +00:00
|
|
|
|
2000-05-22 07:46:47 +00:00
|
|
|
(description)
|
2000-05-14 17:08:28 +00:00
|
|
|
|
2000-05-22 07:46:47 +00:00
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
2000-05-14 17:08:28 +00:00
|
|
|
|
2000-05-22 07:46:47 +00:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
2000-05-14 17:08:28 +00:00
|
|
|
|
2000-05-22 07:46:47 +00:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
2000-05-14 17:08:28 +00:00
|
|
|
|
2000-05-22 07:46:47 +00:00
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
$Id$
|
2000-05-14 17:08:28 +00:00
|
|
|
*/
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-05-17 10:03:19 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2000-12-08 06:51:37 +00:00
|
|
|
# include "config.h"
|
2000-05-17 10:03:19 +00:00
|
|
|
#endif
|
2000-05-21 11:28:37 +00:00
|
|
|
|
2000-05-14 20:34:28 +00:00
|
|
|
#include <limits.h>
|
2000-05-12 03:44:21 +00:00
|
|
|
#include <direct.h>
|
2001-01-24 00:06:58 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
2000-05-21 19:59:44 +00:00
|
|
|
#include "server.h"
|
|
|
|
|
|
|
|
/* This is unused in the client, but we need the symbol there too. */
|
2000-12-08 06:51:37 +00:00
|
|
|
server_static_t svs;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-12-08 06:51:37 +00:00
|
|
|
cvar_t *sys_nostdout;
|
2000-08-17 13:38:57 +00:00
|
|
|
|
2000-08-17 12:40:26 +00:00
|
|
|
/* The translation table between the graphical font and plain ASCII --KB */
|
2000-12-08 06:51:37 +00:00
|
|
|
static char qfont_table[256] = {
|
|
|
|
'\0', '#', '#', '#', '#', '.', '#', '#',
|
|
|
|
'#', 9, 10, '#', ' ', 13, '.', '.',
|
|
|
|
'[', ']', '0', '1', '2', '3', '4', '5',
|
|
|
|
'6', '7', '8', '9', '.', '<', '=', '>',
|
|
|
|
' ', '!', '"', '#', '$', '%', '&', '\'',
|
|
|
|
'(', ')', '*', '+', ',', '-', '.', '/',
|
|
|
|
'0', '1', '2', '3', '4', '5', '6', '7',
|
|
|
|
'8', '9', ':', ';', '<', '=', '>', '?',
|
|
|
|
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
|
|
|
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
|
|
|
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
|
|
|
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
|
|
|
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
|
|
|
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
|
|
|
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
|
|
|
'x', 'y', 'z', '{', '|', '}', '~', '<',
|
|
|
|
|
|
|
|
'<', '=', '>', '#', '#', '.', '#', '#',
|
|
|
|
'#', '#', ' ', '#', ' ', '>', '.', '.',
|
|
|
|
'[', ']', '0', '1', '2', '3', '4', '5',
|
|
|
|
'6', '7', '8', '9', '.', '<', '=', '>',
|
|
|
|
' ', '!', '"', '#', '$', '%', '&', '\'',
|
|
|
|
'(', ')', '*', '+', ',', '-', '.', '/',
|
|
|
|
'0', '1', '2', '3', '4', '5', '6', '7',
|
|
|
|
'8', '9', ':', ';', '<', '=', '>', '?',
|
|
|
|
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
|
|
|
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
|
|
|
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
|
|
|
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
|
|
|
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
|
|
|
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
|
|
|
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
|
|
|
'x', 'y', 'z', '{', '|', '}', '~', '<'
|
2000-08-17 12:40:26 +00:00
|
|
|
};
|
|
|
|
|
2000-05-14 20:34:28 +00:00
|
|
|
/*
|
|
|
|
==============
|
|
|
|
Sys_DoubleTime
|
|
|
|
==============
|
|
|
|
*/
|
2000-12-08 06:51:37 +00:00
|
|
|
double
|
|
|
|
Sys_DoubleTime (void)
|
2000-05-14 20:34:28 +00:00
|
|
|
{
|
|
|
|
static DWORD starttime;
|
|
|
|
static qboolean first = true;
|
2000-12-08 06:51:37 +00:00
|
|
|
DWORD now;
|
2000-05-14 20:34:28 +00:00
|
|
|
|
2000-12-08 06:51:37 +00:00
|
|
|
now = timeGetTime ();
|
2000-05-14 20:34:28 +00:00
|
|
|
|
|
|
|
if (first) {
|
|
|
|
first = false;
|
|
|
|
starttime = now;
|
|
|
|
return 0.0;
|
|
|
|
}
|
2000-08-17 12:40:26 +00:00
|
|
|
|
2000-12-08 06:51:37 +00:00
|
|
|
if (now < starttime) // wrapped?
|
2000-05-14 20:34:28 +00:00
|
|
|
return (now / 1000.0) + (LONG_MAX - starttime / 1000.0);
|
|
|
|
|
|
|
|
if (now - starttime == 0)
|
|
|
|
return 0.0;
|
|
|
|
|
|
|
|
return (now - starttime) / 1000.0;
|
|
|
|
}
|
2000-10-02 04:24:08 +00:00
|
|
|
|
2000-08-17 12:40:26 +00:00
|
|
|
#define MAXPRINTMSG 4096
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
Sys_Printf
|
|
|
|
================
|
|
|
|
*/
|
2000-12-08 06:51:37 +00:00
|
|
|
void
|
|
|
|
Sys_Printf (char *fmt, ...)
|
2000-08-17 12:40:26 +00:00
|
|
|
{
|
2000-12-08 06:51:37 +00:00
|
|
|
va_list argptr;
|
|
|
|
char msg[MAXPRINTMSG];
|
2000-10-02 04:24:08 +00:00
|
|
|
|
2000-12-08 06:51:37 +00:00
|
|
|
unsigned char *p;
|
2000-08-17 12:40:26 +00:00
|
|
|
|
2000-11-01 03:54:43 +00:00
|
|
|
if (sys_nostdout && sys_nostdout->int_val)
|
2000-08-17 12:40:26 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
va_start (argptr, fmt);
|
2000-10-02 04:24:08 +00:00
|
|
|
vsnprintf (msg, sizeof (msg), fmt, argptr);
|
2000-08-17 12:40:26 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
/* translate to ASCII instead of printing [xx] --KB */
|
2000-10-02 04:24:08 +00:00
|
|
|
for (p = (unsigned char *) msg; *p; p++)
|
|
|
|
putc (qfont_table[*p], stdout);
|
|
|
|
|
|
|
|
fflush (stdout);
|
2000-08-17 12:40:26 +00:00
|
|
|
}
|
2000-05-14 20:34:28 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
/*
|
|
|
|
================
|
2000-05-10 23:17:39 +00:00
|
|
|
Sys_mkdir
|
2000-05-10 11:29:38 +00:00
|
|
|
================
|
|
|
|
*/
|
2000-12-08 06:51:37 +00:00
|
|
|
void
|
|
|
|
Sys_mkdir (char *path)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-12-08 06:51:37 +00:00
|
|
|
_mkdir (path);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|