From: havoc Date: Sat, 28 Sep 2002 05:35:21 +0000 (+0000) Subject: map and load commands are now delayed until the video system is started, this fixes... X-Git-Tag: RELEASE_0_2_0_RC1~184 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=798d907bb916ac4f89e854794a28540913b71b01;hp=275526b51e0cc486f423539e2aa9473f91bf2b50 map and load commands are now delayed until the video system is started, this fixes crashs caused by the video system starting after the configs are read git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2457 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_parse.c b/cl_parse.c index afc2fa3d..608b3ef8 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -291,8 +291,6 @@ Con_DPrintf ("CL_SignonReply: %i\n", cls.signon); } MSG_WriteByte (&cls.message, clc_stringcmd); - //sprintf (str, "spawn %s", cls.spawnparms); - //MSG_WriteString (&cls.message, str); MSG_WriteString (&cls.message, "spawn"); break; diff --git a/client.h b/client.h index 0df1f7a2..1dd0df3c 100644 --- a/client.h +++ b/client.h @@ -251,7 +251,6 @@ typedef struct #define SIGNONS 4 // signon messages to receive before connected -#define MAX_MAPSTRING 2048 #define MAX_DEMOS 8 #define MAX_DEMONAME 16 @@ -271,11 +270,6 @@ typedef struct { cactive_t state; -// personalization data sent to server - char mapstring[MAX_QPATH]; - // to restart a level - //char spawnparms[MAX_MAPSTRING]; - // demo loop control // -1 = don't play demos int demonum; @@ -657,5 +651,7 @@ extern mempool_t *cl_refdef_mempool; #include "cgamevm.h" +void Host_PerformSpawnServerAndLoadGame(void); + #endif diff --git a/host.c b/host.c index 55aa6868..c0a07774 100644 --- a/host.c +++ b/host.c @@ -786,6 +786,9 @@ void _Host_Frame (float time) CDAudio_Update(); + // LordHavoc: map and load are delayed until video is initialized + Host_PerformSpawnServerAndLoadGame(); + if (host_speeds.integer) { pass1 = (time1 - time3)*1000000; diff --git a/host_cmd.c b/host_cmd.c index 2fbc012f..6a648c38 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -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. @@ -20,7 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" -int current_skill; +int current_skill; +char sv_spawnmap[MAX_QPATH]; +char sv_loadgame[MAX_OSPATH]; dfunction_t *ED_FindFunction (char *name); @@ -233,7 +235,6 @@ SERVER TRANSITIONS =============================================================================== */ - /* ====================== Host_Map_f @@ -245,9 +246,6 @@ command from the console. Active clients are kicked off. */ void Host_Map_f (void) { - int i; - char name[MAX_QPATH]; - if (cmd_source != src_command) return; @@ -260,33 +258,8 @@ void Host_Map_f (void) key_dest = key_game; // remove console or menu - cls.mapstring[0] = 0; - for (i=0 ; i : continue game on a new level\n"); @@ -311,8 +282,7 @@ void Host_Changelevel_f (void) return; } SV_SaveSpawnparms (); - strcpy (level, Cmd_Argv(1)); - SV_SpawnServer (level); + strcpy (sv_spawnmap, Cmd_Argv(1)); } /* @@ -324,16 +294,12 @@ Restarts the current server for a dead player */ void Host_Restart_f (void) { - char mapname[MAX_QPATH]; - if (cls.demoplayback || !sv.active) return; if (cmd_source != src_command) return; - strcpy (mapname, sv.name); // must copy out, because it gets cleared - // in sv_spawnserver - SV_SpawnServer (mapname); + strcpy (sv_spawnmap, sv.name); } /* @@ -359,8 +325,8 @@ User command to connect to server */ void Host_Connect_f (void) { - char name[MAX_QPATH]; - + char name[MAX_QPATH]; + cls.demonum = -1; // stop demo loop in case this fails if (cls.demoplayback) CL_Disconnect (); @@ -510,7 +476,23 @@ Host_Loadgame_f */ void Host_Loadgame_f (void) { - char name[MAX_OSPATH]; + if (cmd_source != src_command) + return; + + if (Cmd_Argc() != 2) + { + Con_Printf ("load : load a game\n"); + return; + } + + sprintf (sv_loadgame, "%s/%s", com_gamedir, Cmd_Argv(1)); + COM_DefaultExtension (sv_loadgame, ".sav"); + + Con_Printf ("Loading game from %s...\n", sv_loadgame); +} + +void Host_PerformLoadGame(char *name) +{ QFile *f; char mapname[MAX_QPATH]; float time, tfloat; @@ -523,21 +505,8 @@ void Host_Loadgame_f (void) int version; float spawn_parms[NUM_SPAWN_PARMS]; - if (cmd_source != src_command) - return; - - if (Cmd_Argc() != 2) - { - Con_Printf ("load : load a game\n"); - return; - } - cls.demonum = -1; // stop demo loop in case this fails - sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1)); - COM_DefaultExtension (name, ".sav"); - - Con_Printf ("Loading game from %s...\n", name); f = Qopen (name, "rz"); if (!f) { @@ -557,7 +526,8 @@ void Host_Loadgame_f (void) SCR_BeginLoadingPlaque (); str = Qgetline (f); - for (i=0 ; ispawn_parms[i] = spawn_parms[i]; if (cls.state != ca_dedicated) @@ -695,9 +665,9 @@ void Host_Name_f (void) Con_Printf ("%s renamed to %s\n", host_client->name, newName); strcpy (host_client->name, newName); host_client->edict->v.netname = host_client->name - pr_strings; - + // send notification to all clients - + MSG_WriteByte (&sv.reliable_datagram, svc_updatename); MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients); MSG_WriteString (&sv.reliable_datagram, host_client->name); @@ -1619,6 +1589,24 @@ void Host_Stopdemo_f (void) CL_Disconnect (); } +// LordHavoc: because we don't want to load things before the video starts, +// we have to delay map and game loads until AFTER video is initialized +void Host_PerformSpawnServerAndLoadGame(void) +{ + if (vid_hidden) + return; + if (sv_loadgame[0]) + Host_PerformLoadGame(sv_loadgame); + else if (sv_spawnmap[0]) + { + SV_SpawnServer(sv_spawnmap); + if (sv.active && cls.state != ca_dedicated) + Cmd_ExecuteString ("connect local", src_command); + } + sv_loadgame[0] = 0; + sv_spawnmap[0] = 0; +} + //============================================================================= /*