]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
changed Host_Init to execute configs only once
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 6 May 2005 11:37:35 +0000 (11:37 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 6 May 2005 11:37:35 +0000 (11:37 +0000)
cleaned up Host_Init (and related functions like Con_Init, COM_Init, Cbuf_Init, etc) a great deal
now uses host_framecount >= 3 checks instead of host_loopactive or host_initialized checks, this should fix any problems with crashes erasing config.cfg
VID_Open and friends are now called from Host_StartVideo which is called by SCR_BeginLoadingPlaque (such as by SV_SpawnServer) as well as the end of Host_Init, this only calls them the first time it is called, so it can be called during config parsing (such as +map start on the commandline)
moved sys_usetimegettime and dedicated server console opening in sys_wgl.c into Sys_InitConsole and Sys_Init_Commands functions called by Host_Init
merged Sys_Shared_EarlyInit and Sys_Shared_LateInit into Host_Init
got rid of sys_usetimegettime (windows-only) cvar in sys_sdl.c
changed type of a number of vid_* variables from int to qboolean
renamed vidmode_active to vid_isfullscreen in vid_glx.c for more code consistency
fixed a bug in vid_glx.c that made it grab the mouse/keyboard even when it was not the active window
no longer grabs mouse while playing demos in a window

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5235 d7cf8633-e32d-0410-b094-e92efae38249

20 files changed:
cl_screen.c
cmd.c
cmd.h
common.c
console.c
console.h
cvar.c
fs.c
host.c
quakedef.h
sys.h
sys_linux.c
sys_sdl.c
sys_shared.c
sys_win.c
vid.h
vid_glx.c
vid_sdl.c
vid_shared.c
vid_wgl.c

index a21127d355b3d2f105703d7613a6654f203b2096..02632b2c9aa80a7fc9b5e104c530f3960b2ac169 100644 (file)
@@ -300,7 +300,8 @@ SCR_BeginLoadingPlaque
 */
 void SCR_BeginLoadingPlaque (void)
 {
-       S_StopAllSounds ();
+       Host_StartVideo();
+       S_StopAllSounds();
        SCR_UpdateLoadingScreen();
 }
 
diff --git a/cmd.c b/cmd.c
index cd8863059d9f7e0a2a47700ba82b47c714238159..6e82998478d257b2566922ac3232db367d8d7050 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -68,28 +68,6 @@ static void Cmd_Wait_f (void)
 static sizebuf_t       cmd_text;
 static qbyte           cmd_text_buf[32768];
 
-/*
-============
-Cbuf_Init
-============
-*/
-void Cbuf_Init (void)
-{
-       // space for commands and script files
-       cmd_text.data = cmd_text_buf;
-       cmd_text.maxsize = sizeof(cmd_text_buf);
-       cmd_text.cursize = 0;
-}
-
-/*
-============
-Cbuf_Shutdown
-============
-*/
-void Cbuf_Shutdown (void)
-{
-}
-
 /*
 ============
 Cbuf_AddText
@@ -226,6 +204,7 @@ quake +prog jctest.qp +cmd amlev1
 quake -nosound +cmd amlev1
 ===============
 */
+qboolean host_stuffcmdsrun = false;
 void Cmd_StuffCmds_f (void)
 {
        int             i, j, l;
@@ -238,6 +217,7 @@ void Cmd_StuffCmds_f (void)
                return;
        }
 
+       host_stuffcmdsrun = true;
        for (i = 0;i < com_argc;i++)
        {
                if (com_argv[i] && com_argv[i][0] == '+' && (com_argv[i][1] < '0' || com_argv[i][1] > '9'))
@@ -369,7 +349,7 @@ static void Cmd_Alias_f (void)
                }
                a->next = current;
        }
-       
+
 
 // copy the rest of the command line
        cmd[0] = 0;             // start out with a null string
@@ -464,7 +444,14 @@ Cmd_Init
 void Cmd_Init (void)
 {
        cmd_mempool = Mem_AllocPool("commands", 0, NULL);
+       // space for commands and script files
+       cmd_text.data = cmd_text_buf;
+       cmd_text.maxsize = sizeof(cmd_text_buf);
+       cmd_text.cursize = 0;
+}
 
+void Cmd_Init_Commands (void)
+{
 //
 // register our commands
 //
@@ -830,36 +817,30 @@ void Cmd_ExecuteString (const char *text, cmd_source_t src)
                return;         // no tokens
        }
 
-// check functions (only after host_initialized)
-       if (host_initialized || !strcasecmp(cmd_argv[0], "exec") || !strcasecmp(cmd_argv[0], "set") || !strcasecmp(cmd_argv[0], "seta"))
+// check functions
+       for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
        {
-               for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
+               if (!strcasecmp (cmd_argv[0],cmd->name))
                {
-                       if (!strcasecmp (cmd_argv[0],cmd->name))
-                       {
-                               cmd->function ();
-                               cmd_tokenizebufferpos = oldpos;
-                               return;
-                       }
+                       cmd->function ();
+                       cmd_tokenizebufferpos = oldpos;
+                       return;
                }
        }
 
-// check alias (only after host_initialized)
-       if (host_initialized)
+// check alias
+       for (a=cmd_alias ; a ; a=a->next)
        {
-               for (a=cmd_alias ; a ; a=a->next)
+               if (!strcasecmp (cmd_argv[0], a->name))
                {
-                       if (!strcasecmp (cmd_argv[0], a->name))
-                       {
-                               Cbuf_InsertText (a->value);
-                               cmd_tokenizebufferpos = oldpos;
-                               return;
-                       }
+                       Cbuf_InsertText (a->value);
+                       cmd_tokenizebufferpos = oldpos;
+                       return;
                }
        }
 
-// check cvars (always)
-       if (!Cvar_Command () && host_initialized)
+// check cvars
+       if (!Cvar_Command ())
                Con_Printf("Unknown command \"%s\"\n", Cmd_Argv(0));
 
        cmd_tokenizebufferpos = oldpos;
diff --git a/cmd.h b/cmd.h
index 66ab6af0219d4458b27fae557831c2572737ac58..3ee7865dc2eac1c20abf322683f83cf7810624af 100644 (file)
--- a/cmd.h
+++ b/cmd.h
@@ -8,7 +8,7 @@ of the License, or (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
@@ -40,6 +40,8 @@ The game starts with a Cbuf_AddText ("exec quake.rc\n"); Cbuf_Execute ();
 void Cbuf_Init (void);
 // allocates an initial text buffer that will grow as needed
 
+void Cmd_Init_Commands (void);
+
 void Cbuf_Shutdown (void);
 
 void Cbuf_AddText (const char *text);
index 74d26067a8d79d74a3f1dca692b7ba59940da51b..f568a828ea60f9812b2170a0a2d51f0dd389701f 100644 (file)
--- a/common.c
+++ b/common.c
@@ -1001,35 +1001,15 @@ void COM_InitGameType (void)
 }
 
 
