mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-25 22:01:33 +00:00
beginnings of a progs re-deffer tool to take care of stupid qc compilers that
strip def names.
This commit is contained in:
parent
bb7cf1b448
commit
c50793b54a
15 changed files with 743 additions and 0 deletions
11
tools/qfdefs/.gitignore
vendored
Normal file
11
tools/qfdefs/.gitignore
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
.vimrc
|
||||
ChangeLog
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
confdefs.h
|
||||
configure
|
||||
config.log
|
||||
config.cache
|
||||
config.status
|
||||
qfdefs.lsm
|
53
tools/qfdefs/Makefile.am
Normal file
53
tools/qfdefs/Makefile.am
Normal file
|
@ -0,0 +1,53 @@
|
|||
# Makefile.am
|
||||
#
|
||||
# Automake-using build system for QuakeForge
|
||||
#
|
||||
# Copyright (C) 2000 Jeff Teunissen <deek@quakeforge.net>
|
||||
#
|
||||
# This Makefile 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
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
AUTOMAKE_OPTIONS= foreign
|
||||
|
||||
SUBDIRS= include source
|
||||
|
||||
# uncomment the following if qfcc requires the math library
|
||||
#qfcc_LDADD=-lm
|
||||
|
||||
EXTRA_DIST=qfcc.lsm.in qfcc.spec.in
|
||||
|
||||
dist-zip: distdir
|
||||
-chmod -R a+r $(distdir)
|
||||
ZIP="-r9q" zip $(distdir).zip $(NOCONV_DIST)
|
||||
ZIP="-r9ql" zip $(distdir).zip $(distdir) -x $(NOCONV_DIST)
|
||||
-rm -rf $(distdir)
|
||||
|
||||
dist-bz2: distdir
|
||||
-chmod -R a+r $(distdir)
|
||||
BZIP2="-9" $(TAR) Ichof $(distdir).tar.bz2 $(distdir)
|
||||
-rm -rf $(distdir)
|
||||
|
||||
dist-all-local: distdir
|
||||
-chmod -R a+r $(distdir)
|
||||
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
|
||||
BZIP2="-9" $(TAR) Ichof $(distdir).tar.bz2 $(distdir)
|
||||
ZIP="-r9q" zip $(distdir).zip $(NOCONV_DIST)
|
||||
ZIP="-r9ql" zip $(distdir).zip $(distdir) -x $(NOCONV_DIST)
|
||||
-rm -rf $(distdir)
|
9
tools/qfdefs/acconfig.h
Normal file
9
tools/qfdefs/acconfig.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
Compiler/Machine-Specific Configuration
|
||||
*/
|
||||
#ifndef __config_h_
|
||||
#define __config_h_
|
||||
@TOP@
|
||||
|
||||
@BOTTOM@
|
||||
#endif // __config_h_
|
2
tools/qfdefs/bootstrap
Executable file
2
tools/qfdefs/bootstrap
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
aclocal && autoheader && automake --add-missing && autoconf
|
102
tools/qfdefs/configure.in
Normal file
102
tools/qfdefs/configure.in
Normal file
|
@ -0,0 +1,102 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.13)
|
||||
AC_INIT(source/qfdefs.c)
|
||||
AC_REVISION($Revision$) dnl
|
||||
AM_CONFIG_HEADER(include/config.h)
|
||||
AC_CANONICAL_SYSTEM
|
||||
|
||||
dnl Every other copy of the package version number gets its value from here
|
||||
AM_INIT_AUTOMAKE(qfdefs, 0.1.0)
|
||||
|
||||
AC_SUBST(VERSION)
|
||||
|
||||
ISODATE=`date +%Y-%m-%d`
|
||||
AC_SUBST(ISODATE)
|
||||
|
||||
AC_LANG_C
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_PROG_YACC
|
||||
AM_PROG_LEX
|
||||
|
||||
dnl We want warnings, lots of warnings...
|
||||
if test "x$GCC" = xyes; then
|
||||
CFLAGS="$CFLAGS -Wall -Werror"
|
||||
# CFLAGS="$CFLAGS -Wall -pedantic"
|
||||
fi
|
||||
|
||||
|
||||
dnl Checks for libraries.
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(sys/types.h sys/wait.h unistd.h)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_ARG_ENABLE(profile,
|
||||
[ --enable-profile compile with profiling (for development)],
|
||||
profile=$enable_profile
|
||||
)
|
||||
if test "x$profile" = xyes; then
|
||||
BUILD_TYPE="$BUILD_TYPE Profile"
|
||||
if test "x$GCC" = xyes; then
|
||||
CFLAGS="`echo $CFLAGS | sed -e 's/-fomit-frame-pointer//g'` -pg"
|
||||
LDFLAGS="$LDFLAGS -pg"
|
||||
else
|
||||
CFLAGS="$CFLAGS -p"
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl Checks for library functions.
|
||||
|
||||
AC_MSG_CHECKING(for timeGetTime in -lwinmm)
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$LIBS -lwinmm"
|
||||
AC_TRY_COMPILE(
|
||||
[#include <windows.h>],
|
||||
[timeGetTime ();],
|
||||
AC_MSG_RESULT(yes),
|
||||
LIBS="$save_LIBS"
|
||||
AC_MSG_RESULT(no)
|
||||
)
|
||||
|
||||
AC_ARG_WITH(qf,
|
||||
[ --with-qf=DIR location of QF libs and headers (prefix)],
|
||||
if test "x$withval" != xyes ; then
|
||||
LIBS="$LIBS -L${withval}/lib"
|
||||
INCLUDES="$INCLUDES -I${withval}/include"
|
||||
fi
|
||||
,
|
||||
HAVE_QF=auto
|
||||
)
|
||||
AC_CHECK_HEADER(QF/qtypes.h, :, HAVE_QF=no)
|
||||
if test "x$HAVE_QF" != xno; then
|
||||
AC_CHECK_LIB(QFutil, Hash_NewTable,
|
||||
:, HAVE_QF=no,
|
||||
[]
|
||||
)
|
||||
fi
|
||||
if test "x$HAVE_QF" != xno; then
|
||||
AC_CHECK_LIB(QFgamecode, PR_Opcode,
|
||||
:, HAVE_QF=no,
|
||||
[-lQFutil]
|
||||
)
|
||||
fi
|
||||
|
||||
if test "x$HAVE_QF" = xno; then
|
||||
echo '***'
|
||||
echo '*** You seem to not have the QuakeForge libs & headers installed'
|
||||
echo '***'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
AC_OUTPUT(
|
||||
include/Makefile
|
||||
source/Makefile
|
||||
Makefile
|
||||
qfdefs.lsm
|
||||
)
|
7
tools/qfdefs/include/.gitignore
vendored
Normal file
7
tools/qfdefs/include/.gitignore
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
.vimrc
|
||||
Makefile.in
|
||||
Makefile
|
||||
config.h.in
|
||||
config.h
|
||||
stamp-h.in
|
||||
stamp-h
|
0
tools/qfdefs/include/Makefile.am
Normal file
0
tools/qfdefs/include/Makefile.am
Normal file
20
tools/qfdefs/include/def.h
Normal file
20
tools/qfdefs/include/def.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef __def_h
|
||||
#define __def_h
|
||||
|
||||
#include <QF/pr_comp.h>
|
||||
|
||||
typedef struct {
|
||||
etype_t type;
|
||||
unsigned short offset;
|
||||
const char *name;
|
||||
} def_t;
|
||||
|
||||
extern def_t nq_global_defs[];
|
||||
extern def_t nq_field_defs[];
|
||||
extern int nq_crc;
|
||||
|
||||
extern def_t qw_global_defs[];
|
||||
extern def_t qw_field_defs[];
|
||||
extern int qw_crc;
|
||||
|
||||
#endif//__def_h
|
143
tools/qfdefs/include/progdefs.nq
Normal file
143
tools/qfdefs/include/progdefs.nq
Normal file
|
@ -0,0 +1,143 @@
|
|||
|
||||
/* file generated by qcc, do not modify */
|
||||
|
||||
typedef struct
|
||||
{ int pad[28];
|
||||
int self;
|
||||
int other;
|
||||
int world;
|
||||
float time;
|
||||
float frametime;
|
||||
float force_retouch;
|
||||
string_t mapname;
|
||||
float deathmatch;
|
||||
float coop;
|
||||
float teamplay;
|
||||
float serverflags;
|
||||
float total_secrets;
|
||||
float total_monsters;
|
||||
float found_secrets;
|
||||
float killed_monsters;
|
||||
float parm1;
|
||||
float parm2;
|
||||
float parm3;
|
||||
float parm4;
|
||||
float parm5;
|
||||
float parm6;
|
||||
float parm7;
|
||||
float parm8;
|
||||
float parm9;
|
||||
float parm10;
|
||||
float parm11;
|
||||
float parm12;
|
||||
float parm13;
|
||||
float parm14;
|
||||
float parm15;
|
||||
float parm16;
|
||||
vec3_t v_forward;
|
||||
vec3_t v_up;
|
||||
vec3_t v_right;
|
||||
float trace_allsolid;
|
||||
float trace_startsolid;
|
||||
float trace_fraction;
|
||||
vec3_t trace_endpos;
|
||||
vec3_t trace_plane_normal;
|
||||
float trace_plane_dist;
|
||||
int trace_ent;
|
||||
float trace_inopen;
|
||||
float trace_inwater;
|
||||
int msg_entity;
|
||||
func_t main;
|
||||
func_t StartFrame;
|
||||
func_t PlayerPreThink;
|
||||
func_t PlayerPostThink;
|
||||
func_t ClientKill;
|
||||
func_t ClientConnect;
|
||||
func_t PutClientInServer;
|
||||
func_t ClientDisconnect;
|
||||
func_t SetNewParms;
|
||||
func_t SetChangeParms;
|
||||
} globalvars_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float modelindex;
|
||||
vec3_t absmin;
|
||||
vec3_t absmax;
|
||||
float ltime;
|
||||
float movetype;
|
||||
float solid;
|
||||
vec3_t origin;
|
||||
vec3_t oldorigin;
|
||||
vec3_t velocity;
|
||||
vec3_t angles;
|
||||
vec3_t avelocity;
|
||||
vec3_t punchangle;
|
||||
string_t classname;
|
||||
string_t model;
|
||||
float frame;
|
||||
float skin;
|
||||
float effects;
|
||||
vec3_t mins;
|
||||
vec3_t maxs;
|
||||
vec3_t size;
|
||||
func_t touch;
|
||||
func_t use;
|
||||
func_t think;
|
||||
func_t blocked;
|
||||
float nextthink;
|
||||
int groundentity;
|
||||
float health;
|
||||
float frags;
|
||||
float weapon;
|
||||
string_t weaponmodel;
|
||||
float weaponframe;
|
||||
float currentammo;
|
||||
float ammo_shells;
|
||||
float ammo_nails;
|
||||
float ammo_rockets;
|
||||
float ammo_cells;
|
||||
float items;
|
||||
float takedamage;
|
||||
int chain;
|
||||
float deadflag;
|
||||
vec3_t view_ofs;
|
||||
float button0;
|
||||
float button1;
|
||||
float button2;
|
||||
float impulse;
|
||||
float fixangle;
|
||||
vec3_t v_angle;
|
||||
float idealpitch;
|
||||
string_t netname;
|
||||
int enemy;
|
||||
float flags;
|
||||
float colormap;
|
||||
float team;
|
||||
float max_health;
|
||||
float teleport_time;
|
||||
float armortype;
|
||||
float armorvalue;
|
||||
float waterlevel;
|
||||
float watertype;
|
||||
float ideal_yaw;
|
||||
float yaw_speed;
|
||||
int aiment;
|
||||
int goalentity;
|
||||
float spawnflags;
|
||||
string_t target;
|
||||
string_t targetname;
|
||||
float dmg_take;
|
||||
float dmg_save;
|
||||
int dmg_inflictor;
|
||||
int owner;
|
||||
vec3_t movedir;
|
||||
string_t message;
|
||||
float sounds;
|
||||
string_t noise;
|
||||
string_t noise1;
|
||||
string_t noise2;
|
||||
string_t noise3;
|
||||
} entvars_t;
|
||||
|
||||
#define PROGHEADER_CRC 5927
|
167
tools/qfdefs/include/progdefs.qw
Normal file
167
tools/qfdefs/include/progdefs.qw
Normal file
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
progdefs.h
|
||||
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
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
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
/* file generated by qcc, do not modify */
|
||||
|
||||
typedef struct
|
||||
{ int pad[28];
|
||||
int self;
|
||||
int other;
|
||||
int world;
|
||||
float time;
|
||||
float frametime;
|
||||
int newmis;
|
||||
float force_retouch;
|
||||
string_t mapname;
|
||||
float serverflags;
|
||||
float total_secrets;
|
||||
float total_monsters;
|
||||
float found_secrets;
|
||||
float killed_monsters;
|
||||
float parm1;
|
||||
float parm2;
|
||||
float parm3;
|
||||
float parm4;
|
||||
float parm5;
|
||||
float parm6;
|
||||
float parm7;
|
||||
float parm8;
|
||||
float parm9;
|
||||
float parm10;
|
||||
float parm11;
|
||||
float parm12;
|
||||
float parm13;
|
||||
float parm14;
|
||||
float parm15;
|
||||
float parm16;
|
||||
vec3_t v_forward;
|
||||
vec3_t v_up;
|
||||
vec3_t v_right;
|
||||
float trace_allsolid;
|
||||
float trace_startsolid;
|
||||
float trace_fraction;
|
||||
vec3_t trace_endpos;
|
||||
vec3_t trace_plane_normal;
|
||||
float trace_plane_dist;
|
||||
int trace_ent;
|
||||
float trace_inopen;
|
||||
float trace_inwater;
|
||||
int msg_entity;
|
||||
func_t main;
|
||||
func_t StartFrame;
|
||||
func_t PlayerPreThink;
|
||||
func_t PlayerPostThink;
|
||||
func_t ClientKill;
|
||||
func_t ClientConnect;
|
||||
func_t PutClientInServer;
|
||||
func_t ClientDisconnect;
|
||||
func_t SetNewParms;
|
||||
func_t SetChangeParms;
|
||||
} globalvars_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float modelindex;
|
||||
vec3_t absmin;
|
||||
vec3_t absmax;
|
||||
float ltime;
|
||||
float lastruntime;
|
||||
float movetype;
|
||||
float solid;
|
||||
vec3_t origin;
|
||||
vec3_t oldorigin;
|
||||
vec3_t velocity;
|
||||
vec3_t angles;
|
||||
vec3_t avelocity;
|
||||
string_t classname;
|
||||
string_t model;
|
||||
float frame;
|
||||
float skin;
|
||||
float effects;
|
||||
vec3_t mins;
|
||||
vec3_t maxs;
|
||||
vec3_t size;
|
||||
func_t touch;
|
||||
func_t use;
|
||||
func_t think;
|
||||
func_t blocked;
|
||||
float nextthink;
|
||||
int groundentity;
|
||||
float health;
|
||||
float frags;
|
||||
float weapon;
|
||||
string_t weaponmodel;
|
||||
float weaponframe;
|
||||
float currentammo;
|
||||
float ammo_shells;
|
||||
float ammo_nails;
|
||||
float ammo_rockets;
|
||||
float ammo_cells;
|
||||
float items;
|
||||
float takedamage;
|
||||
int chain;
|
||||
float deadflag;
|
||||
vec3_t view_ofs;
|
||||
float button0;
|
||||
float button1;
|
||||
float button2;
|
||||
float impulse;
|
||||
float fixangle;
|
||||
vec3_t v_angle;
|
||||
string_t netname;
|
||||
int enemy;
|
||||
float flags;
|
||||
float colormap;
|
||||
float team;
|
||||
float max_health;
|
||||
float teleport_time;
|
||||
float armortype;
|
||||
float armorvalue;
|
||||
float waterlevel;
|
||||
float watertype;
|
||||
float ideal_yaw;
|
||||
float yaw_speed;
|
||||
int aiment;
|
||||
int goalentity;
|
||||
float spawnflags;
|
||||
string_t target;
|
||||
string_t targetname;
|
||||
float dmg_take;
|
||||
float dmg_save;
|
||||
int dmg_inflictor;
|
||||
int owner;
|
||||
vec3_t movedir;
|
||||
string_t message;
|
||||
float sounds;
|
||||
string_t noise;
|
||||
string_t noise1;
|
||||
string_t noise2;
|
||||
string_t noise3;
|
||||
} entvars_t;
|
||||
|
||||
#define PROGHEADER_CRC 54730
|
19
tools/qfdefs/qfdefs.lsm.in
Normal file
19
tools/qfdefs/qfdefs.lsm.in
Normal file
|
@ -0,0 +1,19 @@
|
|||
Begin3
|
||||
Title: qfcc
|
||||
Version: @VERSION@
|
||||
Entered-date: @ISODATE@
|
||||
Description: The QuakeForge Code Compiler
|
||||
@configure_input@
|
||||
qfcc is a compiler for the GameC (formerly QuakeC) language.
|
||||
It is intended to replace the original QuakeC compiler.
|
||||
Keywords: Quake, QuakeC, QuakeForge, GameC, compiler
|
||||
Author: quake-devel@lists.sourceforge.net (The QuakeForge Project)
|
||||
Maintained-by: quake-devel@lists.sourceforge.net (The QuakeForge Project)
|
||||
Primary-site: http://www.quakeforge.net/
|
||||
31k qfcc-@VERSION@.tar.gz
|
||||
500 qfcc.lsm
|
||||
Alternate-site:
|
||||
Original-site:
|
||||
Platforms:
|
||||
Copying-policy: GNU copyleft
|
||||
End
|
8
tools/qfdefs/source/.gitignore
vendored
Normal file
8
tools/qfdefs/source/.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
.vimrc
|
||||
Makefile.in
|
||||
Makefile
|
||||
.deps
|
||||
gendefs
|
||||
defs_nq.c
|
||||
defs_qw.c
|
||||
qfdefs
|
19
tools/qfdefs/source/Makefile.am
Normal file
19
tools/qfdefs/source/Makefile.am
Normal file
|
@ -0,0 +1,19 @@
|
|||
AUTOMAKE_OPTIONS= foreign
|
||||
|
||||
INCLUDES= -I$(top_srcdir)/include
|
||||
|
||||
bin_PROGRAMS= qfdefs
|
||||
noinst_PROGRAMS= gendefs
|
||||
|
||||
qfdefs_SOURCES= qfdefs.c defs_nq.c defs_qw.c
|
||||
qfdefs_LDADD= -lQFgamecode -lQFutil
|
||||
|
||||
gendefs_SOURCES= gendefs.c
|
||||
|
||||
defs_nq.c: $(top_srcdir)/include/progdefs.nq gendefs
|
||||
./gendefs nq $(top_srcdir)/include/progdefs.nq defs_nq.c
|
||||
|
||||
defs_qw.c: $(top_srcdir)/include/progdefs.qw gendefs
|
||||
./gendefs qw $(top_srcdir)/include/progdefs.qw defs_qw.c
|
||||
|
||||
CLEANFILES= defs_nq.c defs_qw.c
|
116
tools/qfdefs/source/gendefs.c
Normal file
116
tools/qfdefs/source/gendefs.c
Normal file
|
@ -0,0 +1,116 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
int offset;
|
||||
|
||||
void
|
||||
output_def (FILE *out, const char *line)
|
||||
{
|
||||
const char *type, *type_e;
|
||||
const char *name, *name_e;
|
||||
|
||||
for (type = line; *type && isspace (*type); type++)
|
||||
;
|
||||
for (type_e = type; *type_e && !isspace (*type_e); type_e++)
|
||||
;
|
||||
for (name = type_e; *name && isspace (*name); name++)
|
||||
;
|
||||
for (name_e = name; *name_e && !isspace (*name_e) && *name_e != ';'; name_e++)
|
||||
;
|
||||
if (strncmp ("int", type, type_e - type) == 0) {
|
||||
fprintf (out, "\t{ev_entity,\t%d,\t\"%.*s\"},\n",
|
||||
offset, name_e - name, name);
|
||||
offset += 1;
|
||||
} else if (strncmp ("float", type, type_e - type) == 0) {
|
||||
fprintf (out, "\t{ev_float,\t%d,\t\"%.*s\"},\n",
|
||||
offset, name_e - name, name);
|
||||
offset += 1;
|
||||
} else if (strncmp ("string_t", type, type_e - type) == 0) {
|
||||
fprintf (out, "\t{ev_string,\t%d,\t\"%.*s\"},\n",
|
||||
offset, name_e - name, name);
|
||||
offset += 1;
|
||||
} else if (strncmp ("vec3_t", type, type_e - type) == 0) {
|
||||
fprintf (out, "\t{ev_vector,\t%d,\t\"%.*s\"},\n",
|
||||
offset, name_e - name, name);
|
||||
offset += 3;
|
||||
} else if (strncmp ("func_t", type, type_e - type) == 0) {
|
||||
fprintf (out, "\t{ev_func,\t%d,\t\"%.*s\"},\n",
|
||||
offset, name_e - name, name);
|
||||
offset += 1;
|
||||
} else {
|
||||
fprintf (stderr, "unknown type %.*s\n", type_e - type, type);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
FILE *in, *out;
|
||||
char buf[256];
|
||||
int state = 0;
|
||||
|
||||
if (argc != 4) {
|
||||
fprintf (stderr, "usage: gendefs prefix infile outfile\n");
|
||||
return 1;
|
||||
}
|
||||
if (!(in = fopen (argv[2], "rt"))) {
|
||||
perror (argv[2]);
|
||||
return 1;
|
||||
}
|
||||
if (!(out = fopen (argv[3], "wt"))) {
|
||||
perror (argv[3]);
|
||||
return 1;
|
||||
}
|
||||
fputs ("#include \"def.h\"\n\n", out);
|
||||
while (fgets (buf, sizeof (buf), in)) {
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (buf[0] == '{')
|
||||
state++;
|
||||
break;
|
||||
case 1:
|
||||
fprintf (out, "def_t %s_global_defs[] = {\n", argv[1]);
|
||||
offset = 28;
|
||||
state++;
|
||||
case 2:
|
||||
if (buf[0] == '}') {
|
||||
fputs ("};\n", out);
|
||||
state++;
|
||||
break;
|
||||
}
|
||||
output_def (out, buf);
|
||||
break;
|
||||
case 3:
|
||||
if (buf[0] == '{')
|
||||
state++;
|
||||
break;
|
||||
case 4:
|
||||
fputs ("\n", out);
|
||||
fprintf (out, "def_t %s_field_defs[] = {\n", argv[1]);
|
||||
offset = 0;
|
||||
state++;
|
||||
case 5:
|
||||
if (buf[0] == '}') {
|
||||
state++;
|
||||
break;
|
||||
}
|
||||
output_def (out, buf);
|
||||
break;
|
||||
case 6:
|
||||
fputs ("};\n", out);
|
||||
state++;
|
||||
break;
|
||||
case 7:
|
||||
if (strncmp ("#define", buf, 7) == 0) {
|
||||
int crc;
|
||||
sscanf (buf, "#define PROGHEADER_CRC %d", &crc);
|
||||
fprintf (out, "\nint %s_crc = %d;\n", argv[1], crc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
67
tools/qfdefs/source/qfdefs.c
Normal file
67
tools/qfdefs/source/qfdefs.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
#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>
|
||||
#include <QF/zone.h>
|
||||
|
||||
void *membase;
|
||||
int memsize = 16*1024*1024;
|
||||
|
||||
extern char *type_name[];
|
||||
|
||||
progs_t progs;
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
Cvar_Init_Hash ();
|
||||
Cmd_Init_Hash ();
|
||||
membase = malloc (memsize);
|
||||
Memory_Init (membase, memsize);
|
||||
Cvar_Init ();
|
||||
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);
|
||||
|
||||
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) {
|
||||
PR_LoadProgsFile (&progs, *++argv);
|
||||
if (!progs.progs) {
|
||||
fprintf (stderr, "failed to load %s\n", *argv);
|
||||
return 1;
|
||||
}
|
||||
if (progs.progs->version < 0x100)
|
||||
printf ("%s: version %d\n", *argv, progs.progs->version);
|
||||
else
|
||||
printf ("%s: version %x.%03x.%03x\n", *argv,
|
||||
(progs.progs->version >> 24) & 0xff,
|
||||
(progs.progs->version >> 12) & 0xfff,
|
||||
progs.progs->version & 0xfff);
|
||||
for (i = 0; i < progs.progs->numglobaldefs; i++) {
|
||||
ddef_t *def = &progs.pr_globaldefs[i];
|
||||
printf ("%-8s %d %-5d %s\n", type_name[def->type & ~DEF_SAVEGLOBAL], (def->type & DEF_SAVEGLOBAL) != 0, def->ofs, PR_GetString (&progs, def->s_name));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue