diff --git a/include/QF/pr_comp.h b/include/QF/pr_comp.h index b051ba71a..02ba11011 100644 --- a/include/QF/pr_comp.h +++ b/include/QF/pr_comp.h @@ -42,6 +42,8 @@ typedef enum { ev_type_count // not a type, gives number of types } etype_t; +extern int pr_type_size[ev_type_count]; + #define OFS_NULL 0 #define OFS_RETURN 1 diff --git a/include/QF/progs.h b/include/QF/progs.h index 44109143d..74b388cbd 100644 --- a/include/QF/progs.h +++ b/include/QF/progs.h @@ -139,8 +139,6 @@ int NUM_FOR_BAD_EDICT(progs_t *pr, edict_t *e); #define E_VECTOR(e,o) E_var (e, o, vector) #define E_STRING(p,e,o) (PR_GetString (p, E_var (e, o, string))) -extern int type_size[8]; - typedef void (*builtin_proc) (progs_t *pr); typedef struct { const char *name; diff --git a/libs/gamecode/engine/pr_edict.c b/libs/gamecode/engine/pr_edict.c index 328c40e50..633e3d6d8 100644 --- a/libs/gamecode/engine/pr_edict.c +++ b/libs/gamecode/engine/pr_edict.c @@ -56,15 +56,18 @@ cvar_t *pr_boundscheck; cvar_t *pr_deadbeef_ents; cvar_t *pr_deadbeef_locals; -int type_size[8] = { +int pr_type_size[ev_type_count] = { + 1, 1, - sizeof (string_t) / 4, 1, 3, 1, 1, - sizeof (func_t) / 4, - sizeof (void *) / 4 + 1, + 1, + 4, + 1, + 1, }; const char *type_name[ev_type_count] = { @@ -622,10 +625,10 @@ ED_Write (progs_t * pr, VFile *f, edict_t *ed) // if the value is still all 0, skip the field type = d->type & ~DEF_SAVEGLOBAL; - for (j = 0; j < type_size[type]; j++) + for (j = 0; j < pr_type_size[type]; j++) if (v[j].integer_var) break; - if (j == type_size[type]) + if (j == pr_type_size[type]) continue; Qprintf (f, "\"%s\" ", name); diff --git a/tools/qfcc/include/qfcc.h b/tools/qfcc/include/qfcc.h index b3fbd58c8..c3cea8db7 100644 --- a/tools/qfcc/include/qfcc.h +++ b/tools/qfcc/include/qfcc.h @@ -329,7 +329,6 @@ typedef union eval_s union eval_s *ptr; } eval_t; -extern int type_size[ev_type_count]; extern def_t *def_for_type[8]; extern type_t type_void; diff --git a/tools/qfcc/source/emit.c b/tools/qfcc/source/emit.c index 0a7ba2f85..ef3fd737a 100644 --- a/tools/qfcc/source/emit.c +++ b/tools/qfcc/source/emit.c @@ -171,7 +171,7 @@ emit_assign_expr (expr_t *e) } else { if (def_a->constant) { if (options.code.cow) { - int size = type_size [def_a->type->type]; + int size = pr_type_size [def_a->type->type]; int ofs = PR_NewLocation (def_a->type); memcpy (pr_globals + ofs, pr_globals + def_a->ofs, size); diff --git a/tools/qfcc/source/pr_def.c b/tools/qfcc/source/pr_def.c index 182c6de48..6de0e63df 100644 --- a/tools/qfcc/source/pr_def.c +++ b/tools/qfcc/source/pr_def.c @@ -111,7 +111,7 @@ PR_GetDef (type_t *type, const char *name, def_t *scope, int *allocate) d->used = 1; d->parent = def; } else { - *allocate += type_size[type->type]; + *allocate += pr_type_size[type->type]; } if (type->type == ev_field) { @@ -135,7 +135,7 @@ PR_GetDef (type_t *type, const char *name, def_t *scope, int *allocate) d->used = 1; // always `used' d->parent = def; } else { - pr.size_fields += type_size[type->aux_type->type]; + pr.size_fields += pr_type_size[type->aux_type->type]; } } @@ -173,7 +173,7 @@ PR_NewDef (type_t *type, const char *name, def_t *scope) int PR_NewLocation (type_t *type) { - int size = type_size[type->type]; + int size = pr_type_size[type->type]; locref_t *loc; if (free_locs[size]) { @@ -192,7 +192,7 @@ PR_NewLocation (type_t *type) void PR_FreeLocation (def_t *def) { - int size = type_size[def->type->type]; + int size = pr_type_size[def->type->type]; locref_t *loc; if (!free_free_locs) { @@ -213,7 +213,7 @@ PR_FreeLocation (def_t *def) def_t * PR_GetTempDef (type_t *type, def_t *scope) { - int size = type_size[type->type]; + int size = pr_type_size[type->type]; def_t *def; if (free_temps[size]) { def = free_temps[size]; @@ -222,7 +222,7 @@ PR_GetTempDef (type_t *type, def_t *scope) } else { def = PR_NewDef (type, 0, scope); def->ofs = *scope->alloc; - *scope->alloc += type_size[size]; + *scope->alloc += pr_type_size[size]; } def->users = 0; def->next = temp_scope.next; @@ -244,7 +244,7 @@ PR_FreeTempDefs (void) if (d->users < 0) printf ("%s:%d: warning: %3d %3d\n", strings + d->file, d->line, d->ofs, d->users); - size = type_size[d->type->type]; + size = pr_type_size[d->type->type]; if (d->expr) d->expr->e.temp.def = 0; diff --git a/tools/qfcc/source/pr_imm.c b/tools/qfcc/source/pr_imm.c index 64214f63b..8f78a26d6 100644 --- a/tools/qfcc/source/pr_imm.c +++ b/tools/qfcc/source/pr_imm.c @@ -198,7 +198,7 @@ PR_ReuseConstant (expr_t *expr, def_t *def) if (e.type == ex_string) e.e.integer_val = CopyString (r); - memcpy (pr_globals + cn->ofs, &e.e, 4 * type_size[type->type]); + memcpy (pr_globals + cn->ofs, &e.e, 4 * pr_type_size[type->type]); Hash_Add (tab, cn); diff --git a/tools/qfcc/source/pr_lex.c b/tools/qfcc/source/pr_lex.c index 6667146c0..a7724d692 100644 --- a/tools/qfcc/source/pr_lex.c +++ b/tools/qfcc/source/pr_lex.c @@ -68,8 +68,6 @@ type_t type_integer = { ev_integer, &def_integer }; type_t type_floatfield = { ev_field, &def_field, NULL, &type_float }; -int type_size[ev_type_count] = { 1, 1, 1, 3, 1, 1, 1, 1, 4, 1 }; - def_t def_void = { &type_void, "temp" }; def_t def_string = { &type_string, "temp" }; def_t def_float = { &type_float, "temp" }; diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index a034da6c3..a0107a9a2 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -810,7 +810,7 @@ finish_function (function_t *f) df->locals = f->def->locals; df->parm_start = 0; for (i = 0; i < df->numparms; i++) - df->parm_size[i] = type_size[f->def->type->parm_types[i]->type]; + df->parm_size[i] = pr_type_size[f->def->type->parm_types[i]->type]; if (f->aux) { def_t *def; diff --git a/tools/qfcc/source/qfcc.c b/tools/qfcc/source/qfcc.c index a905f72cf..dde34f54b 100644 --- a/tools/qfcc/source/qfcc.c +++ b/tools/qfcc/source/qfcc.c @@ -920,7 +920,7 @@ PR_PrintFunction (def_t *def) for (d = def->scope_next; d; d = d->scope_next) { printf ("%s: %d %d %d\n", d->name ? d->name : "", - d->ofs, d->type->type, type_size[d->type->type]); + d->ofs, d->type->type, pr_type_size[d->type->type]); for (r = d->refs; r; r = r->next) printf (" %d", r->statement - statements); printf ("\n");