mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 23:11:38 +00:00
Handle old global vector compontents.
In the original save gave format, global vectors were saved as individual components rather than as a single vector, using the _x/_y/_z tags on the vector name. However, recent qfcc completely dumped vector components as separate defs, so old save games would have trouble loading with progs built with a recent qfcc. Thus, do the component translation if necessary.
This commit is contained in:
parent
e42c5a4272
commit
d3c2afc5d7
1 changed files with 23 additions and 0 deletions
|
@ -342,6 +342,7 @@ ED_ConvertToPlist (progs_t *pr, script_t *script)
|
|||
VISIBLE void
|
||||
ED_InitGlobals (progs_t *pr, plitem_t *globals)
|
||||
{
|
||||
ddef_t vector_def;
|
||||
ddef_t *global;
|
||||
plitem_t *keys;
|
||||
int count;
|
||||
|
@ -354,6 +355,28 @@ ED_InitGlobals (progs_t *pr, plitem_t *globals)
|
|||
global_name = PL_String (PL_ObjectAtIndex (keys, count));
|
||||
value = PL_String (PL_ObjectForKey (globals, global_name));
|
||||
global = PR_FindGlobal (pr, global_name);
|
||||
//FIXME should this be here?
|
||||
//This is a hardcoded fix for a design mistake in the original qcc
|
||||
//(saving global vector components rather than the whole vector).
|
||||
if (!global) {
|
||||
int len = strlen (global_name);
|
||||
const char *tag = global_name + len - 2;
|
||||
if (len > 2 && tag[0] == '_' && strchr ("xyz", tag[1])) {
|
||||
char *vector_name = strdup (global_name);
|
||||
vector_name[len - 2] = 0;
|
||||
global = PR_FindGlobal (pr, vector_name);
|
||||
if (global) {
|
||||
if ((global->type & ~DEF_SAVEGLOBAL) == ev_vector) {
|
||||
vector_def = *global;
|
||||
vector_def.ofs += tag[1] - 'x';
|
||||
vector_def.type = ev_float;
|
||||
global = &vector_def;
|
||||
} else {
|
||||
global = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!global) {
|
||||
Sys_Printf ("'%s' is not a global\n", global_name);
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue