int com_argc;
const char **com_argv;
-char com_cmdline[MAX_INPUTLINE];
-
gamemode_t gamemode;
const char *gamename;
const char *gamedirname1;
return 0;
}
-/*
-================
-COM_CheckRegistered
-
-Looks for the pop.txt file and verifies it.
-Sets the "registered" cvar.
-Immediately exits out if an alternate game was attempted to be started without
-being registered.
-================
-*/
-void COM_CheckRegistered (void)
-{
- Cvar_Set ("cmdline", com_cmdline);
-
- if (gamemode == GAME_NORMAL && !FS_FileExists("gfx/pop.lmp"))
- {
- if (fs_modified)
- Con_Print("Playing shareware version, with modification.\nwarning: most mods require full quake data.\n");
- else
- Con_Print("Playing shareware version.\n");
- return;
- }
-
- Cvar_Set ("registered", "1");
- Con_Print("Playing registered version.\n");
-}
-
-
-/*
-================
-COM_InitArgv
-================
-*/
-void COM_InitArgv (void)
-{
- int i, j, n;
- // reconstitute the command line for the cmdline externally visible cvar
- n = 0;
- for (j = 0;(j < MAX_NUM_ARGVS) && (j < com_argc);j++)
- {
- i = 0;
- if (strstr(com_argv[j], " "))
- {
- // arg contains whitespace, store quotes around it
- com_cmdline[n++] = '\"';
- while ((n < ((int)sizeof(com_cmdline) - 1)) && com_argv[j][i])
- com_cmdline[n++] = com_argv[j][i++];
- com_cmdline[n++] = '\"';
- }
- else
- {
- while ((n < ((int)sizeof(com_cmdline) - 1)) && com_argv[j][i])
- com_cmdline[n++] = com_argv[j][i++];
- }
- if (n < ((int)sizeof(com_cmdline) - 1))
- com_cmdline[n++] = ' ';
- else
- break;
- }
- com_cmdline[n] = 0;
-}
-
-
//===========================================================================
// Game mods
*/
void COM_Init_Commands (void)
{
+ int i, j, n;
+ char com_cmdline[MAX_INPUTLINE];
+
Cvar_RegisterVariable (®istered);
Cvar_RegisterVariable (&cmdline);
+
+ // reconstitute the command line for the cmdline externally visible cvar
+ n = 0;
+ for (j = 0;(j < MAX_NUM_ARGVS) && (j < com_argc);j++)
+ {
+ i = 0;
+ if (strstr(com_argv[j], " "))
+ {
+ // arg contains whitespace, store quotes around it
+ com_cmdline[n++] = '\"';
+ while ((n < ((int)sizeof(com_cmdline) - 1)) && com_argv[j][i])
+ com_cmdline[n++] = com_argv[j][i++];
+ com_cmdline[n++] = '\"';
+ }
+ else
+ {
+ while ((n < ((int)sizeof(com_cmdline) - 1)) && com_argv[j][i])
+ com_cmdline[n++] = com_argv[j][i++];
+ }
+ if (n < ((int)sizeof(com_cmdline) - 1))
+ com_cmdline[n++] = ' ';
+ else
+ break;
+ }
+ com_cmdline[n] = 0;
+ Cvar_Set ("cmdline", com_cmdline);
}
/*
int COM_CheckParm (const char *parm);
void COM_Init (void);
void COM_Shutdown (void);
-void COM_InitArgv (void);
void COM_InitGameType (void);
char *va(const char *format, ...);
cvar_t con_notify = {CVAR_SAVE, "con_notify","4", "how many notify lines to show (0-32)"};
cvar_t con_textsize = {CVAR_SAVE, "con_textsize","8", "console text size in virtual 2D pixels"}; //[515]: console text size in pixels
+
+cvar_t sys_specialcharactertranslation = {0, "sys_specialcharactertranslation", "1", "terminal console conchars to ASCII translation (set to 0 if your conchars.tga is for an 8bit character set or if you want raw output)"};
+#ifdef WIN32
+cvar_t sys_colortranslation = {0, "sys_colortranslation", "0",
+#else
+cvar_t sys_colortranslation = {0, "sys_colortranslation", "1",
+#endif
+ "terminal console color translation (supported values: 0 = strip color codes, 1 = translate to ANSI codes, 2 = no translation)"};
+
#define MAX_NOTIFYLINES 32
// cl.time time the line was generated for transparent notify lines
float con_times[MAX_NOTIFYLINES];
logqueue = (unsigned char *)Mem_Alloc (tempmempool, logq_size);
logq_ind = 0;
+ Cvar_RegisterVariable (&sys_colortranslation);
+ Cvar_RegisterVariable (&sys_specialcharactertranslation);
+
Cvar_RegisterVariable (&log_file);
// support for the classic Quake option
// COMMANDLINEOPTION: Console: -condebug logs console messages to qconsole.log, see also log_file
if (COM_CheckParm ("-condebug") != 0)
Cvar_SetQuick (&log_file, "qconsole.log");
-}
-void Con_Init_Commands (void)
-{
// register our cvars
Cvar_RegisterVariable (&con_notifytime);
Cvar_RegisterVariable (&con_notify);
if (!sys_nostdout)
{
unsigned char *p;
- for (p = (unsigned char *) line;*p; p++)
- *p = qfont_table[*p];
- Sys_PrintToTerminal(line);
+ if(sys_specialcharactertranslation.integer)
+ {
+ for (p = (unsigned char *) line;*p; p++)
+ *p = qfont_table[*p];
+ }
+
+ if(sys_colortranslation.integer == 1) // ANSI
+ {
+ static char printline[MAX_INPUTLINE * 4 + 3];
+ // 2 can become 7 bytes, rounding that up to 8, and 3 bytes are added at the end
+ // a newline can transform into four bytes, but then prevents the three extra bytes from appearing
+ int lastcolor = 0;
+ const char *in;
+ char *out;
+ for(in = line, out = printline; *in; ++in)
+ {
+ switch(*in)
+ {
+ case '^':
+ switch(in[1])
+ {
+ case '^':
+ ++in;
+ *out++ = '^';
+ break;
+ case '0':
+ case '7':
+ // normal color
+ ++in;
+ if(lastcolor == 0) break; else lastcolor = 0;
+ *out++ = 0x1B; *out++ = '['; *out++ = 'm';
+ break;
+ case '1':
+ // light red
+ ++in;
+ if(lastcolor == 1) break; else lastcolor = 1;
+ *out++ = 0x1B; *out++ = '['; *out++ = '1'; *out++ = ';'; *out++ = '3'; *out++ = '1'; *out++ = 'm';
+ break;
+ case '2':
+ // light green
+ ++in;
+ if(lastcolor == 2) break; else lastcolor = 2;
+ *out++ = 0x1B; *out++ = '['; *out++ = '1'; *out++ = ';'; *out++ = '3'; *out++ = '2'; *out++ = 'm';
+ break;
+ case '3':
+ // yellow
+ ++in;
+ if(lastcolor == 3) break; else lastcolor = 3;
+ *out++ = 0x1B; *out++ = '['; *out++ = '1'; *out++ = ';'; *out++ = '3'; *out++ = '3'; *out++ = 'm';
+ break;
+ case '4':
+ // light blue
+ ++in;
+ if(lastcolor == 4) break; else lastcolor = 4;
+ *out++ = 0x1B; *out++ = '['; *out++ = '1'; *out++ = ';'; *out++ = '3'; *out++ = '4'; *out++ = 'm';
+ break;
+ case '5':
+ // light cyan
+ ++in;
+ if(lastcolor == 5) break; else lastcolor = 5;
+ *out++ = 0x1B; *out++ = '['; *out++ = '1'; *out++ = ';'; *out++ = '3'; *out++ = '6'; *out++ = 'm';
+ break;
+ case '6':
+ // light magenta
+ ++in;
+ if(lastcolor == 6) break; else lastcolor = 6;
+ *out++ = 0x1B; *out++ = '['; *out++ = '1'; *out++ = ';'; *out++ = '3'; *out++ = '5'; *out++ = 'm';
+ break;
+ // 7 handled above
+ case '8':
+ case '9':
+ // bold normal color
+ ++in;
+ if(lastcolor == 8) break; else lastcolor = 8;
+ *out++ = 0x1B; *out++ = '['; *out++ = '0'; *out++ = ';'; *out++ = '1'; *out++ = 'm';
+ break;
+ default:
+ *out++ = '^';
+ break;
+ }
+ break;
+ case '\n':
+ if(lastcolor != 0)
+ {
+ *out++ = 0x1B; *out++ = '['; *out++ = 'm';
+ lastcolor = 0;
+ }
+ *out++ = *in;
+ break;
+ default:
+ *out++ = *in;
+ break;
+ }
+ }
+ if(lastcolor != 0)
+ {
+ *out++ = 0x1B;
+ *out++ = '[';
+ *out++ = 'm';
+ }
+ *out++ = 0;
+ Sys_PrintToTerminal(printline);
+ }
+ else if(sys_colortranslation.integer == 2) // Quake
+ {
+ Sys_PrintToTerminal(line);
+ }
+ else // strip
+ {
+ static char printline[MAX_INPUTLINE]; // it can only get shorter here
+ const char *in;
+ char *out;
+ for(in = line, out = printline; *in; ++in)
+ {
+ switch(*in)
+ {
+ case '^':
+ switch(in[1])
+ {
+ case '^':
+ ++in;
+ *out++ = '^';
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ ++in;
+ break;
+ default:
+ *out++ = '^';
+ break;
+ }
+ break;
+ default:
+ *out++ = *in;
+ break;
+ }
+ }
+ *out++ = 0;
+ Sys_PrintToTerminal(printline);
+ }
}
// empty the line buffer
index = 0;
fs_searchpaths = search;
}
}
- return;
}
-
- // add the game-specific paths
- // gamedirname1 (typically id1)
- FS_AddGameHierarchy (gamedirname1);
-
- // add the game-specific path, if any
- if (gamedirname2)
+ else
{
- fs_modified = true;
- FS_AddGameHierarchy (gamedirname2);
- }
-
- // set the com_modname (reported in server info)
- strlcpy(com_modname, gamedirname1, sizeof(com_modname));
+ // add the game-specific paths
+ // gamedirname1 (typically id1)
+ FS_AddGameHierarchy (gamedirname1);
- // -game <gamedir>
- // Adds basedir/gamedir as an override game
- // LordHavoc: now supports multiple -game directories
- for (i = 1;i < com_argc;i++)
- {
- if (!com_argv[i])
- continue;
- if (!strcmp (com_argv[i], "-game") && i < com_argc-1)
+ // add the game-specific path, if any
+ if (gamedirname2)
{
- i++;
fs_modified = true;
- FS_AddGameHierarchy (com_argv[i]);
- // update the com_modname
- strlcpy (com_modname, com_argv[i], sizeof (com_modname));
+ FS_AddGameHierarchy (gamedirname2);
+ }
+
+ // set the com_modname (reported in server info)
+ strlcpy(com_modname, gamedirname1, sizeof(com_modname));
+
+ // -game <gamedir>
+ // Adds basedir/gamedir as an override game
+ // LordHavoc: now supports multiple -game directories
+ for (i = 1;i < com_argc;i++)
+ {
+ if (!com_argv[i])
+ continue;
+ if (!strcmp (com_argv[i], "-game") && i < com_argc-1)
+ {
+ i++;
+ fs_modified = true;
+ FS_AddGameHierarchy (com_argv[i]);
+ // update the com_modname
+ strlcpy (com_modname, com_argv[i], sizeof (com_modname));
+ }
}
+
+ // If "-condebug" is in the command line, remove the previous log file
+ if (COM_CheckParm ("-condebug") != 0)
+ unlink (va("%s/qconsole.log", fs_gamedir));
}
- // If "-condebug" is in the command line, remove the previous log file
- if (COM_CheckParm ("-condebug") != 0)
- unlink (va("%s/qconsole.log", fs_gamedir));
+ // look for the pop.lmp file and set registered to true if it is found
+ if (gamemode == GAME_NORMAL && !FS_FileExists("gfx/pop.lmp"))
+ {
+ if (fs_modified)
+ Con_Print("Playing shareware version, with modification.\nwarning: most mods require full quake data.\n");
+ else
+ Con_Print("Playing shareware version.\n");
+ }
+ else
+ {
+ Cvar_Set ("registered", "1");
+ if (gamemode == GAME_NORMAL || gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE)
+ Con_Print("Playing registered version.\n");
+ }
+
+ // set the default screenshot name to either the mod name or the
+ // gamemode screenshot name
+ if (fs_modified)
+ Cvar_SetQuick (&scr_screenshot_name, com_modname);
+ else
+ Cvar_SetQuick (&scr_screenshot_name, gamescreenshotname);
}
void FS_Init_Commands(void)
Cmd_AddCommand ("path", FS_Path_f, "print searchpath (game directories and archives)");
Cmd_AddCommand ("dir", FS_Dir_f, "list files in searchpath matching an * filename pattern, one per line");
Cmd_AddCommand ("ls", FS_Ls_f, "list files in searchpath matching an * filename pattern, multiple per line");
-
- // set the default screenshot name to either the mod name or the
- // gamemode screenshot name
- if (fs_modified)
- Cvar_SetQuick (&scr_screenshot_name, com_modname);
- else
- Cvar_SetQuick (&scr_screenshot_name, gamescreenshotname);
}
/*
extern void PR_Cmd_Init(void);
extern void COM_Init_Commands(void);
extern void FS_Init_Commands(void);
-extern void COM_CheckRegistered(void);
extern qboolean host_stuffcmdsrun;
/*
int i;
const char* os;
+ // LordHavoc: quake never seeded the random number generator before... heh
+ srand(time(NULL));
+
// FIXME: this is evil, but possibly temporary
// COMMANDLINEOPTION: Console: -developer enables warnings and other notices (RECOMMENDED for mod developers)
if (COM_CheckParm("-developer"))
developer_memorydebug.string = "100";
}
- // LordHavoc: quake never seeded the random number generator before... heh
- srand(time(NULL));
+// COMMANDLINEOPTION: Console: -nostdout disables text output to the terminal the game was launched from
+ if (COM_CheckParm("-nostdout"))
+ sys_nostdout = 1;
// used by everything
Memory_Init();
- // initialize console and logging
- Con_Init();
-
// initialize console command/cvar/alias/command execution systems
Cmd_Init();
- // parse commandline
- COM_InitArgv();
+ // initialize memory subsystem cvars/commands
+ Memory_Init_Commands();
+
+ // initialize console and logging and its cvars/commands
+ Con_Init();
+
+ // initialize various cvars that could not be initialized earlier
+ Curl_Init_Commands();
+ Cmd_Init_Commands();
+ Sys_Init_Commands();
+ COM_Init_Commands();
+ FS_Init_Commands();
// initialize console window (only used by sys_win.c)
Sys_InitConsole();
os = "Unknown";
#endif
dpsnprintf (engineversion, sizeof (engineversion), "%s %s %s", gamename, os, buildstring);
+ Con_Printf("%s\n", engineversion);
-// COMMANDLINEOPTION: Console: -nostdout disables text output to the terminal the game was launched from
- if (COM_CheckParm("-nostdout"))
- sys_nostdout = 1;
- else
- Con_Printf("%s\n", engineversion);
+ // initialize ixtable
+ Mathlib_Init();
// initialize filesystem (including fs_basedir, fs_gamedir, -path, -game, scr_screenshot_name)
FS_Init();
- // initialize various cvars that could not be initialized earlier
- Memory_Init_Commands();
- Con_Init_Commands();
- Curl_Init_Commands();
- Cmd_Init_Commands();
- Sys_Init_Commands();
- COM_Init_Commands();
- FS_Init_Commands();
- COM_CheckRegistered();
-
- // initialize ixtable
- Mathlib_Init();
-
NetConn_Init();
Curl_Init();
//PR_Init();