made global host_parms a pointer, set in main(). adjusted places where

host_parms is used. made COM_Init() and Host_Init() to take no arguments.
made Sys_Init() to set host_parms->userdir: at present, it is set to
host_parms->basedir, to be changed properly when user directories are
implemented.

git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@443 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2011-04-19 16:41:45 +00:00
parent ccf800306b
commit f6b6f49a7e
9 changed files with 28 additions and 23 deletions

View file

@ -1211,7 +1211,7 @@ static void FitzTest_f (void)
COM_Init COM_Init
================ ================
*/ */
void COM_Init (const char *basedir) void COM_Init (void)
{ {
int i = 0x12345678; int i = 0x12345678;
/* U N I X */ /* U N I X */
@ -1919,7 +1919,7 @@ void COM_InitFilesystem (void) //johnfitz -- modified based on topaz's tutorial
if (i && i < com_argc-1) if (i && i < com_argc-1)
strcpy (com_basedir, com_argv[i + 1]); strcpy (com_basedir, com_argv[i + 1]);
else else
strcpy (com_basedir, host_parms.basedir); strcpy (com_basedir, host_parms->basedir);
j = strlen (com_basedir); j = strlen (com_basedir);
if (j > 0) if (j > 0)

View file

@ -171,7 +171,7 @@ extern int safemode;
*/ */
int COM_CheckParm (const char *parm); int COM_CheckParm (const char *parm);
void COM_Init (const char *path); void COM_Init (void);
void COM_InitArgv (int argc, char **argv); void COM_InitArgv (int argc, char **argv);
const char *COM_SkipPath (const char *pathname); const char *COM_SkipPath (const char *pathname);

View file

@ -36,7 +36,7 @@ Memory is cleared / released when a server or client begins, not when they end.
*/ */
quakeparms_t host_parms; quakeparms_t *host_parms;
qboolean host_initialized; // true if into command execution qboolean host_initialized; // true if into command execution
@ -796,7 +796,7 @@ void Host_Frame (float time)
Host_Init Host_Init
==================== ====================
*/ */
void Host_Init (quakeparms_t *parms) void Host_Init (void)
{ {
if (standard_quake) if (standard_quake)
minimum_memory = MINIMUM_MEMORY; minimum_memory = MINIMUM_MEMORY;
@ -804,22 +804,20 @@ void Host_Init (quakeparms_t *parms)
minimum_memory = MINIMUM_MEMORY_LEVELPAK; minimum_memory = MINIMUM_MEMORY_LEVELPAK;
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)
Sys_Error ("Only %4.1f megs of memory available, can't execute game", host_parms->memsize / (float)0x100000);
if (parms->memsize < minimum_memory) com_argc = host_parms->argc;
Sys_Error ("Only %4.1f megs of memory available, can't execute game", parms->memsize / (float)0x100000); com_argv = host_parms->argv;
com_argc = parms->argc; Memory_Init (host_parms->membase, host_parms->memsize);
com_argv = parms->argv;
Memory_Init (parms->membase, parms->memsize);
Cbuf_Init (); Cbuf_Init ();
Cmd_Init (); Cmd_Init ();
LOG_Init (parms); LOG_Init (host_parms);
Cvar_Init (); //johnfitz Cvar_Init (); //johnfitz
COM_Init (parms->basedir); COM_Init ();
Host_InitLocal (); Host_InitLocal ();
W_LoadWadFile (); //johnfitz -- filename is now hard-coded for honesty W_LoadWadFile (); //johnfitz -- filename is now hard-coded for honesty
if (cls.state != ca_dedicated) if (cls.state != ca_dedicated)
@ -833,7 +831,7 @@ void Host_Init (quakeparms_t *parms)
SV_Init (); SV_Init ();
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));
if (cls.state != ca_dedicated) if (cls.state != ca_dedicated)
{ {

View file

@ -153,7 +153,7 @@ void Host_Game_f (void)
return; return;
} }
strcpy (pakfile, va("%s/%s", host_parms.basedir, Cmd_Argv(1))); strcpy (pakfile, va("%s/%s", host_parms->basedir, Cmd_Argv(1)));
if (!Q_strcasecmp(pakfile, com_gamedir)) //no change if (!Q_strcasecmp(pakfile, com_gamedir)) //no change
{ {
Con_Printf("\"game\" is already \"%s\"\n", COM_SkipPath(com_gamedir)); Con_Printf("\"game\" is already \"%s\"\n", COM_SkipPath(com_gamedir));
@ -414,7 +414,7 @@ void Modlist_Init (void)
if (i && i < com_argc-1) if (i && i < com_argc-1)
sprintf (dir_string, "%s/", com_argv[i+1]); sprintf (dir_string, "%s/", com_argv[i+1]);
else else
sprintf (dir_string, "%s/", host_parms.basedir); sprintf (dir_string, "%s/", host_parms->basedir);
dir_p = opendir(dir_string); dir_p = opendir(dir_string);
if (dir_p == NULL) if (dir_p == NULL)

View file

@ -26,14 +26,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define DEFAULT_MEMORY 0x4000000 #define DEFAULT_MEMORY 0x4000000
static quakeparms_t parms;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
SDL_Event event; SDL_Event event;
quakeparms_t parms;
int t; int t;
int done = 0; int done = 0;
double time, oldtime, newtime; double time, oldtime, newtime;
host_parms = &parms;
parms.basedir = "."; parms.basedir = ".";
parms.argc = argc; parms.argc = argc;
@ -69,7 +71,7 @@ int main(int argc, char *argv[])
FITZQUAKE_VERSION, QUAKESPASM_VER_PATCH); FITZQUAKE_VERSION, QUAKESPASM_VER_PATCH);
Sys_Printf("Host_Init\n"); Sys_Printf("Host_Init\n");
Host_Init(&parms); Host_Init();
oldtime = Sys_FloatTime(); oldtime = Sys_FloatTime();
if (isDedicated) if (isDedicated)

View file

@ -265,7 +265,7 @@ extern qboolean noclip_anglehack;
// //
// host // host
// //
extern quakeparms_t host_parms; extern quakeparms_t *host_parms;
extern cvar_t sys_ticrate; extern cvar_t sys_ticrate;
extern cvar_t sys_throttle; extern cvar_t sys_throttle;
@ -283,7 +283,7 @@ extern double realtime; // not bounded in any way, changed at
void Host_ClearMemory (void); void Host_ClearMemory (void);
void Host_ServerFrame (void); void Host_ServerFrame (void);
void Host_InitCommands (void); void Host_InitCommands (void);
void Host_Init (quakeparms_t *parms); void Host_Init (void);
void Host_Shutdown(void); void Host_Shutdown(void);
void Host_Error (const char *error, ...) __attribute__((__format__(__printf__,1,2), __noreturn__)); void Host_Error (const char *error, ...) __attribute__((__format__(__printf__,1,2), __noreturn__));
void Host_EndGame (const char *message, ...) __attribute__((__format__(__printf__,1,2), __noreturn__)); void Host_EndGame (const char *message, ...) __attribute__((__format__(__printf__,1,2), __noreturn__));

View file

@ -171,7 +171,7 @@ void S_Init (void)
sndspeed.value = Q_atoi(com_argv[COM_CheckParm("-sndspeed")+1]); sndspeed.value = Q_atoi(com_argv[COM_CheckParm("-sndspeed")+1]);
} }
if (host_parms.memsize < 0x800000) if (host_parms->memsize < 0x800000)
{ {
Cvar_Set ("loadas8bit", "1"); Cvar_Set ("loadas8bit", "1");
Con_Printf ("loading all sounds as 8bit\n"); Con_Printf ("loading all sounds as 8bit\n");

View file

@ -141,6 +141,7 @@ int Sys_FileTime (const char *path)
void Sys_Init (void) void Sys_Init (void)
{ {
host_parms->userdir = host_parms->basedir; /* TODO: implement properly! */
} }
void Sys_mkdir (const char *path) void Sys_mkdir (const char *path)

View file

@ -148,6 +148,10 @@ void Sys_Init (void)
{ {
OSVERSIONINFO vinfo; OSVERSIONINFO vinfo;
host_parms->userdir = host_parms->basedir;
/* user directories not really necessary for windows guys.
* can be done if necessary, though... */
vinfo.dwOSVersionInfoSize = sizeof(vinfo); vinfo.dwOSVersionInfoSize = sizeof(vinfo);
if (!GetVersionEx (&vinfo)) if (!GetVersionEx (&vinfo))