#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"};
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<MAX_NUM_ARGVS) && (j< argc) ; j++)
+ for (j = 0;(j < MAX_NUM_ARGVS) && (j < com_argc);j++)
{
i = 0;
-
- while ((n < (CMDLINE_LENGTH - 1)) && argv[j][i])
- {
- com_cmdline[n++] = argv[j][i++];
- }
-
+ while ((n < (CMDLINE_LENGTH - 1)) && com_argv[j][i])
+ com_cmdline[n++] = com_argv[j][i++];
if (n < (CMDLINE_LENGTH - 1))
com_cmdline[n++] = ' ';
else
break;
}
-
com_cmdline[n] = 0;
+}
- safe = false;
-
- for (com_argc=0 ; (com_argc<MAX_NUM_ARGVS) && (com_argc < argc) ;
- com_argc++)
- {
- largv[com_argc] = argv[com_argc];
- if (!strcmp ("-safe", argv[com_argc]))
- safe = true;
- }
+void COM_InitGameType (void)
+{
+ char name[128];
+ COM_StripExtension(com_argv[0], name);
+ COM_ToLowerString(name, name);
- if (safe)
- {
- // force all the safe-mode switches. Note that we reserved extra space in
- // case we need to add these, so we don't need an overflow check
- for (i=0 ; i<NUM_SAFE_ARGVS ; i++)
- {
- largv[com_argc] = safeargvs[i];
- com_argc++;
- }
- }
+ if (strstr(name, "transfusion"))
+ gamemode = GAME_TRANSFUSION;
+ else if (strstr(name, "zymotic"))
+ gamemode = GAME_ZYMOTIC;
+ else if (strstr(name, "fiendarena"))
+ gamemode = GAME_FIENDARENA;
+ else if (strstr(name, "nehahra"))
+ gamemode = GAME_NEHAHRA;
+ else if (strstr(name, "hipnotic"))
+ gamemode = GAME_HIPNOTIC;
+ else if (strstr(name, "rogue"))
+ gamemode = GAME_ROGUE;
+ else
+ gamemode = GAME_NORMAL;
- largv[com_argc] = argvdummy;
- com_argv = largv;
-
-#if TRANSFUSION
- gamemode = GAME_TRANSFUSION;
-#elif ZYMOTIC
- gamemode = GAME_ZYMOTIC;
-#elif FIENDARENA
- gamemode = GAME_FIENDARENA;
-#elif NEHAHRA
- gamemode = GAME_NEHAHRA;
-#else
if (COM_CheckParm ("-transfusion"))
gamemode = GAME_TRANSFUSION;
else if (COM_CheckParm ("-zymotic"))
gamemode = GAME_HIPNOTIC;
else if (COM_CheckParm ("-rogue"))
gamemode = GAME_ROGUE;
-#endif
+ else if (COM_CheckParm ("-quake"))
+ gamemode = GAME_NORMAL;
+
switch(gamemode)
{
case GAME_NORMAL:
- gamename = "DarkPlaces";
+ if (registered.integer)
+ gamename = "DarkPlaces-Quake";
+ else
+ gamename = "DarkPlaces-SharewareQuake";
break;
case GAME_HIPNOTIC:
gamename = "Darkplaces-Hipnotic";
gamename = "Transfusion";
break;
default:
- Sys_Error("COM_InitArgv: unknown gamemode %i\n", gamemode);
+ Sys_Error("COM_InitGameType: unknown gamemode %i\n", gamemode);
break;
}
}
}
}
+int COM_StringBeginsWith(const char *s, const char *match)
+{
+ for (;*s && *match;s++, match++)
+ if (*s != *match)
+ return false;
+ return true;
+}
+
int COM_CheckParm (char *parm);
void COM_Init (void);
-void COM_InitArgv (int argc, char **argv);
+void COM_InitArgv (void);
+void COM_InitGameType (void);
char *COM_SkipPath (char *pathname);
void COM_StripExtension (char *in, char *out);
extern char *gamename;
// LordHavoc: useful...
-extern void COM_ToLowerString(char *in, char *out);
-extern void COM_ToUpperString(char *in, char *out);
+void COM_ToLowerString(char *in, char *out);
+void COM_ToUpperString(char *in, char *out);
+int COM_StringBeginsWith(const char *s, const char *match);
typedef struct stringlist_s
{
// LordHavoc: quake never seeded the random number generator before... heh
srand(time(NULL));
- com_argc = host_parms.argc;
- com_argv = host_parms.argv;
// FIXME: this is evil, but possibly temporary
if (COM_CheckParm("-developer"))
{
//=============================================================================
-// the host system specifies the base of the directory tree, the
-// command line parms passed to the program, and the amount of memory
-// available for the program to use
+// the host system specifies the base of the directory tree
typedef struct
{
#if CACHEENABLE
char *cachedir; // for development over ISDN lines
#endif
- int argc;
- char **argv;
} quakeparms_t;
#include "quakedef.h"
-char *basedir = ".";
-#if CACHEENABLE
-char *cachedir = "/tmp";
-#endif
-
// =======================================================================
// General routines
// =======================================================================
usleep(1);
}
-int main (int c, char **v)
+int main (int argc, char **argv)
{
double frameoldtime, framenewtime;
memset(&host_parms, 0, sizeof(host_parms));
- host_parms.argc = c;
- host_parms.argv = v;
- host_parms.basedir = basedir;
+ 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);
#include "quakedef.h"
#include <time.h>
-#ifndef WIN32
+#ifdef WIN32
+#include <direct.h>
+#else
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
'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', '{', '|', '}', '~', '<'
};
{
Memory_Init ();
+ COM_InitArgv();
+ COM_InitGameType();
+
#if defined(__linux__)
sprintf (engineversion, "%s Linux %s", gamename, buildstring);
#elif defined(WIN32)
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)
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++;
}
}
}
- host_parms.argv = argv;
+ com_argv = argv;
Sys_Shared_EarlyInit();