-extern void Mathlib_Init(void);
-extern void FS_Init (void);
-
 /*
 ================
 COM_Init
 ================
 */
-void COM_Init (void)
+void COM_Init_Commands (void)
 {
        Cvar_RegisterVariable (&registered);
        Cvar_RegisterVariable (&cmdline);
-
-       Mathlib_Init();
-
-       FS_Init ();
-       COM_CheckRegistered ();
-}
-
-extern void FS_Shutdown (void);
-
-/*
-================
-COM_Shutdown
-================
-*/
-void COM_Shutdown (void)
-{
-       FS_Shutdown ();
 }
 
 /*
index aabc53ea1c313a211f2892bbc07569b00888f0f1..d5a1b31029ea1f61c9f517b7b28f5d81277fe675 100644 (file)
--- a/console.c
+++ b/console.c
@@ -105,27 +105,6 @@ const char* Log_Timestamp (const char *desc)
 }
 
 
-/*
-====================
-Log_Init
-====================
-*/
-void Log_Init (void)
-{
-       // Allocate a log queue
-       logq_size = 512;
-       logqueue = Mem_Alloc (tempmempool, logq_size);
-       logq_ind = 0;
-
-       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");
-}
-
-
 /*
 ====================
 Log_Open
@@ -351,45 +330,35 @@ void Con_CheckResize (void)
        if (width == con_linewidth)
                return;
 
-       if (width < 1)                  // video hasn't been initialized yet
-       {
-               width = 80;
-               con_linewidth = width;
-               con_totallines = CON_TEXTSIZE / con_linewidth;
-               memset (con_text, ' ', CON_TEXTSIZE);
-       }
-       else
-       {
-               oldwidth = con_linewidth;
-               con_linewidth = width;
-               oldtotallines = con_totallines;
-               con_totallines = CON_TEXTSIZE / con_linewidth;
-               numlines = oldtotallines;
+       oldwidth = con_linewidth;
+       con_linewidth = width;
+       oldtotallines = con_totallines;
+       con_totallines = CON_TEXTSIZE / con_linewidth;
+       numlines = oldtotallines;
 
-               if (con_totallines < numlines)
-                       numlines = con_totallines;
+       if (con_totallines < numlines)
+               numlines = con_totallines;
 
-               numchars = oldwidth;
+       numchars = oldwidth;
 
-               if (con_linewidth < numchars)
-                       numchars = con_linewidth;
+       if (con_linewidth < numchars)
+               numchars = con_linewidth;
 
-               memcpy (tbuf, con_text, CON_TEXTSIZE);
-               memset (con_text, ' ', CON_TEXTSIZE);
+       memcpy (tbuf, con_text, CON_TEXTSIZE);
+       memset (con_text, ' ', CON_TEXTSIZE);
 
-               for (i=0 ; i<numlines ; i++)
+       for (i=0 ; i<numlines ; i++)
+       {
+               for (j=0 ; j<numchars ; j++)
                {
-                       for (j=0 ; j<numchars ; j++)
-                       {
-                               con_text[(con_totallines - 1 - i) * con_linewidth + j] =
-                                               tbuf[((con_current - i + oldtotallines) %
-                                                         oldtotallines) * oldwidth + j];
-                       }
+                       con_text[(con_totallines - 1 - i) * con_linewidth + j] =
+                                       tbuf[((con_current - i + oldtotallines) %
+                                                 oldtotallines) * oldwidth + j];
                }
-
-               Con_ClearNotify ();
        }
 
+       Con_ClearNotify ();
+
        con_backscroll = 0;
        con_current = con_totallines - 1;
 }
@@ -402,9 +371,24 @@ Con_Init
 void Con_Init (void)
 {
        memset (con_text, ' ', CON_TEXTSIZE);
-       con_linewidth = -1;
-       Con_CheckResize ();
+       con_linewidth = 80;
+       con_totallines = CON_TEXTSIZE / con_linewidth;
+
+       // Allocate a log queue
+       logq_size = 512;
+       logqueue = Mem_Alloc (tempmempool, logq_size);
+       logq_ind = 0;
+
+       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);
index abe35cf9c676f1f0c85bbdebf919601b65884610..53711b962a8aa72ab9f25780f0fef648bdc40518 100644 (file)
--- a/console.h
+++ b/console.h
@@ -30,6 +30,7 @@ extern qboolean con_initialized;
 
 void Con_CheckResize (void);
 void Con_Init (void);
+void Con_Init_Commands (void);
 void Con_DrawConsole (int lines);
 void Con_Print(const char *txt);
 void Con_Printf(const char *fmt, ...);
diff --git a/cvar.c b/cvar.c
index a8f6a27b326426c590b0530643cc2db73449c3d1..b77fee3d4490dd1ca5f2f344bad94a5e97afe3a1 100644 (file)
--- a/cvar.c
+++ b/cvar.c
@@ -353,7 +353,7 @@ cvar_t *Cvar_Get (const char *name, const char *value, int flags)
 
        if (developer.integer)
                Con_Printf("Cvar_Get(\"%s\", \"%s\", %i);\n", name, value, flags);
-       
+
 // first check to see if it has already been defined
        cvar = Cvar_FindVar (name);
        if (cvar)
@@ -407,9 +407,7 @@ qboolean    Cvar_Command (void)
 // perform a variable print or set
        if (Cmd_Argc() == 1)
        {
-               // only print if host_initialized (otherwise it could print twice if this is in a script)
-               if (host_initialized)
-                       Con_Printf("\"%s\" is \"%s\"\n", v->name, v->string);
+               Con_Printf("\"%s\" is \"%s\"\n", v->name, v->string);
                return true;
        }
 
diff --git a/fs.c b/fs.c
index 39a5aecadd1a68ed823dba01022c27540505f162..904645d6811ae2de99ffd6e7621891cae18d6b73 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -853,8 +853,6 @@ void FS_AddGameHierarchy (const char *dir)
        const char *homedir;
 #endif
 
-       strlcpy (com_modname, dir, sizeof (com_modname));
-
        // Add the common game directory
        FS_AddGameDirectory (va("%s/%s", fs_basedir, dir));
 
@@ -904,12 +902,6 @@ void FS_Init (void)
 
        fs_mempool = Mem_AllocPool("file management", 0, NULL);
 
-       Cvar_RegisterVariable (&scr_screenshot_name);
-
-       Cmd_AddCommand ("path", FS_Path_f);
-       Cmd_AddCommand ("dir", FS_Dir_f);
-       Cmd_AddCommand ("ls", FS_Ls_f);
-
        strcpy(fs_basedir, ".");
        strcpy(fs_gamedir, ".");
 
@@ -963,7 +955,6 @@ void FS_Init (void)
        // add the game-specific paths
        // gamedirname1 (typically id1)
        FS_AddGameHierarchy (gamedirname1);
-       Cvar_SetQuick (&scr_screenshot_name, gamescreenshotname);
 
        // add the game-specific path, if any
        if (gamedirname2)
@@ -972,6 +963,9 @@ void FS_Init (void)
                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
@@ -984,7 +978,8 @@ void FS_Init (void)
                        i++;
                        fs_modified = true;
                        FS_AddGameHierarchy (com_argv[i]);
-                       Cvar_SetQuick (&scr_screenshot_name, com_modname);
+                       // update the com_modname
+                       strlcpy (com_modname, com_argv[i], sizeof (com_modname));
                }
        }
 
@@ -993,6 +988,22 @@ void FS_Init (void)
                unlink (va("%s/qconsole.log", fs_gamedir));
 }
 
+void FS_Init_Commands(void)
+{
+       Cvar_RegisterVariable (&scr_screenshot_name);
+
+       Cmd_AddCommand ("path", FS_Path_f);
+       Cmd_AddCommand ("dir", FS_Dir_f);
+       Cmd_AddCommand ("ls", FS_Ls_f);
+
+       // 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);
+}
+
 /*
 ================
 FS_Shutdown
diff --git a/host.c b/host.c
index fd66518c7c1b7e8b6244df25400fa93c2728a457..8d3389ff92cd7a489a13c4f3547348b377b43cce 100644 (file)
--- a/host.c
+++ b/host.c
@@ -36,10 +36,9 @@ Memory is cleared / released when a server or client begins, not when they end.
 
 */
 
