]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fixed loadgame to support stock quake savegames (which have 64 lightstyles, darkplace...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 7 Feb 2006 15:36:56 +0000 (15:36 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 7 Feb 2006 15:36:56 +0000 (15:36 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5950 d7cf8633-e32d-0410-b094-e92efae38249

host_cmd.c

index f2db17f3b8f76d812264ced228c01d9db1fb541a..c14d7752adb5e39c66d2ca521b1733a28ba35fc3 100644 (file)
@@ -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