From ffc96e13f19d988fc209614a62c9472d02964f59 Mon Sep 17 00:00:00 2001 From: havoc Date: Sat, 4 Oct 2008 17:38:02 +0000 Subject: [PATCH] implemented Quake-compatible savegame saving (writes 64 or more styles) enhanced savegame format with a large comment block at the end containing the true lightstyle data (not padded with m lines), and model and sound precaches, this should fix the famous Quake bug of reloading a savegame with a different version of a mod, or a mod that randomly precaches different monsters or similar git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8521 d7cf8633-e32d-0410-b094-e92efae38249 --- host_cmd.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 97 insertions(+), 13 deletions(-) diff --git a/host_cmd.c b/host_cmd.c index 93d4cb09..ee974ac6 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -442,10 +442,16 @@ LOAD / SAVE GAME void Host_Savegame_to (const char *name) { qfile_t *f; - int i; + int i, lightstyles = 64; char comment[SAVEGAME_COMMENT_LENGTH+1]; qboolean isserver; + // first we have to figure out if this can be saved in 64 lightstyles + // (for Quake compatibility) + for (i=64 ; inum_edicts ; i++) { + FS_Printf(f,"// edict %d\n", i); //Con_Printf("edict %d...\n", i); PRVM_ED_Write (f, PRVM_EDICT_NUM(i)); } +#if 1 + FS_Printf(f,"/*\n"); + FS_Printf(f,"// DarkPlaces extended savegame\n"); + // darkplaces extension - extra lightstyles, support for color lightstyles + for (i=0 ; i= 0 && i < MAX_LIGHTSTYLES) + strlcpy(sv.lightstyles[i], com_token, sizeof(sv.lightstyles[i])); + else + Con_Printf("unsupported lightstyle %i \"%s\"\n", i, com_token); + } + else if (!strcmp(com_token, "sv.model_precache")) + { + COM_ParseToken_Simple(&t, false, false); + i = atoi(com_token); + COM_ParseToken_Simple(&t, false, false); + if (i >= 0 && i < MAX_MODELS) + { + strlcpy(sv.model_precache[i], com_token, sizeof(sv.model_precache[i])); + sv.models[i] = Mod_ForName (sv.model_precache[i], true, false, false); + } + else + Con_Printf("unsupported model %i \"%s\"\n", i, com_token); + } + else if (!strcmp(com_token, "sv.sound_precache")) + { + COM_ParseToken_Simple(&t, false, false); + i = atoi(com_token); + COM_ParseToken_Simple(&t, false, false); + if (i >= 0 && i < MAX_SOUNDS) + strlcpy(sv.sound_precache[i], com_token, sizeof(sv.sound_precache[i])); + else + Con_Printf("unsupported sound %i \"%s\"\n", i, com_token); + } + // skip any trailing text or unrecognized commands + while (COM_ParseToken_Simple(&t, true, false) && strcmp(com_token, "\n")) + ; + } + } + SV_VM_End(); // make sure we're connected to loopback -- 2.39.2