+ if(developer_entityparsing.integer)
+ Con_Printf("Host_Loadgame_f: skipping until extended data\n");
+
+ // read extended data if present
+ // the extended data is stored inside a /* */ comment block, which the
+ // parser intentionally skips, so we have to check for it manually here
+ if(end)
+ {
+ while (*end == '\r' || *end == '\n')
+ end++;
+ if (end[0] == '/' && end[1] == '*' && (end[2] == '\r' || end[2] == '\n'))
+ {
+ if(developer_entityparsing.integer)
+ Con_Printf("Host_Loadgame_f: loading extended data\n");
+
+ Con_Printf("Loading extended DarkPlaces savegame\n");
+ t = end + 2;
+ memset(sv.lightstyles[0], 0, sizeof(sv.lightstyles));
+ memset(sv.model_precache[0], 0, sizeof(sv.model_precache));
+ memset(sv.sound_precache[0], 0, sizeof(sv.sound_precache));
+ BufStr_Flush(prog);
+
+ while (COM_ParseToken_Simple(&t, false, false, true))
+ {
+ if (!strcmp(com_token, "sv.lightstyles"))
+ {
+ COM_ParseToken_Simple(&t, false, false, true);
+ i = atoi(com_token);
+ COM_ParseToken_Simple(&t, false, false, true);
+ if (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, true);
+ i = atoi(com_token);
+ COM_ParseToken_Simple(&t, false, false, true);
+ 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, sv.model_precache[i][0] == '*' ? sv.worldname : NULL);
+ }
+ 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, true);
+ i = atoi(com_token);
+ COM_ParseToken_Simple(&t, false, false, true);
+ 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);
+ }
+ else if (!strcmp(com_token, "sv.buffer"))
+ {
+ if (COM_ParseToken_Simple(&t, false, false, true))
+ {
+ i = atoi(com_token);
+ if (i >= 0)
+ {
+ k = STRINGBUFFER_SAVED;
+ if (COM_ParseToken_Simple(&t, false, false, true))
+ k |= atoi(com_token);
+ if (!BufStr_FindCreateReplace(prog, i, k, "string"))
+ Con_Printf("failed to create stringbuffer %i\n", i);
+ }
+ else
+ Con_Printf("unsupported stringbuffer index %i \"%s\"\n", i, com_token);
+ }
+ else
+ Con_Printf("unexpected end of line when parsing sv.buffer (expected buffer index)\n");
+ }
+ else if (!strcmp(com_token, "sv.bufstr"))
+ {
+ if (!COM_ParseToken_Simple(&t, false, false, true))
+ Con_Printf("unexpected end of line when parsing sv.bufstr\n");
+ else
+ {
+ i = atoi(com_token);
+ stringbuffer = BufStr_FindCreateReplace(prog, i, STRINGBUFFER_SAVED, "string");
+ if (stringbuffer)
+ {
+ if (COM_ParseToken_Simple(&t, false, false, true))
+ {
+ k = atoi(com_token);
+ if (COM_ParseToken_Simple(&t, false, false, true))
+ BufStr_Set(prog, stringbuffer, k, com_token);
+ else
+ Con_Printf("unexpected end of line when parsing sv.bufstr (expected string)\n");
+ }
+ else
+ Con_Printf("unexpected end of line when parsing sv.bufstr (expected strindex)\n");
+ }
+ else
+ Con_Printf("failed to create stringbuffer %i \"%s\"\n", i, com_token);
+ }
+ }
+ // skip any trailing text or unrecognized commands
+ while (COM_ParseToken_Simple(&t, true, false, true) && strcmp(com_token, "\n"))
+ ;
+ }
+ }
+ }
+ Mem_Free(text);
+
+ // remove all temporary flagged string buffers (ones created with BufStr_FindCreateReplace)
+ numbuffers = (int)Mem_ExpandableArray_IndexRange(&prog->stringbuffersarray);
+ for (i = 0; i < numbuffers; i++)
+ {
+ if ( (stringbuffer = (prvm_stringbuffer_t *)Mem_ExpandableArray_RecordAtIndex(&prog->stringbuffersarray, i)) )
+ if (stringbuffer->flags & STRINGBUFFER_TEMP)
+ BufStr_Del(prog, stringbuffer);
+ }
+
+ if(developer_entityparsing.integer)
+ Con_Printf("Host_Loadgame_f: finished\n");