From cb5c262ffc00e8eb402359237e6689ff9086f2ca Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 28 Mar 2001 17:17:56 +0000 Subject: [PATCH] qtypes.h: remove includes of qdefs.h and compat.h pr_comp.h: merge pr_comp.h from quake and qfcc, removing the copy in qfcc cmdlib.[ch]: nuke the endian code. qendian.c: initialise the LittleLong etc pointers at compile time rather than run time com.c (both nq and qw): nuke the LittleLong etc init code everything else: fix up after the qtypes.h cleanup --- include/QF/pr_comp.h | 52 +++++----- include/QF/qtypes.h | 9 +- libs/gamecode/pr_edict.c | 1 + libs/util/cmd.c | 1 + libs/util/cvar.c | 1 + libs/util/info.c | 1 + libs/util/qendian.c | 25 +++-- nq/source/com.c | 19 ---- nq/source/in_sdl.c | 1 + nq/source/in_svgalib.c | 1 + nq/source/in_x11.c | 1 + nq/source/joy_linux.c | 1 + nq/source/quakefs.c | 1 + nq/source/snd_mix.c | 1 + nq/source/sv_progs.c | 3 +- qw/include/net.h | 3 +- qw/source/cd_linux.c | 1 + qw/source/cl_ents.c | 1 + qw/source/cl_main.c | 1 + qw/source/cl_parse.c | 1 + qw/source/cl_slist.c | 1 + qw/source/com.c | 19 ---- qw/source/d_init.c | 1 + qw/source/gl_dyn_part.c | 1 + qw/source/gl_rmain.c | 1 + qw/source/gl_rsurf.c | 1 + qw/source/gl_screen.c | 1 + qw/source/gl_skin.c | 1 + qw/source/gl_textures.c | 1 + qw/source/gl_view.c | 1 + qw/source/in_sdl.c | 1 + qw/source/in_svgalib.c | 1 + qw/source/in_x11.c | 1 + qw/source/joy_linux.c | 1 + qw/source/pmovetst.c | 1 + qw/source/quakefs.c | 1 + qw/source/r_misc.c | 1 + qw/source/r_part.c | 1 + qw/source/r_view.c | 1 + qw/source/sbar.c | 1 + qw/source/screen.c | 1 + qw/source/skin.c | 1 + qw/source/snd_mix.c | 1 + qw/source/sv_ccmds.c | 1 + qw/source/sv_ents.c | 1 + qw/source/sv_main.c | 1 + qw/source/sv_progs.c | 1 + qw/source/sv_user.c | 1 + qw/source/sw_skin.c | 1 + qw/source/sw_view.c | 1 + qw/source/sys_unix.c | 1 + qw/source/vid_glx.c | 1 + qw/source/vid_sdl.c | 1 + qw/source/vid_sgl.c | 1 + qw/source/vid_svgalib.c | 1 + qw/source/vid_x11.c | 1 + tools/qfcc/configure.in | 25 +++-- tools/qfcc/include/cmdlib.h | 17 ++-- tools/qfcc/include/pr_comp.h | 179 ---------------------------------- tools/qfcc/include/qfcc.h | 2 +- tools/qfcc/source/Makefile.am | 6 +- tools/qfcc/source/cmdlib.c | 137 -------------------------- tools/qfcc/source/pr_comp.c | 8 +- tools/qfcc/source/pr_lex.c | 4 +- tools/qfcc/source/qfcc.c | 25 ++--- 65 files changed, 151 insertions(+), 431 deletions(-) delete mode 100644 tools/qfcc/include/pr_comp.h diff --git a/include/QF/pr_comp.h b/include/QF/pr_comp.h index 58b49e995..f4d8c077b 100644 --- a/include/QF/pr_comp.h +++ b/include/QF/pr_comp.h @@ -1,38 +1,31 @@ -/* - pr_comp.h +/* Copyright (C) 1996-1997 Id Software, Inc. - (description) + 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. - Copyright (C) 1996-1997 Id Software, Inc. + 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. - 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. + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - 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$ + See file, 'COPYING', for details. */ -// this file is shared by quake and qcc - -#ifndef _PR_COMP_H -#define _PR_COMP_H +// this file is shared by QuakeForge and qfcc +#ifndef __pr_comp_h +#define __pr_comp_h #include "QF/qtypes.h" +typedef int func_t; +typedef int string_t; + typedef enum { ev_void, ev_string, @@ -44,6 +37,7 @@ typedef enum { ev_pointer } etype_t; + #define OFS_NULL 0 #define OFS_RETURN 1 #define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors @@ -56,6 +50,7 @@ typedef enum { #define OFS_PARM7 25 #define RESERVED_OFS 28 + enum { OP_DONE, OP_MUL_F, @@ -134,6 +129,7 @@ enum { OP_BITOR }; + typedef struct statement_s { unsigned short op; @@ -167,8 +163,8 @@ typedef struct byte parm_size[MAX_PARMS]; } dfunction_t; -#define PROG_VERSION 6 +#define PROG_VERSION 6 typedef struct { int version; @@ -195,4 +191,4 @@ typedef struct int entityfields; } dprograms_t; -#endif // _PR_COMP_H +#endif // __pr_comp_h diff --git a/include/QF/qtypes.h b/include/QF/qtypes.h index 9e1793bde..1688f1011 100644 --- a/include/QF/qtypes.h +++ b/include/QF/qtypes.h @@ -34,8 +34,8 @@ #include #include -#include "QF/qdefs.h" -#include "QF/compat.h" +//#include "QF/qdefs.h" +//#include "QF/compat.h" #define MAX_QPATH 64 @@ -44,10 +44,13 @@ typedef unsigned char byte; #endif +#ifndef _DEF_BOOL_ +# define _DEF_BOOL_ // KJB Undefined true and false defined in SciTech's DEBUG.H header #undef true #undef false typedef enum {false, true} qboolean; +#endif // From mathlib... typedef float vec_t; @@ -58,8 +61,6 @@ typedef int fixed8_t; typedef int fixed16_t; -typedef int func_t; -typedef int string_t; typedef byte pixel_t; #endif // __qtypes_h diff --git a/libs/gamecode/pr_edict.c b/libs/gamecode/pr_edict.c index 3a3ee385e..251432d28 100644 --- a/libs/gamecode/pr_edict.c +++ b/libs/gamecode/pr_edict.c @@ -35,6 +35,7 @@ #ifdef HAVE_STRINGS_H # include #endif +#include #include "QF/cmd.h" #include "QF/console.h" diff --git a/libs/util/cmd.c b/libs/util/cmd.c index 9a1f09e56..d1d5aba26 100644 --- a/libs/util/cmd.c +++ b/libs/util/cmd.c @@ -40,6 +40,7 @@ #include "QF/cvar.h" #include "QF/cmd.h" +#include "QF/compat.h" #include "QF/console.h" #include "QF/hash.h" #include "QF/qargs.h" diff --git a/libs/util/cvar.c b/libs/util/cvar.c index b3b820d2e..9256463c1 100644 --- a/libs/util/cvar.c +++ b/libs/util/cvar.c @@ -42,6 +42,7 @@ #include #include +#include "QF/compat.h" #include "QF/console.h" #include "QF/cmd.h" #include "QF/cvar.h" diff --git a/libs/util/info.c b/libs/util/info.c index 9d3b3b4f1..7ae0905b1 100644 --- a/libs/util/info.c +++ b/libs/util/info.c @@ -39,6 +39,7 @@ #include #include +#include "QF/compat.h" #include "QF/console.h" #include "QF/info.h" diff --git a/libs/util/qendian.c b/libs/util/qendian.c index f942bb579..8171ef0a9 100644 --- a/libs/util/qendian.c +++ b/libs/util/qendian.c @@ -34,19 +34,30 @@ #include +#include "QF/qendian.h" #include "QF/qtypes.h" /* BYTE ORDER FUNCTIONS */ -qboolean bigendien; -short (*BigShort) (short l); -short (*LittleShort) (short l); -int (*BigLong) (int l); -int (*LittleLong) (int l); -float (*BigFloat) (float l); -float (*LittleFloat) (float l); +#ifndef WORDS_BIGENDIAN +qboolean bigendien = false;; +short (*BigShort) (short l) = ShortSwap; +short (*LittleShort) (short l) = ShortNoSwap; +int (*BigLong) (int l) = LongSwap; +int (*LittleLong) (int l) = LongNoSwap; +float (*BigFloat) (float l) = FloatSwap; +float (*LittleFloat) (float l) = FloatNoSwap; +#else +qboolean bigendien = true;; +short (*BigShort) (short l) = ShortNoSwap; +short (*LittleShort) (short l) = ShortSwap; +int (*BigLong) (int l) = LongNoSwap; +int (*LittleLong) (int l) = LongSwap; +float (*BigFloat) (float l) = FloatNoSwap; +float (*LittleFloat) (float l) = FloatSwap; +#endif short ShortSwap (short l) diff --git a/nq/source/com.c b/nq/source/com.c index be3d1250f..64fba2380 100644 --- a/nq/source/com.c +++ b/nq/source/com.c @@ -30,7 +30,6 @@ # include "config.h" #endif -#include "QF/qendian.h" #include "QF/cvar.h" #include "QF/quakefs.h" #include "QF/console.h" @@ -81,24 +80,6 @@ COM_Init void COM_Init () { -#ifndef WORDS_BIGENDIAN - bigendien = false; - BigShort = ShortSwap; - LittleShort = ShortNoSwap; - BigLong = LongSwap; - LittleLong = LongNoSwap; - BigFloat = FloatSwap; - LittleFloat = FloatNoSwap; -#else - bigendien = true; - BigShort = ShortNoSwap; - LittleShort = ShortSwap; - BigLong = LongNoSwap; - LittleLong = LongSwap; - BigFloat = FloatNoSwap; - LittleFloat = FloatSwap; -#endif - registered = Cvar_Get ("registered", "0", CVAR_NONE, "None"); cmdline = Cvar_Get ("cmdline", "0", CVAR_SERVERINFO, "None"); Cmd_AddCommand ("path", COM_Path_f, "No Description"); diff --git a/nq/source/in_sdl.c b/nq/source/in_sdl.c index a8fb6b7e5..52cab872f 100644 --- a/nq/source/in_sdl.c +++ b/nq/source/in_sdl.c @@ -33,6 +33,7 @@ #include #include "client.h" +#include "QF/compat.h" #include "QF/console.h" #include "QF/cvar.h" #include "draw.h" diff --git a/nq/source/in_svgalib.c b/nq/source/in_svgalib.c index 17ebcba9e..2cc74a81e 100644 --- a/nq/source/in_svgalib.c +++ b/nq/source/in_svgalib.c @@ -45,6 +45,7 @@ #include "client.h" #include "QF/cmd.h" +#include "QF/compat.h" #include "QF/console.h" #include "QF/cvar.h" #include "host.h" diff --git a/nq/source/in_x11.c b/nq/source/in_x11.c index 7d2bc3c1d..4e2a41999 100644 --- a/nq/source/in_x11.c +++ b/nq/source/in_x11.c @@ -57,6 +57,7 @@ #endif #include "client.h" +#include "QF/compat.h" #include "QF/console.h" #include "context_x11.h" #include "QF/cmd.h" diff --git a/nq/source/joy_linux.c b/nq/source/joy_linux.c index 43a8d810e..07db42a24 100644 --- a/nq/source/joy_linux.c +++ b/nq/source/joy_linux.c @@ -36,6 +36,7 @@ #include #include +#include "QF/compat.h" #include "QF/console.h" #include "client.h" #include "QF/cvar.h" diff --git a/nq/source/quakefs.c b/nq/source/quakefs.c index 77db91919..89b7c9351 100644 --- a/nq/source/quakefs.c +++ b/nq/source/quakefs.c @@ -62,6 +62,7 @@ #include #include "QF/cmd.h" +#include "QF/compat.h" #include "QF/console.h" #include "QF/cvar.h" #include "draw.h" diff --git a/nq/source/snd_mix.c b/nq/source/snd_mix.c index 010f2623e..947914c24 100644 --- a/nq/source/snd_mix.c +++ b/nq/source/snd_mix.c @@ -36,6 +36,7 @@ # include #endif +#include "QF/compat.h" #include "QF/console.h" #include "sound.h" diff --git a/nq/source/sv_progs.c b/nq/source/sv_progs.c index f029004d2..7efc4961c 100644 --- a/nq/source/sv_progs.c +++ b/nq/source/sv_progs.c @@ -40,11 +40,12 @@ #include "QF/cmd.h" #include "QF/console.h" #include "host.h" -#include "progdefs.h" #include "server.h" #include "sv_progs.h" #include "world.h" +#include "progdefs.h" + progs_t sv_pr_state; sv_globals_t sv_globals; sv_funcs_t sv_funcs; diff --git a/qw/include/net.h b/qw/include/net.h index 5b96f44c8..43d869dc1 100644 --- a/qw/include/net.h +++ b/qw/include/net.h @@ -30,8 +30,9 @@ #define _NET_H #include "QF/gcc_attr.h" -#include "QF/sizebuf.h" #include "QF/cvar.h" +#include "QF/qdefs.h" +#include "QF/sizebuf.h" #define PORT_ANY -1 diff --git a/qw/source/cd_linux.c b/qw/source/cd_linux.c index cf6be4202..e981087d8 100644 --- a/qw/source/cd_linux.c +++ b/qw/source/cd_linux.c @@ -41,6 +41,7 @@ #ifdef HAVE_STRINGS_H # include #endif +#include #include diff --git a/qw/source/cl_ents.c b/qw/source/cl_ents.c index e56af06e9..2e55ddd45 100644 --- a/qw/source/cl_ents.c +++ b/qw/source/cl_ents.c @@ -41,6 +41,7 @@ #include "cl_main.h" #include "cl_pred.h" #include "cl_tent.h" +#include "QF/compat.h" #include "QF/console.h" #include "d_iface.h" #include "host.h" diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index 7bb74a248..bfa28041d 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -72,6 +72,7 @@ #include "cl_tent.h" #include "client.h" #include "QF/cmd.h" +#include "QF/compat.h" #include "QF/console.h" #include "QF/cvar.h" #include "draw.h" diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index c52e3fd7d..aabd4d931 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -52,6 +52,7 @@ #include "cl_tent.h" #include "client.h" #include "QF/cmd.h" +#include "QF/compat.h" #include "QF/console.h" #include "host.h" #include "QF/msg.h" diff --git a/qw/source/cl_slist.c b/qw/source/cl_slist.c index 8ef4ae2e8..c89b6d7e7 100644 --- a/qw/source/cl_slist.c +++ b/qw/source/cl_slist.c @@ -44,6 +44,7 @@ #ifdef HAVE_UNISTD_H # include #endif +#include #include "bothdefs.h" #include "cl_slist.h" diff --git a/qw/source/com.c b/qw/source/com.c index b5e9931a9..a7b5073e5 100644 --- a/qw/source/com.c +++ b/qw/source/com.c @@ -35,7 +35,6 @@ #include "QF/cmd.h" #include "QF/console.h" #include "QF/cvar.h" -#include "QF/qendian.h" #include "QF/quakefs.h" #include "QF/sys.h" @@ -86,24 +85,6 @@ COM_CheckRegistered (void) void COM_Init (void) { -#ifndef WORDS_BIGENDIAN - bigendien = false; - BigShort = ShortSwap; - LittleShort = ShortNoSwap; - BigLong = LongSwap; - LittleLong = LongNoSwap; - BigFloat = FloatSwap; - LittleFloat = FloatNoSwap; -#else - bigendien = true; - BigShort = ShortNoSwap; - LittleShort = ShortSwap; - BigLong = LongNoSwap; - LittleLong = LongSwap; - BigFloat = FloatNoSwap; - LittleFloat = FloatSwap; -#endif - Cmd_AddCommand ("path", COM_Path_f, "Show what paths Quake is using"); COM_Filesystem_Init (); diff --git a/qw/source/d_init.c b/qw/source/d_init.c index c277893e6..1e48eedcf 100644 --- a/qw/source/d_init.c +++ b/qw/source/d_init.c @@ -30,6 +30,7 @@ # include "config.h" #endif +#include "QF/compat.h" #include "bothdefs.h" #include "d_local.h" diff --git a/qw/source/gl_dyn_part.c b/qw/source/gl_dyn_part.c index 4789cf199..c3e1ad5e6 100644 --- a/qw/source/gl_dyn_part.c +++ b/qw/source/gl_dyn_part.c @@ -39,6 +39,7 @@ #include #include "QF/cmd.h" +#include "QF/compat.h" #include "QF/console.h" #include "glquake.h" #include "host.h" diff --git a/qw/source/gl_rmain.c b/qw/source/gl_rmain.c index d1e7d39f0..2e615d73e 100644 --- a/qw/source/gl_rmain.c +++ b/qw/source/gl_rmain.c @@ -45,6 +45,7 @@ #include "cl_main.h" #include "cl_parse.h" //FIXME CL_NewTranslation #include "commdef.h" +#include "QF/compat.h" #include "QF/console.h" #include "locs.h" #include "glquake.h" diff --git a/qw/source/gl_rsurf.c b/qw/source/gl_rsurf.c index 630c7f9fd..cb79f6ea3 100644 --- a/qw/source/gl_rsurf.c +++ b/qw/source/gl_rsurf.c @@ -41,6 +41,7 @@ #include #include "glquake.h" +#include "QF/compat.h" #include "QF/sys.h" qboolean r_cache_thrash; diff --git a/qw/source/gl_screen.c b/qw/source/gl_screen.c index 7fed79d76..5838fc1c9 100644 --- a/qw/source/gl_screen.c +++ b/qw/source/gl_screen.c @@ -40,6 +40,7 @@ #include "cl_parse.h" #include "QF/cmd.h" +#include "QF/compat.h" #include "QF/console.h" #include "draw.h" #include "glquake.h" diff --git a/qw/source/gl_skin.c b/qw/source/gl_skin.c index e89c2f22c..22b5affbf 100644 --- a/qw/source/gl_skin.c +++ b/qw/source/gl_skin.c @@ -34,6 +34,7 @@ #include "host.h" #include "protocol.h" #include "skin.h" +#include "QF/compat.h" #include "QF/sys.h" #include "texture.h" diff --git a/qw/source/gl_textures.c b/qw/source/gl_textures.c index 8808f308e..bfa2d35e4 100644 --- a/qw/source/gl_textures.c +++ b/qw/source/gl_textures.c @@ -40,6 +40,7 @@ #include #include "QF/cmd.h" +#include "QF/compat.h" #include "QF/console.h" #include "QF/crc.h" #include "draw.h" diff --git a/qw/source/gl_view.c b/qw/source/gl_view.c index 0cf0843f3..e96ae257b 100644 --- a/qw/source/gl_view.c +++ b/qw/source/gl_view.c @@ -41,6 +41,7 @@ #include "bothdefs.h" #include "glquake.h" #include "view.h" +#include "QF/compat.h" extern byte *host_basepal; diff --git a/qw/source/in_sdl.c b/qw/source/in_sdl.c index ee38723d2..2f42c6051 100644 --- a/qw/source/in_sdl.c +++ b/qw/source/in_sdl.c @@ -34,6 +34,7 @@ #include "client.h" #include "cl_input.h" #include "cl_main.h" +#include "QF/compat.h" #include "QF/console.h" #include "QF/cvar.h" #include "draw.h" diff --git a/qw/source/in_svgalib.c b/qw/source/in_svgalib.c index dbccc8e73..d48b64af3 100644 --- a/qw/source/in_svgalib.c +++ b/qw/source/in_svgalib.c @@ -45,6 +45,7 @@ #include "cl_input.h" #include "client.h" #include "QF/cmd.h" +#include "QF/compat.h" #include "QF/console.h" #include "QF/cvar.h" #include "host.h" diff --git a/qw/source/in_x11.c b/qw/source/in_x11.c index 16e05bd8e..fb5fd222b 100644 --- a/qw/source/in_x11.c +++ b/qw/source/in_x11.c @@ -57,6 +57,7 @@ #include "cl_input.h" #include "client.h" +#include "QF/compat.h" #include "QF/console.h" #include "context_x11.h" #include "QF/cmd.h" diff --git a/qw/source/joy_linux.c b/qw/source/joy_linux.c index 563e0e3d2..ec955e2a9 100644 --- a/qw/source/joy_linux.c +++ b/qw/source/joy_linux.c @@ -35,6 +35,7 @@ #include #include +#include "QF/compat.h" #include "QF/console.h" #include "client.h" #include "QF/cvar.h" diff --git a/qw/source/pmovetst.c b/qw/source/pmovetst.c index 4a7706e52..11b800e3d 100644 --- a/qw/source/pmovetst.c +++ b/qw/source/pmovetst.c @@ -36,6 +36,7 @@ # include #endif +#include "QF/compat.h" #include "QF/console.h" #include "model.h" #include "pmove.h" diff --git a/qw/source/quakefs.c b/qw/source/quakefs.c index abe79cd0c..82fa1b81f 100644 --- a/qw/source/quakefs.c +++ b/qw/source/quakefs.c @@ -63,6 +63,7 @@ #include "QF/cmd.h" #include "commdef.h" +#include "QF/compat.h" #include "QF/console.h" #include "QF/cvar.h" #include "draw.h" diff --git a/qw/source/r_misc.c b/qw/source/r_misc.c index d4dc66a83..28b4f6f8e 100644 --- a/qw/source/r_misc.c +++ b/qw/source/r_misc.c @@ -30,6 +30,7 @@ # include "config.h" #endif +#include "QF/compat.h" #include "QF/console.h" #include "QF/cmd.h" #include "cl_parse.h" diff --git a/qw/source/r_part.c b/qw/source/r_part.c index 712d731c4..1b662cd35 100644 --- a/qw/source/r_part.c +++ b/qw/source/r_part.c @@ -32,6 +32,7 @@ #include +#include "QF/compat.h" #include "QF/console.h" #include "host.h" #include "QF/qargs.h" diff --git a/qw/source/r_view.c b/qw/source/r_view.c index 523ca5676..674237e32 100644 --- a/qw/source/r_view.c +++ b/qw/source/r_view.c @@ -36,6 +36,7 @@ #include "bothdefs.h" #include "client.h" #include "QF/cmd.h" +#include "QF/compat.h" #include "QF/cvar.h" #include "host.h" #include "QF/msg.h" diff --git a/qw/source/sbar.c b/qw/source/sbar.c index 9d07a105b..e30493917 100644 --- a/qw/source/sbar.c +++ b/qw/source/sbar.c @@ -42,6 +42,7 @@ #include "cl_cam.h" #include "client.h" #include "QF/cmd.h" +#include "QF/compat.h" #include "commdef.h" #include "draw.h" #include "QF/msg.h" diff --git a/qw/source/screen.c b/qw/source/screen.c index e560cd791..c7be875b1 100644 --- a/qw/source/screen.c +++ b/qw/source/screen.c @@ -41,6 +41,7 @@ #include "cl_parse.h" #include "client.h" #include "QF/cmd.h" +#include "QF/compat.h" #include "QF/console.h" #include "d_iface.h" #include "draw.h" diff --git a/qw/source/skin.c b/qw/source/skin.c index c5cf02fd4..65daff1c2 100644 --- a/qw/source/skin.c +++ b/qw/source/skin.c @@ -38,6 +38,7 @@ #include "cl_parse.h" #include "client.h" +#include "QF/compat.h" #include "QF/console.h" #include "QF/cmd.h" #include "host.h" diff --git a/qw/source/snd_mix.c b/qw/source/snd_mix.c index 010f2623e..947914c24 100644 --- a/qw/source/snd_mix.c +++ b/qw/source/snd_mix.c @@ -36,6 +36,7 @@ # include #endif +#include "QF/compat.h" #include "QF/console.h" #include "sound.h" diff --git a/qw/source/sv_ccmds.c b/qw/source/sv_ccmds.c index c882f4374..a1fc9aec9 100644 --- a/qw/source/sv_ccmds.c +++ b/qw/source/sv_ccmds.c @@ -40,6 +40,7 @@ #include "bothdefs.h" #include "QF/cmd.h" +#include "QF/compat.h" #include "QF/msg.h" #include "QF/qargs.h" #include "QF/qendian.h" diff --git a/qw/source/sv_ents.c b/qw/source/sv_ents.c index e7418656a..f3da7e529 100644 --- a/qw/source/sv_ents.c +++ b/qw/source/sv_ents.c @@ -36,6 +36,7 @@ # include #endif +#include "QF/compat.h" #include "QF/msg.h" #include "msg_ucmd.h" #include "server.h" diff --git a/qw/source/sv_main.c b/qw/source/sv_main.c index a79c1d6d0..6218a639a 100644 --- a/qw/source/sv_main.c +++ b/qw/source/sv_main.c @@ -42,6 +42,7 @@ #include "bothdefs.h" #include "buildnum.h" #include "QF/cmd.h" +#include "QF/compat.h" #include "model.h" #include "net.h" #include "QF/msg.h" diff --git a/qw/source/sv_progs.c b/qw/source/sv_progs.c index 50e5124e6..7920b41f4 100644 --- a/qw/source/sv_progs.c +++ b/qw/source/sv_progs.c @@ -38,6 +38,7 @@ #endif #include "QF/cmd.h" +#include "QF/compat.h" #include "server.h" #include "progdefs.h" #include "sv_progs.h" diff --git a/qw/source/sv_user.c b/qw/source/sv_user.c index 031eeef3f..278b68578 100644 --- a/qw/source/sv_user.c +++ b/qw/source/sv_user.c @@ -44,6 +44,7 @@ #include "bothdefs.h" #include "QF/checksum.h" #include "QF/cmd.h" +#include "QF/compat.h" #include "QF/cvar.h" #include "QF/msg.h" #include "msg_ucmd.h" diff --git a/qw/source/sw_skin.c b/qw/source/sw_skin.c index 03c1635bb..6f5503425 100644 --- a/qw/source/sw_skin.c +++ b/qw/source/sw_skin.c @@ -40,6 +40,7 @@ #include "client.h" #include "host.h" #include "skin.h" +#include "QF/compat.h" #include "QF/sys.h" #include "vid.h" diff --git a/qw/source/sw_view.c b/qw/source/sw_view.c index 064ba0337..2b4f28f74 100644 --- a/qw/source/sw_view.c +++ b/qw/source/sw_view.c @@ -34,6 +34,7 @@ #include "host.h" #include "r_local.h" #include "view.h" +#include "QF/compat.h" extern cvar_t *cl_cshift_powerup; diff --git a/qw/source/sys_unix.c b/qw/source/sys_unix.c index 6a3dee3d0..ceb8b83d8 100644 --- a/qw/source/sys_unix.c +++ b/qw/source/sys_unix.c @@ -32,6 +32,7 @@ #endif #include +#include #include #include #include diff --git a/qw/source/vid_glx.c b/qw/source/vid_glx.c index 62fabbddf..12910c398 100644 --- a/qw/source/vid_glx.c +++ b/qw/source/vid_glx.c @@ -46,6 +46,7 @@ # include #endif +#include "QF/compat.h" #include "QF/console.h" #include "context_x11.h" #include "glquake.h" diff --git a/qw/source/vid_sdl.c b/qw/source/vid_sdl.c index 91d6970e4..21e13ec7e 100644 --- a/qw/source/vid_sdl.c +++ b/qw/source/vid_sdl.c @@ -35,6 +35,7 @@ #ifdef HAVE_STRINGS_H # include #endif +#include #include diff --git a/qw/source/vid_sgl.c b/qw/source/vid_sgl.c index 3f46444cf..27c61624a 100644 --- a/qw/source/vid_sgl.c +++ b/qw/source/vid_sgl.c @@ -41,6 +41,7 @@ #include +#include "QF/compat.h" #include "QF/console.h" #include "glquake.h" #include "host.h" diff --git a/qw/source/vid_svgalib.c b/qw/source/vid_svgalib.c index d2201f70b..2b54c1187 100644 --- a/qw/source/vid_svgalib.c +++ b/qw/source/vid_svgalib.c @@ -47,6 +47,7 @@ #include #include "QF/cmd.h" +#include "QF/compat.h" #include "QF/console.h" #include "QF/cvar.h" #include "d_local.h" diff --git a/qw/source/vid_x11.c b/qw/source/vid_x11.c index 40271182f..d63430f67 100644 --- a/qw/source/vid_x11.c +++ b/qw/source/vid_x11.c @@ -67,6 +67,7 @@ #include "client.h" #include "QF/cmd.h" +#include "QF/compat.h" #include "QF/console.h" #include "context_x11.h" #include "QF/cvar.h" diff --git a/tools/qfcc/configure.in b/tools/qfcc/configure.in index 2f2260ed7..caacd6e4a 100644 --- a/tools/qfcc/configure.in +++ b/tools/qfcc/configure.in @@ -37,6 +37,13 @@ if test "$1" = gcc; then fi fi +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. @@ -49,29 +56,32 @@ dnl Checks for library functions. AC_ARG_WITH(qf-headers, [ --with-qf-headers=DIR use the QuakeForge headers found in DRI], -QF_HEADERS=$withval, QF_HEADERS=auto) +QF_INCL=$withval, QF_INCL=auto) AC_ARG_WITH(qf-libs, [ --with-qf-libs=DIR use the QuakeForge libs found in DRI], QF_LIBS=$withval, QF_LIBS=auto) AC_MSG_CHECKING(for QF headers location) -if test "x$QF_HEADERS" = xauto; then +if test "x$QF_INCL" = xauto; then qf_dir=`cd ${srcdir}/../..; pwd` if test -r ${qf_dir}/include/QF/qtypes.h; then - QF_HEADERS="-I ${qf_dir}/include" + QF_INCL="-I${qf_dir}/include" else - QF_HEADERS='' + QF_INCL='' fi else - QF_HEADERS="-I ${QF_HEADERS}" + QF_INCL="-I${QF_INCL}" fi -AC_MSG_RESULT($QF_HEADERS) +AC_MSG_RESULT($QF_INCL) +AC_SUBST(QF_INCL) AC_MSG_CHECKING(for QF libs location) +QF_DEPS="" if test "x$QF_LIBS" = xauto; then qf_dir=`cd ${srcdir}/../..; pwd` if test -r ${qf_dir}/libs/util/qfplist.c; then QF_LIBS="-L ${qf_dir}/libs/util" + QF_DEPS="${qf_dir}/libs/libqfutil.a" else QF_LIBS='' fi @@ -79,6 +89,9 @@ else QF_LIBS="-L ${QF_LIBS}" fi AC_MSG_RESULT($QF_LIBS) +QF_LIBS="${QF_LIBS} -lqfutil" +AC_SUBST(QF_LIBS) +AC_SUBST(QF_DEPS) AC_OUTPUT( include/Makefile diff --git a/tools/qfcc/include/cmdlib.h b/tools/qfcc/include/cmdlib.h index 0203887b5..692aea039 100644 --- a/tools/qfcc/include/cmdlib.h +++ b/tools/qfcc/include/cmdlib.h @@ -30,12 +30,16 @@ #include #include -#ifndef __BYTEBOOL__ -#define __BYTEBOOL__ -typedef enum {false, true} qboolean; +#ifndef _DEF_BYTE_ +# define _DEF_BYTE_ typedef unsigned char byte; #endif +#ifndef _DEF_BOOL_ +# define _DEF_BOOL_ +typedef enum {false, true} qboolean; +#endif + // the dec offsetof macro doesn't work very well... #define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier) @@ -57,13 +61,6 @@ void SafeWrite (FILE *f, void *buffer, int count); int LoadFile (char *filename, void **bufferptr); -short BigShort (short l); -short LittleShort (short l); -int BigLong (int l); -int LittleLong (int l); -float BigFloat (float l); -float LittleFloat (float l); - char *COM_Parse (char *data); extern char com_token[1024]; diff --git a/tools/qfcc/include/pr_comp.h b/tools/qfcc/include/pr_comp.h deleted file mode 100644 index 8b7d20323..000000000 --- a/tools/qfcc/include/pr_comp.h +++ /dev/null @@ -1,179 +0,0 @@ -/* 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 the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - See file, 'COPYING', for details. -*/ - -// this file is shared by QuakeForge and qfcc - -typedef int func_t; -typedef int string_t; - -typedef enum {ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, ev_function, ev_pointer} etype_t; - - -#define OFS_NULL 0 -#define OFS_RETURN 1 -#define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors -#define OFS_PARM1 7 -#define OFS_PARM2 10 -#define OFS_PARM3 13 -#define OFS_PARM4 16 -#define OFS_PARM5 19 -#define OFS_PARM6 22 -#define OFS_PARM7 25 -#define RESERVED_OFS 28 - - -enum { - OP_DONE, - OP_MUL_F, - OP_MUL_V, - OP_MUL_FV, - OP_MUL_VF, - OP_DIV_F, - OP_ADD_F, - OP_ADD_V, - OP_SUB_F, - OP_SUB_V, - - OP_EQ_F, - OP_EQ_V, - OP_EQ_S, - OP_EQ_E, - OP_EQ_FNC, - - OP_NE_F, - OP_NE_V, - OP_NE_S, - OP_NE_E, - OP_NE_FNC, - - OP_LE, - OP_GE, - OP_LT, - OP_GT, - - OP_LOAD_F, - OP_LOAD_V, - OP_LOAD_S, - OP_LOAD_ENT, - OP_LOAD_FLD, - OP_LOAD_FNC, - - OP_ADDRESS, - - OP_STORE_F, - OP_STORE_V, - OP_STORE_S, - OP_STORE_ENT, - OP_STORE_FLD, - OP_STORE_FNC, - - OP_STOREP_F, - OP_STOREP_V, - OP_STOREP_S, - OP_STOREP_ENT, - OP_STOREP_FLD, - OP_STOREP_FNC, - - OP_RETURN, - OP_NOT_F, - OP_NOT_V, - OP_NOT_S, - OP_NOT_ENT, - OP_NOT_FNC, - OP_IF, - OP_IFNOT, - OP_CALL0, - OP_CALL1, - OP_CALL2, - OP_CALL3, - OP_CALL4, - OP_CALL5, - OP_CALL6, - OP_CALL7, - OP_CALL8, - OP_STATE, - OP_GOTO, - OP_AND, - OP_OR, - - OP_BITAND, - OP_BITOR -}; - - -typedef struct statement_s -{ - unsigned short op; - short a,b,c; -} dstatement_t; - -typedef struct -{ - unsigned short type; // if DEF_SAVEGLOBGAL bit is set - // the variable needs to be saved in savegames - unsigned short ofs; - int s_name; -} ddef_t; -#define DEF_SAVEGLOBGAL (1<<15) - -#define MAX_PARMS 8 - -typedef struct -{ - int first_statement; // negative numbers are builtins - int parm_start; - int locals; // total ints of parms + locals - - int profile; // runtime - - int s_name; - int s_file; // source file defined in - - int numparms; - byte parm_size[MAX_PARMS]; -} dfunction_t; - - -#define PROG_VERSION 6 -typedef struct -{ - int version; - int crc; // check of header file - - int ofs_statements; - int numstatements; // statement 0 is an error - - int ofs_globaldefs; - int numglobaldefs; - - int ofs_fielddefs; - int numfielddefs; - - int ofs_functions; - int numfunctions; // function 0 is an empty - - int ofs_strings; - int numstrings; // first string is a null string - - int ofs_globals; - int numglobals; - - int entityfields; -} dprograms_t; - diff --git a/tools/qfcc/include/qfcc.h b/tools/qfcc/include/qfcc.h index 2d748657d..8f4e53680 100644 --- a/tools/qfcc/include/qfcc.h +++ b/tools/qfcc/include/qfcc.h @@ -22,7 +22,7 @@ #include #include -#include "pr_comp.h" +#include "QF/pr_comp.h" /* diff --git a/tools/qfcc/source/Makefile.am b/tools/qfcc/source/Makefile.am index 8d1210ab9..2eaba6c3c 100644 --- a/tools/qfcc/source/Makefile.am +++ b/tools/qfcc/source/Makefile.am @@ -28,8 +28,10 @@ # AUTOMAKE_OPTIONS= foreign -INCLUDES= -I$(top_srcdir)/include +INCLUDES= -I$(top_srcdir)/include $(QF_INCL) bin_PROGRAMS= qfcc -qfcc_SOURCES= cmdlib.c pr_comp.c pr_lex.c qfcc.c +qfcc_SOURCES= cmdlib.c pr_comp.c pr_lex.c qfcc.c +qfcc_LDADD= $(QF_LIBS) +qfcc_DEPENDENCIES= $(QF_DEPS) diff --git a/tools/qfcc/source/cmdlib.c b/tools/qfcc/source/cmdlib.c index a4a59ca4d..e9abbb7fe 100644 --- a/tools/qfcc/source/cmdlib.c +++ b/tools/qfcc/source/cmdlib.c @@ -289,143 +289,6 @@ LoadFile (char *filename, void **bufferptr) return length; } -/* -============================================================================ - - BYTE ORDER FUNCTIONS - -============================================================================ -*/ - -#ifdef WORDS_BIGENDIAN - -short -LittleShort (short l) -{ - byte b1, b2; - - b1 = l & 255; - b2 = (l >> 8) & 255; - - return (b1 << 8) + b2; -} - -short -BigShort (short l) -{ - return l; -} - -int -LittleLong (int l) -{ - byte b1, b2, b3, b4; - - b1 = l & 255; - b2 = (l >> 8) & 255; - b3 = (l >> 16) & 255; - b4 = (l >> 24) & 255; - - return ((int) b1 << 24) + ((int) b2 << 16) + ((int) b3 << 8) + b4; -} - -int -BigLong (int l) -{ - return l; -} - - -float -LittleFloat (float l) -{ - union { - byte b[4]; - float f; - } in, out; - - in.f = l; - out.b[0] = in.b[3]; - out.b[1] = in.b[2]; - out.b[2] = in.b[1]; - out.b[3] = in.b[0]; - - return out.f; -} - -float -BigFloat (float l) -{ - return l; -} - -#else - - -short -BigShort (short l) -{ - byte b1, b2; - - b1 = l & 255; - b2 = (l >> 8) & 255; - - return (b1 << 8) + b2; -} - -short -LittleShort (short l) -{ - return l; -} - - -int -BigLong (int l) -{ - byte b1, b2, b3, b4; - - b1 = l & 255; - b2 = (l >> 8) & 255; - b3 = (l >> 16) & 255; - b4 = (l >> 24) & 255; - - return ((int) b1 << 24) + ((int) b2 << 16) + ((int) b3 << 8) + b4; -} - -int -LittleLong (int l) -{ - return l; -} - -float -BigFloat (float l) -{ - union { - byte b[4]; - float f; - } in, out; - - in.f = l; - out.b[0] = in.b[3]; - out.b[1] = in.b[2]; - out.b[2] = in.b[1]; - out.b[3] = in.b[0]; - - return out.f; -} - -float -LittleFloat (float l) -{ - return l; -} - - -#endif - - //======================================================= diff --git a/tools/qfcc/source/pr_comp.c b/tools/qfcc/source/pr_comp.c index 411b2d5f3..e0c49a4e3 100644 --- a/tools/qfcc/source/pr_comp.c +++ b/tools/qfcc/source/pr_comp.c @@ -349,7 +349,7 @@ PR_ParseFunctionCall (def_t *func) t = func->type; - if (t->type != ev_function) + if (t->type != ev_func) PR_ParseError ("not a function"); // copy the arguments to the global parameter variables @@ -440,7 +440,7 @@ PR_Term (void) return PR_Statement (&pr_opcodes[OP_NOT_ENT], e, 0); case ev_vector: return PR_Statement (&pr_opcodes[OP_NOT_V], e, 0); - case ev_function: + case ev_func: return PR_Statement (&pr_opcodes[OP_NOT_FNC], e, 0); default: PR_ParseError ("Type mismatch for !"); @@ -839,7 +839,7 @@ PR_ParseDefs (void) type = PR_ParseType (); - if (pr_scope && (type->type == ev_field || type->type == ev_function)) + if (pr_scope && (type->type == ev_field || type->type == ev_func)) PR_ParseError ("Fields and functions must be global"); do { @@ -852,7 +852,7 @@ PR_ParseDefs (void) if (def->initialized) PR_ParseError ("%s redeclared", name); - if (type->type == ev_function) { + if (type->type == ev_func) { locals_start = locals_end = numpr_globals; pr_scope = def; f = PR_ParseImmediateStatements (type); diff --git a/tools/qfcc/source/pr_lex.c b/tools/qfcc/source/pr_lex.c index 561d4c3c2..6340f33df 100644 --- a/tools/qfcc/source/pr_lex.c +++ b/tools/qfcc/source/pr_lex.c @@ -62,7 +62,7 @@ type_t type_vector = { ev_vector, &def_vector }; type_t type_entity = { ev_entity, &def_entity }; type_t type_field = { ev_field, &def_field }; // type_function is a void() function used for state defs -type_t type_function = { ev_function, &def_function, NULL, &type_void }; +type_t type_function = { ev_func, &def_function, NULL, &type_void }; type_t type_pointer = { ev_pointer, &def_pointer }; type_t type_floatfield = { ev_field, &def_field, NULL, &type_float }; @@ -649,7 +649,7 @@ PR_ParseType (void) // function type memset (&new, 0, sizeof (new)); - new.type = ev_function; + new.type = ev_func; new.aux_type = type; // return type new.num_parms = 0; if (!PR_Check (tt_punct, ")")) { diff --git a/tools/qfcc/source/qfcc.c b/tools/qfcc/source/qfcc.c index 7fed8e07c..3104c0603 100644 --- a/tools/qfcc/source/qfcc.c +++ b/tools/qfcc/source/qfcc.c @@ -30,9 +30,11 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif +#include "QF/qendian.h" #include "qfcc.h" + char sourcedir[1024]; char destfile[1024]; @@ -204,7 +206,7 @@ WriteData (int crc) int i; for (def = pr.def_head.next; def; def = def->next) { - if (def->type->type == ev_function) { + if (def->type->type == ev_func) { // df = &functions[numfunctions]; // numfunctions++; } else if (def->type->type == ev_field) { @@ -220,9 +222,9 @@ WriteData (int crc) dd->type = def->type->type; if (!def->initialized - && def->type->type != ev_function + && def->type->type != ev_func && def->type->type != ev_field && def->scope == NULL) - dd->type |= DEF_SAVEGLOBGAL; + dd->type |= DEF_SAVEGLOBAL; dd->s_name = CopyString (def->name); dd->ofs = def->ofs; } @@ -392,7 +394,7 @@ PR_ValueString (etype_t type, void *val) case ev_entity: sprintf (line, "entity %i", *(int *) val); break; - case ev_function: + case ev_func: if (!(f = functions + *(int *) val)) sprintf (line, "undefined function"); else @@ -468,7 +470,7 @@ PR_GlobalString (gofs_t ofs) if (!(def = pr_global_defs[ofs])) return PR_GlobalStringNoContents (ofs); - if (def->initialized && def->type->type != ev_function) { + if (def->initialized && def->type->type != ev_func) { s = PR_ValueString (def->type->type, &pr_globals[ofs]); sprintf (line, "%i(%s)", ofs, s); } else { @@ -582,7 +584,7 @@ PR_FinishCompilation (void) // check to make sure all functions prototyped have code for (d = pr.def_head.next; d; d = d->next) { - if (d->type->type == ev_function && !d->scope) { // function args ok + if (d->type->type == ev_func && !d->scope) { // function args ok // f = G_FUNCTION(d->ofs); // if (!f || (!f->code && !f->builtin)) if (!d->initialized) { @@ -633,7 +635,7 @@ PR_WriteProgdefs (char *filename) case ev_string: fprintf (f, "\tstring_t\t%s;\n", d->name); break; - case ev_function: + case ev_func: fprintf (f, "\tfunc_t\t%s;\n", d->name); break; case ev_entity: @@ -666,7 +668,7 @@ PR_WriteProgdefs (char *filename) case ev_string: fprintf (f, "\tstring_t\t%s;\n", d->name); break; - case ev_function: + case ev_func: fprintf (f, "\tfunc_t\t%s;\n", d->name); break; case ev_entity: @@ -752,12 +754,12 @@ Options: \n\ -h, --help display this help and exit\n\ -V, --version output version information and exit\n\ "); - return; + return 1; } if (CheckParm ("-V") || CheckParm ("--version")) { printf ("%s version %s\n", PACKAGE, VERSION); - return; + return 1; } if ((p = CheckParm ("--source")) && p < argc - 1) { @@ -796,7 +798,7 @@ Options: \n\ LoadFile (filename, (void *) &src2); if (!PR_CompileFile (src2, filename)) - exit (1); + return 1; } if (!PR_FinishCompilation ()) @@ -813,4 +815,5 @@ Options: \n\ stop = I_FloatTime (); printf ("Compilation time: %i seconds.\n", (int) (stop - start)); + return 0; }