-// true if into command execution
-qboolean host_initialized;
-// LordHavoc: used to turn Host_Error into Sys_Error if starting up or shutting down
-qboolean host_loopactive = false;
+// how many frames have occurred
+// (checked by Host_Error and Host_SaveConfig_f)
+int host_framecount;
 // LordHavoc: set when quit is executed
 qboolean host_shuttingdown = false;
 
@@ -50,8 +49,6 @@ double host_realframetime;
 double realtime;
 // realtime from previous frame
 double oldrealtime;
-// how many frames have occurred
-int host_framecount;
 
 // used for -developer commandline parameter, hacky hacky
 int forcedeveloper;
@@ -117,9 +114,9 @@ void Host_Error (const char *error, ...)
 
        Con_Printf("Host_Error: %s\n", hosterrorstring1);
 
-       // LordHavoc: if first frame has not been shown, or currently shutting
-       // down, do Sys_Error instead
-       if (!host_loopactive || host_shuttingdown)
+       // LordHavoc: if crashing very early, or currently shutting down, do
+       // Sys_Error instead
+       if (host_framecount < 3 || host_shuttingdown)
                Sys_Error ("Host_Error: %s", hosterrorstring1);
 
        if (hosterror)
@@ -154,10 +151,10 @@ void Host_Error (const char *error, ...)
 
 void Host_ServerOptions (void)
 {
-       int i, numplayers;
+       int i;
 
        // general default
-       numplayers = 8;
+       svs.maxclients = 8;
 
 // COMMANDLINEOPTION: Server: -dedicated [playerlimit] starts a dedicated server (with a command console), default playerlimit is 8
 // COMMANDLINEOPTION: Server: -listen [playerlimit] starts a multiplayer server with graphical client, like singleplayer but other players can connect, default playerlimit is 8
@@ -169,8 +166,8 @@ void Host_ServerOptions (void)
                {
                        cls.state = ca_dedicated;
                        // default players unless specified
-                       if (i != (com_argc - 1))
-                               numplayers = atoi (com_argv[i+1]);
+                       if (i + 1 < com_argc && atoi (com_argv[i+1]) >= 1)
+                               svs.maxclients = atoi (com_argv[i+1]);
                        if (COM_CheckParm ("-listen"))
                                Sys_Error ("Only one of -dedicated or -listen can be specified");
                }
@@ -181,14 +178,14 @@ void Host_ServerOptions (void)
                        if (i)
                        {
                                // default players unless specified
-                               if (i != (com_argc - 1))
-                                       numplayers = atoi (com_argv[i+1]);
+                               if (i + 1 < com_argc && atoi (com_argv[i+1]) >= 1)
+                                       svs.maxclients = atoi (com_argv[i+1]);
                        }
                        else
                        {
                                // default players in some games, singleplayer in most
                                if (gamemode != GAME_TRANSFUSION && gamemode != GAME_GOODVSBAD2 && gamemode != GAME_NEXUIZ && gamemode != GAME_BATTLEMECH)
-                                       numplayers = 1;
+                                       svs.maxclients = 1;
                        }
                }
        }
@@ -201,20 +198,16 @@ void Host_ServerOptions (void)
                // check for -dedicated specifying how many players
                i = COM_CheckParm ("-dedicated");
                // default players unless specified
-               if (i && i != (com_argc - 1))
-                       numplayers = atoi (com_argv[i+1]);
+               if (i && i + 1 < com_argc && atoi (com_argv[i+1]) >= 1)
+                       svs.maxclients = atoi (com_argv[i+1]);
        }
 
-       if (numplayers < 1)
-               numplayers = 8;
+       svs.maxclients = bound(1, svs.maxclients, MAX_SCOREBOARD);
 
-       numplayers = bound(1, numplayers, MAX_SCOREBOARD);
+       svs.clients = Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
 
-       if (numplayers > 1 && !deathmatch.integer)
+       if (svs.maxclients > 1 && !deathmatch.integer)
                Cvar_SetValueQuick(&deathmatch, 1);
