2001-09-28 07:09:38 +00:00
|
|
|
/*
|
|
|
|
#FILENAME#
|
|
|
|
|
|
|
|
#DESCRIPTION#
|
|
|
|
|
|
|
|
Copyright (C) 2001 #AUTHOR#
|
|
|
|
|
|
|
|
Author: #AUTHOR#
|
|
|
|
Date: #DATE#
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
static const char rcsid[] =
|
|
|
|
"$Id$";
|
|
|
|
|
2001-07-17 20:05:57 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <QF/cmd.h>
|
|
|
|
#include <QF/cvar.h>
|
|
|
|
#include "QF/progs.h"
|
|
|
|
#include <QF/vfs.h>
|
|
|
|
#include <QF/sys.h>
|
2001-07-18 00:26:14 +00:00
|
|
|
#include <QF/va.h>
|
2001-07-17 20:05:57 +00:00
|
|
|
#include <QF/zone.h>
|
|
|
|
|
2001-07-17 20:33:17 +00:00
|
|
|
#include "def.h"
|
|
|
|
|
2001-07-17 20:05:57 +00:00
|
|
|
void *membase;
|
|
|
|
int memsize = 16*1024*1024;
|
|
|
|
|
|
|
|
progs_t progs;
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
2001-07-17 22:15:41 +00:00
|
|
|
def_t *globals, *fields, *def;
|
|
|
|
|
2001-07-17 20:05:57 +00:00
|
|
|
Cvar_Init_Hash ();
|
|
|
|
Cmd_Init_Hash ();
|
|
|
|
membase = malloc (memsize);
|
|
|
|
Memory_Init (membase, memsize);
|
|
|
|
Cvar_Init ();
|
|
|
|
Cmd_Init ();
|
|
|
|
|
2001-07-17 22:15:41 +00:00
|
|
|
Cvar_Get ("fs_basegame", "", 0, 0, 0);
|
|
|
|
Cvar_Get ("fs_userpath", "", 0, 0, 0);
|
|
|
|
Cvar_Get ("fs_sharepath", "", 0, 0, 0);
|
2001-07-17 20:05:57 +00:00
|
|
|
|
|
|
|
PR_Init_Cvars ();
|
|
|
|
COM_Filesystem_Init_Cvars ();
|
|
|
|
COM_Filesystem_Init ();
|
|
|
|
PR_Init ();
|
|
|
|
|
|
|
|
if (argc < 2) {
|
|
|
|
fprintf (stderr, "usage: qfdefs <progs> ...\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
while (--argc) {
|
2001-07-18 00:26:14 +00:00
|
|
|
int fix = 0;
|
2002-01-30 17:20:10 +00:00
|
|
|
int size;
|
|
|
|
VFile *file;
|
|
|
|
|
|
|
|
progs.progs_name = *++argv;
|
|
|
|
size = COM_FOpenFile (progs.progs_name, &file);
|
|
|
|
if (size != -1)
|
|
|
|
PR_LoadProgsFile (&progs, file, size, 0, 0);
|
|
|
|
if (size == -1 || !progs.progs) {
|
|
|
|
fprintf (stderr, "failed to load %s\n", progs.progs_name);
|
2001-07-17 20:05:57 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (progs.progs->version < 0x100)
|
2002-01-30 17:20:10 +00:00
|
|
|
printf ("%s: version %d\n", progs.progs_name, progs.progs->version);
|
2001-07-17 20:05:57 +00:00
|
|
|
else
|
2002-01-30 17:20:10 +00:00
|
|
|
printf ("%s: version %x.%03x.%03x\n", progs.progs_name,
|
2001-07-17 20:05:57 +00:00
|
|
|
(progs.progs->version >> 24) & 0xff,
|
|
|
|
(progs.progs->version >> 12) & 0xfff,
|
|
|
|
progs.progs->version & 0xfff);
|
2001-07-17 20:33:17 +00:00
|
|
|
if (progs.progs->crc == nq_crc) {
|
2002-01-30 17:20:10 +00:00
|
|
|
printf ("%s: netquake crc\n", progs.progs_name);
|
2001-07-17 22:15:41 +00:00
|
|
|
Init_Defs (nq_global_defs, nq_field_defs);
|
|
|
|
globals = nq_global_defs;
|
|
|
|
fields = nq_field_defs;
|
2001-07-17 20:33:17 +00:00
|
|
|
} else if (progs.progs->crc == qw_crc) {
|
2002-01-30 17:20:10 +00:00
|
|
|
printf ("%s: quakeworld crc\n", progs.progs_name);
|
2001-07-17 22:15:41 +00:00
|
|
|
Init_Defs (qw_global_defs, qw_field_defs);
|
|
|
|
globals = qw_global_defs;
|
|
|
|
fields = qw_field_defs;
|
2001-07-17 20:33:17 +00:00
|
|
|
} else {
|
2002-01-30 17:20:10 +00:00
|
|
|
printf ("%s: unknown crc %d\n", progs.progs_name, progs.progs->crc);
|
2001-07-17 22:15:41 +00:00
|
|
|
continue;
|
2001-07-17 20:05:57 +00:00
|
|
|
}
|
2001-07-17 22:15:41 +00:00
|
|
|
for (def = globals; def->name; def++)
|
|
|
|
if (!PR_FindGlobal (&progs, def->name))
|
|
|
|
break;
|
|
|
|
if (!def->name)
|
2002-01-30 17:20:10 +00:00
|
|
|
printf ("%s: all system globals accounted for\n", progs.progs_name);
|
2001-07-18 00:26:14 +00:00
|
|
|
else {
|
2002-01-30 17:20:10 +00:00
|
|
|
printf ("%s: some system globals missing\n", progs.progs_name);
|
2001-07-18 00:26:14 +00:00
|
|
|
fix_missing_globals (&progs, globals);
|
|
|
|
fix++;
|
|
|
|
}
|
2001-07-17 22:15:41 +00:00
|
|
|
for (def = fields; def->name; def++)
|
|
|
|
if (!ED_FindField (&progs, def->name))
|
|
|
|
break;
|
|
|
|
if (!def->name)
|
2002-01-30 17:20:10 +00:00
|
|
|
printf ("%s: all system fields accounted for\n", progs.progs_name);
|
2001-07-18 00:26:14 +00:00
|
|
|
else {
|
2002-01-30 17:20:10 +00:00
|
|
|
printf ("%s: some system fields missing\n", progs.progs_name);
|
2001-07-18 00:26:14 +00:00
|
|
|
}
|
|
|
|
if (fix) {
|
|
|
|
//XXX FIXME endian fixups
|
2002-01-30 17:20:10 +00:00
|
|
|
FILE *f = fopen (va ("%s.new", progs.progs_name), "wb");
|
2001-07-18 00:26:14 +00:00
|
|
|
fwrite (progs.progs, progs.progs_size, 1, f);
|
|
|
|
fclose (f);
|
|
|
|
}
|
2001-07-17 20:05:57 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|