From 80cbaf49351c00ec6dcc52ba01dcad7487ec77ba Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 20 Aug 2002 07:08:40 +0000 Subject: [PATCH 1/1] got rid of host_parms.argc and argv, now uses com_argc and com_argv directly git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2262 d7cf8633-e32d-0410-b094-e92efae38249 --- common.c | 98 ++++++++++++++++++++++------------------------------ common.h | 8 +++-- host.c | 2 -- quakedef.h | 6 +--- sys_linux.c | 16 ++++----- sys_shared.c | 9 +++-- sys_win.c | 26 ++++++++------ 7 files changed, 78 insertions(+), 87 deletions(-) diff --git a/common.c b/common.c index 1f38d06c..a6aeab1e 100644 --- a/common.c +++ b/common.c @@ -29,14 +29,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" -#define NUM_SAFE_ARGVS 7 - -static char *largv[MAX_NUM_ARGVS + NUM_SAFE_ARGVS + 1]; -static char *argvdummy = " "; - -static char *safeargvs[NUM_SAFE_ARGVS] = - {"-stdvid", "-nolan", "-nosound", "-nocdaudio", "-nojoy", "-nomouse", "-window"}; - cvar_t registered = {0, "registered","0"}; cvar_t cmdline = {0, "cmdline","0"}; @@ -735,64 +727,45 @@ void COM_Path_f (void); COM_InitArgv ================ */ -void COM_InitArgv (int argc, char **argv) +void COM_InitArgv (void) { - qboolean safe; - int i, j, n; - -// reconstitute the command line for the cmdline externally visible cvar + int i, j, n; + // reconstitute the command line for the cmdline externally visible cvar n = 0; - - for (j=0 ; (j -#ifndef WIN32 +#ifdef WIN32 +#include +#else #include #include #include @@ -45,7 +47,7 @@ static char qfont_table[256] = { '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', + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '<' }; @@ -237,6 +239,9 @@ void Sys_Shared_EarlyInit(void) { Memory_Init (); + COM_InitArgv(); + COM_InitGameType(); + #if defined(__linux__) sprintf (engineversion, "%s Linux %s", gamename, buildstring); #elif defined(WIN32) diff --git a/sys_win.c b/sys_win.c index 5bd55f90..a0c2ed03 100644 --- a/sys_win.c +++ b/sys_win.c @@ -351,10 +351,10 @@ static char *empty_string = ""; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { - double frameoldtime, framenewtime; - MEMORYSTATUS lpBuffer; - static char cwd[1024]; - int t; + double frameoldtime, framenewtime; + MEMORYSTATUS lpBuffer; +// static char cwd[1024]; + int t; /* previous instances do not exist in Win32 */ if (hPrevInstance) @@ -366,28 +366,34 @@ 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 = cwd; + host_parms.basedir = "."; +#if CACHEENABLE + host_parms.cachedir = "."; +#endif - host_parms.argc = 1; + com_argc = 1; argv[0] = empty_string; - while (*lpCmdLine && (host_parms.argc < MAX_NUM_ARGVS)) + while (*lpCmdLine && (com_argc < MAX_NUM_ARGVS)) { while (*lpCmdLine && ((*lpCmdLine <= 32) || (*lpCmdLine > 126))) lpCmdLine++; if (*lpCmdLine) { - argv[host_parms.argc] = lpCmdLine; - host_parms.argc++; + argv[com_argc] = lpCmdLine; + com_argc++; while (*lpCmdLine && ((*lpCmdLine > 32) && (*lpCmdLine <= 126))) lpCmdLine++; @@ -399,7 +405,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin } } } - host_parms.argv = argv; + com_argv = argv; Sys_Shared_EarlyInit(); -- 2.39.2