-
-       svs.maxclients = numplayers;
-       svs.clients = Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
 }
 
 /*
@@ -225,8 +218,6 @@ Host_InitLocal
 void Host_SaveConfig_f(void);
 void Host_InitLocal (void)
 {
-       Host_InitCommands ();
-
        Cmd_AddCommand("saveconfig", Host_SaveConfig_f);
 
        Cvar_RegisterVariable (&host_framerate);
@@ -257,8 +248,6 @@ void Host_InitLocal (void)
 
        Cvar_RegisterVariable (&timestamps);
        Cvar_RegisterVariable (&timeformat);
-
-       Host_ServerOptions ();
 }
 
 
@@ -275,8 +264,8 @@ void Host_SaveConfig_f(void)
 
 // dedicated servers initialize the host but don't parse and set the
 // config.cfg cvars
-       // LordHavoc: save a config only after Host_Frame finished the first frame
-       if (host_initialized && host_loopactive && cls.state != ca_dedicated)
+       // LordHavoc: don't save a config if it crashed in startup
+       if (host_framecount >= 3 && cls.state != ca_dedicated)
        {
                f = FS_Open ("config.cfg", "wb", false, false);
                if (!f)
@@ -833,8 +822,6 @@ void _Host_Frame (float time)
        }
 
        host_framecount++;
-       host_loopactive = true;
-
 }
 
 void Host_Frame (float time)
@@ -875,7 +862,33 @@ void Host_Frame (float time)
 
 //============================================================================
 
-void Render_Init(void);
+qboolean vid_opened = false;
+void Host_StartVideo(void)
+{
+       if (!vid_opened && cls.state != ca_dedicated)
+       {
+               vid_opened = true;
+               VID_Open();
+               CDAudio_Startup();
+               CL_InitTEnts();  // We must wait after sound startup to load tent sounds
+               MR_Init();
+               SCR_BeginLoadingPlaque();
+       }
+}
+
+char engineversion[128];
+
+qboolean sys_nostdout = false;
+
+extern void Render_Init(void);
+extern void Mathlib_Init(void);
+extern void FS_Init(void);
+extern void FS_Shutdown(void);
+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;
 
 /*
 ====================
@@ -885,10 +898,53 @@ Host_Init
 void Host_Init (void)
 {
        int i;
+       const char* os;
 
        // LordHavoc: quake never seeded the random number generator before... heh
        srand(time(NULL));
 
+       // 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 console window (only used by sys_win.c)
+       Sys_InitConsole();
+
+       // detect gamemode from commandline options or executable name
+       COM_InitGameType();
+
+       // construct a version string for the corner of the console
+#if defined(__linux__)
+       os = "Linux";
+#elif defined(WIN32)
+       os = "Windows";
+#elif defined(__FreeBSD__)
+       os = "FreeBSD";
+#elif defined(__NetBSD__)
+       os = "NetBSD";
+#elif defined(__OpenBSD__)
+       os = "OpenBSD";
+#elif defined(MACOSX)
+       os = "Mac OS X";
+#else
+       os = "Unknown";
+#endif
+       dpsnprintf (engineversion, sizeof (engineversion), "%s %s %s", gamename, os, buildstring);
+
+// 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);
+
        // FIXME: this is evil, but possibly temporary
 // COMMANDLINEOPTION: Console: -developer enables warnings and other notices (RECOMMENDED for mod developers)
        if (COM_CheckParm("-developer"))
@@ -898,112 +954,88 @@ void Host_Init (void)
                developer.value = 1;
        }
 
-       Cmd_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();
-       Cbuf_Init();
-       R_Modules_Init();
-       V_Init();
-       COM_Init();
-       Key_Init();
+       Con_Init_Commands();
+       Cmd_Init_Commands();
+       Sys_Init_Commands();
+       COM_Init_Commands();
+       FS_Init_Commands();
+       COM_CheckRegistered();
+
+       // initialize ixtable
+       Mathlib_Init();
+
+       NetConn_Init();
        PR_Init();
+       PR_Cmd_Init();
        PRVM_Init();
        Mod_Init();
-       NetConn_Init();
        SV_Init();
+       Host_InitCommands();
        Host_InitLocal();
-
-       Con_Printf("Builddate: %s\n", buildstring);
+       Host_ServerOptions();
 
        if (cls.state != ca_dedicated)
        {
+               Con_Printf("Initializing client\n");
+
+               R_Modules_Init();
                Palette_Init();
                MR_Init_Commands();
                VID_Shared_Init();
                VID_Init();
-
                Render_Init();
                S_Init();
                CDAudio_Init();
+               Key_Init();
+               V_Init();
                CL_Init();
        }
 
-       Cbuf_Execute();
-
-       // only cvars are executed when host_initialized == false
-       if (gamemode == GAME_TEU)
-               Cbuf_InsertText("exec teu.rc\n");
-       else
-               Cbuf_InsertText("exec quake.rc\n");
-
-       Cbuf_Execute();
-       Cbuf_Execute();
-       Cbuf_Execute();
-
-       host_initialized = true;
-
-       Con_DPrint("========Initialized=========\n");
-
-       if (cls.state != ca_dedicated)
-       {
-               VID_Open();
-               CDAudio_Startup();
-               CL_InitTEnts ();  // We must wait after sound startup to load tent sounds
-               SCR_BeginLoadingPlaque();
-               MR_Init();
-       }
-
-       // set up the default startmap_sp and startmap_dm aliases, mods can
-       // override these
+       // set up the default startmap_sp and startmap_dm aliases (mods can
+       // override these) and then execute the quake.rc startup script
        if (gamemode == GAME_NEHAHRA)
-       {
-               Cbuf_InsertText ("alias startmap_sp \"map nehstart\"\n");
-               Cbuf_InsertText ("alias startmap_dm \"map nehstart\"\n");
-       }
+               Cbuf_InsertText("alias startmap_sp \"map nehstart\"\nalias startmap_dm \"map nehstart\"\nexec quake.rc\n");
        else if (gamemode == GAME_TRANSFUSION)
-       {
-               Cbuf_InsertText ("alias startmap_sp \"map e1m1\"\n");
-               Cbuf_InsertText ("alias startmap_dm \"map bb1\"\n");
-       }
+               Cbuf_InsertText("alias startmap_sp \"map e1m1\"\n""alias startmap_dm \"map bb1\"\nexec quake.rc\n");
        else if (gamemode == GAME_NEXUIZ)
-       {
-               Cbuf_InsertText ("alias startmap_sp \"map nexdm01\"\n");
-               Cbuf_InsertText ("alias startmap_dm \"map nexdm01\"\n");
-       }
+               Cbuf_InsertText("alias startmap_sp \"map nexdm01\"\nalias startmap_dm \"map nexdm01\"\nexec quake.rc\n");
+       else if (gamemode == GAME_TEU)
+               Cbuf_InsertText("alias startmap_sp \"map start\"\nalias startmap_dm \"map start\"\nexec teu.rc\n");
        else
-       {
-               Cbuf_InsertText ("alias startmap_sp \"map start\"\n");
-               Cbuf_InsertText ("alias startmap_dm \"map start\"\n");
-       }
+               Cbuf_InsertText("alias startmap_sp \"map start\"\nalias startmap_dm \"map start\"\nexec quake.rc\n");
 
-       // stuff it again so the first host frame will execute it again, this time
-       // in its entirety
-       if (gamemode == GAME_TEU)
-               Cbuf_InsertText("exec teu.rc\n");
-       else
-               Cbuf_InsertText("exec quake.rc\n");
+       // if stuffcmds wasn't run, then quake.rc is probably missing, use default
+       if (!host_stuffcmdsrun)
+               Cbuf_InsertText("exec default.cfg\nexec config.cfg\nexec autoexec.cfg\nstuffcmds\nstartdemos\n");
 
        Cbuf_Execute();
        Cbuf_Execute();
        Cbuf_Execute();
 
-       // We must wait for the log_file cvar to be initialized to start the log
-       Log_Start ();
-
-       if (cls.state == ca_dedicated || COM_CheckParm("-listen"))
-       if (!sv.active && !cls.demoplayback && !cls.connect_trying)
-               Cbuf_InsertText ("startmap_dm\n");
-
-       Cbuf_Execute();
+       // save console log up to this point to log_file if it was set by configs
+       Log_Start();
 
        // check for special benchmark mode
 // COMMANDLINEOPTION: Client: -benchmark <demoname> runs a timedemo and quits, results of any timedemo can be found in gamedir/benchmark.log (for example id1/benchmark.log)
        i = COM_CheckParm("-benchmark");
        if (i && i + 1 < com_argc)
        if (!sv.active && !cls.demoplayback && !cls.connect_trying)
+       {
                Cbuf_InsertText(va("timedemo %s\n", com_argv[i + 1]));
+               Cbuf_Execute();
+       }
 
-       Cbuf_Execute();
+       if (cls.state == ca_dedicated || COM_CheckParm("-listen"))
+       if (!sv.active && !cls.demoplayback && !cls.connect_trying)
+       {
+               Cbuf_InsertText("startmap_dm\n");
+               Cbuf_Execute();
+       }
 
        if (!sv.active && !cls.demoplayback && !cls.connect_trying)
        {
@@ -1013,11 +1045,12 @@ void Host_Init (void)
                        Cbuf_InsertText("playvideo logo\n");
                        Cbuf_InsertText("cd loop 1\n");
                }
+               Cbuf_Execute();
        }
 
-       Cbuf_Execute();
-       Cbuf_Execute();
-       Cbuf_Execute();
+       Con_DPrint("========Initialized=========\n");
+
+       Host_StartVideo();
 }
 
 
@@ -1061,7 +1094,6 @@ void Host_Shutdown(void)
        S_Terminate ();
        NetConn_Shutdown ();
        PR_Shutdown ();
-       Cbuf_Shutdown ();
 
        if (cls.state != ca_dedicated)
        {
@@ -1072,8 +1104,8 @@ void Host_Shutdown(void)
        Cmd_Shutdown();
        CL_Shutdown();
        Sys_Shutdown();
-       Log_Close ();
-       COM_Shutdown ();
+       Log_Close();
+       FS_Shutdown();
        Memory_Shutdown();
 }
 
index 7b8596302ee1a938af0161a7a5c7bfa58f9f82de..0417274c9002b9d850184820c2ca644c4ad7f55d 100644 (file)
@@ -222,8 +222,6 @@ extern qboolean noclip_anglehack;
 
 extern cvar_t developer;
 
-// true if into command execution
-extern qboolean host_initialized;
 extern double host_frametime;
 // the real frametime, before slowmo and clamping are applied (used for console scrolling)
 extern double host_realframetime;
@@ -236,6 +234,7 @@ void Host_ClearMemory(void);
 void Host_InitCommands(void);
 void Host_Init(void);
 void Host_Shutdown(void);
+void Host_StartVideo(void);
 void Host_Error(const char *error, ...);
 void Host_Frame(float time);
 void Host_Quit_f(void);
diff --git a/sys.h b/sys.h
index 4a992f6df0c5876829bae7ab4fa3d933f9fc6e01..afaf8ecc4adab8f4af1b74b73413bc7aef819927 100644 (file)
--- a/sys.h
+++ b/sys.h
@@ -49,10 +49,11 @@ qboolean Sys_LoadLibrary (const char** dllnames, dllhandle_t* handle, const dllf
 void Sys_UnloadLibrary (dllhandle_t* handle);
 void* Sys_GetProcAddress (dllhandle_t handle, const char* name);
 
-// called after Com_InitArgv
-void Sys_Shared_EarlyInit (void);
-// called after Host_init
-void Sys_Shared_LateInit (void);
+// called early in Host_Init
+void Sys_InitConsole (void);
+// called after command system is initialized but before first Con_Print
+void Sys_Init_Commands (void);
+
 
 // returns current timestamp
 char *Sys_TimeString(const char *timeformat);
index 1666a7f5c4aab49d8d9727e29bea964e846ac6a0..3f67c89a6c36d049a02f54f35db23783e14bfd10 100644 (file)
@@ -211,6 +211,14 @@ char *Sys_GetClipboardData (void)
        return NULL;
 }
 
+void Sys_InitConsole (void)
+{
+}
+
+void Sys_Init_Commands (void)
+{
+}
+
 int main (int argc, char **argv)
 {
        double frameoldtime, framenewtime;
@@ -224,12 +232,8 @@ int main (int argc, char **argv)
        fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
 #endif
 
-       Sys_Shared_EarlyInit();
-
        Host_Init();
 
-       Sys_Shared_LateInit();
-
        frameoldtime = Sys_DoubleTime () - 0.1;
        while (1)
        {
index 6f1653177c2536aa67cab1c4a039a29671a35701..bdefa12255a10eb0e7698774f034dffd80f527cb 100644 (file)
--- a/sys_sdl.c
+++ b/sys_sdl.c
 
 #include <SDL.h>
 
-#ifdef WIN32
-cvar_t sys_usetimegettime = {CVAR_SAVE, "sys_usetimegettime", "1"};
-#endif
-
 // =======================================================================
 // General routines
 // =======================================================================
@@ -29,7 +25,7 @@ void Sys_Shutdown (void)
        fflush(stdout);
        SDL_Quit();
 }
-       
+
 
 void Sys_Error (const char *error, ...)
 {
@@ -64,35 +60,6 @@ double Sys_DoubleTime (void)
        static int first = true;
        static double oldtime = 0.0, curtime = 0.0;
        double newtime;
-#ifdef WIN32
-       // LordHavoc: note to people modifying this code, DWORD is specifically defined as an unsigned 32bit number, therefore the 65536.0 * 65536.0 is fine.
-       if (!sys_usetimegettime.integer)
-       {
-               // QueryPerformanceCounter
-               // platform:
-               // Windows 95/98/ME/NT/2000/XP
-               // features:
-               // very accurate (CPU cycles)
-               // known issues:
-               // does not necessarily match realtime too well (tends to get faster and faster in win98)
-               // wraps around occasionally on some platforms (depends on CPU speed and probably other unknown factors)
-               double timescale;
-               LARGE_INTEGER PerformanceFreq;
-               LARGE_INTEGER PerformanceCount;
-
-               if (!QueryPerformanceFrequency (&PerformanceFreq))
-                       Sys_Error ("No hardware timer available");
-               QueryPerformanceCounter (&PerformanceCount);
-
-               #ifdef __BORLANDC__
-               timescale = 1.0 / ((double) PerformanceFreq.u.LowPart + (double) PerformanceFreq.u.HighPart * 65536.0 * 65536.0);
-               newtime = ((double) PerformanceCount.u.LowPart + (double) PerformanceCount.u.HighPart * 65536.0 * 65536.0) * timescale;
-               #else
-               timescale = 1.0 / ((double) PerformanceFreq.LowPart + (double) PerformanceFreq.HighPart * 65536.0 * 65536.0);
-               newtime = ((double) PerformanceCount.LowPart + (double) PerformanceCount.HighPart * 65536.0 * 65536.0) * timescale;
-               #endif
-       } else
-#endif
        newtime = (double) SDL_GetTicks() / 1000.0;
 
 
@@ -194,7 +161,7 @@ char *Sys_GetClipboardData (void)
 
                if ((hClipboardData = GetClipboardData (CF_TEXT)) != 0)
                {
-                       if ((cliptext = GlobalLock (hClipboardData)) != 0) 
+                       if ((cliptext = GlobalLock (hClipboardData)) != 0)
                        {
                                data = malloc (GlobalSize(hClipboardData)+1);
                                strcpy (data, cliptext);
@@ -209,6 +176,14 @@ char *Sys_GetClipboardData (void)
 #endif
 }
 
+void Sys_InitConsole (void)
+{
+}
+
+void Sys_Init_Commands (void)
+{
+}
+
 int main (int argc, char *argv[])
 {
        double frameoldtime, framenewtime;
@@ -222,16 +197,8 @@ int main (int argc, char *argv[])
        fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
 #endif
 
-       Sys_Shared_EarlyInit();
-
-#ifdef WIN32
-       Cvar_RegisterVariable(&sys_usetimegettime);
-#endif
-
        Host_Init();
 
-       Sys_Shared_LateInit();
-
        frameoldtime = Sys_DoubleTime () - 0.1;
        while (1)
        {
index 9b4aea623989069b6ad652e912625c7ef3609052..6cd86758ad9d76a0edda0257ddfb8ac8b3603de9 100644 (file)
@@ -7,8 +7,6 @@
 # include <dlfcn.h>
 #endif
 
-qboolean sys_nostdout = false;
-
 static char sys_timestring[128];
 char *Sys_TimeString(const char *timeformat)
 {
@@ -26,46 +24,6 @@ void Sys_Quit (void)
        exit(0);
 }
 
-char engineversion[128];
-
-void Sys_Shared_EarlyInit(void)
-{
-       const char* os;
-
-       Memory_Init ();
-       Log_Init ();
-
-       COM_InitArgv();
-       COM_InitGameType();
-
-#if defined(__linux__)
-       os = "Linux";
-#elif defined(WIN32)
-       os = "Windows";
-#elif defined(__FreeBSD__)
-       os = "FreeBSD";
-#elif defined(__NetBSD__)
-       os = "NetBSD";
-#elif defined(__OpenBSD__)
-       os = "OpenBSD";
-#elif defined(MACOSX)
-       os = "Mac OS X";
-#else
-       os = "Unknown";
-#endif
-       dpsnprintf (engineversion, sizeof (engineversion), "%s %s %s", gamename, os, buildstring);
-
-// 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);
-}
-
-void Sys_Shared_LateInit(void)
-{
-}
-
 /*
 ===============================================================================
 
index 4fa62ee06cc5e4c6186ffc1fdab6fb02019e6452..02be56b4393be41479467a02d3c7910a99f982f2 100644 (file)
--- a/sys_win.c
+++ b/sys_win.c
@@ -279,7 +279,7 @@ char *Sys_GetClipboardData (void)
 
                if ((hClipboardData = GetClipboardData (CF_TEXT)) != 0)
                {
-                       if ((cliptext = GlobalLock (hClipboardData)) != 0) 
+                       if ((cliptext = GlobalLock (hClipboardData)) != 0)
                        {
                                data = malloc (GlobalSize(hClipboardData)+1);
                                strcpy (data, cliptext);
@@ -291,6 +291,55 @@ char *Sys_GetClipboardData (void)
        return data;
 }
 
+void Sys_InitConsole (void)
+{
+       // initialize the windows dedicated server console if needed
+       tevent = CreateEvent(NULL, false, false, NULL);
+
+       if (!tevent)
+               Sys_Error ("Couldn't create event");
+
+       // LordHavoc: can't check cls.state because it hasn't been initialized yet
+       // if (cls.state == ca_dedicated)
+       if (COM_CheckParm("-dedicated"))
+       {
+               if (!AllocConsole ())
+                       Sys_Error ("Couldn't create dedicated server console");
+
+               hinput = GetStdHandle (STD_INPUT_HANDLE);
+               houtput = GetStdHandle (STD_OUTPUT_HANDLE);
+
+       // give QHOST a chance to hook into the console
+               if ((t = COM_CheckParm ("-HFILE")) > 0)
+               {
+                       if (t < com_argc)
+                               hFile = (HANDLE)atoi (com_argv[t+1]);
+               }
+
+               if ((t = COM_CheckParm ("-HPARENT")) > 0)
+               {
+                       if (t < com_argc)
+                               heventParent = (HANDLE)atoi (com_argv[t+1]);
+               }
+
+               if ((t = COM_CheckParm ("-HCHILD")) > 0)
+               {
+                       if (t < com_argc)
+                               heventChild = (HANDLE)atoi (com_argv[t+1]);
+               }
+
+               InitConProc (hFile, heventParent, heventChild);
+       }
+
+// because sound is off until we become active
+       S_BlockSound ();
+}
+
+void Sys_Init_Commands (void)
+{
+       Cvar_RegisterVariable(&sys_usetimegettime);
+}
+
 /*
 ==============================================================================
 
@@ -365,56 +414,10 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
                }
        }
 
-       Sys_Shared_EarlyInit();
-
-       Cvar_RegisterVariable(&sys_usetimegettime);
-
-       tevent = CreateEvent(NULL, false, false, NULL);
-
-       if (!tevent)
-               Sys_Error ("Couldn't create event");
-
-       // LordHavoc: can't check cls.state because it hasn't been initialized yet
-       // if (cls.state == ca_dedicated)
-       if (COM_CheckParm("-dedicated"))
-       {
-               if (!AllocConsole ())
-                       Sys_Error ("Couldn't create dedicated server console");
-
-               hinput = GetStdHandle (STD_INPUT_HANDLE);
-               houtput = GetStdHandle (STD_OUTPUT_HANDLE);
-
-       // give QHOST a chance to hook into the console
-               if ((t = COM_CheckParm ("-HFILE")) > 0)
-               {
-                       if (t < com_argc)
-                               hFile = (HANDLE)atoi (com_argv[t+1]);
-               }
-
-               if ((t = COM_CheckParm ("-HPARENT")) > 0)
-               {
-                       if (t < com_argc)
-                               heventParent = (HANDLE)atoi (com_argv[t+1]);
-               }
-
-               if ((t = COM_CheckParm ("-HCHILD")) > 0)
-               {
-                       if (t < com_argc)
-                               heventChild = (HANDLE)atoi (com_argv[t+1]);
-               }
-
-               InitConProc (hFile, heventParent, heventChild);
-       }
-
-// because sound is off until we become active
-       S_BlockSound ();
-
        Host_Init ();
 
-       Sys_Shared_LateInit();
-
        frameoldtime = Sys_DoubleTime ();
-       
+
        /* main window message loop */
        while (1)
        {
diff --git a/vid.h b/vid.h
index e845edd6ede8cac65c39b74f282473e019c5e879..cd4a04ef72915040d3c218eed76612334c3c2972 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -41,10 +41,10 @@ extern viddef_t vid;
 extern void (*vid_menudrawfn)(void);
 extern void (*vid_menukeyfn)(int key);
 
-extern int vid_hidden;
-extern int vid_activewindow;
+extern qboolean vid_hidden;
+extern qboolean vid_activewindow;
 extern cvar_t vid_hardwaregammasupported;
-extern int vid_usinghwgamma;
+extern qboolean vid_usinghwgamma;
 
 extern cvar_t vid_fullscreen;
 extern cvar_t vid_width;
index aa86a167961ef98fc0174235a2c197459ce227a4..803f76b9f595d19c0e13fb94df73e097463aa128 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -109,7 +109,7 @@ static int scr_width, scr_height;
 
 static XF86VidModeModeInfo **vidmodes;
 static int num_vidmodes;
-static qboolean vidmode_active = false;
+static qboolean vid_isfullscreen = false;
 
 static Visual *vidx11_visual;
 static Colormap vidx11_colormap;
@@ -601,13 +601,13 @@ void VID_Shutdown(void)
                uninstall_grabs();
 
                // FIXME: glXDestroyContext here?
-               if (vidmode_active)
+               if (vid_isfullscreen)
                        XF86VidModeSwitchToMode(vidx11_display, vidx11_screen, vidmodes[0]);
                if (win)
                        XDestroyWindow(vidx11_display, win);
                XCloseDisplay(vidx11_display);
        }
