mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-13 00:24:12 +00:00
revert my fs code subversion (2001/07/17 22:10:20 utc commit) as it's no
longer necessary with the new progs loading code
This commit is contained in:
parent
37e2aa8ad5
commit
7a195bb910
2 changed files with 116 additions and 63 deletions
|
@ -391,8 +391,8 @@ open_file (searchpath_t *search, const char *filename, QFile **gzfile,
|
||||||
(int) sizeof (netpath), search->filename,
|
(int) sizeof (netpath), search->filename,
|
||||||
(int) sizeof (netpath), filename);
|
(int) sizeof (netpath), filename);
|
||||||
// check a file in the directory tree
|
// check a file in the directory tree
|
||||||
snprintf (netpath, sizeof (netpath), "%s%s%s", search->filename,
|
snprintf (netpath, sizeof (netpath), "%s/%s", search->filename,
|
||||||
search->filename[0] ? "/" : "", filename);
|
filename);
|
||||||
|
|
||||||
strncpy (foundname, filename, MAX_OSPATH);
|
strncpy (foundname, filename, MAX_OSPATH);
|
||||||
if (Sys_FileTime (netpath) == -1)
|
if (Sys_FileTime (netpath) == -1)
|
||||||
|
@ -785,19 +785,6 @@ COM_Filesystem_Init (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!fs_sharepath->string[0]
|
|
||||||
&& !fs_userpath->string[0]
|
|
||||||
&& !fs_basegame->string[0]) {
|
|
||||||
// a util (or a silly user:) are subverting the fs code
|
|
||||||
// add the directory to the search path
|
|
||||||
searchpath_t *search = calloc (1, sizeof (searchpath_t));
|
|
||||||
strcpy (search->filename, "");
|
|
||||||
search->next = com_searchpaths;
|
|
||||||
com_searchpaths = search;
|
|
||||||
com_base_searchpaths = com_searchpaths;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// start up with basegame->string by default
|
// start up with basegame->string by default
|
||||||
COM_CreateGameDirectory (fs_basegame->string);
|
COM_CreateGameDirectory (fs_basegame->string);
|
||||||
|
|
||||||
|
|
|
@ -40,99 +40,165 @@ static const char rcsid[] =
|
||||||
#include <QF/cmd.h>
|
#include <QF/cmd.h>
|
||||||
#include <QF/cvar.h>
|
#include <QF/cvar.h>
|
||||||
#include "QF/progs.h"
|
#include "QF/progs.h"
|
||||||
#include <QF/quakefs.h>
|
#include <QF/quakeio.h>
|
||||||
#include <QF/sys.h>
|
#include <QF/sys.h>
|
||||||
#include <QF/va.h>
|
#include <QF/va.h>
|
||||||
#include <QF/zone.h>
|
#include <QF/zone.h>
|
||||||
|
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
|
|
||||||
void *membase;
|
static edict_t *edicts;
|
||||||
int memsize = 16*1024*1024;
|
static int num_edicts;
|
||||||
|
static int reserved_edicts = 1;
|
||||||
|
static progs_t pr;
|
||||||
|
static void *membase;
|
||||||
|
static int memsize = 1024*1024;
|
||||||
|
|
||||||
progs_t progs;
|
static QFile *
|
||||||
|
open_file (const char *path, int *len)
|
||||||
|
{
|
||||||
|
QFile *file = Qopen (path, "rbz");
|
||||||
|
if (!file) {
|
||||||
|
perror (path);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*len = Qfilesize (file);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
load_file (progs_t *pr, const char *name)
|
||||||
|
{
|
||||||
|
QFile *file;
|
||||||
|
int size;
|
||||||
|
void *sym;
|
||||||
|
|
||||||
|
file = open_file (name, &size);
|
||||||
|
if (!file) {
|
||||||
|
file = open_file (va ("%s.gz", name), &size);
|
||||||
|
if (!file) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sym = malloc (size);
|
||||||
|
Qread (file, sym, size);
|
||||||
|
return sym;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
allocate_progs_mem (progs_t *pr, int size)
|
||||||
|
{
|
||||||
|
return malloc (size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
free_progs_mem (progs_t *pr, void *mem)
|
||||||
|
{
|
||||||
|
free (mem);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_qf (void)
|
||||||
|
{
|
||||||
|
Cvar_Init_Hash ();
|
||||||
|
Cmd_Init_Hash ();
|
||||||
|
Cvar_Init ();
|
||||||
|
Sys_Init_Cvars ();
|
||||||
|
Cmd_Init ();
|
||||||
|
|
||||||
|
membase = malloc (memsize);
|
||||||
|
Memory_Init (membase, memsize);
|
||||||
|
|
||||||
|
PR_Init_Cvars ();
|
||||||
|
PR_Init ();
|
||||||
|
|
||||||
|
pr.edicts = &edicts;
|
||||||
|
pr.num_edicts = &num_edicts;
|
||||||
|
pr.reserved_edicts = &reserved_edicts;
|
||||||
|
pr.load_file = load_file;
|
||||||
|
pr.allocate_progs_mem = allocate_progs_mem;
|
||||||
|
pr.free_progs_mem = free_progs_mem;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
load_progs (const char *name)
|
||||||
|
{
|
||||||
|
QFile *file;
|
||||||
|
int size;
|
||||||
|
|
||||||
|
file = open_file (name, &size);
|
||||||
|
if (!file) {
|
||||||
|
perror (name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
pr.progs_name = name;
|
||||||
|
PR_LoadProgsFile (&pr, file, size, 1, 0);
|
||||||
|
Qclose (file);
|
||||||
|
PR_LoadStrings (&pr);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
def_t *globals, *fields, *def;
|
def_t *globals, *fields, *def;
|
||||||
|
|
||||||
Cvar_Init_Hash ();
|
|
||||||
Cmd_Init_Hash ();
|
|
||||||
membase = malloc (memsize);
|
|
||||||
Memory_Init (membase, memsize);
|
|
||||||
Cvar_Init ();
|
|
||||||
Cmd_Init ();
|
|
||||||
|
|
||||||
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 ();
|
|
||||||
COM_Filesystem_Init ();
|
|
||||||
PR_Init ();
|
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
fprintf (stderr, "usage: qfdefs <progs> ...\n");
|
fprintf (stderr, "usage: qfdefs <progs> ...\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
init_qf ();
|
||||||
while (--argc) {
|
while (--argc) {
|
||||||
int fix = 0;
|
int fix = 0;
|
||||||
int size;
|
|
||||||
QFile *file;
|
|
||||||
|
|
||||||
progs.progs_name = *++argv;
|
if (!load_progs (*++argv)) {
|
||||||
size = COM_FOpenFile (progs.progs_name, &file);
|
fprintf (stderr, "failed to load %s\n", *argv);
|
||||||
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);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (progs.progs->version < 0x100)
|
|
||||||
printf ("%s: version %d\n", progs.progs_name, progs.progs->version);
|
if (pr.progs->version < 0x100)
|
||||||
|
printf ("%s: version %d\n", pr.progs_name, pr.progs->version);
|
||||||
else
|
else
|
||||||
printf ("%s: version %x.%03x.%03x\n", progs.progs_name,
|
printf ("%s: version %x.%03x.%03x\n", pr.progs_name,
|
||||||
(progs.progs->version >> 24) & 0xff,
|
(pr.progs->version >> 24) & 0xff,
|
||||||
(progs.progs->version >> 12) & 0xfff,
|
(pr.progs->version >> 12) & 0xfff,
|
||||||
progs.progs->version & 0xfff);
|
pr.progs->version & 0xfff);
|
||||||
if (progs.progs->crc == nq_crc) {
|
if (pr.progs->crc == nq_crc) {
|
||||||
printf ("%s: netquake crc\n", progs.progs_name);
|
printf ("%s: netquake crc\n", pr.progs_name);
|
||||||
Init_Defs (nq_global_defs, nq_field_defs);
|
Init_Defs (nq_global_defs, nq_field_defs);
|
||||||
globals = nq_global_defs;
|
globals = nq_global_defs;
|
||||||
fields = nq_field_defs;
|
fields = nq_field_defs;
|
||||||
} else if (progs.progs->crc == qw_crc) {
|
} else if (pr.progs->crc == qw_crc) {
|
||||||
printf ("%s: quakeworld crc\n", progs.progs_name);
|
printf ("%s: quakeworld crc\n", pr.progs_name);
|
||||||
Init_Defs (qw_global_defs, qw_field_defs);
|
Init_Defs (qw_global_defs, qw_field_defs);
|
||||||
globals = qw_global_defs;
|
globals = qw_global_defs;
|
||||||
fields = qw_field_defs;
|
fields = qw_field_defs;
|
||||||
} else {
|
} else {
|
||||||
printf ("%s: unknown crc %d\n", progs.progs_name, progs.progs->crc);
|
printf ("%s: unknown crc %d\n", pr.progs_name, pr.progs->crc);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (def = globals; def->name; def++)
|
for (def = globals; def->name; def++)
|
||||||
if (!PR_FindGlobal (&progs, def->name))
|
if (!PR_FindGlobal (&pr, def->name))
|
||||||
break;
|
break;
|
||||||
if (!def->name)
|
if (!def->name)
|
||||||
printf ("%s: all system globals accounted for\n", progs.progs_name);
|
printf ("%s: all system globals accounted for\n", pr.progs_name);
|
||||||
else {
|
else {
|
||||||
printf ("%s: some system globals missing\n", progs.progs_name);
|
printf ("%s: some system globals missing\n", pr.progs_name);
|
||||||
fix_missing_globals (&progs, globals);
|
fix_missing_globals (&pr, globals);
|
||||||
fix++;
|
fix++;
|
||||||
}
|
}
|
||||||
for (def = fields; def->name; def++)
|
for (def = fields; def->name; def++)
|
||||||
if (!ED_FindField (&progs, def->name))
|
if (!ED_FindField (&pr, def->name))
|
||||||
break;
|
break;
|
||||||
if (!def->name)
|
if (!def->name)
|
||||||
printf ("%s: all system fields accounted for\n", progs.progs_name);
|
printf ("%s: all system fields accounted for\n", pr.progs_name);
|
||||||
else {
|
else {
|
||||||
printf ("%s: some system fields missing\n", progs.progs_name);
|
printf ("%s: some system fields missing\n", pr.progs_name);
|
||||||
}
|
}
|
||||||
if (fix) {
|
if (fix) {
|
||||||
//XXX FIXME endian fixups
|
//XXX FIXME endian fixups
|
||||||
FILE *f = fopen (va ("%s.new", progs.progs_name), "wb");
|
FILE *f = fopen (va ("%s.new", pr.progs_name), "wb");
|
||||||
fwrite (progs.progs, progs.progs_size, 1, f);
|
fwrite (pr.progs, pr.progs_size, 1, f);
|
||||||
fclose (f);
|
fclose (f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue