From: havoc Date: Tue, 20 Aug 2002 08:28:01 +0000 (+0000) Subject: got rid of host_parms X-Git-Tag: RELEASE_0_2_0_RC1~330 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=a4394993ac2f4f5a10cc45f4b1eacef5b037d393 got rid of host_parms added com_basedir cleaned up gamedir related code git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2263 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/common.c b/common.c index a6aeab1e..ed25c294 100644 --- a/common.c +++ b/common.c @@ -41,6 +41,7 @@ qboolean msg_suppress_1 = 0; void COM_InitFilesystem (void); char com_token[1024]; +char com_basedir[MAX_OSPATH]; int com_argc; char **com_argv; @@ -50,6 +51,7 @@ char com_cmdline[CMDLINE_LENGTH]; int gamemode; char *gamename; +char *gamedirname; /* @@ -616,7 +618,7 @@ skipwhite: return NULL; // end of file; data++; } - + // skip // comments if (c=='/' && data[1] == '/') { @@ -788,24 +790,31 @@ void COM_InitGameType (void) gamename = "DarkPlaces-Quake"; else gamename = "DarkPlaces-SharewareQuake"; + gamedirname = ""; break; case GAME_HIPNOTIC: gamename = "Darkplaces-Hipnotic"; + gamedirname = "hipnotic"; break; case GAME_ROGUE: gamename = "Darkplaces-Rogue"; + gamedirname = "rogue"; break; case GAME_NEHAHRA: gamename = "DarkPlaces-Nehahra"; + gamedirname = "nehahra"; break; case GAME_FIENDARENA: gamename = "FiendArena"; + gamedirname = "fiendarena"; break; case GAME_ZYMOTIC: gamename = "Zymotic"; + gamedirname = "zymotic"; break; case GAME_TRANSFUSION: gamename = "Transfusion"; + gamedirname = "transfusion"; break; default: Sys_Error("COM_InitGameType: unknown gamemode %i\n", gamemode); @@ -1185,7 +1194,7 @@ int COM_FindFile (char *filename, QFile **file, qboolean quiet, qboolean zip) #endif cachetime = Sys_FileTime (cachepath); - + if (cachetime < findtime) COM_CopyFile (netpath, cachepath); strcpy (netpath, cachepath); @@ -1384,93 +1393,40 @@ COM_InitFilesystem */ void COM_InitFilesystem (void) { - int i, j; - char basedir[MAX_OSPATH]; - searchpath_t *search; + int i; + searchpath_t *search; -// -// -basedir -// Overrides the system supplied base directory (under GAMENAME) -// + strcpy(com_basedir, ""); + + // -basedir + // Overrides the system supplied base directory (under GAMENAME) i = COM_CheckParm ("-basedir"); if (i && i < com_argc-1) - strcpy (basedir, com_argv[i+1]); - else - strcpy (basedir, host_parms.basedir); + strcpy (com_basedir, com_argv[i+1]); - j = strlen (basedir); - - if (j > 0) - { - if ((basedir[j-1] == '\\') || (basedir[j-1] == '/')) - basedir[j-1] = 0; - } - -#if CACHEENABLE -// -// -cachedir -// Overrides the system supplied cache directory (NULL or /qcache) -// -cachedir - will disable caching. -// - i = COM_CheckParm ("-cachedir"); - if (i && i < com_argc-1) - { - if (com_argv[i+1][0] == '-') - com_cachedir[0] = 0; - else - strcpy (com_cachedir, com_argv[i+1]); - } - else if (host_parms.cachedir) - strcpy (com_cachedir, host_parms.cachedir); - else - com_cachedir[0] = 0; -#endif + i = strlen (com_basedir); + if (i > 0 && (com_basedir[i-1] == '\\' || com_basedir[i-1] == '/')) + com_basedir[i-1] = 0; // start up with GAMENAME by default (id1) - COM_AddGameDirectory (va("%s/"GAMENAME, basedir) ); - - switch(gamemode) + COM_AddGameDirectory (va("%s/"GAMENAME, com_basedir)); + if (gamedirname[0]) { - case GAME_NORMAL: - break; - case GAME_HIPNOTIC: - COM_AddGameDirectory (va("%s/hipnotic", basedir) ); - break; - case GAME_ROGUE: - COM_AddGameDirectory (va("%s/rogue", basedir) ); - break; - case GAME_NEHAHRA: - COM_AddGameDirectory (va("%s/nehahra", basedir) ); - break; - case GAME_FIENDARENA: - COM_AddGameDirectory (va("%s/fiendarena", basedir) ); - break; - case GAME_ZYMOTIC: - COM_AddGameDirectory (va("%s/zymotic", basedir) ); - break; - case GAME_TRANSFUSION: - COM_AddGameDirectory (va("%s/transfusion", basedir) ); - break; - default: - Sys_Error("COM_InitFilesystem: unknown gamemode %i\n", gamemode); - break; + com_modified = true; + COM_AddGameDirectory (va("%s/%s", com_basedir, gamedirname)); } -// -// -game -// Adds basedir/gamedir as an override game -// + // -game + // Adds basedir/gamedir as an override game i = COM_CheckParm ("-game"); if (i && i < com_argc-1) { com_modified = true; - COM_AddGameDirectory (va("%s/%s", basedir, com_argv[i+1])); + COM_AddGameDirectory (va("%s/%s", com_basedir, com_argv[i+1])); } -// -// -path [] ... -// Fully specifies the exact search path, overriding the generated one -// + // -path [] ... + // Fully specifies the exact search path, overriding the generated one i = COM_CheckParm ("-path"); if (i) { diff --git a/common.h b/common.h index b5b7bebf..617622cc 100644 --- a/common.h +++ b/common.h @@ -132,9 +132,9 @@ extern qboolean com_eof; char *COM_Parse (char *data); - -extern int com_argc; -extern char **com_argv; +extern char com_basedir[MAX_OSPATH]; +extern int com_argc; +extern char **com_argv; int COM_CheckParm (char *parm); void COM_Init (void); diff --git a/host.c b/host.c index 32562e13..e04cc622 100644 --- a/host.c +++ b/host.c @@ -34,8 +34,6 @@ Memory is cleared / released when a server or client begins, not when they end. */ -quakeparms_t host_parms; - qboolean host_initialized; // true if into command execution qboolean host_loopactive = false; // LordHavoc: used to turn Host_Error into Sys_Error if starting up or shutting down qboolean host_shuttingdown = false; // LordHavoc: set when quit is executed diff --git a/quakedef.h b/quakedef.h index 23c2061a..201cd783 100644 --- a/quakedef.h +++ b/quakedef.h @@ -195,31 +195,11 @@ extern char *buildstring; #include "portals.h" -//============================================================================= - -// the host system specifies the base of the directory tree - -typedef struct -{ - char *basedir; -#if CACHEENABLE - char *cachedir; // for development over ISDN lines -#endif -} quakeparms_t; - - -//============================================================================= - - - extern qboolean noclip_anglehack; - // // host // -extern quakeparms_t host_parms; - extern cvar_t sys_ticrate; extern cvar_t developer; diff --git a/sys_linux.c b/sys_linux.c index 451844ce..87c36913 100644 --- a/sys_linux.c +++ b/sys_linux.c @@ -145,14 +145,8 @@ int main (int argc, char **argv) signal(SIGFPE, SIG_IGN); - memset(&host_parms, 0, sizeof(host_parms)); - com_argc = argc; com_argv = argv; - host_parms.basedir = "."; -#if CACHEENABLE - host_parms.cachedir = "/tmp"; -#endif fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY); diff --git a/sys_win.c b/sys_win.c index a0c2ed03..b9f68afc 100644 --- a/sys_win.c +++ b/sys_win.c @@ -353,7 +353,6 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin { double frameoldtime, framenewtime; MEMORYSTATUS lpBuffer; -// static char cwd[1024]; int t; /* previous instances do not exist in Win32 */ @@ -366,22 +365,6 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin lpBuffer.dwLength = sizeof(MEMORYSTATUS); GlobalMemoryStatus (&lpBuffer); -/* - if (!GetCurrentDirectory (sizeof(cwd), cwd)) - Sys_Error ("Couldn't determine current directory"); - - if (cwd[strlen(cwd)-1] == '/') - cwd[strlen(cwd)-1] = 0; -*/ - - memset(&host_parms, 0, sizeof(host_parms)); - -// host_parms.basedir = cwd; - host_parms.basedir = "."; -#if CACHEENABLE - host_parms.cachedir = "."; -#endif - com_argc = 1; argv[0] = empty_string;