mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-13 00:24:12 +00:00
defs.c:
use the right hash table fix_globals.c: clean up the math
This commit is contained in:
parent
e9ed59ec27
commit
d6c2943ae3
2 changed files with 18 additions and 18 deletions
|
@ -70,7 +70,7 @@ Find_Global_Def_offs (int offs)
|
||||||
|
|
||||||
d.offset = offs;
|
d.offset = offs;
|
||||||
strcpy (rep, get_key_offs (&d, 0));
|
strcpy (rep, get_key_offs (&d, 0));
|
||||||
return Hash_Find (global_defs_by_name, rep);
|
return Hash_Find (global_defs_by_offs, rep);
|
||||||
}
|
}
|
||||||
|
|
||||||
def_t *
|
def_t *
|
||||||
|
@ -87,5 +87,5 @@ Find_Field_Def_offs (int offs)
|
||||||
|
|
||||||
d.offset = offs;
|
d.offset = offs;
|
||||||
strcpy (rep, get_key_offs (&d, 0));
|
strcpy (rep, get_key_offs (&d, 0));
|
||||||
return Hash_Find (field_defs_by_name, rep);
|
return Hash_Find (field_defs_by_offs, rep);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ fix_missing_globals (progs_t *pr, def_t *globals)
|
||||||
ddef_t **new_defs, *d, **n;
|
ddef_t **new_defs, *d, **n;
|
||||||
char *new_strings;
|
char *new_strings;
|
||||||
dprograms_t *progs;
|
dprograms_t *progs;
|
||||||
|
int offs;
|
||||||
|
|
||||||
for (def = globals; def->name; def ++) {
|
for (def = globals; def->name; def ++) {
|
||||||
if (!PR_FindGlobal (pr, def->name)) {
|
if (!PR_FindGlobal (pr, def->name)) {
|
||||||
|
@ -69,32 +70,31 @@ fix_missing_globals (progs_t *pr, def_t *globals)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
new_strings = calloc (strings_size, 1);
|
new_strings = calloc (strings_size, 1);
|
||||||
for (i = 0; i < 0; i++) {
|
for (i = 0; i < defs_count; i++) {
|
||||||
def = Find_Global_Def_offs (n[i]->ofs);
|
def = Find_Global_Def_offs (new_defs[i]->ofs);
|
||||||
strcpy (new_strings + n[i]->s_name, def->name);
|
strcpy (new_strings + new_defs[i]->s_name, def->name);
|
||||||
n[i]->s_name += pr->pr_stringsize;
|
new_defs[i]->s_name += pr->pr_stringsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
defs_size = defs_count * sizeof (ddef_t);
|
defs_size = defs_count * sizeof (ddef_t);
|
||||||
progs = malloc (pr->progs_size + strings_size + defs_size);
|
progs = malloc (pr->progs_size + strings_size + defs_size);
|
||||||
memcpy (progs, pr->progs, pr->progs_size);
|
memcpy (progs, pr->progs, pr->progs_size);
|
||||||
|
|
||||||
memmove ((char*)progs + progs->ofs_globaldefs + defs_size,
|
offs = progs->ofs_globaldefs + progs->numglobaldefs * sizeof (ddef_t);
|
||||||
(char*)progs + progs->ofs_globaldefs
|
|
||||||
+ progs->numglobaldefs * sizeof (ddef_t),
|
memmove ((char*)progs + offs + defs_size, (char*)progs + offs,
|
||||||
pr->progs_size - (progs->ofs_globaldefs + progs->numglobaldefs));
|
pr->progs_size - offs);
|
||||||
memcpy ((char*)progs + progs->ofs_globaldefs
|
memcpy ((char*)progs + offs, new_defs, defs_size);
|
||||||
+ progs->numglobaldefs * sizeof (ddef_t),
|
|
||||||
new_defs, defs_size);
|
|
||||||
progs->numglobaldefs += defs_count;
|
progs->numglobaldefs += defs_count;
|
||||||
pr->progs_size += defs_size;
|
pr->progs_size += defs_size;
|
||||||
update_offsets (progs, progs->ofs_globaldefs, defs_size);
|
update_offsets (progs, progs->ofs_globaldefs, defs_size);
|
||||||
|
|
||||||
memmove ((char*)progs + progs->ofs_strings + strings_size,
|
offs = progs->ofs_strings + progs->numstrings;
|
||||||
(char*)progs + progs->ofs_strings + progs->numstrings,
|
memmove ((char*)progs + offs + strings_size, (char*)progs + offs,
|
||||||
pr->progs_size - (progs->ofs_strings + progs->numstrings));
|
pr->progs_size - offs);
|
||||||
memcpy ((char*)progs + progs->ofs_globaldefs + progs->numstrings,
|
memcpy ((char*)progs + offs, new_strings, strings_size);
|
||||||
new_strings, strings_size);
|
|
||||||
progs->numstrings += strings_size;
|
progs->numstrings += strings_size;
|
||||||
pr->progs_size += strings_size;
|
pr->progs_size += strings_size;
|
||||||
update_offsets (progs, progs->ofs_strings, strings_size);
|
update_offsets (progs, progs->ofs_strings, strings_size);
|
||||||
|
|
Loading…
Reference in a new issue