check for missing defs (and use the new quakefs subversion mechanism)

This commit is contained in:
Bill Currie 2001-07-17 22:15:41 +00:00
parent ffd459c931
commit 36af2c6078
5 changed files with 126 additions and 11 deletions

View file

@ -17,4 +17,10 @@ extern def_t qw_global_defs[];
extern def_t qw_field_defs[];
extern int qw_crc;
void Init_Defs (def_t *gtab, def_t *ftab);
def_t *Find_Global_Def_name (const char *name);
def_t *Find_Global_Def_offs (int offs);
def_t *Find_Field_Def_name (const char *name);
def_t *Find_Field_Def_offs (int offs);
#endif//__def_h

View file

@ -5,7 +5,7 @@ INCLUDES= -I$(top_srcdir)/include
bin_PROGRAMS= qfdefs
noinst_PROGRAMS= gendefs
qfdefs_SOURCES= qfdefs.c defs_nq.c defs_qw.c
qfdefs_SOURCES= defs.c defs_nq.c defs_qw.c qfdefs.c
qfdefs_LDADD= -lQFgamecode -lQFutil
gendefs_SOURCES= gendefs.c

View file

@ -0,0 +1,91 @@
#include <QF/hash.h>
#include "def.h"
static hashtab_t *global_defs_by_name;
static hashtab_t *global_defs_by_offs;
static hashtab_t *field_defs_by_name;
static hashtab_t *field_defs_by_offs;
static const char *
get_key_name (void *d, void *unused)
{
return ((def_t*)d)->name;
}
static const char *
get_key_offs (void *_d, void *unused)
{
def_t *d = (def_t*)_d;
static char rep[4];
rep[0] = (d->offset & 0x7f) + 1;
rep[1] = ((d->offset >> 7) & 0x7f) + 1;
rep[2] = ((d->offset >> 14) & 0x7f) + 1;
return rep;
}
void
Init_Defs (def_t *gtab, def_t *ftab)
{
if (global_defs_by_name)
Hash_FlushTable (global_defs_by_name);
else
global_defs_by_name = Hash_NewTable (1021, get_key_name, 0, 0);
if (global_defs_by_offs)
Hash_FlushTable (global_defs_by_offs);
else
global_defs_by_offs = Hash_NewTable (1021, get_key_offs, 0, 0);
while (gtab->name) {
Hash_Add (global_defs_by_name, gtab);
Hash_Add (global_defs_by_offs, gtab);
gtab++;
}
if (field_defs_by_name)
Hash_FlushTable (field_defs_by_name);
else
field_defs_by_name = Hash_NewTable (1021, get_key_name, 0, 0);
if (field_defs_by_offs)
Hash_FlushTable (field_defs_by_offs);
else
field_defs_by_offs = Hash_NewTable (1021, get_key_offs, 0, 0);
while (ftab->name) {
Hash_Add (field_defs_by_name, ftab);
Hash_Add (field_defs_by_offs, ftab);
ftab++;
}
}
def_t *
Find_Global_Def_name (const char *name)
{
return Hash_Find (global_defs_by_name, name);
}
def_t *
Find_Global_Def_offs (int offs)
{
def_t d;
char rep[4];
d.offset = offs;
strcpy (rep, get_key_offs (&d, 0));
return Hash_Find (global_defs_by_name, rep);
}
def_t *
Find_Field_Def_name (const char *name)
{
return Hash_Find (field_defs_by_name, name);
}
def_t *
Find_Field_Def_offs (int offs)
{
def_t d;
char rep[4];
d.offset = offs;
strcpy (rep, get_key_offs (&d, 0));
return Hash_Find (field_defs_by_name, rep);
}

View file

@ -77,6 +77,7 @@ main (int argc, char **argv)
state++;
case 2:
if (buf[0] == '}') {
fputs ("\t{ev_void,\t0,\t0},\n", out);
fputs ("};\n", out);
state++;
break;
@ -100,6 +101,7 @@ main (int argc, char **argv)
output_def (out, buf);
break;
case 6:
fputs ("\t{ev_void,\t0,\t0},\n", out);
fputs ("};\n", out);
state++;
break;

View file

@ -24,6 +24,8 @@ progs_t progs;
int
main (int argc, char **argv)
{
def_t *globals, *fields, *def;
Cvar_Init_Hash ();
Cmd_Init_Hash ();
membase = malloc (memsize);
@ -32,9 +34,9 @@ main (int argc, char **argv)
Cbuf_Init ();
Cmd_Init ();
Cvar_Get ("fs_basegame", ".", 0, 0, 0);
Cvar_Get ("fs_userpath", "/", 0, 0, 0);
Cvar_Get ("fs_sharepath", "/", 0, 0, 0);
Cvar_Get ("fs_basegame", "", 0, 0, 0);
Cvar_Get ("fs_userpath", "", 0, 0, 0);
Cvar_Get ("fs_sharepath", "", 0, 0, 0);
PR_Init_Cvars ();
COM_Filesystem_Init_Cvars ();
@ -60,18 +62,32 @@ main (int argc, char **argv)
progs.progs->version & 0xfff);
if (progs.progs->crc == nq_crc) {
printf ("%s: netquake crc\n", *argv);
Init_Defs (nq_global_defs, nq_field_defs);
globals = nq_global_defs;
fields = nq_field_defs;
} else if (progs.progs->crc == qw_crc) {
printf ("%s: quakeworld crc\n", *argv);
Init_Defs (qw_global_defs, qw_field_defs);
globals = qw_global_defs;
fields = qw_field_defs;
} else {
printf ("%s: unknown crc %d\n", *argv, progs.progs->crc);
continue;
}
printf ("statements: %d @ %d\n", progs.progs->numstatements, progs.progs->ofs_statements);
printf ("globaldefs: %d @ %d\n", progs.progs->numglobaldefs, progs.progs->ofs_globaldefs);
printf ("fielddefs: %d @ %d\n", progs.progs->numfielddefs, progs.progs->ofs_fielddefs);
printf ("functions: %d @ %d\n", progs.progs->numfunctions, progs.progs->ofs_functions);
printf ("strings: %d @ %d\n", progs.progs->numstrings, progs.progs->ofs_strings);
printf ("globals: %d @ %d\n", progs.progs->numglobals, progs.progs->ofs_globals);
printf ("fields: %d\n", progs.progs->entityfields);
for (def = globals; def->name; def++)
if (!PR_FindGlobal (&progs, def->name))
break;
if (!def->name)
printf ("%s: all system globals accounted for\n", *argv);
else
printf ("%s: some system globals missing\n", *argv);
for (def = fields; def->name; def++)
if (!ED_FindField (&progs, def->name))
break;
if (!def->name)
printf ("%s: all system fields accounted for\n", *argv);
else
printf ("%s: some system fields missing\n", *argv);
}
return 0;
}