From bf26788158570268db8161d4188fea43f5ff249f Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 7 Feb 2006 15:36:56 +0000 Subject: [PATCH] fixed loadgame to support stock quake savegames (which have 64 lightstyles, darkplaces savegames have 256) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5950 d7cf8633-e32d-0410-b094-e92efae38249 --- host_cmd.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/host_cmd.c b/host_cmd.c index f2db17f3..c14d7752 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -570,6 +570,7 @@ void Host_Loadgame_f (void) float time; const char *start; const char *t; + const char *oldt; char *text; prvm_edict_t *ent; int i; @@ -651,10 +652,33 @@ void Host_Loadgame_f (void) for (i = 0;i < MAX_LIGHTSTYLES;i++) { // light style + oldt = t; COM_ParseToken(&t, false); + // if this is a 64 lightstyle savegame produced by Quake, stop now + // we have to check this because darkplaces saves 256 lightstyle savegames + if (com_token[0] == '{') + { + t = oldt; + break; + } strlcpy(sv.lightstyles[i], com_token, sizeof(sv.lightstyles[i])); } + // now skip everything before the first opening brace + // (this is for forward compatibility, so that older versions (at + // least ones with this fix) can load savegames with extra data before the + // first brace, as might be produced by a later engine version) + for(;;) + { + oldt = t; + COM_ParseToken(&t, false); + if (com_token[0] == '{') + { + t = oldt; + break; + } + } + // load the edicts out of the savegame file SV_VM_Begin(); // -1 is the globals -- 2.39.2