+ 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));
+ 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.bufstr"))
+ {
+ COM_ParseToken_Simple(&t, false, false, true);
+ i = atoi(com_token);
+ COM_ParseToken_Simple(&t, false, false, true);
+ k = atoi(com_token);
+ COM_ParseToken_Simple(&t, false, false, true);
+ stringbuffer = (prvm_stringbuffer_t*) Mem_ExpandableArray_RecordAtIndex(&prog->stringbuffersarray, i);
+ // VorteX: nasty code, cleanup required
+ // create buffer at this index
+ if(!stringbuffer)
+ stringbuffer = (prvm_stringbuffer_t *) Mem_ExpandableArray_AllocRecordAtIndex(&prog->stringbuffersarray, i);
+ if (!stringbuffer)
+ Con_Printf("cant write string %i into buffer %i\n", k, i);
+ else
+ {
+ // code copied from VM_bufstr_set
+ // expand buffer
+ if (stringbuffer->max_strings <= i)
+ {
+ char **oldstrings = stringbuffer->strings;
+ stringbuffer->max_strings = max(stringbuffer->max_strings * 2, 128);
+ while (stringbuffer->max_strings <= i)
+ stringbuffer->max_strings *= 2;
+ stringbuffer->strings = (char **) Mem_Alloc(prog->progs_mempool, stringbuffer->max_strings * sizeof(stringbuffer->strings[0]));
+ if (stringbuffer->num_strings > 0)
+ memcpy(stringbuffer->strings, oldstrings, stringbuffer->num_strings * sizeof(stringbuffer->strings[0]));
+ if (oldstrings)
+ Mem_Free(oldstrings);
+ }
+ // allocate string
+ stringbuffer->num_strings = max(stringbuffer->num_strings, k + 1);
+ if(stringbuffer->strings[k])
+ Mem_Free(stringbuffer->strings[k]);
+ stringbuffer->strings[k] = NULL;
+ alloclen = strlen(com_token) + 1;
+ stringbuffer->strings[k] = (char *)Mem_Alloc(prog->progs_mempool, alloclen);
+ memcpy(stringbuffer->strings[k], com_token, alloclen);
+ }
+ }
+ // skip any trailing text or unrecognized commands
+ while (COM_ParseToken_Simple(&t, true, false, true) && strcmp(com_token, "\n"))
+ ;
+ }
+ }
+ }
+ Mem_Free(text);
+
+ if(developer_entityparsing.integer)
+ Con_Printf("Host_Loadgame_f: finished\n");