quakeparms_t audit.

changed all parms references to directly access host_parms to improve readability, and removed unused basedir references. (all remaining fields in quakeparms_t deserve to be there)
This commit is contained in:
Forest Hale 2000-11-27 13:17:48 +00:00
parent 18a411916b
commit 9ce5fc95df
9 changed files with 70 additions and 103 deletions

View file

@ -166,8 +166,6 @@ entity_t cl_visedicts_list[2][MAX_VISEDICTS];
double connect_time = -1; // for connection retransmits double connect_time = -1; // for connection retransmits
quakeparms_t host_parms;
qboolean host_initialized; // true if into command execution qboolean host_initialized; // true if into command execution
qboolean nomaster; qboolean nomaster;
@ -1577,18 +1575,16 @@ void Host_Frame (float time)
Host_Init Host_Init
==================== ====================
*/ */
void Host_Init (quakeparms_t *parms) void Host_Init ()
{ {
if (COM_CheckParm ("-minmemory")) if (COM_CheckParm ("-minmemory"))
parms->memsize = MINIMUM_MEMORY; host_parms.memsize = MINIMUM_MEMORY;
host_parms = *parms; if (host_parms.memsize < MINIMUM_MEMORY)
if (parms->memsize < MINIMUM_MEMORY)
Sys_Error ("Only %4.1f megs of memory reported, can't execute game", Sys_Error ("Only %4.1f megs of memory reported, can't execute game",
parms->memsize / (float)0x100000); host_parms.memsize / (float)0x100000);
Memory_Init (parms->membase, parms->memsize); Memory_Init (host_parms.membase, host_parms.memsize);
Cvar_Init (); Cvar_Init ();
Sys_Init_Cvars (); Sys_Init_Cvars ();
Sys_Init(); Sys_Init();
@ -1648,7 +1644,7 @@ void Host_Init (quakeparms_t *parms)
Mod_Init (); Mod_Init ();
// Con_Printf ("Exe: "__TIME__" "__DATE__"\n"); // Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
Con_Printf ("%4.1f megs RAM used.\n",parms->memsize/ (1024*1024.0)); Con_Printf ("%4.1f megs RAM used.\n",host_parms.memsize/ (1024*1024.0));
R_Textures_Init (); R_Textures_Init ();

View file

@ -256,7 +256,6 @@ C_LINKAGE int SDL_main(int c, char **v)
{ {
double time, oldtime, newtime; double time, oldtime, newtime;
quakeparms_t parms;
int j; int j;
static char cwd[1024]; static char cwd[1024];
@ -266,42 +265,31 @@ C_LINKAGE int SDL_main(int c, char **v)
signal(SIGFPE, SIG_IGN); signal(SIGFPE, SIG_IGN);
#endif #endif
memset(&parms, 0, sizeof(parms)); memset(&host_parms, 0, sizeof(host_parms));
COM_InitArgv(c, v); COM_InitArgv(c, v);
parms.argc = com_argc; host_parms.argc = com_argc;
parms.argv = com_argv; host_parms.argv = com_argv;
parms.memsize = 16*1024*1024; host_parms.memsize = 16*1024*1024;
j = COM_CheckParm("-mem"); j = COM_CheckParm("-mem");
if (j) if (j)
parms.memsize = (int) (atof(com_argv[j+1]) * 1024 * 1024); host_parms.memsize = (int) (atof(com_argv[j+1]) * 1024 * 1024);
parms.membase = malloc (parms.memsize); host_parms.membase = malloc (host_parms.memsize);
if (!parms.membase) { if (!host_parms.membase) {
printf("Can't allocate memory for zone.\n"); printf("Can't allocate memory for zone.\n");
return 1; return 1;
} }
/* if (!GetCurrentDirectory (sizeof(cwd), cwd))
Sys_Error ("Couldn't determine current directory");
if (cwd[strlen(cwd)-1] == '/')
cwd[strlen(cwd)-1] = 0;
parms.basedir = cwd;
*/
parms.basedir = BASEDIR;
#ifndef WIN32 #ifndef WIN32
noconinput = COM_CheckParm("-noconinput"); noconinput = COM_CheckParm("-noconinput");
if (!noconinput) if (!noconinput)
fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | O_NONBLOCK); fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | O_NONBLOCK);
#endif #endif
Host_Init(&parms); Host_Init();
oldtime = Sys_DoubleTime (); oldtime = Sys_DoubleTime ();
while (1) while (1)

View file

@ -219,7 +219,6 @@ int main (int c, char **v)
{ {
double time, oldtime, newtime; double time, oldtime, newtime;
quakeparms_t parms;
int j; int j;
// static char cwd[1024]; // static char cwd[1024];
@ -227,30 +226,28 @@ int main (int c, char **v)
// signal(SIGFPE, floating_point_exception_handler); // signal(SIGFPE, floating_point_exception_handler);
signal(SIGFPE, SIG_IGN); signal(SIGFPE, SIG_IGN);
memset(&parms, 0, sizeof(parms)); memset(&host_parms, 0, sizeof(host_parms));
COM_InitArgv(c, v); COM_InitArgv(c, v);
parms.argc = com_argc; host_parms.argc = com_argc;
parms.argv = com_argv; host_parms.argv = com_argv;
parms.memsize = 8 * 1024 * 1024; // 8MB default heap host_parms.memsize = 8 * 1024 * 1024; // 8MB default heap
j = COM_CheckParm("-mem"); j = COM_CheckParm("-mem");
if (j) if (j)
parms.memsize = (int) (atof(com_argv[j+1]) * 1024 * 1024); host_parms.memsize = (int) (atof(com_argv[j+1]) * 1024 * 1024);
parms.membase = malloc (parms.memsize); host_parms.membase = malloc (host_parms.memsize);
if (!parms.membase) { if (!host_parms.membase) {
printf("Can't allocate memory for zone.\n"); printf("Can't allocate memory for zone.\n");
return 1; return 1;
} }
parms.basedir = BASEDIR;
noconinput = COM_CheckParm("-noconinput"); noconinput = COM_CheckParm("-noconinput");
if (!noconinput) if (!noconinput)
fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | O_NONBLOCK); fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | O_NONBLOCK);
Host_Init(&parms); Host_Init();
oldtime = Sys_DoubleTime (); oldtime = Sys_DoubleTime ();
while (1) while (1)

View file

@ -418,7 +418,6 @@ HWND hwnd_dialog;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{ {
// MSG msg; // MSG msg;
quakeparms_t parms;
double time, oldtime, newtime; double time, oldtime, newtime;
MEMORYSTATUS lpBuffer; MEMORYSTATUS lpBuffer;
static char cwd[1024]; static char cwd[1024];
@ -441,20 +440,18 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
if (cwd[strlen(cwd)-1] == '/') if (cwd[strlen(cwd)-1] == '/')
cwd[strlen(cwd)-1] = 0; cwd[strlen(cwd)-1] = 0;
parms.basedir = cwd; host_parms.argc = 1;
parms.argc = 1;
argv[0] = empty_string; argv[0] = empty_string;
while (*lpCmdLine && (parms.argc < MAX_NUM_ARGVS)) while (*lpCmdLine && (host_parms.argc < MAX_NUM_ARGVS))
{ {
while (*lpCmdLine && ((*lpCmdLine <= 32) || (*lpCmdLine > 126))) while (*lpCmdLine && ((*lpCmdLine <= 32) || (*lpCmdLine > 126)))
lpCmdLine++; lpCmdLine++;
if (*lpCmdLine) if (*lpCmdLine)
{ {
argv[parms.argc] = lpCmdLine; argv[host_parms.argc] = lpCmdLine;
parms.argc++; host_parms.argc++;
while (*lpCmdLine && ((*lpCmdLine > 32) && (*lpCmdLine <= 126))) while (*lpCmdLine && ((*lpCmdLine > 32) && (*lpCmdLine <= 126)))
lpCmdLine++; lpCmdLine++;
@ -468,12 +465,12 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
} }
} }
parms.argv = argv; host_parms.argv = argv;
COM_InitArgv (parms.argc, parms.argv); COM_InitArgv (host_parms.argc, host_parms.argv);
parms.argc = com_argc; host_parms.argc = com_argc;
parms.argv = com_argv; host_parms.argv = com_argv;
hwnd_dialog = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, NULL); hwnd_dialog = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, NULL);
@ -498,28 +495,28 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
// take the greater of all the available memory or half the total memory, // take the greater of all the available memory or half the total memory,
// but at least 8 Mb and no more than 16 Mb, unless they explicitly // but at least 8 Mb and no more than 16 Mb, unless they explicitly
// request otherwise // request otherwise
parms.memsize = lpBuffer.dwAvailPhys; host_parms.memsize = lpBuffer.dwAvailPhys;
if (parms.memsize < MINIMUM_WIN_MEMORY) if (host_parms.memsize < MINIMUM_WIN_MEMORY)
parms.memsize = MINIMUM_WIN_MEMORY; host_parms.memsize = MINIMUM_WIN_MEMORY;
if (parms.memsize < (lpBuffer.dwTotalPhys >> 1)) if (host_parms.memsize < (lpBuffer.dwTotalPhys >> 1))
parms.memsize = lpBuffer.dwTotalPhys >> 1; host_parms.memsize = lpBuffer.dwTotalPhys >> 1;
if (parms.memsize > MAXIMUM_WIN_MEMORY) if (host_parms.memsize > MAXIMUM_WIN_MEMORY)
parms.memsize = MAXIMUM_WIN_MEMORY; host_parms.memsize = MAXIMUM_WIN_MEMORY;
if (COM_CheckParm ("-heapsize")) if (COM_CheckParm ("-heapsize"))
{ {
t = COM_CheckParm("-heapsize") + 1; t = COM_CheckParm("-heapsize") + 1;
if (t < com_argc) if (t < com_argc)
parms.memsize = atoi (com_argv[t]) * 1024; host_parms.memsize = atoi (com_argv[t]) * 1024;
} }
parms.membase = malloc (parms.memsize); host_parms.membase = malloc (host_parms.memsize);
if (!parms.membase) if (!host_parms.membase)
Sys_Error ("Not enough memory free; check disk space\n"); Sys_Error ("Not enough memory free; check disk space\n");
tevent = CreateEvent(NULL, FALSE, FALSE, NULL); tevent = CreateEvent(NULL, FALSE, FALSE, NULL);
@ -531,7 +528,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
S_BlockSound (); S_BlockSound ();
Sys_Printf ("Host_Init\n"); Sys_Printf ("Host_Init\n");
Host_Init (&parms); Host_Init ();
oldtime = Sys_DoubleTime (); oldtime = Sys_DoubleTime ();

View file

@ -119,6 +119,7 @@ cvar_t *fs_userpath;
cvar_t *fs_sharepath; cvar_t *fs_sharepath;
cvar_t *fs_basegame; cvar_t *fs_basegame;
quakeparms_t host_parms;
int com_filesize; int com_filesize;

View file

@ -53,7 +53,6 @@
#include "ver_check.h" #include "ver_check.h"
#include "world.h" #include "world.h"
quakeparms_t host_parms;
qboolean host_initialized; // true if into command execution qboolean host_initialized; // true if into command execution
double sv_frametime; double sv_frametime;
@ -1812,22 +1811,20 @@ SV_InitNet (void)
SV_Init SV_Init
*/ */
void void
SV_Init (quakeparms_t *parms) SV_Init ()
{ {
COM_InitArgv (parms->argc, parms->argv); COM_InitArgv (host_parms.argc, host_parms.argv);
// COM_AddParm ("-game"); // COM_AddParm ("-game");
// COM_AddParm ("qw"); // COM_AddParm ("qw");
if (COM_CheckParm ("-minmemory")) if (COM_CheckParm ("-minmemory"))
parms->memsize = MINIMUM_MEMORY; host_parms.memsize = MINIMUM_MEMORY;
host_parms = *parms; if (host_parms.memsize < MINIMUM_MEMORY)
if (parms->memsize < MINIMUM_MEMORY)
SV_Error ("Only %4.1f megs of memory reported, can't execute game", SV_Error ("Only %4.1f megs of memory reported, can't execute game",
parms->memsize / (float) 0x100000); host_parms.memsize / (float) 0x100000);
Memory_Init (parms->membase, parms->memsize); Memory_Init (host_parms.membase, host_parms.memsize);
Cvar_Init (); Cvar_Init ();
Sys_Init_Cvars (); Sys_Init_Cvars ();
Sys_Init (); Sys_Init ();
@ -1880,7 +1877,7 @@ SV_Init (quakeparms_t *parms)
host_initialized = true; host_initialized = true;
// Con_Printf ("Exe: "__TIME__" "__DATE__"\n"); // Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
Con_Printf ("%4.1f megabyte heap\n", parms->memsize / (1024 * 1024.0)); Con_Printf ("%4.1f megabyte heap\n", host_parms.memsize / (1024 * 1024.0));
Con_Printf ("\n%s server, Version %s (build %04d)\n\n", PROGRAM, VERSION, Con_Printf ("\n%s server, Version %s (build %04d)\n\n", PROGRAM, VERSION,
build_number ()); build_number ());

View file

@ -161,29 +161,26 @@ main
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
double time, oldtime, newtime; double time, oldtime, newtime;
quakeparms_t parms;
fd_set fdset; fd_set fdset;
extern int net_socket; extern int net_socket;
struct timeval timeout; struct timeval timeout;
int j; int j;
memset (&parms, 0, sizeof(parms)); memset (&host_parms, 0, sizeof(host_parms));
COM_InitArgv (argc, argv); COM_InitArgv (argc, argv);
parms.argc = com_argc; host_parms.argc = com_argc;
parms.argv = com_argv; host_parms.argv = com_argv;
parms.memsize = 16*1024*1024; host_parms.memsize = 16*1024*1024;
j = COM_CheckParm("-mem"); j = COM_CheckParm("-mem");
if (j) if (j)
parms.memsize = (int) (atof(com_argv[j+1]) * 1024 * 1024); host_parms.memsize = (int) (atof(com_argv[j+1]) * 1024 * 1024);
if ((parms.membase = malloc (parms.memsize)) == NULL) if ((host_parms.membase = malloc (host_parms.memsize)) == NULL)
Sys_Error("Can't allocate %d\n", parms.memsize); Sys_Error("Can't allocate %d\n", host_parms.memsize);
parms.basedir = BASEDIR; SV_Init ();
SV_Init (&parms);
// run one frame immediately for first heartbeat // run one frame immediately for first heartbeat
SV_Frame (0.1); SV_Frame (0.1);

View file

@ -196,7 +196,6 @@ char *newargv[256];
int main (int argc, char **argv) int main (int argc, char **argv)
{ {
quakeparms_t parms;
double newtime, time, oldtime; double newtime, time, oldtime;
struct timeval timeout; struct timeval timeout;
fd_set fdset; fd_set fdset;
@ -205,27 +204,25 @@ int main (int argc, char **argv)
COM_InitArgv (argc, argv); COM_InitArgv (argc, argv);
parms.argc = com_argc; host_parms.argc = com_argc;
parms.argv = com_argv; host_parms.argv = com_argv;
parms.memsize = 16*1024*1024; host_parms.memsize = 16*1024*1024;
if ((t = COM_CheckParm ("-heapsize")) != 0 && if ((t = COM_CheckParm ("-heapsize")) != 0 &&
t + 1 < com_argc) t + 1 < com_argc)
parms.memsize = atoi (com_argv[t + 1]) * 1024; host_parms.memsize = atoi (com_argv[t + 1]) * 1024;
if ((t = COM_CheckParm ("-mem")) != 0 && if ((t = COM_CheckParm ("-mem")) != 0 &&
t + 1 < com_argc) t + 1 < com_argc)
parms.memsize = atoi (com_argv[t + 1]) * 1024 * 1024; host_parms.memsize = atoi (com_argv[t + 1]) * 1024 * 1024;
parms.membase = malloc (parms.memsize); host_parms.membase = malloc (host_parms.memsize);
if (!parms.membase) if (!host_parms.membase)
Sys_Error("Insufficient memory.\n"); Sys_Error("Insufficient memory.\n");
parms.basedir = "."; SV_Init ();
SV_Init (&parms);
if (COM_CheckParm ("-nopriority")) if (COM_CheckParm ("-nopriority"))
{ {

View file

@ -149,19 +149,16 @@ void Sys_LowFPPrecision (void)
void main (int argc, char **argv) void main (int argc, char **argv)
{ {
quakeparms_t parms; host_parms.memsize = 5861376;
host_parms.membase = malloc (host_parms.memsize);
parms.memsize = 5861376;
parms.membase = malloc (parms.memsize);
parms.basedir = ".";
COM_InitArgv (argc, argv); COM_InitArgv (argc, argv);
parms.argc = com_argc; host_parms.argc = com_argc;
parms.argv = com_argv; host_parms.argv = com_argv;
printf ("Host_Init\n"); printf ("Host_Init\n");
Host_Init (&parms); Host_Init ();
while (1) while (1)
{ {
Host_Frame (0.1); Host_Frame (0.1);