-       vidmode_active = false;
+       vid_isfullscreen = false;
        vidx11_display = NULL;
        win = 0;
        ctx = NULL;
@@ -662,10 +662,12 @@ void VID_Finish (void)
 
 // handle the mouse state when windowed if that's changed
        vid_usemouse = false;
-       if (vid_mouse.integer && !key_consoleactive)
+       if (vid_mouse.integer && !key_consoleactive && !cls.demoplayback)
                vid_usemouse = true;
-       if (vidmode_active)
+       if (vid_isfullscreen)
                vid_usemouse = true;
+       if (!vid_activewindow)
+               vid_usemouse = false;
        if (vid_usemouse)
        {
                if (!vid_usingmouse)
@@ -831,7 +833,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
 
                                // change to the mode
                                XF86VidModeSwitchToMode(vidx11_display, vidx11_screen, vidmodes[best_fit]);
-                               vidmode_active = true;
+                               vid_isfullscreen = true;
 
                                // Move the viewport to top left
                                XF86VidModeSetViewPort(vidx11_display, vidx11_screen, 0, 0);
@@ -850,7 +852,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
        // LordHavoc: save the colormap for later, too
        vidx11_colormap = attr.colormap = XCreateColormap(vidx11_display, root, visinfo->visual, AllocNone);
        attr.event_mask = X_MASK;
-       if (vidmode_active)
+       if (vid_isfullscreen)
        {
                mask = CWBackPixel | CWColormap | CWSaveUnder | CWBackingStore | CWEventMask | CWOverrideRedirect;
                attr.override_redirect = True;
@@ -869,7 +871,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
        wm_delete_window_atom = XInternAtom(vidx11_display, "WM_DELETE_WINDOW", false);
        XSetWMProtocols(vidx11_display, win, &wm_delete_window_atom, 1);
 
-       if (vidmode_active)
+       if (vid_isfullscreen)
        {
                XMoveWindow(vidx11_display, win, 0, 0);
                XRaiseWindow(vidx11_display, win);
index 826d8d98a1f864a91821a3e60cf77ac2a7a8d6e7..196fe4f497b39b7bc0fd511b268946e291078a22 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -23,8 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 // Tell startup code that we have a client
 int cl_available = true;
-static int vid_usingmouse;
-static int vid_isfullscreen;
+static qboolean vid_usingmouse;
+static qboolean vid_isfullscreen;
 
 static SDL_Surface *screen;
 
@@ -42,7 +42,7 @@ static void IN_Shutdown( void );
 #define tenoh  0,0,0,0,0, 0,0,0,0,0
 #define fiftyoh tenoh, tenoh, tenoh, tenoh, tenoh
 #define hundredoh fiftyoh, fiftyoh
-static unsigned int tbl_sdltoquake[] = 
+static unsigned int tbl_sdltoquake[] =
 {
        0,0,0,0,                //SDLK_UNKNOWN          = 0,
        0,0,0,0,                //SDLK_FIRST            = 0,
@@ -233,7 +233,7 @@ static void IN_MouseMove (void)
 
 void IN_Move( void )
 {
-       IN_MouseMove(); 
+       IN_MouseMove();
 }
 
 static void IN_Init( void )
@@ -255,13 +255,13 @@ static void IN_Shutdown( void )
 // Message Handling
 ////
 
-static int Sys_EventFilter( SDL_Event *event ) 
+static int Sys_EventFilter( SDL_Event *event )
 {
        //TODO: Add a quit query in linux, too - though linux user are more likely to know what they do
 #ifdef WIN32
        if( event->type == SDL_QUIT && MessageBox( NULL, "Are you sure you want to quit?", "Confirm Exit", MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION ) == IDNO )
                return 0;
-       else 
+       else
                return 1;
 #else
        return 1;
@@ -282,7 +282,7 @@ void Sys_SendKeyEvents( void )
                                Key_Event( MapKey( event.key.keysym.sym ), (char)event.key.keysym.unicode, (event.key.state == SDL_PRESSED) );
                                break;
                        case SDL_ACTIVEEVENT:
-                               if( event.active.state == SDL_APPACTIVE ) 
+                               if( event.active.state == SDL_APPACTIVE )
                                {
                                        if( event.active.gain )
                                                vid_hidden = false;
@@ -291,14 +291,14 @@ void Sys_SendKeyEvents( void )
                                }
                                break;
                        case SDL_MOUSEBUTTONDOWN:
-                               if( event.button.button == SDL_BUTTON_MIDDLE ) 
+                               if( event.button.button == SDL_BUTTON_MIDDLE )
                                        event.button.button = SDL_BUTTON_RIGHT;
                                else if( event.button.button == SDL_BUTTON_RIGHT )
                                        event.button.button = SDL_BUTTON_MIDDLE;
                                Key_Event( K_MOUSE1 + event.button.button - 1, 0, true );
                                break;
                        case SDL_MOUSEBUTTONUP:
-                               if( event.button.button == SDL_BUTTON_MIDDLE ) 
+                               if( event.button.button == SDL_BUTTON_MIDDLE )
                                        event.button.button = SDL_BUTTON_RIGHT;
                                else if( event.button.button == SDL_BUTTON_RIGHT )
                                        event.button.button = SDL_BUTTON_MIDDLE;
@@ -341,7 +341,7 @@ static void VID_SetCaption()
        // set the caption
        SDL_WM_SetCaption( gamename, NULL );
 
-       // get the HWND handle 
+       // get the HWND handle
     SDL_VERSION( &info.version );
        if( !SDL_GetWMInfo( &info ) )
                return;
@@ -363,7 +363,7 @@ static void VID_OutputVersion()
        Con_Printf(     "Linked against SDL version %d.%d.%d\n"
                                        "Using SDL library version %d.%d.%d\n",
                                        SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL,
-                                       version->major, version->minor, version->patch );       
+                                       version->major, version->minor, version->patch );
 }
 
 int VID_InitMode(int fullscreen, int width, int height, int bpp)
@@ -374,8 +374,8 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
 
        VID_OutputVersion();
 
-       /* 
-       SDL Hack 
+       /*
+       SDL Hack
                We cant switch from one OpenGL video mode to another.
                Thus we first switch to some stupid 2D mode and then back to OpenGL.
        */
@@ -391,13 +391,13 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
        if (i && i < com_argc - 1)
                drivername = com_argv[i + 1];
        if (SDL_GL_LoadLibrary(drivername) < 0)
-       {   
+       {
                Con_Printf("Unable to load GL driver \"%s\": %s\n", drivername, SDL_GetError());
                return false;
        }
 
        qglGetString = GL_GetProcAddress("glGetString");
-       
+
        // Knghtbrd: should do platform-specific extension string function here
 
        if (qglGetString == NULL)
@@ -439,7 +439,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
                return false;
        }
        VID_SetCaption();
-       
+
        gl_renderer = qglGetString(GL_RENDERER);
        gl_vendor = qglGetString(GL_VENDOR);
        gl_version = qglGetString(GL_VERSION);
@@ -449,7 +449,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp)
        //TODO: maybe ;)
        gl_platformextensions = "";
        gl_videosyncavailable = false;
-       
+
        GL_Init();
 
        vid_hidden = false;
@@ -485,7 +485,7 @@ void VID_GetWindowSize (int *x, int *y, int *width, int *height)
 void VID_Finish (void)
 {
        Uint8 appstate;
-       int vid_usemouse;
+       qboolean vid_usemouse;
 
        if (r_speeds.integer || gl_finish.integer)
                qglFinish();
@@ -496,11 +496,11 @@ void VID_Finish (void)
 
        if( !( appstate & SDL_APPMOUSEFOCUS ) || !( appstate & SDL_APPINPUTFOCUS ) )
                vid_activewindow = false;
-       else 
+       else
                vid_activewindow = true;
 
        vid_usemouse = false;
-       if( vid_mouse.integer && !key_consoleactive )
+       if( vid_mouse.integer && !key_consoleactive && !cls.demoplayback )
                vid_usemouse = true;
        if( vid_isfullscreen )
                vid_usemouse = true;
index 2160e4b065f917b365f6f4db8e30ddce6409c8ce..a2dfc9a6ca054b3c796caa2503acffb23fd2fa54 100644 (file)
@@ -50,15 +50,15 @@ int gl_support_vertex_shader = false;
 int gl_support_fragment_shader = false;
 
 // LordHavoc: if window is hidden, don't update screen
-int vid_hidden = true;
+qboolean vid_hidden = true;
 // LordHavoc: if window is not the active window, don't hog as much CPU time,
 // let go of the mouse, turn off sound, and restore system gamma ramps...
-int vid_activewindow = true;
+qboolean vid_activewindow = true;
 
 // we don't know until we try it!
 cvar_t vid_hardwaregammasupported = {CVAR_READONLY,"vid_hardwaregammasupported","1"};
 // whether hardware gamma ramps are currently in effect
-int vid_usinghwgamma = false;
+qboolean vid_usinghwgamma = false;
 
 unsigned short vid_gammaramps[768];
 unsigned short vid_systemgammaramps[768];
@@ -686,7 +686,7 @@ void VID_CheckExtensions(void)
                                gl_support_fragment_shader = GL_CheckExtension("GL_ARB_fragment_shader", NULL, "-nofragmentshader", false);
 }
 
-int vid_vertexarrays_are_var = false;
+qboolean vid_vertexarrays_are_var = false;
 void *VID_AllocVertexArrays(mempool_t *pool, int size, int fast, float readfrequency, float writefrequency, float priority)
 {
        void *m;
@@ -1022,7 +1022,7 @@ static void VID_CloseSystems(void)
        R_Modules_Shutdown();
 }
 
-int vid_commandlinecheck = true;
+qboolean vid_commandlinecheck = true;
 
 void VID_Restart_f(void)
 {
index b76da3d608cb2935c81f64d2ba30200449132bc3..46589db67637c0c2c5c0b1430ec736e860e63039 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -88,7 +88,7 @@ static HGLRC baseRC;
 
 //HWND WINAPI InitializeWindow (HINSTANCE hInstance, int nCmdShow);
 
-static int vid_isfullscreen;
+static qboolean vid_isfullscreen;
 
 //void VID_MenuDraw (void);
 //void VID_MenuKey (int key);
@@ -314,7 +314,7 @@ void VID_Finish (void)
 
 // handle the mouse state when windowed if that's changed
        vid_usemouse = false;
-       if (vid_mouse.integer && !key_consoleactive)
+       if (vid_mouse.integer && !key_consoleactive && !cls.demoplayback)
                vid_usemouse = true;
        if (vid_isfullscreen)
                vid_usemouse = true;
@@ -452,8 +452,6 @@ void ClearAllStates (void)
        IN_ClearStates ();
 }
 
-extern qboolean host_loopactive;
-
 void AppActivate(BOOL fActive, BOOL minimize)
 /****************************************************************************
 *