From 67ee0c38c4fcc70e4610109d2c15023d4b7f23c0 Mon Sep 17 00:00:00 2001 From: tma Date: Wed, 26 Oct 2005 19:45:21 +0000 Subject: * Moved various source files from their mod sdk locations to places more appropriate for open source Q3 * This patch looks bigger than it really is, however it will probably break the VC and OS X builds (easy to fix though) git-svn-id: svn://svn.icculus.org/quake3/trunk@181 edf5b092-35ff-0310-97b2-ce42778d08ea --- code/botlib/be_aas.h | 221 +++++++ code/botlib/be_aas_bspq3.c | 6 +- code/botlib/be_aas_cluster.c | 6 +- code/botlib/be_aas_debug.c | 6 +- code/botlib/be_aas_entity.c | 6 +- code/botlib/be_aas_file.c | 6 +- code/botlib/be_aas_main.c | 6 +- code/botlib/be_aas_move.c | 6 +- code/botlib/be_aas_optimize.c | 6 +- code/botlib/be_aas_reach.c | 6 +- code/botlib/be_aas_route.c | 6 +- code/botlib/be_aas_routealt.c | 6 +- code/botlib/be_aas_sample.c | 6 +- code/botlib/be_ai_char.c | 8 +- code/botlib/be_ai_char.h | 48 ++ code/botlib/be_ai_chat.c | 10 +- code/botlib/be_ai_chat.h | 113 ++++ code/botlib/be_ai_gen.c | 8 +- code/botlib/be_ai_gen.h | 33 + code/botlib/be_ai_goal.c | 10 +- code/botlib/be_ai_goal.h | 118 ++++ code/botlib/be_ai_move.c | 14 +- code/botlib/be_ai_move.h | 144 ++++ code/botlib/be_ai_weap.c | 8 +- code/botlib/be_ai_weap.h | 104 +++ code/botlib/be_ai_weight.c | 6 +- code/botlib/be_ea.c | 4 +- code/botlib/be_ea.h | 66 ++ code/botlib/be_interface.c | 20 +- code/botlib/botlib.h | 516 +++++++++++++++ code/botlib/l_crc.c | 4 +- code/botlib/l_libvar.c | 2 +- code/botlib/l_log.c | 4 +- code/botlib/l_memory.c | 4 +- code/botlib/l_precomp.c | 4 +- code/botlib/l_script.c | 4 +- code/botlib/l_struct.c | 4 +- code/bspc/aas_create.c | 2 +- code/bspc/aas_map.c | 2 +- code/bspc/aas_store.h | 2 +- code/bspc/be_aas_bspc.c | 6 +- code/bspc/map_q3.c | 2 +- code/cgame/cg_local.h | 4 +- code/cgame/tr_types.h | 229 ------- code/client/cl_cgame.c | 2 +- code/client/cl_net_chan.c | 2 +- code/client/cl_ui.c | 2 +- code/client/client.h | 2 +- code/client/keycodes.h | 163 +++++ code/client/keys.h | 2 +- code/client/snd_local.h | 2 +- code/game/ai_chat.c | 18 +- code/game/ai_cmd.c | 18 +- code/game/ai_dmnet.c | 20 +- code/game/ai_dmq3.c | 18 +- code/game/ai_main.c | 20 +- code/game/ai_team.c | 18 +- code/game/ai_vcmd.c | 18 +- code/game/be_aas.h | 221 ------- code/game/be_ai_char.h | 48 -- code/game/be_ai_chat.h | 113 ---- code/game/be_ai_gen.h | 33 - code/game/be_ai_goal.h | 118 ---- code/game/be_ai_move.h | 144 ---- code/game/be_ai_weap.h | 104 --- code/game/be_ea.h | 66 -- code/game/bg_lib.c | 2 +- code/game/bg_misc.c | 2 +- code/game/bg_pmove.c | 2 +- code/game/bg_slidemove.c | 2 +- code/game/botlib.h | 516 --------------- code/game/g_local.h | 2 +- code/game/q_math.c | 1307 ------------------------------------ code/game/q_shared.c | 1252 ----------------------------------- code/game/q_shared.h | 1456 ----------------------------------------- code/game/surfaceflags.h | 80 --- code/jpeg-6/jload.c | 2 +- code/null/mac_net.c | 2 +- code/q3_ui/keycodes.h | 163 ----- code/q3_ui/ui_local.h | 6 +- code/qcommon/cm_local.h | 2 +- code/qcommon/cmd.c | 2 +- code/qcommon/cmd.c.save | 636 ------------------ code/qcommon/common.c | 2 +- code/qcommon/cvar.c | 2 +- code/qcommon/files.c | 2 +- code/qcommon/huffman.c | 2 +- code/qcommon/msg.c | 2 +- code/qcommon/net_chan.c | 2 +- code/qcommon/q_math.c | 1307 ++++++++++++++++++++++++++++++++++++ code/qcommon/q_shared.c | 1252 +++++++++++++++++++++++++++++++++++ code/qcommon/q_shared.h | 1456 +++++++++++++++++++++++++++++++++++++++++ code/qcommon/surfaceflags.h | 80 +++ code/qcommon/vm_local.h | 2 +- code/renderer/tr_local.h | 2 +- code/renderer/tr_public.h | 2 +- code/renderer/tr_types.h | 229 +++++++ code/server/server.h | 2 +- code/server/sv_bot.c | 2 +- code/server/sv_game.c | 2 +- code/server/sv_net_chan.c | 2 +- code/ui/keycodes.h | 163 ----- code/ui/ui_local.h | 6 +- code/ui/ui_shared.h | 6 +- code/unix/Makefile | 54 +- code/unix/linux_signals.c | 2 +- code/unix/linux_snd.c | 2 +- code/unix/sdl_snd.c | 2 +- code/unix/unix_main.c | 2 +- code/unix/unix_net.c | 2 +- code/unix/unix_shared.c | 2 +- code/win32/win_net.c | 2 +- code/win32/win_shared.c | 2 +- 113 files changed, 6097 insertions(+), 6880 deletions(-) create mode 100644 code/botlib/be_aas.h create mode 100644 code/botlib/be_ai_char.h create mode 100644 code/botlib/be_ai_chat.h create mode 100644 code/botlib/be_ai_gen.h create mode 100644 code/botlib/be_ai_goal.h create mode 100644 code/botlib/be_ai_move.h create mode 100644 code/botlib/be_ai_weap.h create mode 100644 code/botlib/be_ea.h create mode 100644 code/botlib/botlib.h delete mode 100644 code/cgame/tr_types.h create mode 100644 code/client/keycodes.h delete mode 100644 code/game/be_aas.h delete mode 100644 code/game/be_ai_char.h delete mode 100644 code/game/be_ai_chat.h delete mode 100644 code/game/be_ai_gen.h delete mode 100644 code/game/be_ai_goal.h delete mode 100644 code/game/be_ai_move.h delete mode 100644 code/game/be_ai_weap.h delete mode 100644 code/game/be_ea.h delete mode 100644 code/game/botlib.h delete mode 100644 code/game/q_math.c delete mode 100644 code/game/q_shared.c delete mode 100644 code/game/q_shared.h delete mode 100644 code/game/surfaceflags.h delete mode 100644 code/q3_ui/keycodes.h delete mode 100644 code/qcommon/cmd.c.save create mode 100644 code/qcommon/q_math.c create mode 100644 code/qcommon/q_shared.c create mode 100644 code/qcommon/q_shared.h create mode 100644 code/qcommon/surfaceflags.h create mode 100644 code/renderer/tr_types.h delete mode 100644 code/ui/keycodes.h (limited to 'code') diff --git a/code/botlib/be_aas.h b/code/botlib/be_aas.h new file mode 100644 index 0000000..4a98a8e --- /dev/null +++ b/code/botlib/be_aas.h @@ -0,0 +1,221 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code 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. + +Quake III Arena source code 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 Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +/***************************************************************************** + * name: be_aas.h + * + * desc: Area Awareness System, stuff exported to the AI + * + * $Archive: /source/code/botlib/be_aas.h $ + * + *****************************************************************************/ + +#ifndef MAX_STRINGFIELD +#define MAX_STRINGFIELD 80 +#endif + +//travel flags +#define TFL_INVALID 0x00000001 //traveling temporary not possible +#define TFL_WALK 0x00000002 //walking +#define TFL_CROUCH 0x00000004 //crouching +#define TFL_BARRIERJUMP 0x00000008 //jumping onto a barrier +#define TFL_JUMP 0x00000010 //jumping +#define TFL_LADDER 0x00000020 //climbing a ladder +#define TFL_WALKOFFLEDGE 0x00000080 //walking of a ledge +#define TFL_SWIM 0x00000100 //swimming +#define TFL_WATERJUMP 0x00000200 //jumping out of the water +#define TFL_TELEPORT 0x00000400 //teleporting +#define TFL_ELEVATOR 0x00000800 //elevator +#define TFL_ROCKETJUMP 0x00001000 //rocket jumping +#define TFL_BFGJUMP 0x00002000 //bfg jumping +#define TFL_GRAPPLEHOOK 0x00004000 //grappling hook +#define TFL_DOUBLEJUMP 0x00008000 //double jump +#define TFL_RAMPJUMP 0x00010000 //ramp jump +#define TFL_STRAFEJUMP 0x00020000 //strafe jump +#define TFL_JUMPPAD 0x00040000 //jump pad +#define TFL_AIR 0x00080000 //travel through air +#define TFL_WATER 0x00100000 //travel through water +#define TFL_SLIME 0x00200000 //travel through slime +#define TFL_LAVA 0x00400000 //travel through lava +#define TFL_DONOTENTER 0x00800000 //travel through donotenter area +#define TFL_FUNCBOB 0x01000000 //func bobbing +#define TFL_FLIGHT 0x02000000 //flight +#define TFL_BRIDGE 0x04000000 //move over a bridge +// +#define TFL_NOTTEAM1 0x08000000 //not team 1 +#define TFL_NOTTEAM2 0x10000000 //not team 2 + +//default travel flags +#define TFL_DEFAULT TFL_WALK|TFL_CROUCH|TFL_BARRIERJUMP|\ + TFL_JUMP|TFL_LADDER|\ + TFL_WALKOFFLEDGE|TFL_SWIM|TFL_WATERJUMP|\ + TFL_TELEPORT|TFL_ELEVATOR|\ + TFL_AIR|TFL_WATER|TFL_JUMPPAD|TFL_FUNCBOB + +typedef enum +{ + SOLID_NOT, // no interaction with other objects + SOLID_TRIGGER, // only touch when inside, after moving + SOLID_BBOX, // touch on edge + SOLID_BSP // bsp clip, touch on edge +} solid_t; + +//a trace is returned when a box is swept through the AAS world +typedef struct aas_trace_s +{ + qboolean startsolid; // if true, the initial point was in a solid area + float fraction; // time completed, 1.0 = didn't hit anything + vec3_t endpos; // final position + int ent; // entity blocking the trace + int lastarea; // last area the trace was in (zero if none) + int area; // area blocking the trace (zero if none) + int planenum; // number of the plane that was hit +} aas_trace_t; + +/* Defined in botlib.h + +//bsp_trace_t hit surface +typedef struct bsp_surface_s +{ + char name[16]; + int flags; + int value; +} bsp_surface_t; + +//a trace is returned when a box is swept through the BSP world +typedef struct bsp_trace_s +{ + qboolean allsolid; // if true, plane is not valid + qboolean startsolid; // if true, the initial point was in a solid area + float fraction; // time completed, 1.0 = didn't hit anything + vec3_t endpos; // final position + cplane_t plane; // surface normal at impact + float exp_dist; // expanded plane distance + int sidenum; // number of the brush side hit + bsp_surface_t surface; // hit surface + int contents; // contents on other side of surface hit + int ent; // number of entity hit +} bsp_trace_t; +// +*/ + +//entity info +typedef struct aas_entityinfo_s +{ + int valid; // true if updated this frame + int type; // entity type + int flags; // entity flags + float ltime; // local time + float update_time; // time between last and current update + int number; // number of the entity + vec3_t origin; // origin of the entity + vec3_t angles; // angles of the model + vec3_t old_origin; // for lerping + vec3_t lastvisorigin; // last visible origin + vec3_t mins; // bounding box minimums + vec3_t maxs; // bounding box maximums + int groundent; // ground entity + int solid; // solid type + int modelindex; // model used + int modelindex2; // weapons, CTF flags, etc + int frame; // model frame number + int event; // impulse events -- muzzle flashes, footsteps, etc + int eventParm; // even parameter + int powerups; // bit flags + int weapon; // determines weapon and flash model, etc + int legsAnim; // mask off ANIM_TOGGLEBIT + int torsoAnim; // mask off ANIM_TOGGLEBIT +} aas_entityinfo_t; + +// area info +typedef struct aas_areainfo_s +{ + int contents; + int flags; + int presencetype; + int cluster; + vec3_t mins; + vec3_t maxs; + vec3_t center; +} aas_areainfo_t; + +// client movement prediction stop events, stop as soon as: +#define SE_NONE 0 +#define SE_HITGROUND 1 // the ground is hit +#define SE_LEAVEGROUND 2 // there's no ground +#define SE_ENTERWATER 4 // water is entered +#define SE_ENTERSLIME 8 // slime is entered +#define SE_ENTERLAVA 16 // lava is entered +#define SE_HITGROUNDDAMAGE 32 // the ground is hit with damage +#define SE_GAP 64 // there's a gap +#define SE_TOUCHJUMPPAD 128 // touching a jump pad area +#define SE_TOUCHTELEPORTER 256 // touching teleporter +#define SE_ENTERAREA 512 // the given stoparea is entered +#define SE_HITGROUNDAREA 1024 // a ground face in the area is hit +#define SE_HITBOUNDINGBOX 2048 // hit the specified bounding box +#define SE_TOUCHCLUSTERPORTAL 4096 // touching a cluster portal + +typedef struct aas_clientmove_s +{ + vec3_t endpos; //position at the end of movement prediction + int endarea; //area at end of movement prediction + vec3_t velocity; //velocity at the end of movement prediction + aas_trace_t trace; //last trace + int presencetype; //presence type at end of movement prediction + int stopevent; //event that made the prediction stop + int endcontents; //contents at the end of movement prediction + float time; //time predicted ahead + int frames; //number of frames predicted ahead +} aas_clientmove_t; + +// alternate route goals +#define ALTROUTEGOAL_ALL 1 +#define ALTROUTEGOAL_CLUSTERPORTALS 2 +#define ALTROUTEGOAL_VIEWPORTALS 4 + +typedef struct aas_altroutegoal_s +{ + vec3_t origin; + int areanum; + unsigned short starttraveltime; + unsigned short goaltraveltime; + unsigned short extratraveltime; +} aas_altroutegoal_t; + +// route prediction stop events +#define RSE_NONE 0 +#define RSE_NOROUTE 1 //no route to goal +#define RSE_USETRAVELTYPE 2 //stop as soon as on of the given travel types is used +#define RSE_ENTERCONTENTS 4 //stop when entering the given contents +#define RSE_ENTERAREA 8 //stop when entering the given area + +typedef struct aas_predictroute_s +{ + vec3_t endpos; //position at the end of movement prediction + int endarea; //area at end of movement prediction + int stopevent; //event that made the prediction stop + int endcontents; //contents at the end of movement prediction + int endtravelflags; //end travel flags + int numareas; //number of areas predicted ahead + int time; //time predicted ahead (in hundreth of a sec) +} aas_predictroute_t; diff --git a/code/botlib/be_aas_bspq3.c b/code/botlib/be_aas_bspq3.c index 97c286d..68084be 100644 --- a/code/botlib/be_aas_bspq3.c +++ b/code/botlib/be_aas_bspq3.c @@ -29,14 +29,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_memory.h" #include "l_script.h" #include "l_precomp.h" #include "l_struct.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_aas_def.h" diff --git a/code/botlib/be_aas_cluster.c b/code/botlib/be_aas_cluster.c index 118dd0a..cdbce02 100644 --- a/code/botlib/be_aas_cluster.c +++ b/code/botlib/be_aas_cluster.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_memory.h" #include "l_script.h" #include "l_precomp.h" @@ -38,8 +38,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_memory.h" #include "l_libvar.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_aas_def.h" diff --git a/code/botlib/be_aas_debug.c b/code/botlib/be_aas_debug.c index a665c0c..c27475e 100644 --- a/code/botlib/be_aas_debug.c +++ b/code/botlib/be_aas_debug.c @@ -29,15 +29,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_memory.h" #include "l_script.h" #include "l_precomp.h" #include "l_struct.h" #include "l_libvar.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_interface.h" #include "be_aas_funcs.h" #include "be_aas_def.h" diff --git a/code/botlib/be_aas_entity.c b/code/botlib/be_aas_entity.c index e11356b..0ec201c 100644 --- a/code/botlib/be_aas_entity.c +++ b/code/botlib/be_aas_entity.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_memory.h" #include "l_script.h" #include "l_precomp.h" @@ -37,8 +37,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_utils.h" #include "l_log.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_interface.h" #include "be_aas_def.h" diff --git a/code/botlib/be_aas_file.c b/code/botlib/be_aas_file.c index f73c962..6d4103a 100644 --- a/code/botlib/be_aas_file.c +++ b/code/botlib/be_aas_file.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_memory.h" #include "l_script.h" #include "l_precomp.h" @@ -37,8 +37,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_libvar.h" #include "l_utils.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_interface.h" #include "be_aas_def.h" diff --git a/code/botlib/be_aas_main.c b/code/botlib/be_aas_main.c index dac1ce3..ad04ef7 100644 --- a/code/botlib/be_aas_main.c +++ b/code/botlib/be_aas_main.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_memory.h" #include "l_libvar.h" #include "l_utils.h" @@ -38,8 +38,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_struct.h" #include "l_log.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_interface.h" #include "be_aas_def.h" diff --git a/code/botlib/be_aas_move.c b/code/botlib/be_aas_move.c index 3433153..5b3ac1f 100644 --- a/code/botlib/be_aas_move.c +++ b/code/botlib/be_aas_move.c @@ -29,15 +29,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_memory.h" #include "l_script.h" #include "l_precomp.h" #include "l_struct.h" #include "l_libvar.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_aas_def.h" diff --git a/code/botlib/be_aas_optimize.c b/code/botlib/be_aas_optimize.c index 605dc4d..48b6c90 100644 --- a/code/botlib/be_aas_optimize.c +++ b/code/botlib/be_aas_optimize.c @@ -30,15 +30,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_libvar.h" #include "l_memory.h" #include "l_script.h" #include "l_precomp.h" #include "l_struct.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_interface.h" #include "be_aas_def.h" diff --git a/code/botlib/be_aas_reach.c b/code/botlib/be_aas_reach.c index f26523a..4b7f8ee 100644 --- a/code/botlib/be_aas_reach.c +++ b/code/botlib/be_aas_reach.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_log.h" #include "l_memory.h" #include "l_script.h" @@ -37,8 +37,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_precomp.h" #include "l_struct.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_aas_def.h" diff --git a/code/botlib/be_aas_route.c b/code/botlib/be_aas_route.c index 642be81..9275bf2 100644 --- a/code/botlib/be_aas_route.c +++ b/code/botlib/be_aas_route.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_utils.h" #include "l_memory.h" #include "l_log.h" @@ -39,8 +39,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_precomp.h" #include "l_struct.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_interface.h" #include "be_aas_def.h" diff --git a/code/botlib/be_aas_routealt.c b/code/botlib/be_aas_routealt.c index 956302d..20705db 100644 --- a/code/botlib/be_aas_routealt.c +++ b/code/botlib/be_aas_routealt.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_utils.h" #include "l_memory.h" #include "l_log.h" @@ -37,8 +37,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_precomp.h" #include "l_struct.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_interface.h" #include "be_aas_def.h" diff --git a/code/botlib/be_aas_sample.c b/code/botlib/be_aas_sample.c index f12b5e0..a2f0d0b 100644 --- a/code/botlib/be_aas_sample.c +++ b/code/botlib/be_aas_sample.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_memory.h" #include "l_script.h" #include "l_precomp.h" @@ -38,8 +38,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_libvar.h" #endif #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_interface.h" #include "be_aas_funcs.h" #include "be_aas_def.h" diff --git a/code/botlib/be_ai_char.c b/code/botlib/be_ai_char.c index ea34030..778a70d 100644 --- a/code/botlib/be_ai_char.c +++ b/code/botlib/be_ai_char.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_log.h" #include "l_memory.h" #include "l_utils.h" @@ -38,11 +38,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_struct.h" #include "l_libvar.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_interface.h" -#include "../game/be_ai_char.h" +#include "be_ai_char.h" #define MAX_CHARACTERISTICS 80 diff --git a/code/botlib/be_ai_char.h b/code/botlib/be_ai_char.h new file mode 100644 index 0000000..573fa1d --- /dev/null +++ b/code/botlib/be_ai_char.h @@ -0,0 +1,48 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code 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. + +Quake III Arena source code 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 Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +/***************************************************************************** + * name: be_ai_char.h + * + * desc: bot characters + * + * $Archive: /source/code/botlib/be_ai_char.h $ + * + *****************************************************************************/ + +//loads a bot character from a file +int BotLoadCharacter(char *charfile, float skill); +//frees a bot character +void BotFreeCharacter(int character); +//returns a float characteristic +float Characteristic_Float(int character, int index); +//returns a bounded float characteristic +float Characteristic_BFloat(int character, int index, float min, float max); +//returns an integer characteristic +int Characteristic_Integer(int character, int index); +//returns a bounded integer characteristic +int Characteristic_BInteger(int character, int index, int min, int max); +//returns a string characteristic +void Characteristic_String(int character, int index, char *buf, int size); +//free cached bot characters +void BotShutdownCharacters(void); diff --git a/code/botlib/be_ai_chat.c b/code/botlib/be_ai_chat.c index 7c719dd..a05a8eb 100644 --- a/code/botlib/be_ai_chat.c +++ b/code/botlib/be_ai_chat.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_memory.h" #include "l_libvar.h" #include "l_script.h" @@ -38,12 +38,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_utils.h" #include "l_log.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_interface.h" -#include "../game/be_ea.h" -#include "../game/be_ai_chat.h" +#include "be_ea.h" +#include "be_ai_chat.h" //escape character diff --git a/code/botlib/be_ai_chat.h b/code/botlib/be_ai_chat.h new file mode 100644 index 0000000..67a38ed --- /dev/null +++ b/code/botlib/be_ai_chat.h @@ -0,0 +1,113 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code 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. + +Quake III Arena source code 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 Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +/***************************************************************************** + * name: be_ai_chat.h + * + * desc: char AI + * + * $Archive: /source/code/botlib/be_ai_chat.h $ + * + *****************************************************************************/ + +#define MAX_MESSAGE_SIZE 256 +#define MAX_CHATTYPE_NAME 32 +#define MAX_MATCHVARIABLES 8 + +#define CHAT_GENDERLESS 0 +#define CHAT_GENDERFEMALE 1 +#define CHAT_GENDERMALE 2 + +#define CHAT_ALL 0 +#define CHAT_TEAM 1 +#define CHAT_TELL 2 + +//a console message +typedef struct bot_consolemessage_s +{ + int handle; + float time; //message time + int type; //message type + char message[MAX_MESSAGE_SIZE]; //message + struct bot_consolemessage_s *prev, *next; //prev and next in list +} bot_consolemessage_t; + +//match variable +typedef struct bot_matchvariable_s +{ + char offset; + int length; +} bot_matchvariable_t; +//returned to AI when a match is found +typedef struct bot_match_s +{ + char string[MAX_MESSAGE_SIZE]; + int type; + int subtype; + bot_matchvariable_t variables[MAX_MATCHVARIABLES]; +} bot_match_t; + +//setup the chat AI +int BotSetupChatAI(void); +//shutdown the chat AI +void BotShutdownChatAI(void); +//returns the handle to a newly allocated chat state +int BotAllocChatState(void); +//frees the chatstate +void BotFreeChatState(int handle); +//adds a console message to the chat state +void BotQueueConsoleMessage(int chatstate, int type, char *message); +//removes the console message from the chat state +void BotRemoveConsoleMessage(int chatstate, int handle); +//returns the next console message from the state +int BotNextConsoleMessage(int chatstate, bot_consolemessage_t *cm); +//returns the number of console messages currently stored in the state +int BotNumConsoleMessages(int chatstate); +//selects a chat message of the given type +void BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); +//returns the number of initial chat messages of the given type +int BotNumInitialChats(int chatstate, char *type); +//find and select a reply for the given message +int BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); +//returns the length of the currently selected chat message +int BotChatLength(int chatstate); +//enters the selected chat message +void BotEnterChat(int chatstate, int clientto, int sendto); +//get the chat message ready to be output +void BotGetChatMessage(int chatstate, char *buf, int size); +//checks if the first string contains the second one, returns index into first string or -1 if not found +int StringContains(char *str1, char *str2, int casesensitive); +//finds a match for the given string using the match templates +int BotFindMatch(char *str, bot_match_t *match, unsigned long int context); +//returns a variable from a match +void BotMatchVariable(bot_match_t *match, int variable, char *buf, int size); +//unify all the white spaces in the string +void UnifyWhiteSpaces(char *string); +//replace all the context related synonyms in the string +void BotReplaceSynonyms(char *string, unsigned long int context); +//loads a chat file for the chat state +int BotLoadChatFile(int chatstate, char *chatfile, char *chatname); +//store the gender of the bot in the chat state +void BotSetChatGender(int chatstate, int gender); +//store the bot name in the chat state +void BotSetChatName(int chatstate, char *name, int client); + diff --git a/code/botlib/be_ai_gen.c b/code/botlib/be_ai_gen.c index b897738..e71c8cf 100644 --- a/code/botlib/be_ai_gen.c +++ b/code/botlib/be_ai_gen.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_memory.h" #include "l_log.h" #include "l_utils.h" @@ -37,11 +37,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_precomp.h" #include "l_struct.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_interface.h" -#include "../game/be_ai_gen.h" +#include "be_ai_gen.h" //=========================================================================== // diff --git a/code/botlib/be_ai_gen.h b/code/botlib/be_ai_gen.h new file mode 100644 index 0000000..2a4b53d --- /dev/null +++ b/code/botlib/be_ai_gen.h @@ -0,0 +1,33 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code 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. + +Quake III Arena source code 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 Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +/***************************************************************************** + * name: be_ai_gen.h + * + * desc: genetic selection + * + * $Archive: /source/code/botlib/be_ai_gen.h $ + * + *****************************************************************************/ + +int GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child); diff --git a/code/botlib/be_ai_goal.c b/code/botlib/be_ai_goal.c index c3f721a..4d53e6c 100644 --- a/code/botlib/be_ai_goal.c +++ b/code/botlib/be_ai_goal.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_utils.h" #include "l_libvar.h" #include "l_memory.h" @@ -38,13 +38,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_precomp.h" #include "l_struct.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_interface.h" #include "be_ai_weight.h" -#include "../game/be_ai_goal.h" -#include "../game/be_ai_move.h" +#include "be_ai_goal.h" +#include "be_ai_move.h" //#define DEBUG_AI_GOAL #ifdef RANDOMIZE diff --git a/code/botlib/be_ai_goal.h b/code/botlib/be_ai_goal.h new file mode 100644 index 0000000..354609d --- /dev/null +++ b/code/botlib/be_ai_goal.h @@ -0,0 +1,118 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code 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. + +Quake III Arena source code 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 Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +/***************************************************************************** + * name: be_ai_goal.h + * + * desc: goal AI + * + * $Archive: /source/code/botlib/be_ai_goal.h $ + * + *****************************************************************************/ + +#define MAX_AVOIDGOALS 256 +#define MAX_GOALSTACK 8 + +#define GFL_NONE 0 +#define GFL_ITEM 1 +#define GFL_ROAM 2 +#define GFL_DROPPED 4 + +//a bot goal +typedef struct bot_goal_s +{ + vec3_t origin; //origin of the goal + int areanum; //area number of the goal + vec3_t mins, maxs; //mins and maxs of the goal + int entitynum; //number of the goal entity + int number; //goal number + int flags; //goal flags + int iteminfo; //item information +} bot_goal_t; + +//reset the whole goal state, but keep the item weights +void BotResetGoalState(int goalstate); +//reset avoid goals +void BotResetAvoidGoals(int goalstate); +//remove the goal with the given number from the avoid goals +void BotRemoveFromAvoidGoals(int goalstate, int number); +//push a goal onto the goal stack +void BotPushGoal(int goalstate, bot_goal_t *goal); +//pop a goal from the goal stack +void BotPopGoal(int goalstate); +//empty the bot's goal stack +void BotEmptyGoalStack(int goalstate); +//dump the avoid goals +void BotDumpAvoidGoals(int goalstate); +//dump the goal stack +void BotDumpGoalStack(int goalstate); +//get the name name of the goal with the given number +void BotGoalName(int number, char *name, int size); +//get the top goal from the stack +int BotGetTopGoal(int goalstate, bot_goal_t *goal); +//get the second goal on the stack +int BotGetSecondGoal(int goalstate, bot_goal_t *goal); +//choose the best long term goal item for the bot +int BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags); +//choose the best nearby goal item for the bot +//the item may not be further away from the current bot position than maxtime +//also the travel time from the nearby goal towards the long term goal may not +//be larger than the travel time towards the long term goal from the current bot position +int BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, + bot_goal_t *ltg, float maxtime); +//returns true if the bot touches the goal +int BotTouchingGoal(vec3_t origin, bot_goal_t *goal); +//returns true if the goal should be visible but isn't +int BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, bot_goal_t *goal); +//search for a goal for the given classname, the index can be used +//as a start point for the search when multiple goals are available with that same classname +int BotGetLevelItemGoal(int index, char *classname, bot_goal_t *goal); +//get the next camp spot in the map +int BotGetNextCampSpotGoal(int num, bot_goal_t *goal); +//get the map location with the given name +int BotGetMapLocationGoal(char *name, bot_goal_t *goal); +//returns the avoid goal time +float BotAvoidGoalTime(int goalstate, int number); +//set the avoid goal time +void BotSetAvoidGoalTime(int goalstate, int number, float avoidtime); +//initializes the items in the level +void BotInitLevelItems(void); +//regularly update dynamic entity items (dropped weapons, flags etc.) +void BotUpdateEntityItems(void); +//interbreed the goal fuzzy logic +void BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child); +//save the goal fuzzy logic to disk +void BotSaveGoalFuzzyLogic(int goalstate, char *filename); +//mutate the goal fuzzy logic +void BotMutateGoalFuzzyLogic(int goalstate, float range); +//loads item weights for the bot +int BotLoadItemWeights(int goalstate, char *filename); +//frees the item weights of the bot +void BotFreeItemWeights(int goalstate); +//returns the handle of a newly allocated goal state +int BotAllocGoalState(int client); +//free the given goal state +void BotFreeGoalState(int handle); +//setup the goal AI +int BotSetupGoalAI(void); +//shut down the goal AI +void BotShutdownGoalAI(void); diff --git a/code/botlib/be_ai_move.c b/code/botlib/be_ai_move.c index 30eefc7..02b8e4a 100644 --- a/code/botlib/be_ai_move.c +++ b/code/botlib/be_ai_move.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_memory.h" #include "l_libvar.h" #include "l_utils.h" @@ -37,21 +37,21 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_precomp.h" #include "l_struct.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_interface.h" -#include "../game/be_ea.h" -#include "../game/be_ai_goal.h" -#include "../game/be_ai_move.h" +#include "be_ea.h" +#include "be_ai_goal.h" +#include "be_ai_move.h" //#define DEBUG_AI_MOVE //#define DEBUG_ELEVATOR //#define DEBUG_GRAPPLE -// bk001204 - redundant bot_avoidspot_t, see ../game/be_ai_move.h +// bk001204 - redundant bot_avoidspot_t, see be_ai_move.h //movement state //NOTE: the moveflags MFL_ONGROUND, MFL_TELEPORTED, MFL_WATERJUMP and diff --git a/code/botlib/be_ai_move.h b/code/botlib/be_ai_move.h new file mode 100644 index 0000000..0aed6d7 --- /dev/null +++ b/code/botlib/be_ai_move.h @@ -0,0 +1,144 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code 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. + +Quake III Arena source code 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 Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +/***************************************************************************** + * name: be_ai_move.h + * + * desc: movement AI + * + * $Archive: /source/code/botlib/be_ai_move.h $ + * + *****************************************************************************/ + +//movement types +#define MOVE_WALK 1 +#define MOVE_CROUCH 2 +#define MOVE_JUMP 4 +#define MOVE_GRAPPLE 8 +#define MOVE_ROCKETJUMP 16 +#define MOVE_BFGJUMP 32 +//move flags +#define MFL_BARRIERJUMP 1 //bot is performing a barrier jump +#define MFL_ONGROUND 2 //bot is in the ground +#define MFL_SWIMMING 4 //bot is swimming +#define MFL_AGAINSTLADDER 8 //bot is against a ladder +#define MFL_WATERJUMP 16 //bot is waterjumping +#define MFL_TELEPORTED 32 //bot is being teleported +#define MFL_GRAPPLEPULL 64 //bot is being pulled by the grapple +#define MFL_ACTIVEGRAPPLE 128 //bot is using the grapple hook +#define MFL_GRAPPLERESET 256 //bot has reset the grapple +#define MFL_WALK 512 //bot should walk slowly +// move result flags +#define MOVERESULT_MOVEMENTVIEW 1 //bot uses view for movement +#define MOVERESULT_SWIMVIEW 2 //bot uses view for swimming +#define MOVERESULT_WAITING 4 //bot is waiting for something +#define MOVERESULT_MOVEMENTVIEWSET 8 //bot has set the view in movement code +#define MOVERESULT_MOVEMENTWEAPON 16 //bot uses weapon for movement +#define MOVERESULT_ONTOPOFOBSTACLE 32 //bot is ontop of obstacle +#define MOVERESULT_ONTOPOF_FUNCBOB 64 //bot is ontop of a func_bobbing +#define MOVERESULT_ONTOPOF_ELEVATOR 128 //bot is ontop of an elevator (func_plat) +#define MOVERESULT_BLOCKEDBYAVOIDSPOT 256 //bot is blocked by an avoid spot +// +#define MAX_AVOIDREACH 1 +#define MAX_AVOIDSPOTS 32 +// avoid spot types +#define AVOID_CLEAR 0 //clear all avoid spots +#define AVOID_ALWAYS 1 //avoid always +#define AVOID_DONTBLOCK 2 //never totally block +// restult types +#define RESULTTYPE_ELEVATORUP 1 //elevator is up +#define RESULTTYPE_WAITFORFUNCBOBBING 2 //waiting for func bobbing to arrive +#define RESULTTYPE_BADGRAPPLEPATH 4 //grapple path is obstructed +#define RESULTTYPE_INSOLIDAREA 8 //stuck in solid area, this is bad + +//structure used to initialize the movement state +//the or_moveflags MFL_ONGROUND, MFL_TELEPORTED and MFL_WATERJUMP come from the playerstate +typedef struct bot_initmove_s +{ + vec3_t origin; //origin of the bot + vec3_t velocity; //velocity of the bot + vec3_t viewoffset; //view offset + int entitynum; //entity number of the bot + int client; //client number of the bot + float thinktime; //time the bot thinks + int presencetype; //presencetype of the bot + vec3_t viewangles; //view angles of the bot + int or_moveflags; //values ored to the movement flags +} bot_initmove_t; + +//NOTE: the ideal_viewangles are only valid if MFL_MOVEMENTVIEW is set +typedef struct bot_moveresult_s +{ + int failure; //true if movement failed all together + int type; //failure or blocked type + int blocked; //true if blocked by an entity + int blockentity; //entity blocking the bot + int traveltype; //last executed travel type + int flags; //result flags + int weapon; //weapon used for movement + vec3_t movedir; //movement direction + vec3_t ideal_viewangles; //ideal viewangles for the movement +} bot_moveresult_t; + +#define bot_moveresult_t_cleared(x) bot_moveresult_t (x) = {0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, {0, 0, 0}} + +// bk001204: from code/botlib/be_ai_move.c +// TTimo 04/12/2001 was moved here to avoid dup defines +typedef struct bot_avoidspot_s +{ + vec3_t origin; + float radius; + int type; +} bot_avoidspot_t; + +//resets the whole move state +void BotResetMoveState(int movestate); +//moves the bot to the given goal +void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, int travelflags); +//moves the bot in the specified direction using the specified type of movement +int BotMoveInDirection(int movestate, vec3_t dir, float speed, int type); +//reset avoid reachability +void BotResetAvoidReach(int movestate); +//resets the last avoid reachability +void BotResetLastAvoidReach(int movestate); +//returns a reachability area if the origin is in one +int BotReachabilityArea(vec3_t origin, int client); +//view target based on movement +int BotMovementViewTarget(int movestate, bot_goal_t *goal, int travelflags, float lookahead, vec3_t target); +//predict the position of a player based on movement towards a goal +int BotPredictVisiblePosition(vec3_t origin, int areanum, bot_goal_t *goal, int travelflags, vec3_t target); +//returns the handle of a newly allocated movestate +int BotAllocMoveState(void); +//frees the movestate with the given handle +void BotFreeMoveState(int handle); +//initialize movement state before performing any movement +void BotInitMoveState(int handle, bot_initmove_t *initmove); +//add a spot to avoid (if type == AVOID_CLEAR all spots are removed) +void BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type); +//must be called every map change +void BotSetBrushModelTypes(void); +//setup movement AI +int BotSetupMoveAI(void); +//shutdown movement AI +void BotShutdownMoveAI(void); + diff --git a/code/botlib/be_ai_weap.c b/code/botlib/be_ai_weap.c index 22d989e..a6fddf8 100644 --- a/code/botlib/be_ai_weap.c +++ b/code/botlib/be_ai_weap.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_libvar.h" #include "l_log.h" #include "l_memory.h" @@ -38,12 +38,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_precomp.h" #include "l_struct.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_interface.h" #include "be_ai_weight.h" //fuzzy weights -#include "../game/be_ai_weap.h" +#include "be_ai_weap.h" //#define DEBUG_AI_WEAP diff --git a/code/botlib/be_ai_weap.h b/code/botlib/be_ai_weap.h new file mode 100644 index 0000000..b78ad68 --- /dev/null +++ b/code/botlib/be_ai_weap.h @@ -0,0 +1,104 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code 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. + +Quake III Arena source code 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 Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +/***************************************************************************** + * name: be_ai_weap.h + * + * desc: weapon AI + * + * $Archive: /source/code/botlib/be_ai_weap.h $ + * + *****************************************************************************/ + +//projectile flags +#define PFL_WINDOWDAMAGE 1 //projectile damages through window +#define PFL_RETURN 2 //set when projectile returns to owner +//weapon flags +#define WFL_FIRERELEASED 1 //set when projectile is fired with key-up event +//damage types +#define DAMAGETYPE_IMPACT 1 //damage on impact +#define DAMAGETYPE_RADIAL 2 //radial damage +#define DAMAGETYPE_VISIBLE 4 //damage to all entities visible to the projectile + +typedef struct projectileinfo_s +{ + char name[MAX_STRINGFIELD]; + char model[MAX_STRINGFIELD]; + int flags; + float gravity; + int damage; + float radius; + int visdamage; + int damagetype; + int healthinc; + float push; + float detonation; + float bounce; + float bouncefric; + float bouncestop; +} projectileinfo_t; + +typedef struct weaponinfo_s +{ + int valid; //true if the weapon info is valid + int number; //number of the weapon + char name[MAX_STRINGFIELD]; + char model[MAX_STRINGFIELD]; + int level; + int weaponindex; + int flags; + char projectile[MAX_STRINGFIELD]; + int numprojectiles; + float hspread; + float vspread; + float speed; + float acceleration; + vec3_t recoil; + vec3_t offset; + vec3_t angleoffset; + float extrazvelocity; + int ammoamount; + int ammoindex; + float activate; + float reload; + float spinup; + float spindown; + projectileinfo_t proj; //pointer to the used projectile +} weaponinfo_t; + +//setup the weapon AI +int BotSetupWeaponAI(void); +//shut down the weapon AI +void BotShutdownWeaponAI(void); +//returns the best weapon to fight with +int BotChooseBestFightWeapon(int weaponstate, int *inventory); +//returns the information of the current weapon +void BotGetWeaponInfo(int weaponstate, int weapon, weaponinfo_t *weaponinfo); +//loads the weapon weights +int BotLoadWeaponWeights(int weaponstate, char *filename); +//returns a handle to a newly allocated weapon state +int BotAllocWeaponState(void); +//frees the weapon state +void BotFreeWeaponState(int weaponstate); +//resets the whole weapon state +void BotResetWeaponState(int weaponstate); diff --git a/code/botlib/be_ai_weight.c b/code/botlib/be_ai_weight.c index 9212519..0e239e4 100644 --- a/code/botlib/be_ai_weight.c +++ b/code/botlib/be_ai_weight.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_memory.h" #include "l_log.h" #include "l_utils.h" @@ -38,8 +38,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_struct.h" #include "l_libvar.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_interface.h" #include "be_ai_weight.h" diff --git a/code/botlib/be_ea.c b/code/botlib/be_ea.c index 5c0dd6c..918a455 100644 --- a/code/botlib/be_ea.c +++ b/code/botlib/be_ea.c @@ -29,12 +29,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_memory.h" #include "l_script.h" #include "l_precomp.h" #include "l_struct.h" -#include "../game/botlib.h" +#include "botlib.h" #include "be_interface.h" #define MAX_USERMOVE 400 diff --git a/code/botlib/be_ea.h b/code/botlib/be_ea.h new file mode 100644 index 0000000..1bc436b --- /dev/null +++ b/code/botlib/be_ea.h @@ -0,0 +1,66 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code 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. + +Quake III Arena source code 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 Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// + +/***************************************************************************** + * name: be_ea.h + * + * desc: elementary actions + * + * $Archive: /source/code/botlib/be_ea.h $ + * + *****************************************************************************/ + +//ClientCommand elementary actions +void EA_Say(int client, char *str); +void EA_SayTeam(int client, char *str); +void EA_Command(int client, char *command ); + +void EA_Action(int client, int action); +void EA_Crouch(int client); +void EA_Walk(int client); +void EA_MoveUp(int client); +void EA_MoveDown(int client); +void EA_MoveForward(int client); +void EA_MoveBack(int client); +void EA_MoveLeft(int client); +void EA_MoveRight(int client); +void EA_Attack(int client); +void EA_Respawn(int client); +void EA_Talk(int client); +void EA_Gesture(int client); +void EA_Use(int client); + +//regular elementary actions +void EA_SelectWeapon(int client, int weapon); +void EA_Jump(int client); +void EA_DelayedJump(int client); +void EA_Move(int client, vec3_t dir, float speed); +void EA_View(int client, vec3_t viewangles); + +//send regular input to the server +void EA_EndRegular(int client, float thinktime); +void EA_GetInput(int client, float thinktime, bot_input_t *input); +void EA_ResetInput(int client); +//setup and shutdown routines +int EA_Setup(void); +void EA_Shutdown(void); diff --git a/code/botlib/be_interface.c b/code/botlib/be_interface.c index b4f2d3c..efff32f 100644 --- a/code/botlib/be_interface.c +++ b/code/botlib/be_interface.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_memory.h" #include "l_log.h" #include "l_libvar.h" @@ -37,20 +37,20 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_precomp.h" #include "l_struct.h" #include "aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "botlib.h" +#include "be_aas.h" #include "be_aas_funcs.h" #include "be_aas_def.h" #include "be_interface.h" -#include "../game/be_ea.h" +#include "be_ea.h" #include "be_ai_weight.h" -#include "../game/be_ai_goal.h" -#include "../game/be_ai_move.h" -#include "../game/be_ai_weap.h" -#include "../game/be_ai_chat.h" -#include "../game/be_ai_char.h" -#include "../game/be_ai_gen.h" +#include "be_ai_goal.h" +#include "be_ai_move.h" +#include "be_ai_weap.h" +#include "be_ai_chat.h" +#include "be_ai_char.h" +#include "be_ai_gen.h" //library globals in a structure botlib_globals_t botlibglobals; diff --git a/code/botlib/botlib.h b/code/botlib/botlib.h new file mode 100644 index 0000000..687affe --- /dev/null +++ b/code/botlib/botlib.h @@ -0,0 +1,516 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code 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. + +Quake III Arena source code 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 Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +/***************************************************************************** + * name: botlib.h + * + * desc: bot AI library + * + * $Archive: /source/code/game/botai.h $ + * + *****************************************************************************/ + +#define BOTLIB_API_VERSION 2 + +struct aas_clientmove_s; +struct aas_entityinfo_s; +struct aas_areainfo_s; +struct aas_altroutegoal_s; +struct aas_predictroute_s; +struct bot_consolemessage_s; +struct bot_match_s; +struct bot_goal_s; +struct bot_moveresult_s; +struct bot_initmove_s; +struct weaponinfo_s; + +#define BOTFILESBASEFOLDER "botfiles" +//debug line colors +#define LINECOLOR_NONE -1 +#define LINECOLOR_RED 1//0xf2f2f0f0L +#define LINECOLOR_GREEN 2//0xd0d1d2d3L +#define LINECOLOR_BLUE 3//0xf3f3f1f1L +#define LINECOLOR_YELLOW 4//0xdcdddedfL +#define LINECOLOR_ORANGE 5//0xe0e1e2e3L + +//Print types +#define PRT_MESSAGE 1 +#define PRT_WARNING 2 +#define PRT_ERROR 3 +#define PRT_FATAL 4 +#define PRT_EXIT 5 + +//console message types +#define CMS_NORMAL 0 +#define CMS_CHAT 1 + +//botlib error codes +#define BLERR_NOERROR 0 //no error +#define BLERR_LIBRARYNOTSETUP 1 //library not setup +#define BLERR_INVALIDENTITYNUMBER 2 //invalid entity number +#define BLERR_NOAASFILE 3 //no AAS file available +#define BLERR_CANNOTOPENAASFILE 4 //cannot open AAS file +#define BLERR_WRONGAASFILEID 5 //incorrect AAS file id +#define BLERR_WRONGAASFILEVERSION 6 //incorrect AAS file version +#define BLERR_CANNOTREADAASLUMP 7 //cannot read AAS file lump +#define BLERR_CANNOTLOADICHAT 8 //cannot load initial chats +#define BLERR_CANNOTLOADITEMWEIGHTS 9 //cannot load item weights +#define BLERR_CANNOTLOADITEMCONFIG 10 //cannot load item config +#define BLERR_CANNOTLOADWEAPONWEIGHTS 11 //cannot load weapon weights +#define BLERR_CANNOTLOADWEAPONCONFIG 12 //cannot load weapon config + +//action flags +#define ACTION_ATTACK 0x0000001 +#define ACTION_USE 0x0000002 +#define ACTION_RESPAWN 0x0000008 +#define ACTION_JUMP 0x0000010 +#define ACTION_MOVEUP 0x0000020 +#define ACTION_CROUCH 0x0000080 +#define ACTION_MOVEDOWN 0x0000100 +#define ACTION_MOVEFORWARD 0x0000200 +#define ACTION_MOVEBACK 0x0000800 +#define ACTION_MOVELEFT 0x0001000 +#define ACTION_MOVERIGHT 0x0002000 +#define ACTION_DELAYEDJUMP 0x0008000 +#define ACTION_TALK 0x0010000 +#define ACTION_GESTURE 0x0020000 +#define ACTION_WALK 0x0080000 +#define ACTION_AFFIRMATIVE 0x0100000 +#define ACTION_NEGATIVE 0x0200000 +#define ACTION_GETFLAG 0x0800000 +#define ACTION_GUARDBASE 0x1000000 +#define ACTION_PATROL 0x2000000 +#define ACTION_FOLLOWME 0x8000000 + +//the bot input, will be converted to an usercmd_t +typedef struct bot_input_s +{ + float thinktime; //time since last output (in seconds) + vec3_t dir; //movement direction + float speed; //speed in the range [0, 400] + vec3_t viewangles; //the view angles + int actionflags; //one of the ACTION_? flags + int weapon; //weapon to use +} bot_input_t; + +#ifndef BSPTRACE + +#define BSPTRACE + +//bsp_trace_t hit surface +typedef struct bsp_surface_s +{ + char name[16]; + int flags; + int value; +} bsp_surface_t; + +//remove the bsp_trace_s structure definition l8r on +//a trace is returned when a box is swept through the world +typedef struct bsp_trace_s +{ + qboolean allsolid; // if true, plane is not valid + qboolean startsolid; // if true, the initial point was in a solid area + float fraction; // time completed, 1.0 = didn't hit anything + vec3_t endpos; // final position + cplane_t plane; // surface normal at impact + float exp_dist; // expanded plane distance + int sidenum; // number of the brush side hit + bsp_surface_t surface; // the hit point surface + int contents; // contents on other side of surface hit + int ent; // number of entity hit +} bsp_trace_t; + +#endif // BSPTRACE + +//entity state +typedef struct bot_entitystate_s +{ + int type; // entity type + int flags; // entity flags + vec3_t origin; // origin of the entity + vec3_t angles; // angles of the model + vec3_t old_origin; // for lerping + vec3_t mins; // bounding box minimums + vec3_t maxs; // bounding box maximums + int groundent; // ground entity + int solid; // solid type + int modelindex; // model used + int modelindex2; // weapons, CTF flags, etc + int frame; // model frame number + int event; // impulse events -- muzzle flashes, footsteps, etc + int eventParm; // even parameter + int powerups; // bit flags + int weapon; // determines weapon and flash model, etc + int legsAnim; // mask off ANIM_TOGGLEBIT + int torsoAnim; // mask off ANIM_TOGGLEBIT +} bot_entitystate_t; + +//bot AI library exported functions +typedef struct botlib_import_s +{ + //print messages from the bot library + void (QDECL *Print)(int type, char *fmt, ...); + //trace a bbox through the world + void (*Trace)(bsp_trace_t *trace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask); + //trace a bbox against a specific entity + void (*EntityTrace)(bsp_trace_t *trace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int entnum, int contentmask); + //retrieve the contents at the given point + int (*PointContents)(vec3_t point); + //check if the point is in potential visible sight + int (*inPVS)(vec3_t p1, vec3_t p2); + //retrieve the BSP entity data lump + char *(*BSPEntityData)(void); + // + void (*BSPModelMinsMaxsOrigin)(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin); + //send a bot client command + void (*BotClientCommand)(int client, char *command); + //memory allocation + void *(*GetMemory)(int size); // allocate from Zone + void (*FreeMemory)(void *ptr); // free memory from Zone + int (*AvailableMemory)(void); // available Zone memory + void *(*HunkAlloc)(int size); // allocate from hunk + //file system access + int (*FS_FOpenFile)( const char *qpath, fileHandle_t *file, fsMode_t mode ); + int (*FS_Read)( void *buffer, int len, fileHandle_t f ); + int (*FS_Write)( const void *buffer, int len, fileHandle_t f ); + void (*FS_FCloseFile)( fileHandle_t f ); + int (*FS_Seek)( fileHandle_t f, long offset, int origin ); + //debug visualisation stuff + int (*DebugLineCreate)(void); + void (*DebugLineDelete)(int line); + void (*DebugLineShow)(int line, vec3_t start, vec3_t end, int color); + // + int (*DebugPolygonCreate)(int color, int numPoints, vec3_t *points); + void (*DebugPolygonDelete)(int id); +} botlib_import_t; + +typedef struct aas_export_s +{ + //----------------------------------- + // be_aas_entity.h + //----------------------------------- + void (*AAS_EntityInfo)(int entnum, struct aas_entityinfo_s *info); + //----------------------------------- + // be_aas_main.h + //----------------------------------- + int (*AAS_Initialized)(void); + void (*AAS_PresenceTypeBoundingBox)(int presencetype, vec3_t mins, vec3_t maxs); + float (*AAS_Time)(void); + //-------------------------------------------- + // be_aas_sample.c + //-------------------------------------------- + int (*AAS_PointAreaNum)(vec3_t point); + int (*AAS_PointReachabilityAreaIndex)( vec3_t point ); + int (*AAS_TraceAreas)(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas); + int (*AAS_BBoxAreas)(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas); + int (*AAS_AreaInfo)( int areanum, struct aas_areainfo_s *info ); + //-------------------------------------------- + // be_aas_bspq3.c + //-------------------------------------------- + int (*AAS_PointContents)(vec3_t point); + int (*AAS_NextBSPEntity)(int ent); + int (*AAS_ValueForBSPEpairKey)(int ent, char *key, char *value, int size); + int (*AAS_VectorForBSPEpairKey)(int ent, char *key, vec3_t v); + int (*AAS_FloatForBSPEpairKey)(int ent, char *key, float *value); + int (*AAS_IntForBSPEpairKey)(int ent, char *key, int *value); + //-------------------------------------------- + // be_aas_reach.c + //-------------------------------------------- + int (*AAS_AreaReachability)(int areanum); + //-------------------------------------------- + // be_aas_route.c + //-------------------------------------------- + int (*AAS_AreaTravelTimeToGoalArea)(int areanum, vec3_t origin, int goalareanum, int travelflags); + int (*AAS_EnableRoutingArea)(int areanum, int enable); + int (*AAS_PredictRoute)(struct aas_predictroute_s *route, int areanum, vec3_t origin, + int goalareanum, int travelflags, int maxareas, int maxtime, + int stopevent, int stopcontents, int stoptfl, int stopareanum); + //-------------------------------------------- + // be_aas_altroute.c + //-------------------------------------------- + int (*AAS_AlternativeRouteGoals)(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags, + struct aas_altroutegoal_s *altroutegoals, int maxaltroutegoals, + int type); + //-------------------------------------------- + // be_aas_move.c + //-------------------------------------------- + int (*AAS_Swimming)(vec3_t origin); + int (*AAS_PredictClientMovement)(struct aas_clientmove_s *move, + int entnum, vec3_t origin, + int presencetype, int onground, + vec3_t velocity, vec3_t cmdmove, + int cmdframes, + int maxframes, float frametime, + int stopevent, int stopareanum, int visualize); +} aas_export_t; + +typedef struct ea_export_s +{ + //ClientCommand elementary actions + void (*EA_Command)(int client, char *command ); + void (*EA_Say)(int client, char *str); + void (*EA_SayTeam)(int client, char *str); + // + void (*EA_Action)(int client, int action); + void (*EA_Gesture)(int client); + void (*EA_Talk)(int client); + void (*EA_Attack)(int client); + void (*EA_Use)(int client); + void (*EA_Respawn)(int client); + void (*EA_MoveUp)(int client); + void (*EA_MoveDown)(int client); + void (*EA_MoveForward)(int client); + void (*EA_MoveBack)(int client); + void (*EA_MoveLeft)(int client); + void (*EA_MoveRight)(int client); + void (*EA_Crouch)(int client); + + void (*EA_SelectWeapon)(int client, int weapon); + void (*EA_Jump)(int client); + void (*EA_DelayedJump)(int client); + void (*EA_Move)(int client, vec3_t dir, float speed); + void (*EA_View)(int client, vec3_t viewangles); + //send regular input to the server + void (*EA_EndRegular)(int client, float thinktime); + void (*EA_GetInput)(int client, float thinktime, bot_input_t *input); + void (*EA_ResetInput)(int client); +} ea_export_t; + +typedef struct ai_export_s +{ + //----------------------------------- + // be_ai_char.h + //----------------------------------- + int (*BotLoadCharacter)(char *charfile, float skill); + void (*BotFreeCharacter)(int character); + float (*Characteristic_Float)(int character, int index); + float (*Characteristic_BFloat)(int character, int index, float min, float max); + int (*Characteristic_Integer)(int character, int index); + int (*Characteristic_BInteger)(int character, int index, int min, int max); + void (*Characteristic_String)(int character, int index, char *buf, int size); + //----------------------------------- + // be_ai_chat.h + //----------------------------------- + int (*BotAllocChatState)(void); + void (*BotFreeChatState)(int handle); + void (*BotQueueConsoleMessage)(int chatstate, int type, char *message); + void (*BotRemoveConsoleMessage)(int chatstate, int handle); + int (*BotNextConsoleMessage)(int chatstate, struct bot_consolemessage_s *cm); + int (*BotNumConsoleMessages)(int chatstate); + void (*BotInitialChat)(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); + int (*BotNumInitialChats)(int chatstate, char *type); + int (*BotReplyChat)(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); + int (*BotChatLength)(int chatstate); + void (*BotEnterChat)(int chatstate, int client, int sendto); + void (*BotGetChatMessage)(int chatstate, char *buf, int size); + int (*StringContains)(char *str1, char *str2, int casesensitive); + int (*BotFindMatch)(char *str, struct bot_match_s *match, unsigned long int context); + void (*BotMatchVariable)(struct bot_match_s *match, int variable, char *buf, int size); + void (*UnifyWhiteSpaces)(char *string); + void (*BotReplaceSynonyms)(char *string, unsigned long int context); + int (*BotLoadChatFile)(int chatstate, char *chatfile, char *chatname); + void (*BotSetChatGender)(int chatstate, int gender); + void (*BotSetChatName)(int chatstate, char *name, int client); + //----------------------------------- + // be_ai_goal.h + //----------------------------------- + void (*BotResetGoalState)(int goalstate); + void (*BotResetAvoidGoals)(int goalstate); + void (*BotRemoveFromAvoidGoals)(int goalstate, int number); + void (*BotPushGoal)(int goalstate, struct bot_goal_s *goal); + void (*BotPopGoal)(int goalstate); + void (*BotEmptyGoalStack)(int goalstate); + void (*BotDumpAvoidGoals)(int goalstate); + void (*BotDumpGoalStack)(int goalstate); + void (*BotGoalName)(int number, char *name, int size); + int (*BotGetTopGoal)(int goalstate, struct bot_goal_s *goal); + int (*BotGetSecondGoal)(int goalstate, struct bot_goal_s *goal); + int (*BotChooseLTGItem)(int goalstate, vec3_t origin, int *inventory, int travelflags); + int (*BotChooseNBGItem)(int goalstate, vec3_t origin, int *inventory, int travelflags, + struct bot_goal_s *ltg, float maxtime); + int (*BotTouchingGoal)(vec3_t origin, struct bot_goal_s *goal); + int (*BotItemGoalInVisButNotVisible)(int viewer, vec3_t eye, vec3_t viewangles, struct bot_goal_s *goal); + int (*BotGetLevelItemGoal)(int index, char *classname, struct bot_goal_s *goal); + int (*BotGetNextCampSpotGoal)(int num, struct bot_goal_s *goal); + int (*BotGetMapLocationGoal)(char *name, struct bot_goal_s *goal); + float (*BotAvoidGoalTime)(int goalstate, int number); + void (*BotSetAvoidGoalTime)(int goalstate, int number, float avoidtime); + void (*BotInitLevelItems)(void); + void (*BotUpdateEntityItems)(void); + int (*BotLoadItemWeights)(int goalstate, char *filename); + void (*BotFreeItemWeights)(int goalstate); + void (*BotInterbreedGoalFuzzyLogic)(int parent1, int parent2, int child); + void (*BotSaveGoalFuzzyLogic)(int goalstate, char *filename); + void (*BotMutateGoalFuzzyLogic)(int goalstate, float range); + int (*BotAllocGoalState)(int client); + void (*BotFreeGoalState)(int handle); + //----------------------------------- + // be_ai_move.h + //----------------------------------- + void (*BotResetMoveState)(int movestate); + void (*BotMoveToGoal)(struct bot_moveresult_s *result, int movestate, struct bot_goal_s *goal, int travelflags); + int (*BotMoveInDirection)(int movestate, vec3_t dir, float speed, int type); + void (*BotResetAvoidReach)(int movestate); + void (*BotResetLastAvoidReach)(int movestate); + int (*BotReachabilityArea)(vec3_t origin, int testground); + int (*BotMovementViewTarget)(int movestate, struct bot_goal_s *goal, int travelflags, float lookahead, vec3_t target); + int (*BotPredictVisiblePosition)(vec3_t origin, int areanum, struct bot_goal_s *goal, int travelflags, vec3_t target); + int (*BotAllocMoveState)(void); + void (*BotFreeMoveState)(int handle); + void (*BotInitMoveState)(int handle, struct bot_initmove_s *initmove); + void (*BotAddAvoidSpot)(int movestate, vec3_t origin, float radius, int type); + //----------------------------------- + // be_ai_weap.h + //----------------------------------- + int (*BotChooseBestFightWeapon)(int weaponstate, int *inventory); + void (*BotGetWeaponInfo)(int weaponstate, int weapon, struct weaponinfo_s *weaponinfo); + int (*BotLoadWeaponWeights)(int weaponstate, char *filename); + int (*BotAllocWeaponState)(void); + void (*BotFreeWeaponState)(int weaponstate); + void (*BotResetWeaponState)(int weaponstate); + //----------------------------------- + // be_ai_gen.h + //----------------------------------- + int (*GeneticParentsAndChildSelection)(int numranks, float *ranks, int *parent1, int *parent2, int *child); +} ai_export_t; + +//bot AI library imported functions +typedef struct botlib_export_s +{ + //Area Awareness System functions + aas_export_t aas; + //Elementary Action functions + ea_export_t ea; + //AI functions + ai_export_t ai; + //setup the bot library, returns BLERR_ + int (*BotLibSetup)(void); + //shutdown the bot library, returns BLERR_ + int (*BotLibShutdown)(void); + //sets a library variable returns BLERR_ + int (*BotLibVarSet)(char *var_name, char *value); + //gets a library variable returns BLERR_ + int (*BotLibVarGet)(char *var_name, char *value, int size); + + //sets a C-like define returns BLERR_ + int (*PC_AddGlobalDefine)(char *string); + int (*PC_LoadSourceHandle)(const char *filename); + int (*PC_FreeSourceHandle)(int handle); + int (*PC_ReadTokenHandle)(int handle, pc_token_t *pc_token); + int (*PC_SourceFileAndLine)(int handle, char *filename, int *line); + + //start a frame in the bot library + int (*BotLibStartFrame)(float time); + //load a new map in the bot library + int (*BotLibLoadMap)(const char *mapname); + //entity updates + int (*BotLibUpdateEntity)(int ent, bot_entitystate_t *state); + //just for testing + int (*Test)(int parm0, char *parm1, vec3_t parm2, vec3_t parm3); +} botlib_export_t; + +//linking of bot library +botlib_export_t *GetBotLibAPI( int apiVersion, botlib_import_t *import ); + +/* Library variables: + +name: default: module(s): description: + +"basedir" "" l_utils.c base directory +"gamedir" "" l_utils.c game directory +"cddir" "" l_utils.c CD directory + +"log" "0" l_log.c enable/disable creating a log file +"maxclients" "4" be_interface.c maximum number of clients +"maxentities" "1024" be_interface.c maximum number of entities +"bot_developer" "0" be_interface.c bot developer mode + +"phys_friction" "6" be_aas_move.c ground friction +"phys_stopspeed" "100" be_aas_move.c stop speed +"phys_gravity" "800" be_aas_move.c gravity value +"phys_waterfriction" "1" be_aas_move.c water friction +"phys_watergravity" "400" be_aas_move.c gravity in water +"phys_maxvelocity" "320" be_aas_move.c maximum velocity +"phys_maxwalkvelocity" "320" be_aas_move.c maximum walk velocity +"phys_maxcrouchvelocity" "100" be_aas_move.c maximum crouch velocity +"phys_maxswimvelocity" "150" be_aas_move.c maximum swim velocity +"phys_walkaccelerate" "10" be_aas_move.c walk acceleration +"phys_airaccelerate" "1" be_aas_move.c air acceleration +"phys_swimaccelerate" "4" be_aas_move.c swim acceleration +"phys_maxstep" "18" be_aas_move.c maximum step height +"phys_maxsteepness" "0.7" be_aas_move.c maximum floor steepness +"phys_maxbarrier" "32" be_aas_move.c maximum barrier height +"phys_maxwaterjump" "19" be_aas_move.c maximum waterjump height +"phys_jumpvel" "270" be_aas_move.c jump z velocity +"phys_falldelta5" "40" be_aas_move.c +"phys_falldelta10" "60" be_aas_move.c +"rs_waterjump" "400" be_aas_move.c +"rs_teleport" "50" be_aas_move.c +"rs_barrierjump" "100" be_aas_move.c +"rs_startcrouch" "300" be_aas_move.c +"rs_startgrapple" "500" be_aas_move.c +"rs_startwalkoffledge" "70" be_aas_move.c +"rs_startjump" "300" be_aas_move.c +"rs_rocketjump" "500" be_aas_move.c +"rs_bfgjump" "500" be_aas_move.c +"rs_jumppad" "250" be_aas_move.c +"rs_aircontrolledjumppad" "300" be_aas_move.c +"rs_funcbob" "300" be_aas_move.c +"rs_startelevator" "50" be_aas_move.c +"rs_falldamage5" "300" be_aas_move.c +"rs_falldamage10" "500" be_aas_move.c +"rs_maxjumpfallheight" "450" be_aas_move.c + +"max_aaslinks" "4096" be_aas_sample.c maximum links in the AAS +"max_routingcache" "4096" be_aas_route.c maximum routing cache size in KB +"forceclustering" "0" be_aas_main.c force recalculation of clusters +"forcereachability" "0" be_aas_main.c force recalculation of reachabilities +"forcewrite" "0" be_aas_main.c force writing of aas file +"aasoptimize" "0" be_aas_main.c enable aas optimization +"sv_mapChecksum" "0" be_aas_main.c BSP file checksum +"bot_visualizejumppads" "0" be_aas_reach.c visualize jump pads + +"bot_reloadcharacters" "0" - reload bot character files +"ai_gametype" "0" be_ai_goal.c game type +"droppedweight" "1000" be_ai_goal.c additional dropped item weight +"weapindex_rocketlauncher" "5" be_ai_move.c rl weapon index for rocket jumping +"weapindex_bfg10k" "9" be_ai_move.c bfg weapon index for bfg jumping +"weapindex_grapple" "10" be_ai_move.c grapple weapon index for grappling +"entitytypemissile" "3" be_ai_move.c ET_MISSILE +"offhandgrapple" "0" be_ai_move.c enable off hand grapple hook +"cmd_grappleon" "grappleon" be_ai_move.c command to activate off hand grapple +"cmd_grappleoff" "grappleoff" be_ai_move.c command to deactivate off hand grapple +"itemconfig" "items.c" be_ai_goal.c item configuration file +"weaponconfig" "weapons.c" be_ai_weap.c weapon configuration file +"synfile" "syn.c" be_ai_chat.c file with synonyms +"rndfile" "rnd.c" be_ai_chat.c file with random strings +"matchfile" "match.c" be_ai_chat.c file with match strings +"nochat" "0" be_ai_chat.c disable chats +"max_messages" "1024" be_ai_chat.c console message heap size +"max_weaponinfo" "32" be_ai_weap.c maximum number of weapon info +"max_projectileinfo" "32" be_ai_weap.c maximum number of projectile info +"max_iteminfo" "256" be_ai_goal.c maximum number of item info +"max_levelitems" "256" be_ai_goal.c maximum number of level items + +*/ + diff --git a/code/botlib/l_crc.c b/code/botlib/l_crc.c index 8b1067b..b270045 100644 --- a/code/botlib/l_crc.c +++ b/code/botlib/l_crc.c @@ -33,8 +33,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "../game/q_shared.h" -#include "../game/botlib.h" +#include "../qcommon/q_shared.h" +#include "botlib.h" #include "be_interface.h" //for botimport.Print diff --git a/code/botlib/l_libvar.c b/code/botlib/l_libvar.c index a8629c8..abd17bd 100644 --- a/code/botlib/l_libvar.c +++ b/code/botlib/l_libvar.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "l_memory.h" #include "l_libvar.h" diff --git a/code/botlib/l_log.c b/code/botlib/l_log.c index 7b1a346..bd62244 100644 --- a/code/botlib/l_log.c +++ b/code/botlib/l_log.c @@ -33,8 +33,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "../game/q_shared.h" -#include "../game/botlib.h" +#include "../qcommon/q_shared.h" +#include "botlib.h" #include "be_interface.h" //for botimport.Print #include "l_libvar.h" diff --git a/code/botlib/l_memory.c b/code/botlib/l_memory.c index 7bc12f6..9cdd408 100644 --- a/code/botlib/l_memory.c +++ b/code/botlib/l_memory.c @@ -29,8 +29,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#include "../game/q_shared.h" -#include "../game/botlib.h" +#include "../qcommon/q_shared.h" +#include "botlib.h" #include "l_log.h" #include "be_interface.h" diff --git a/code/botlib/l_precomp.c b/code/botlib/l_precomp.c index 5122931..54199c7 100644 --- a/code/botlib/l_precomp.c +++ b/code/botlib/l_precomp.c @@ -53,8 +53,8 @@ typedef enum {qfalse, qtrue} qboolean; #endif //SCREWUP #ifdef BOTLIB -#include "../game/q_shared.h" -#include "../game/botlib.h" +#include "../qcommon/q_shared.h" +#include "botlib.h" #include "be_interface.h" #include "l_memory.h" #include "l_script.h" diff --git a/code/botlib/l_script.c b/code/botlib/l_script.c index e782e7f..c4af638 100644 --- a/code/botlib/l_script.c +++ b/code/botlib/l_script.c @@ -49,8 +49,8 @@ typedef enum {qfalse, qtrue} qboolean; #ifdef BOTLIB //include files for usage in the bot library -#include "../game/q_shared.h" -#include "../game/botlib.h" +#include "../qcommon/q_shared.h" +#include "botlib.h" #include "be_interface.h" #include "l_script.h" #include "l_memory.h" diff --git a/code/botlib/l_struct.c b/code/botlib/l_struct.c index c628821..ed47c39 100644 --- a/code/botlib/l_struct.c +++ b/code/botlib/l_struct.c @@ -30,8 +30,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ #ifdef BOTLIB -#include "../game/q_shared.h" -#include "../game/botlib.h" //for the include of be_interface.h +#include "../qcommon/q_shared.h" +#include "botlib.h" //for the include of be_interface.h #include "l_script.h" #include "l_precomp.h" #include "l_struct.h" diff --git a/code/bspc/aas_create.c b/code/bspc/aas_create.c index 1705362..733724b 100644 --- a/code/bspc/aas_create.c +++ b/code/bspc/aas_create.c @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "aas_edgemelting.h" #include "aas_prunenodes.h" #include "aas_cfg.h" -#include "../game/surfaceflags.h" +#include "../qcommon/surfaceflags.h" //#define AW_DEBUG //#define L_DEBUG diff --git a/code/bspc/aas_map.c b/code/bspc/aas_map.c index 10c616a..7125a92 100644 --- a/code/bspc/aas_map.c +++ b/code/bspc/aas_map.c @@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../botlib/aasfile.h" //aas_bbox_t #include "aas_store.h" //AAS_MAX_BBOXES #include "aas_cfg.h" -#include "../game/surfaceflags.h" +#include "../qcommon/surfaceflags.h" #define SPAWNFLAG_NOT_EASY 0x00000100 #define SPAWNFLAG_NOT_MEDIUM 0x00000200 diff --git a/code/bspc/aas_store.h b/code/bspc/aas_store.h index 063adbe..58ea1c1 100644 --- a/code/bspc/aas_store.h +++ b/code/bspc/aas_store.h @@ -36,7 +36,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define AAS_MAX_CLUSTERS 65536 #define BSPCINCLUDE -#include "../game/be_aas.h" +#include "../botlib/be_aas.h" #include "../botlib/be_aas_def.h" /* diff --git a/code/bspc/be_aas_bspc.c b/code/bspc/be_aas_bspc.c index 9473287..a569eb7 100644 --- a/code/bspc/be_aas_bspc.c +++ b/code/bspc/be_aas_bspc.c @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../bspc/l_log.h" #include "../bspc/l_qfiles.h" #include "../botlib/l_memory.h" @@ -28,8 +28,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../botlib/l_precomp.h" #include "../botlib/l_struct.h" #include "../botlib/aasfile.h" -#include "../game/botlib.h" -#include "../game/be_aas.h" +#include "../botlib/botlib.h" +#include "../botlib/be_aas.h" #include "../botlib/be_aas_def.h" #include "../qcommon/cm_public.h" diff --git a/code/bspc/map_q3.c b/code/bspc/map_q3.c index 375100c..aed76ea 100644 --- a/code/bspc/map_q3.c +++ b/code/bspc/map_q3.c @@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "aas_map.h" //AAS_CreateMapBrushes #include "l_bsp_q3.h" #include "../qcommon/cm_patch.h" -#include "../game/surfaceflags.h" +#include "../qcommon/surfaceflags.h" #define NODESTACKSIZE 1024 diff --git a/code/cgame/cg_local.h b/code/cgame/cg_local.h index 27ec4fc..be502fc 100644 --- a/code/cgame/cg_local.h +++ b/code/cgame/cg_local.h @@ -20,8 +20,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ // -#include "../game/q_shared.h" -#include "tr_types.h" +#include "../qcommon/q_shared.h" +#include "../renderer/tr_types.h" #include "../game/bg_public.h" #include "cg_public.h" diff --git a/code/cgame/tr_types.h b/code/cgame/tr_types.h deleted file mode 100644 index d68a174..0000000 --- a/code/cgame/tr_types.h +++ /dev/null @@ -1,229 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code 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. - -Quake III Arena source code 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 Foobar; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// -#ifndef __TR_TYPES_H -#define __TR_TYPES_H - - -#define MAX_DLIGHTS 32 // can't be increased, because bit flags are used on surfaces -#define MAX_ENTITIES 1023 // can't be increased without changing drawsurf bit packing - -// renderfx flags -#define RF_MINLIGHT 1 // allways have some light (viewmodel, some items) -#define RF_THIRD_PERSON 2 // don't draw through eyes, only mirrors (player bodies, chat sprites) -#define RF_FIRST_PERSON 4 // only draw through eyes (view weapon, damage blood blob) -#define RF_DEPTHHACK 8 // for view weapon Z crunching -#define RF_NOSHADOW 64 // don't add stencil shadows - -#define RF_LIGHTING_ORIGIN 128 // use refEntity->lightingOrigin instead of refEntity->origin - // for lighting. This allows entities to sink into the floor - // with their origin going solid, and allows all parts of a - // player to get the same lighting -#define RF_SHADOW_PLANE 256 // use refEntity->shadowPlane -#define RF_WRAP_FRAMES 512 // mod the model frames by the maxframes to allow continuous - // animation without needing to know the frame count - -// refdef flags -#define RDF_NOWORLDMODEL 1 // used for player configuration screen -#define RDF_HYPERSPACE 4 // teleportation effect - -typedef struct { - vec3_t xyz; - float st[2]; - byte modulate[4]; -} polyVert_t; - -typedef struct poly_s { - qhandle_t hShader; - int numVerts; - polyVert_t *verts; -} poly_t; - -typedef enum { - RT_MODEL, - RT_POLY, - RT_SPRITE, - RT_BEAM, - RT_RAIL_CORE, - RT_RAIL_RINGS, - RT_LIGHTNING, - RT_PORTALSURFACE, // doesn't draw anything, just info for portals - - RT_MAX_REF_ENTITY_TYPE -} refEntityType_t; - -typedef struct { - refEntityType_t reType; - int renderfx; - - qhandle_t hModel; // opaque type outside refresh - - // most recent data - vec3_t lightingOrigin; // so multi-part models can be lit identically (RF_LIGHTING_ORIGIN) - float shadowPlane; // projection shadows go here, stencils go slightly lower - - vec3_t axis[3]; // rotation vectors - qboolean nonNormalizedAxes; // axis are not normalized, i.e. they have scale - float origin[3]; // also used as MODEL_BEAM's "from" - int frame; // also used as MODEL_BEAM's diameter - - // previous data for frame interpolation - float oldorigin[3]; // also used as MODEL_BEAM's "to" - int oldframe; - float backlerp; // 0.0 = current, 1.0 = old - - // texturing - int skinNum; // inline skin index - qhandle_t customSkin; // NULL for default skin - qhandle_t customShader; // use one image for the entire thing - - // misc - byte shaderRGBA[4]; // colors used by rgbgen entity shaders - float shaderTexCoord[2]; // texture coordinates used by tcMod entity modifiers - float shaderTime; // subtracted from refdef time to control effect start times - - // extra sprite information - float radius; - float rotation; -} refEntity_t; - - -#define MAX_RENDER_STRINGS 8 -#define MAX_RENDER_STRING_LENGTH 32 - -typedef struct { - int x, y, width, height; - float fov_x, fov_y; - vec3_t vieworg; - vec3_t viewaxis[3]; // transformation matrix - - // time in milliseconds for shader effects and other time dependent rendering issues - int time; - - int rdflags; // RDF_NOWORLDMODEL, etc - - // 1 bits will prevent the associated area from rendering at all - byte areamask[MAX_MAP_AREA_BYTES]; - - // text messages for deform text shaders - char text[MAX_RENDER_STRINGS][MAX_RENDER_STRING_LENGTH]; -} refdef_t; - - -typedef enum { - STEREO_CENTER, - STEREO_LEFT, - STEREO_RIGHT -} stereoFrame_t; - - -/* -** glconfig_t -** -** Contains variables specific to the OpenGL configuration -** being run right now. These are constant once the OpenGL -** subsystem is initialized. -*/ -typedef enum { - TC_NONE, - TC_S3TC -} textureCompression_t; - -typedef enum { - GLDRV_ICD, // driver is integrated with window system - // WARNING: there are tests that check for - // > GLDRV_ICD for minidriverness, so this - // should always be the lowest value in this - // enum set - GLDRV_STANDALONE, // driver is a non-3Dfx standalone driver - GLDRV_VOODOO // driver is a 3Dfx standalone driver -} glDriverType_t; - -typedef enum { - GLHW_GENERIC, // where everthing works the way it should - GLHW_3DFX_2D3D, // Voodoo Banshee or Voodoo3, relevant since if this is - // the hardware type then there can NOT exist a secondary - // display adapter - GLHW_RIVA128, // where you can't interpolate alpha - GLHW_RAGEPRO, // where you can't modulate alpha on alpha textures - GLHW_PERMEDIA2 // where you don't have src*dst -} glHardwareType_t; - -typedef struct { - char renderer_string[MAX_STRING_CHARS]; - char vendor_string[MAX_STRING_CHARS]; - char version_string[MAX_STRING_CHARS]; - char extensions_string[BIG_INFO_STRING]; - - int maxTextureSize; // queried from GL - int maxActiveTextures; // multitexture ability - - int colorBits, depthBits, stencilBits; - - glDriverType_t driverType; - glHardwareType_t hardwareType; - - qboolean deviceSupportsGamma; - textureCompression_t textureCompression; - qboolean textureEnvAddAvailable; - - int vidWidth, vidHeight; - // aspect is the screen's physical width / height, which may be different - // than scrWidth / scrHeight if the pixels are non-square - // normal screens should be 4/3, but wide aspect monitors may be 16/9 - float windowAspect; - - int displayFrequency; - - // synonymous with "does rendering consume the entire screen?", therefore - // a Voodoo or Voodoo2 will have this set to TRUE, as will a Win32 ICD that - // used CDS. - qboolean isFullscreen; - qboolean stereoEnabled; - qboolean smpActive; // dual processor -} glconfig_t; - -// FIXME: VM should be OS agnostic .. in theory - -/* -#ifdef Q3_VM - -#define _3DFX_DRIVER_NAME "Voodoo" -#define OPENGL_DRIVER_NAME "Default" - -#elif defined(_WIN32) -*/ - -#if defined(Q3_VM) || defined(_WIN32) - -#define _3DFX_DRIVER_NAME "3dfxvgl" -#define OPENGL_DRIVER_NAME "opengl32" - -#else - -#define _3DFX_DRIVER_NAME "libMesaVoodooGL.so" -// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=524 -#define OPENGL_DRIVER_NAME "libGL.so.1" - -#endif // !defined _WIN32 - -#endif // __TR_TYPES_H diff --git a/code/client/cl_cgame.c b/code/client/cl_cgame.c index b6c0855..09395e5 100644 --- a/code/client/cl_cgame.c +++ b/code/client/cl_cgame.c @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "client.h" -#include "../game/botlib.h" +#include "../botlib/botlib.h" extern botlib_export_t *botlib_export; diff --git a/code/client/cl_net_chan.c b/code/client/cl_net_chan.c index f18e565..3e5ab39 100644 --- a/code/client/cl_net_chan.c +++ b/code/client/cl_net_chan.c @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" #include "client.h" diff --git a/code/client/cl_ui.c b/code/client/cl_ui.c index cda68e2..ab7b62e 100644 --- a/code/client/cl_ui.c +++ b/code/client/cl_ui.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "client.h" -#include "../game/botlib.h" +#include "../botlib/botlib.h" extern botlib_export_t *botlib_export; diff --git a/code/client/client.h b/code/client/client.h index eace49c..ebe3374 100644 --- a/code/client/client.h +++ b/code/client/client.h @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // client.h -- primary header for client -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" #include "../renderer/tr_public.h" #include "../ui/ui_public.h" diff --git a/code/client/keycodes.h b/code/client/keycodes.h new file mode 100644 index 0000000..8f58482 --- /dev/null +++ b/code/client/keycodes.h @@ -0,0 +1,163 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code 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. + +Quake III Arena source code 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 Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +#ifndef __KEYCODES_H__ +#define __KEYCODES_H__ + +// +// these are the key numbers that should be passed to KeyEvent +// + +// normal keys should be passed as lowercased ascii + +typedef enum { + K_TAB = 9, + K_ENTER = 13, + K_ESCAPE = 27, + K_SPACE = 32, + + K_BACKSPACE = 127, + + K_COMMAND = 128, + K_CAPSLOCK, + K_POWER, + K_PAUSE, + + K_UPARROW, + K_DOWNARROW, + K_LEFTARROW, + K_RIGHTARROW, + + K_ALT, + K_CTRL, + K_SHIFT, + K_INS, + K_DEL, + K_PGDN, + K_PGUP, + K_HOME, + K_END, + + K_F1, + K_F2, + K_F3, + K_F4, + K_F5, + K_F6, + K_F7, + K_F8, + K_F9, + K_F10, + K_F11, + K_F12, + K_F13, + K_F14, + K_F15, + + K_KP_HOME, + K_KP_UPARROW, + K_KP_PGUP, + K_KP_LEFTARROW, + K_KP_5, + K_KP_RIGHTARROW, + K_KP_END, + K_KP_DOWNARROW, + K_KP_PGDN, + K_KP_ENTER, + K_KP_INS, + K_KP_DEL, + K_KP_SLASH, + K_KP_MINUS, + K_KP_PLUS, + K_KP_NUMLOCK, + K_KP_STAR, + K_KP_EQUALS, + + K_MOUSE1, + K_MOUSE2, + K_MOUSE3, + K_MOUSE4, + K_MOUSE5, + + K_MWHEELDOWN, + K_MWHEELUP, + + K_JOY1, + K_JOY2, + K_JOY3, + K_JOY4, + K_JOY5, + K_JOY6, + K_JOY7, + K_JOY8, + K_JOY9, + K_JOY10, + K_JOY11, + K_JOY12, + K_JOY13, + K_JOY14, + K_JOY15, + K_JOY16, + K_JOY17, + K_JOY18, + K_JOY19, + K_JOY20, + K_JOY21, + K_JOY22, + K_JOY23, + K_JOY24, + K_JOY25, + K_JOY26, + K_JOY27, + K_JOY28, + K_JOY29, + K_JOY30, + K_JOY31, + K_JOY32, + + K_AUX1, + K_AUX2, + K_AUX3, + K_AUX4, + K_AUX5, + K_AUX6, + K_AUX7, + K_AUX8, + K_AUX9, + K_AUX10, + K_AUX11, + K_AUX12, + K_AUX13, + K_AUX14, + K_AUX15, + K_AUX16, + + K_LAST_KEY // this had better be <256! +} keyNum_t; + + +// The menu code needs to get both key and char events, but +// to avoid duplicating the paths, the char events are just +// distinguished by or'ing in K_CHAR_FLAG (ugly) +#define K_CHAR_FLAG 1024 + +#endif diff --git a/code/client/keys.h b/code/client/keys.h index 3a13107..d55cb85 100644 --- a/code/client/keys.h +++ b/code/client/keys.h @@ -19,7 +19,7 @@ along with Foobar; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#include "../ui/keycodes.h" +#include "keycodes.h" #define MAX_KEYS 256 diff --git a/code/client/snd_local.h b/code/client/snd_local.h index 6131ad3..1c272fe 100644 --- a/code/client/snd_local.h +++ b/code/client/snd_local.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // snd_local.h -- private sound definations -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" #include "snd_public.h" diff --git a/code/game/ai_chat.c b/code/game/ai_chat.c index ae2554e..7dc7fc3 100644 --- a/code/game/ai_chat.c +++ b/code/game/ai_chat.c @@ -31,15 +31,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ #include "g_local.h" -#include "botlib.h" -#include "be_aas.h" -#include "be_ea.h" -#include "be_ai_char.h" -#include "be_ai_chat.h" -#include "be_ai_gen.h" -#include "be_ai_goal.h" -#include "be_ai_move.h" -#include "be_ai_weap.h" +#include "../botlib/botlib.h" +#include "../botlib/be_aas.h" +#include "../botlib/be_ea.h" +#include "../botlib/be_ai_char.h" +#include "../botlib/be_ai_chat.h" +#include "../botlib/be_ai_gen.h" +#include "../botlib/be_ai_goal.h" +#include "../botlib/be_ai_move.h" +#include "../botlib/be_ai_weap.h" // #include "ai_main.h" #include "ai_dmq3.h" diff --git a/code/game/ai_cmd.c b/code/game/ai_cmd.c index fadf07f..2b89a1d 100644 --- a/code/game/ai_cmd.c +++ b/code/game/ai_cmd.c @@ -31,15 +31,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ #include "g_local.h" -#include "botlib.h" -#include "be_aas.h" -#include "be_ea.h" -#include "be_ai_char.h" -#include "be_ai_chat.h" -#include "be_ai_gen.h" -#include "be_ai_goal.h" -#include "be_ai_move.h" -#include "be_ai_weap.h" +#include "../botlib/botlib.h" +#include "../botlib/be_aas.h" +#include "../botlib/be_ea.h" +#include "../botlib/be_ai_char.h" +#include "../botlib/be_ai_chat.h" +#include "../botlib/be_ai_gen.h" +#include "../botlib/be_ai_goal.h" +#include "../botlib/be_ai_move.h" +#include "../botlib/be_ai_weap.h" // #include "ai_main.h" #include "ai_dmq3.h" diff --git a/code/game/ai_dmnet.c b/code/game/ai_dmnet.c index a791edd..7230676 100644 --- a/code/game/ai_dmnet.c +++ b/code/game/ai_dmnet.c @@ -31,15 +31,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ #include "g_local.h" -#include "botlib.h" -#include "be_aas.h" -#include "be_ea.h" -#include "be_ai_char.h" -#include "be_ai_chat.h" -#include "be_ai_gen.h" -#include "be_ai_goal.h" -#include "be_ai_move.h" -#include "be_ai_weap.h" +#include "../botlib/botlib.h" +#include "../botlib/be_aas.h" +#include "../botlib/be_ea.h" +#include "../botlib/be_ai_char.h" +#include "../botlib/be_ai_chat.h" +#include "../botlib/be_ai_gen.h" +#include "../botlib/be_ai_goal.h" +#include "../botlib/be_ai_move.h" +#include "../botlib/be_ai_weap.h" // #include "ai_main.h" #include "ai_dmq3.h" @@ -56,7 +56,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // for the voice chats #include "../../ui/menudef.h" -//goal flag, see be_ai_goal.h for the other GFL_* +//goal flag, see ../botlib/be_ai_goal.h for the other GFL_* #define GFL_AIR 128 int numnodeswitches; diff --git a/code/game/ai_dmq3.c b/code/game/ai_dmq3.c index c373df8..b02d67c 100644 --- a/code/game/ai_dmq3.c +++ b/code/game/ai_dmq3.c @@ -32,15 +32,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "g_local.h" -#include "botlib.h" -#include "be_aas.h" -#include "be_ea.h" -#include "be_ai_char.h" -#include "be_ai_chat.h" -#include "be_ai_gen.h" -#include "be_ai_goal.h" -#include "be_ai_move.h" -#include "be_ai_weap.h" +#include "../botlib/botlib.h" +#include "../botlib/be_aas.h" +#include "../botlib/be_ea.h" +#include "../botlib/be_ai_char.h" +#include "../botlib/be_ai_chat.h" +#include "../botlib/be_ai_gen.h" +#include "../botlib/be_ai_goal.h" +#include "../botlib/be_ai_move.h" +#include "../botlib/be_ai_weap.h" // #include "ai_main.h" #include "ai_dmq3.h" diff --git a/code/game/ai_main.c b/code/game/ai_main.c index 63de0ce..b88d96f 100644 --- a/code/game/ai_main.c +++ b/code/game/ai_main.c @@ -32,16 +32,16 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "g_local.h" -#include "q_shared.h" -#include "botlib.h" //bot lib interface -#include "be_aas.h" -#include "be_ea.h" -#include "be_ai_char.h" -#include "be_ai_chat.h" -#include "be_ai_gen.h" -#include "be_ai_goal.h" -#include "be_ai_move.h" -#include "be_ai_weap.h" +#include "../qcommon/q_shared.h" +#include "../botlib/botlib.h" //bot lib interface +#include "../botlib/be_aas.h" +#include "../botlib/be_ea.h" +#include "../botlib/be_ai_char.h" +#include "../botlib/be_ai_chat.h" +#include "../botlib/be_ai_gen.h" +#include "../botlib/be_ai_goal.h" +#include "../botlib/be_ai_move.h" +#include "../botlib/be_ai_weap.h" // #include "ai_main.h" #include "ai_dmq3.h" diff --git a/code/game/ai_team.c b/code/game/ai_team.c index 44250d8..742c24f 100644 --- a/code/game/ai_team.c +++ b/code/game/ai_team.c @@ -31,15 +31,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ #include "g_local.h" -#include "botlib.h" -#include "be_aas.h" -#include "be_ea.h" -#include "be_ai_char.h" -#include "be_ai_chat.h" -#include "be_ai_gen.h" -#include "be_ai_goal.h" -#include "be_ai_move.h" -#include "be_ai_weap.h" +#include "../botlib/botlib.h" +#include "../botlib/be_aas.h" +#include "../botlib/be_ea.h" +#include "../botlib/be_ai_char.h" +#include "../botlib/be_ai_chat.h" +#include "../botlib/be_ai_gen.h" +#include "../botlib/be_ai_goal.h" +#include "../botlib/be_ai_move.h" +#include "../botlib/be_ai_weap.h" // #include "ai_main.h" #include "ai_dmq3.h" diff --git a/code/game/ai_vcmd.c b/code/game/ai_vcmd.c index 026bbf0..c99d2c3 100644 --- a/code/game/ai_vcmd.c +++ b/code/game/ai_vcmd.c @@ -31,15 +31,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ #include "g_local.h" -#include "botlib.h" -#include "be_aas.h" -#include "be_ea.h" -#include "be_ai_char.h" -#include "be_ai_chat.h" -#include "be_ai_gen.h" -#include "be_ai_goal.h" -#include "be_ai_move.h" -#include "be_ai_weap.h" +#include "../botlib/botlib.h" +#include "../botlib/be_aas.h" +#include "../botlib/be_ea.h" +#include "../botlib/be_ai_char.h" +#include "../botlib/be_ai_chat.h" +#include "../botlib/be_ai_gen.h" +#include "../botlib/be_ai_goal.h" +#include "../botlib/be_ai_move.h" +#include "../botlib/be_ai_weap.h" // #include "ai_main.h" #include "ai_dmq3.h" diff --git a/code/game/be_aas.h b/code/game/be_aas.h deleted file mode 100644 index 4a98a8e..0000000 --- a/code/game/be_aas.h +++ /dev/null @@ -1,221 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code 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. - -Quake III Arena source code 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 Foobar; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// - -/***************************************************************************** - * name: be_aas.h - * - * desc: Area Awareness System, stuff exported to the AI - * - * $Archive: /source/code/botlib/be_aas.h $ - * - *****************************************************************************/ - -#ifndef MAX_STRINGFIELD -#define MAX_STRINGFIELD 80 -#endif - -//travel flags -#define TFL_INVALID 0x00000001 //traveling temporary not possible -#define TFL_WALK 0x00000002 //walking -#define TFL_CROUCH 0x00000004 //crouching -#define TFL_BARRIERJUMP 0x00000008 //jumping onto a barrier -#define TFL_JUMP 0x00000010 //jumping -#define TFL_LADDER 0x00000020 //climbing a ladder -#define TFL_WALKOFFLEDGE 0x00000080 //walking of a ledge -#define TFL_SWIM 0x00000100 //swimming -#define TFL_WATERJUMP 0x00000200 //jumping out of the water -#define TFL_TELEPORT 0x00000400 //teleporting -#define TFL_ELEVATOR 0x00000800 //elevator -#define TFL_ROCKETJUMP 0x00001000 //rocket jumping -#define TFL_BFGJUMP 0x00002000 //bfg jumping -#define TFL_GRAPPLEHOOK 0x00004000 //grappling hook -#define TFL_DOUBLEJUMP 0x00008000 //double jump -#define TFL_RAMPJUMP 0x00010000 //ramp jump -#define TFL_STRAFEJUMP 0x00020000 //strafe jump -#define TFL_JUMPPAD 0x00040000 //jump pad -#define TFL_AIR 0x00080000 //travel through air -#define TFL_WATER 0x00100000 //travel through water -#define TFL_SLIME 0x00200000 //travel through slime -#define TFL_LAVA 0x00400000 //travel through lava -#define TFL_DONOTENTER 0x00800000 //travel through donotenter area -#define TFL_FUNCBOB 0x01000000 //func bobbing -#define TFL_FLIGHT 0x02000000 //flight -#define TFL_BRIDGE 0x04000000 //move over a bridge -// -#define TFL_NOTTEAM1 0x08000000 //not team 1 -#define TFL_NOTTEAM2 0x10000000 //not team 2 - -//default travel flags -#define TFL_DEFAULT TFL_WALK|TFL_CROUCH|TFL_BARRIERJUMP|\ - TFL_JUMP|TFL_LADDER|\ - TFL_WALKOFFLEDGE|TFL_SWIM|TFL_WATERJUMP|\ - TFL_TELEPORT|TFL_ELEVATOR|\ - TFL_AIR|TFL_WATER|TFL_JUMPPAD|TFL_FUNCBOB - -typedef enum -{ - SOLID_NOT, // no interaction with other objects - SOLID_TRIGGER, // only touch when inside, after moving - SOLID_BBOX, // touch on edge - SOLID_BSP // bsp clip, touch on edge -} solid_t; - -//a trace is returned when a box is swept through the AAS world -typedef struct aas_trace_s -{ - qboolean startsolid; // if true, the initial point was in a solid area - float fraction; // time completed, 1.0 = didn't hit anything - vec3_t endpos; // final position - int ent; // entity blocking the trace - int lastarea; // last area the trace was in (zero if none) - int area; // area blocking the trace (zero if none) - int planenum; // number of the plane that was hit -} aas_trace_t; - -/* Defined in botlib.h - -//bsp_trace_t hit surface -typedef struct bsp_surface_s -{ - char name[16]; - int flags; - int value; -} bsp_surface_t; - -//a trace is returned when a box is swept through the BSP world -typedef struct bsp_trace_s -{ - qboolean allsolid; // if true, plane is not valid - qboolean startsolid; // if true, the initial point was in a solid area - float fraction; // time completed, 1.0 = didn't hit anything - vec3_t endpos; // final position - cplane_t plane; // surface normal at impact - float exp_dist; // expanded plane distance - int sidenum; // number of the brush side hit - bsp_surface_t surface; // hit surface - int contents; // contents on other side of surface hit - int ent; // number of entity hit -} bsp_trace_t; -// -*/ - -//entity info -typedef struct aas_entityinfo_s -{ - int valid; // true if updated this frame - int type; // entity type - int flags; // entity flags - float ltime; // local time - float update_time; // time between last and current update - int number; // number of the entity - vec3_t origin; // origin of the entity - vec3_t angles; // angles of the model - vec3_t old_origin; // for lerping - vec3_t lastvisorigin; // last visible origin - vec3_t mins; // bounding box minimums - vec3_t maxs; // bounding box maximums - int groundent; // ground entity - int solid; // solid type - int modelindex; // model used - int modelindex2; // weapons, CTF flags, etc - int frame; // model frame number - int event; // impulse events -- muzzle flashes, footsteps, etc - int eventParm; // even parameter - int powerups; // bit flags - int weapon; // determines weapon and flash model, etc - int legsAnim; // mask off ANIM_TOGGLEBIT - int torsoAnim; // mask off ANIM_TOGGLEBIT -} aas_entityinfo_t; - -// area info -typedef struct aas_areainfo_s -{ - int contents; - int flags; - int presencetype; - int cluster; - vec3_t mins; - vec3_t maxs; - vec3_t center; -} aas_areainfo_t; - -// client movement prediction stop events, stop as soon as: -#define SE_NONE 0 -#define SE_HITGROUND 1 // the ground is hit -#define SE_LEAVEGROUND 2 // there's no ground -#define SE_ENTERWATER 4 // water is entered -#define SE_ENTERSLIME 8 // slime is entered -#define SE_ENTERLAVA 16 // lava is entered -#define SE_HITGROUNDDAMAGE 32 // the ground is hit with damage -#define SE_GAP 64 // there's a gap -#define SE_TOUCHJUMPPAD 128 // touching a jump pad area -#define SE_TOUCHTELEPORTER 256 // touching teleporter -#define SE_ENTERAREA 512 // the given stoparea is entered -#define SE_HITGROUNDAREA 1024 // a ground face in the area is hit -#define SE_HITBOUNDINGBOX 2048 // hit the specified bounding box -#define SE_TOUCHCLUSTERPORTAL 4096 // touching a cluster portal - -typedef struct aas_clientmove_s -{ - vec3_t endpos; //position at the end of movement prediction - int endarea; //area at end of movement prediction - vec3_t velocity; //velocity at the end of movement prediction - aas_trace_t trace; //last trace - int presencetype; //presence type at end of movement prediction - int stopevent; //event that made the prediction stop - int endcontents; //contents at the end of movement prediction - float time; //time predicted ahead - int frames; //number of frames predicted ahead -} aas_clientmove_t; - -// alternate route goals -#define ALTROUTEGOAL_ALL 1 -#define ALTROUTEGOAL_CLUSTERPORTALS 2 -#define ALTROUTEGOAL_VIEWPORTALS 4 - -typedef struct aas_altroutegoal_s -{ - vec3_t origin; - int areanum; - unsigned short starttraveltime; - unsigned short goaltraveltime; - unsigned short extratraveltime; -} aas_altroutegoal_t; - -// route prediction stop events -#define RSE_NONE 0 -#define RSE_NOROUTE 1 //no route to goal -#define RSE_USETRAVELTYPE 2 //stop as soon as on of the given travel types is used -#define RSE_ENTERCONTENTS 4 //stop when entering the given contents -#define RSE_ENTERAREA 8 //stop when entering the given area - -typedef struct aas_predictroute_s -{ - vec3_t endpos; //position at the end of movement prediction - int endarea; //area at end of movement prediction - int stopevent; //event that made the prediction stop - int endcontents; //contents at the end of movement prediction - int endtravelflags; //end travel flags - int numareas; //number of areas predicted ahead - int time; //time predicted ahead (in hundreth of a sec) -} aas_predictroute_t; diff --git a/code/game/be_ai_char.h b/code/game/be_ai_char.h deleted file mode 100644 index 573fa1d..0000000 --- a/code/game/be_ai_char.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code 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. - -Quake III Arena source code 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 Foobar; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// - -/***************************************************************************** - * name: be_ai_char.h - * - * desc: bot characters - * - * $Archive: /source/code/botlib/be_ai_char.h $ - * - *****************************************************************************/ - -//loads a bot character from a file -int BotLoadCharacter(char *charfile, float skill); -//frees a bot character -void BotFreeCharacter(int character); -//returns a float characteristic -float Characteristic_Float(int character, int index); -//returns a bounded float characteristic -float Characteristic_BFloat(int character, int index, float min, float max); -//returns an integer characteristic -int Characteristic_Integer(int character, int index); -//returns a bounded integer characteristic -int Characteristic_BInteger(int character, int index, int min, int max); -//returns a string characteristic -void Characteristic_String(int character, int index, char *buf, int size); -//free cached bot characters -void BotShutdownCharacters(void); diff --git a/code/game/be_ai_chat.h b/code/game/be_ai_chat.h deleted file mode 100644 index 67a38ed..0000000 --- a/code/game/be_ai_chat.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code 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. - -Quake III Arena source code 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 Foobar; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// -/***************************************************************************** - * name: be_ai_chat.h - * - * desc: char AI - * - * $Archive: /source/code/botlib/be_ai_chat.h $ - * - *****************************************************************************/ - -#define MAX_MESSAGE_SIZE 256 -#define MAX_CHATTYPE_NAME 32 -#define MAX_MATCHVARIABLES 8 - -#define CHAT_GENDERLESS 0 -#define CHAT_GENDERFEMALE 1 -#define CHAT_GENDERMALE 2 - -#define CHAT_ALL 0 -#define CHAT_TEAM 1 -#define CHAT_TELL 2 - -//a console message -typedef struct bot_consolemessage_s -{ - int handle; - float time; //message time - int type; //message type - char message[MAX_MESSAGE_SIZE]; //message - struct bot_consolemessage_s *prev, *next; //prev and next in list -} bot_consolemessage_t; - -//match variable -typedef struct bot_matchvariable_s -{ - char offset; - int length; -} bot_matchvariable_t; -//returned to AI when a match is found -typedef struct bot_match_s -{ - char string[MAX_MESSAGE_SIZE]; - int type; - int subtype; - bot_matchvariable_t variables[MAX_MATCHVARIABLES]; -} bot_match_t; - -//setup the chat AI -int BotSetupChatAI(void); -//shutdown the chat AI -void BotShutdownChatAI(void); -//returns the handle to a newly allocated chat state -int BotAllocChatState(void); -//frees the chatstate -void BotFreeChatState(int handle); -//adds a console message to the chat state -void BotQueueConsoleMessage(int chatstate, int type, char *message); -//removes the console message from the chat state -void BotRemoveConsoleMessage(int chatstate, int handle); -//returns the next console message from the state -int BotNextConsoleMessage(int chatstate, bot_consolemessage_t *cm); -//returns the number of console messages currently stored in the state -int BotNumConsoleMessages(int chatstate); -//selects a chat message of the given type -void BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); -//returns the number of initial chat messages of the given type -int BotNumInitialChats(int chatstate, char *type); -//find and select a reply for the given message -int BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); -//returns the length of the currently selected chat message -int BotChatLength(int chatstate); -//enters the selected chat message -void BotEnterChat(int chatstate, int clientto, int sendto); -//get the chat message ready to be output -void BotGetChatMessage(int chatstate, char *buf, int size); -//checks if the first string contains the second one, returns index into first string or -1 if not found -int StringContains(char *str1, char *str2, int casesensitive); -//finds a match for the given string using the match templates -int BotFindMatch(char *str, bot_match_t *match, unsigned long int context); -//returns a variable from a match -void BotMatchVariable(bot_match_t *match, int variable, char *buf, int size); -//unify all the white spaces in the string -void UnifyWhiteSpaces(char *string); -//replace all the context related synonyms in the string -void BotReplaceSynonyms(char *string, unsigned long int context); -//loads a chat file for the chat state -int BotLoadChatFile(int chatstate, char *chatfile, char *chatname); -//store the gender of the bot in the chat state -void BotSetChatGender(int chatstate, int gender); -//store the bot name in the chat state -void BotSetChatName(int chatstate, char *name, int client); - diff --git a/code/game/be_ai_gen.h b/code/game/be_ai_gen.h deleted file mode 100644 index 2a4b53d..0000000 --- a/code/game/be_ai_gen.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code 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. - -Quake III Arena source code 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 Foobar; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// - -/***************************************************************************** - * name: be_ai_gen.h - * - * desc: genetic selection - * - * $Archive: /source/code/botlib/be_ai_gen.h $ - * - *****************************************************************************/ - -int GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child); diff --git a/code/game/be_ai_goal.h b/code/game/be_ai_goal.h deleted file mode 100644 index 354609d..0000000 --- a/code/game/be_ai_goal.h +++ /dev/null @@ -1,118 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code 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. - -Quake III Arena source code 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 Foobar; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// -/***************************************************************************** - * name: be_ai_goal.h - * - * desc: goal AI - * - * $Archive: /source/code/botlib/be_ai_goal.h $ - * - *****************************************************************************/ - -#define MAX_AVOIDGOALS 256 -#define MAX_GOALSTACK 8 - -#define GFL_NONE 0 -#define GFL_ITEM 1 -#define GFL_ROAM 2 -#define GFL_DROPPED 4 - -//a bot goal -typedef struct bot_goal_s -{ - vec3_t origin; //origin of the goal - int areanum; //area number of the goal - vec3_t mins, maxs; //mins and maxs of the goal - int entitynum; //number of the goal entity - int number; //goal number - int flags; //goal flags - int iteminfo; //item information -} bot_goal_t; - -//reset the whole goal state, but keep the item weights -void BotResetGoalState(int goalstate); -//reset avoid goals -void BotResetAvoidGoals(int goalstate); -//remove the goal with the given number from the avoid goals -void BotRemoveFromAvoidGoals(int goalstate, int number); -//push a goal onto the goal stack -void BotPushGoal(int goalstate, bot_goal_t *goal); -//pop a goal from the goal stack -void BotPopGoal(int goalstate); -//empty the bot's goal stack -void BotEmptyGoalStack(int goalstate); -//dump the avoid goals -void BotDumpAvoidGoals(int goalstate); -//dump the goal stack -void BotDumpGoalStack(int goalstate); -//get the name name of the goal with the given number -void BotGoalName(int number, char *name, int size); -//get the top goal from the stack -int BotGetTopGoal(int goalstate, bot_goal_t *goal); -//get the second goal on the stack -int BotGetSecondGoal(int goalstate, bot_goal_t *goal); -//choose the best long term goal item for the bot -int BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags); -//choose the best nearby goal item for the bot -//the item may not be further away from the current bot position than maxtime -//also the travel time from the nearby goal towards the long term goal may not -//be larger than the travel time towards the long term goal from the current bot position -int BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, - bot_goal_t *ltg, float maxtime); -//returns true if the bot touches the goal -int BotTouchingGoal(vec3_t origin, bot_goal_t *goal); -//returns true if the goal should be visible but isn't -int BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, bot_goal_t *goal); -//search for a goal for the given classname, the index can be used -//as a start point for the search when multiple goals are available with that same classname -int BotGetLevelItemGoal(int index, char *classname, bot_goal_t *goal); -//get the next camp spot in the map -int BotGetNextCampSpotGoal(int num, bot_goal_t *goal); -//get the map location with the given name -int BotGetMapLocationGoal(char *name, bot_goal_t *goal); -//returns the avoid goal time -float BotAvoidGoalTime(int goalstate, int number); -//set the avoid goal time -void BotSetAvoidGoalTime(int goalstate, int number, float avoidtime); -//initializes the items in the level -void BotInitLevelItems(void); -//regularly update dynamic entity items (dropped weapons, flags etc.) -void BotUpdateEntityItems(void); -//interbreed the goal fuzzy logic -void BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child); -//save the goal fuzzy logic to disk -void BotSaveGoalFuzzyLogic(int goalstate, char *filename); -//mutate the goal fuzzy logic -void BotMutateGoalFuzzyLogic(int goalstate, float range); -//loads item weights for the bot -int BotLoadItemWeights(int goalstate, char *filename); -//frees the item weights of the bot -void BotFreeItemWeights(int goalstate); -//returns the handle of a newly allocated goal state -int BotAllocGoalState(int client); -//free the given goal state -void BotFreeGoalState(int handle); -//setup the goal AI -int BotSetupGoalAI(void); -//shut down the goal AI -void BotShutdownGoalAI(void); diff --git a/code/game/be_ai_move.h b/code/game/be_ai_move.h deleted file mode 100644 index 0aed6d7..0000000 --- a/code/game/be_ai_move.h +++ /dev/null @@ -1,144 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code 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. - -Quake III Arena source code 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 Foobar; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// - -/***************************************************************************** - * name: be_ai_move.h - * - * desc: movement AI - * - * $Archive: /source/code/botlib/be_ai_move.h $ - * - *****************************************************************************/ - -//movement types -#define MOVE_WALK 1 -#define MOVE_CROUCH 2 -#define MOVE_JUMP 4 -#define MOVE_GRAPPLE 8 -#define MOVE_ROCKETJUMP 16 -#define MOVE_BFGJUMP 32 -//move flags -#define MFL_BARRIERJUMP 1 //bot is performing a barrier jump -#define MFL_ONGROUND 2 //bot is in the ground -#define MFL_SWIMMING 4 //bot is swimming -#define MFL_AGAINSTLADDER 8 //bot is against a ladder -#define MFL_WATERJUMP 16 //bot is waterjumping -#define MFL_TELEPORTED 32 //bot is being teleported -#define MFL_GRAPPLEPULL 64 //bot is being pulled by the grapple -#define MFL_ACTIVEGRAPPLE 128 //bot is using the grapple hook -#define MFL_GRAPPLERESET 256 //bot has reset the grapple -#define MFL_WALK 512 //bot should walk slowly -// move result flags -#define MOVERESULT_MOVEMENTVIEW 1 //bot uses view for movement -#define MOVERESULT_SWIMVIEW 2 //bot uses view for swimming -#define MOVERESULT_WAITING 4 //bot is waiting for something -#define MOVERESULT_MOVEMENTVIEWSET 8 //bot has set the view in movement code -#define MOVERESULT_MOVEMENTWEAPON 16 //bot uses weapon for movement -#define MOVERESULT_ONTOPOFOBSTACLE 32 //bot is ontop of obstacle -#define MOVERESULT_ONTOPOF_FUNCBOB 64 //bot is ontop of a func_bobbing -#define MOVERESULT_ONTOPOF_ELEVATOR 128 //bot is ontop of an elevator (func_plat) -#define MOVERESULT_BLOCKEDBYAVOIDSPOT 256 //bot is blocked by an avoid spot -// -#define MAX_AVOIDREACH 1 -#define MAX_AVOIDSPOTS 32 -// avoid spot types -#define AVOID_CLEAR 0 //clear all avoid spots -#define AVOID_ALWAYS 1 //avoid always -#define AVOID_DONTBLOCK 2 //never totally block -// restult types -#define RESULTTYPE_ELEVATORUP 1 //elevator is up -#define RESULTTYPE_WAITFORFUNCBOBBING 2 //waiting for func bobbing to arrive -#define RESULTTYPE_BADGRAPPLEPATH 4 //grapple path is obstructed -#define RESULTTYPE_INSOLIDAREA 8 //stuck in solid area, this is bad - -//structure used to initialize the movement state -//the or_moveflags MFL_ONGROUND, MFL_TELEPORTED and MFL_WATERJUMP come from the playerstate -typedef struct bot_initmove_s -{ - vec3_t origin; //origin of the bot - vec3_t velocity; //velocity of the bot - vec3_t viewoffset; //view offset - int entitynum; //entity number of the bot - int client; //client number of the bot - float thinktime; //time the bot thinks - int presencetype; //presencetype of the bot - vec3_t viewangles; //view angles of the bot - int or_moveflags; //values ored to the movement flags -} bot_initmove_t; - -//NOTE: the ideal_viewangles are only valid if MFL_MOVEMENTVIEW is set -typedef struct bot_moveresult_s -{ - int failure; //true if movement failed all together - int type; //failure or blocked type - int blocked; //true if blocked by an entity - int blockentity; //entity blocking the bot - int traveltype; //last executed travel type - int flags; //result flags - int weapon; //weapon used for movement - vec3_t movedir; //movement direction - vec3_t ideal_viewangles; //ideal viewangles for the movement -} bot_moveresult_t; - -#define bot_moveresult_t_cleared(x) bot_moveresult_t (x) = {0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, {0, 0, 0}} - -// bk001204: from code/botlib/be_ai_move.c -// TTimo 04/12/2001 was moved here to avoid dup defines -typedef struct bot_avoidspot_s -{ - vec3_t origin; - float radius; - int type; -} bot_avoidspot_t; - -//resets the whole move state -void BotResetMoveState(int movestate); -//moves the bot to the given goal -void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, int travelflags); -//moves the bot in the specified direction using the specified type of movement -int BotMoveInDirection(int movestate, vec3_t dir, float speed, int type); -//reset avoid reachability -void BotResetAvoidReach(int movestate); -//resets the last avoid reachability -void BotResetLastAvoidReach(int movestate); -//returns a reachability area if the origin is in one -int BotReachabilityArea(vec3_t origin, int client); -//view target based on movement -int BotMovementViewTarget(int movestate, bot_goal_t *goal, int travelflags, float lookahead, vec3_t target); -//predict the position of a player based on movement towards a goal -int BotPredictVisiblePosition(vec3_t origin, int areanum, bot_goal_t *goal, int travelflags, vec3_t target); -//returns the handle of a newly allocated movestate -int BotAllocMoveState(void); -//frees the movestate with the given handle -void BotFreeMoveState(int handle); -//initialize movement state before performing any movement -void BotInitMoveState(int handle, bot_initmove_t *initmove); -//add a spot to avoid (if type == AVOID_CLEAR all spots are removed) -void BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type); -//must be called every map change -void BotSetBrushModelTypes(void); -//setup movement AI -int BotSetupMoveAI(void); -//shutdown movement AI -void BotShutdownMoveAI(void); - diff --git a/code/game/be_ai_weap.h b/code/game/be_ai_weap.h deleted file mode 100644 index b78ad68..0000000 --- a/code/game/be_ai_weap.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code 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. - -Quake III Arena source code 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 Foobar; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// - -/***************************************************************************** - * name: be_ai_weap.h - * - * desc: weapon AI - * - * $Archive: /source/code/botlib/be_ai_weap.h $ - * - *****************************************************************************/ - -//projectile flags -#define PFL_WINDOWDAMAGE 1 //projectile damages through window -#define PFL_RETURN 2 //set when projectile returns to owner -//weapon flags -#define WFL_FIRERELEASED 1 //set when projectile is fired with key-up event -//damage types -#define DAMAGETYPE_IMPACT 1 //damage on impact -#define DAMAGETYPE_RADIAL 2 //radial damage -#define DAMAGETYPE_VISIBLE 4 //damage to all entities visible to the projectile - -typedef struct projectileinfo_s -{ - char name[MAX_STRINGFIELD]; - char model[MAX_STRINGFIELD]; - int flags; - float gravity; - int damage; - float radius; - int visdamage; - int damagetype; - int healthinc; - float push; - float detonation; - float bounce; - float bouncefric; - float bouncestop; -} projectileinfo_t; - -typedef struct weaponinfo_s -{ - int valid; //true if the weapon info is valid - int number; //number of the weapon - char name[MAX_STRINGFIELD]; - char model[MAX_STRINGFIELD]; - int level; - int weaponindex; - int flags; - char projectile[MAX_STRINGFIELD]; - int numprojectiles; - float hspread; - float vspread; - float speed; - float acceleration; - vec3_t recoil; - vec3_t offset; - vec3_t angleoffset; - float extrazvelocity; - int ammoamount; - int ammoindex; - float activate; - float reload; - float spinup; - float spindown; - projectileinfo_t proj; //pointer to the used projectile -} weaponinfo_t; - -//setup the weapon AI -int BotSetupWeaponAI(void); -//shut down the weapon AI -void BotShutdownWeaponAI(void); -//returns the best weapon to fight with -int BotChooseBestFightWeapon(int weaponstate, int *inventory); -//returns the information of the current weapon -void BotGetWeaponInfo(int weaponstate, int weapon, weaponinfo_t *weaponinfo); -//loads the weapon weights -int BotLoadWeaponWeights(int weaponstate, char *filename); -//returns a handle to a newly allocated weapon state -int BotAllocWeaponState(void); -//frees the weapon state -void BotFreeWeaponState(int weaponstate); -//resets the whole weapon state -void BotResetWeaponState(int weaponstate); diff --git a/code/game/be_ea.h b/code/game/be_ea.h deleted file mode 100644 index 1bc436b..0000000 --- a/code/game/be_ea.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code 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. - -Quake III Arena source code 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 Foobar; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// - -/***************************************************************************** - * name: be_ea.h - * - * desc: elementary actions - * - * $Archive: /source/code/botlib/be_ea.h $ - * - *****************************************************************************/ - -//ClientCommand elementary actions -void EA_Say(int client, char *str); -void EA_SayTeam(int client, char *str); -void EA_Command(int client, char *command ); - -void EA_Action(int client, int action); -void EA_Crouch(int client); -void EA_Walk(int client); -void EA_MoveUp(int client); -void EA_MoveDown(int client); -void EA_MoveForward(int client); -void EA_MoveBack(int client); -void EA_MoveLeft(int client); -void EA_MoveRight(int client); -void EA_Attack(int client); -void EA_Respawn(int client); -void EA_Talk(int client); -void EA_Gesture(int client); -void EA_Use(int client); - -//regular elementary actions -void EA_SelectWeapon(int client, int weapon); -void EA_Jump(int client); -void EA_DelayedJump(int client); -void EA_Move(int client, vec3_t dir, float speed); -void EA_View(int client, vec3_t viewangles); - -//send regular input to the server -void EA_EndRegular(int client, float thinktime); -void EA_GetInput(int client, float thinktime, bot_input_t *input); -void EA_ResetInput(int client); -//setup and shutdown routines -int EA_Setup(void); -void EA_Shutdown(void); diff --git a/code/game/bg_lib.c b/code/game/bg_lib.c index 140d18a..b198f72 100644 --- a/code/game/bg_lib.c +++ b/code/game/bg_lib.c @@ -3,7 +3,7 @@ // bg_lib,c -- standard C library replacement routines used by code // compiled for the virtual machine -#include "q_shared.h" +#include "../qcommon/q_shared.h" /*- * Copyright (c) 1992, 1993 diff --git a/code/game/bg_misc.c b/code/game/bg_misc.c index 2ff7770..a2049a9 100644 --- a/code/game/bg_misc.c +++ b/code/game/bg_misc.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // // bg_misc.c -- both games misc functions, all completely stateless -#include "q_shared.h" +#include "../qcommon/q_shared.h" #include "bg_public.h" /*QUAKED item_***** ( 0 0 0 ) (-16 -16 -16) (16 16 16) suspended diff --git a/code/game/bg_pmove.c b/code/game/bg_pmove.c index f5f5c68..9fa3887 100644 --- a/code/game/bg_pmove.c +++ b/code/game/bg_pmove.c @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // bg_pmove.c -- both games player movement code // takes a playerstate and a usercmd as input and returns a modifed playerstate -#include "q_shared.h" +#include "../qcommon/q_shared.h" #include "bg_public.h" #include "bg_local.h" diff --git a/code/game/bg_slidemove.c b/code/game/bg_slidemove.c index 6c957a5..183d6e5 100644 --- a/code/game/bg_slidemove.c +++ b/code/game/bg_slidemove.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // // bg_slidemove.c -- part of bg_pmove functionality -#include "q_shared.h" +#include "../qcommon/q_shared.h" #include "bg_public.h" #include "bg_local.h" diff --git a/code/game/botlib.h b/code/game/botlib.h deleted file mode 100644 index 687affe..0000000 --- a/code/game/botlib.h +++ /dev/null @@ -1,516 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code 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. - -Quake III Arena source code 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 Foobar; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// -/***************************************************************************** - * name: botlib.h - * - * desc: bot AI library - * - * $Archive: /source/code/game/botai.h $ - * - *****************************************************************************/ - -#define BOTLIB_API_VERSION 2 - -struct aas_clientmove_s; -struct aas_entityinfo_s; -struct aas_areainfo_s; -struct aas_altroutegoal_s; -struct aas_predictroute_s; -struct bot_consolemessage_s; -struct bot_match_s; -struct bot_goal_s; -struct bot_moveresult_s; -struct bot_initmove_s; -struct weaponinfo_s; - -#define BOTFILESBASEFOLDER "botfiles" -//debug line colors -#define LINECOLOR_NONE -1 -#define LINECOLOR_RED 1//0xf2f2f0f0L -#define LINECOLOR_GREEN 2//0xd0d1d2d3L -#define LINECOLOR_BLUE 3//0xf3f3f1f1L -#define LINECOLOR_YELLOW 4//0xdcdddedfL -#define LINECOLOR_ORANGE 5//0xe0e1e2e3L - -//Print types -#define PRT_MESSAGE 1 -#define PRT_WARNING 2 -#define PRT_ERROR 3 -#define PRT_FATAL 4 -#define PRT_EXIT 5 - -//console message types -#define CMS_NORMAL 0 -#define CMS_CHAT 1 - -//botlib error codes -#define BLERR_NOERROR 0 //no error -#define BLERR_LIBRARYNOTSETUP 1 //library not setup -#define BLERR_INVALIDENTITYNUMBER 2 //invalid entity number -#define BLERR_NOAASFILE 3 //no AAS file available -#define BLERR_CANNOTOPENAASFILE 4 //cannot open AAS file -#define BLERR_WRONGAASFILEID 5 //incorrect AAS file id -#define BLERR_WRONGAASFILEVERSION 6 //incorrect AAS file version -#define BLERR_CANNOTREADAASLUMP 7 //cannot read AAS file lump -#define BLERR_CANNOTLOADICHAT 8 //cannot load initial chats -#define BLERR_CANNOTLOADITEMWEIGHTS 9 //cannot load item weights -#define BLERR_CANNOTLOADITEMCONFIG 10 //cannot load item config -#define BLERR_CANNOTLOADWEAPONWEIGHTS 11 //cannot load weapon weights -#define BLERR_CANNOTLOADWEAPONCONFIG 12 //cannot load weapon config - -//action flags -#define ACTION_ATTACK 0x0000001 -#define ACTION_USE 0x0000002 -#define ACTION_RESPAWN 0x0000008 -#define ACTION_JUMP 0x0000010 -#define ACTION_MOVEUP 0x0000020 -#define ACTION_CROUCH 0x0000080 -#define ACTION_MOVEDOWN 0x0000100 -#define ACTION_MOVEFORWARD 0x0000200 -#define ACTION_MOVEBACK 0x0000800 -#define ACTION_MOVELEFT 0x0001000 -#define ACTION_MOVERIGHT 0x0002000 -#define ACTION_DELAYEDJUMP 0x0008000 -#define ACTION_TALK 0x0010000 -#define ACTION_GESTURE 0x0020000 -#define ACTION_WALK 0x0080000 -#define ACTION_AFFIRMATIVE 0x0100000 -#define ACTION_NEGATIVE 0x0200000 -#define ACTION_GETFLAG 0x0800000 -#define ACTION_GUARDBASE 0x1000000 -#define ACTION_PATROL 0x2000000 -#define ACTION_FOLLOWME 0x8000000 - -//the bot input, will be converted to an usercmd_t -typedef struct bot_input_s -{ - float thinktime; //time since last output (in seconds) - vec3_t dir; //movement direction - float speed; //speed in the range [0, 400] - vec3_t viewangles; //the view angles - int actionflags; //one of the ACTION_? flags - int weapon; //weapon to use -} bot_input_t; - -#ifndef BSPTRACE - -#define BSPTRACE - -//bsp_trace_t hit surface -typedef struct bsp_surface_s -{ - char name[16]; - int flags; - int value; -} bsp_surface_t; - -//remove the bsp_trace_s structure definition l8r on -//a trace is returned when a box is swept through the world -typedef struct bsp_trace_s -{ - qboolean allsolid; // if true, plane is not valid - qboolean startsolid; // if true, the initial point was in a solid area - float fraction; // time completed, 1.0 = didn't hit anything - vec3_t endpos; // final position - cplane_t plane; // surface normal at impact - float exp_dist; // expanded plane distance - int sidenum; // number of the brush side hit - bsp_surface_t surface; // the hit point surface - int contents; // contents on other side of surface hit - int ent; // number of entity hit -} bsp_trace_t; - -#endif // BSPTRACE - -//entity state -typedef struct bot_entitystate_s -{ - int type; // entity type - int flags; // entity flags - vec3_t origin; // origin of the entity - vec3_t angles; // angles of the model - vec3_t old_origin; // for lerping - vec3_t mins; // bounding box minimums - vec3_t maxs; // bounding box maximums - int groundent; // ground entity - int solid; // solid type - int modelindex; // model used - int modelindex2; // weapons, CTF flags, etc - int frame; // model frame number - int event; // impulse events -- muzzle flashes, footsteps, etc - int eventParm; // even parameter - int powerups; // bit flags - int weapon; // determines weapon and flash model, etc - int legsAnim; // mask off ANIM_TOGGLEBIT - int torsoAnim; // mask off ANIM_TOGGLEBIT -} bot_entitystate_t; - -//bot AI library exported functions -typedef struct botlib_import_s -{ - //print messages from the bot library - void (QDECL *Print)(int type, char *fmt, ...); - //trace a bbox through the world - void (*Trace)(bsp_trace_t *trace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask); - //trace a bbox against a specific entity - void (*EntityTrace)(bsp_trace_t *trace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int entnum, int contentmask); - //retrieve the contents at the given point - int (*PointContents)(vec3_t point); - //check if the point is in potential visible sight - int (*inPVS)(vec3_t p1, vec3_t p2); - //retrieve the BSP entity data lump - char *(*BSPEntityData)(void); - // - void (*BSPModelMinsMaxsOrigin)(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin); - //send a bot client command - void (*BotClientCommand)(int client, char *command); - //memory allocation - void *(*GetMemory)(int size); // allocate from Zone - void (*FreeMemory)(void *ptr); // free memory from Zone - int (*AvailableMemory)(void); // available Zone memory - void *(*HunkAlloc)(int size); // allocate from hunk - //file system access - int (*FS_FOpenFile)( const char *qpath, fileHandle_t *file, fsMode_t mode ); - int (*FS_Read)( void *buffer, int len, fileHandle_t f ); - int (*FS_Write)( const void *buffer, int len, fileHandle_t f ); - void (*FS_FCloseFile)( fileHandle_t f ); - int (*FS_Seek)( fileHandle_t f, long offset, int origin ); - //debug visualisation stuff - int (*DebugLineCreate)(void); - void (*DebugLineDelete)(int line); - void (*DebugLineShow)(int line, vec3_t start, vec3_t end, int color); - // - int (*DebugPolygonCreate)(int color, int numPoints, vec3_t *points); - void (*DebugPolygonDelete)(int id); -} botlib_import_t; - -typedef struct aas_export_s -{ - //----------------------------------- - // be_aas_entity.h - //----------------------------------- - void (*AAS_EntityInfo)(int entnum, struct aas_entityinfo_s *info); - //----------------------------------- - // be_aas_main.h - //----------------------------------- - int (*AAS_Initialized)(void); - void (*AAS_PresenceTypeBoundingBox)(int presencetype, vec3_t mins, vec3_t maxs); - float (*AAS_Time)(void); - //-------------------------------------------- - // be_aas_sample.c - //-------------------------------------------- - int (*AAS_PointAreaNum)(vec3_t point); - int (*AAS_PointReachabilityAreaIndex)( vec3_t point ); - int (*AAS_TraceAreas)(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas); - int (*AAS_BBoxAreas)(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas); - int (*AAS_AreaInfo)( int areanum, struct aas_areainfo_s *info ); - //-------------------------------------------- - // be_aas_bspq3.c - //-------------------------------------------- - int (*AAS_PointContents)(vec3_t point); - int (*AAS_NextBSPEntity)(int ent); - int (*AAS_ValueForBSPEpairKey)(int ent, char *key, char *value, int size); - int (*AAS_VectorForBSPEpairKey)(int ent, char *key, vec3_t v); - int (*AAS_FloatForBSPEpairKey)(int ent, char *key, float *value); - int (*AAS_IntForBSPEpairKey)(int ent, char *key, int *value); - //-------------------------------------------- - // be_aas_reach.c - //-------------------------------------------- - int (*AAS_AreaReachability)(int areanum); - //-------------------------------------------- - // be_aas_route.c - //-------------------------------------------- - int (*AAS_AreaTravelTimeToGoalArea)(int areanum, vec3_t origin, int goalareanum, int travelflags); - int (*AAS_EnableRoutingArea)(int areanum, int enable); - int (*AAS_PredictRoute)(struct aas_predictroute_s *route, int areanum, vec3_t origin, - int goalareanum, int travelflags, int maxareas, int maxtime, - int stopevent, int stopcontents, int stoptfl, int stopareanum); - //-------------------------------------------- - // be_aas_altroute.c - //-------------------------------------------- - int (*AAS_AlternativeRouteGoals)(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags, - struct aas_altroutegoal_s *altroutegoals, int maxaltroutegoals, - int type); - //-------------------------------------------- - // be_aas_move.c - //-------------------------------------------- - int (*AAS_Swimming)(vec3_t origin); - int (*AAS_PredictClientMovement)(struct aas_clientmove_s *move, - int entnum, vec3_t origin, - int presencetype, int onground, - vec3_t velocity, vec3_t cmdmove, - int cmdframes, - int maxframes, float frametime, - int stopevent, int stopareanum, int visualize); -} aas_export_t; - -typedef struct ea_export_s -{ - //ClientCommand elementary actions - void (*EA_Command)(int client, char *command ); - void (*EA_Say)(int client, char *str); - void (*EA_SayTeam)(int client, char *str); - // - void (*EA_Action)(int client, int action); - void (*EA_Gesture)(int client); - void (*EA_Talk)(int client); - void (*EA_Attack)(int client); - void (*EA_Use)(int client); - void (*EA_Respawn)(int client); - void (*EA_MoveUp)(int client); - void (*EA_MoveDown)(int client); - void (*EA_MoveForward)(int client); - void (*EA_MoveBack)(int client); - void (*EA_MoveLeft)(int client); - void (*EA_MoveRight)(int client); - void (*EA_Crouch)(int client); - - void (*EA_SelectWeapon)(int client, int weapon); - void (*EA_Jump)(int client); - void (*EA_DelayedJump)(int client); - void (*EA_Move)(int client, vec3_t dir, float speed); - void (*EA_View)(int client, vec3_t viewangles); - //send regular input to the server - void (*EA_EndRegular)(int client, float thinktime); - void (*EA_GetInput)(int client, float thinktime, bot_input_t *input); - void (*EA_ResetInput)(int client); -} ea_export_t; - -typedef struct ai_export_s -{ - //----------------------------------- - // be_ai_char.h - //----------------------------------- - int (*BotLoadCharacter)(char *charfile, float skill); - void (*BotFreeCharacter)(int character); - float (*Characteristic_Float)(int character, int index); - float (*Characteristic_BFloat)(int character, int index, float min, float max); - int (*Characteristic_Integer)(int character, int index); - int (*Characteristic_BInteger)(int character, int index, int min, int max); - void (*Characteristic_String)(int character, int index, char *buf, int size); - //----------------------------------- - // be_ai_chat.h - //----------------------------------- - int (*BotAllocChatState)(void); - void (*BotFreeChatState)(int handle); - void (*BotQueueConsoleMessage)(int chatstate, int type, char *message); - void (*BotRemoveConsoleMessage)(int chatstate, int handle); - int (*BotNextConsoleMessage)(int chatstate, struct bot_consolemessage_s *cm); - int (*BotNumConsoleMessages)(int chatstate); - void (*BotInitialChat)(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); - int (*BotNumInitialChats)(int chatstate, char *type); - int (*BotReplyChat)(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); - int (*BotChatLength)(int chatstate); - void (*BotEnterChat)(int chatstate, int client, int sendto); - void (*BotGetChatMessage)(int chatstate, char *buf, int size); - int (*StringContains)(char *str1, char *str2, int casesensitive); - int (*BotFindMatch)(char *str, struct bot_match_s *match, unsigned long int context); - void (*BotMatchVariable)(struct bot_match_s *match, int variable, char *buf, int size); - void (*UnifyWhiteSpaces)(char *string); - void (*BotReplaceSynonyms)(char *string, unsigned long int context); - int (*BotLoadChatFile)(int chatstate, char *chatfile, char *chatname); - void (*BotSetChatGender)(int chatstate, int gender); - void (*BotSetChatName)(int chatstate, char *name, int client); - //----------------------------------- - // be_ai_goal.h - //----------------------------------- - void (*BotResetGoalState)(int goalstate); - void (*BotResetAvoidGoals)(int goalstate); - void (*BotRemoveFromAvoidGoals)(int goalstate, int number); - void (*BotPushGoal)(int goalstate, struct bot_goal_s *goal); - void (*BotPopGoal)(int goalstate); - void (*BotEmptyGoalStack)(int goalstate); - void (*BotDumpAvoidGoals)(int goalstate); - void (*BotDumpGoalStack)(int goalstate); - void (*BotGoalName)(int number, char *name, int size); - int (*BotGetTopGoal)(int goalstate, struct bot_goal_s *goal); - int (*BotGetSecondGoal)(int goalstate, struct bot_goal_s *goal); - int (*BotChooseLTGItem)(int goalstate, vec3_t origin, int *inventory, int travelflags); - int (*BotChooseNBGItem)(int goalstate, vec3_t origin, int *inventory, int travelflags, - struct bot_goal_s *ltg, float maxtime); - int (*BotTouchingGoal)(vec3_t origin, struct bot_goal_s *goal); - int (*BotItemGoalInVisButNotVisible)(int viewer, vec3_t eye, vec3_t viewangles, struct bot_goal_s *goal); - int (*BotGetLevelItemGoal)(int index, char *classname, struct bot_goal_s *goal); - int (*BotGetNextCampSpotGoal)(int num, struct bot_goal_s *goal); - int (*BotGetMapLocationGoal)(char *name, struct bot_goal_s *goal); - float (*BotAvoidGoalTime)(int goalstate, int number); - void (*BotSetAvoidGoalTime)(int goalstate, int number, float avoidtime); - void (*BotInitLevelItems)(void); - void (*BotUpdateEntityItems)(void); - int (*BotLoadItemWeights)(int goalstate, char *filename); - void (*BotFreeItemWeights)(int goalstate); - void (*BotInterbreedGoalFuzzyLogic)(int parent1, int parent2, int child); - void (*BotSaveGoalFuzzyLogic)(int goalstate, char *filename); - void (*BotMutateGoalFuzzyLogic)(int goalstate, float range); - int (*BotAllocGoalState)(int client); - void (*BotFreeGoalState)(int handle); - //----------------------------------- - // be_ai_move.h - //----------------------------------- - void (*BotResetMoveState)(int movestate); - void (*BotMoveToGoal)(struct bot_moveresult_s *result, int movestate, struct bot_goal_s *goal, int travelflags); - int (*BotMoveInDirection)(int movestate, vec3_t dir, float speed, int type); - void (*BotResetAvoidReach)(int movestate); - void (*BotResetLastAvoidReach)(int movestate); - int (*BotReachabilityArea)(vec3_t origin, int testground); - int (*BotMovementViewTarget)(int movestate, struct bot_goal_s *goal, int travelflags, float lookahead, vec3_t target); - int (*BotPredictVisiblePosition)(vec3_t origin, int areanum, struct bot_goal_s *goal, int travelflags, vec3_t target); - int (*BotAllocMoveState)(void); - void (*BotFreeMoveState)(int handle); - void (*BotInitMoveState)(int handle, struct bot_initmove_s *initmove); - void (*BotAddAvoidSpot)(int movestate, vec3_t origin, float radius, int type); - //----------------------------------- - // be_ai_weap.h - //----------------------------------- - int (*BotChooseBestFightWeapon)(int weaponstate, int *inventory); - void (*BotGetWeaponInfo)(int weaponstate, int weapon, struct weaponinfo_s *weaponinfo); - int (*BotLoadWeaponWeights)(int weaponstate, char *filename); - int (*BotAllocWeaponState)(void); - void (*BotFreeWeaponState)(int weaponstate); - void (*BotResetWeaponState)(int weaponstate); - //----------------------------------- - // be_ai_gen.h - //----------------------------------- - int (*GeneticParentsAndChildSelection)(int numranks, float *ranks, int *parent1, int *parent2, int *child); -} ai_export_t; - -//bot AI library imported functions -typedef struct botlib_export_s -{ - //Area Awareness System functions - aas_export_t aas; - //Elementary Action functions - ea_export_t ea; - //AI functions - ai_export_t ai; - //setup the bot library, returns BLERR_ - int (*BotLibSetup)(void); - //shutdown the bot library, returns BLERR_ - int (*BotLibShutdown)(void); - //sets a library variable returns BLERR_ - int (*BotLibVarSet)(char *var_name, char *value); - //gets a library variable returns BLERR_ - int (*BotLibVarGet)(char *var_name, char *value, int size); - - //sets a C-like define returns BLERR_ - int (*PC_AddGlobalDefine)(char *string); - int (*PC_LoadSourceHandle)(const char *filename); - int (*PC_FreeSourceHandle)(int handle); - int (*PC_ReadTokenHandle)(int handle, pc_token_t *pc_token); - int (*PC_SourceFileAndLine)(int handle, char *filename, int *line); - - //start a frame in the bot library - int (*BotLibStartFrame)(float time); - //load a new map in the bot library - int (*BotLibLoadMap)(const char *mapname); - //entity updates - int (*BotLibUpdateEntity)(int ent, bot_entitystate_t *state); - //just for testing - int (*Test)(int parm0, char *parm1, vec3_t parm2, vec3_t parm3); -} botlib_export_t; - -//linking of bot library -botlib_export_t *GetBotLibAPI( int apiVersion, botlib_import_t *import ); - -/* Library variables: - -name: default: module(s): description: - -"basedir" "" l_utils.c base directory -"gamedir" "" l_utils.c game directory -"cddir" "" l_utils.c CD directory - -"log" "0" l_log.c enable/disable creating a log file -"maxclients" "4" be_interface.c maximum number of clients -"maxentities" "1024" be_interface.c maximum number of entities -"bot_developer" "0" be_interface.c bot developer mode - -"phys_friction" "6" be_aas_move.c ground friction -"phys_stopspeed" "100" be_aas_move.c stop speed -"phys_gravity" "800" be_aas_move.c gravity value -"phys_waterfriction" "1" be_aas_move.c water friction -"phys_watergravity" "400" be_aas_move.c gravity in water -"phys_maxvelocity" "320" be_aas_move.c maximum velocity -"phys_maxwalkvelocity" "320" be_aas_move.c maximum walk velocity -"phys_maxcrouchvelocity" "100" be_aas_move.c maximum crouch velocity -"phys_maxswimvelocity" "150" be_aas_move.c maximum swim velocity -"phys_walkaccelerate" "10" be_aas_move.c walk acceleration -"phys_airaccelerate" "1" be_aas_move.c air acceleration -"phys_swimaccelerate" "4" be_aas_move.c swim acceleration -"phys_maxstep" "18" be_aas_move.c maximum step height -"phys_maxsteepness" "0.7" be_aas_move.c maximum floor steepness -"phys_maxbarrier" "32" be_aas_move.c maximum barrier height -"phys_maxwaterjump" "19" be_aas_move.c maximum waterjump height -"phys_jumpvel" "270" be_aas_move.c jump z velocity -"phys_falldelta5" "40" be_aas_move.c -"phys_falldelta10" "60" be_aas_move.c -"rs_waterjump" "400" be_aas_move.c -"rs_teleport" "50" be_aas_move.c -"rs_barrierjump" "100" be_aas_move.c -"rs_startcrouch" "300" be_aas_move.c -"rs_startgrapple" "500" be_aas_move.c -"rs_startwalkoffledge" "70" be_aas_move.c -"rs_startjump" "300" be_aas_move.c -"rs_rocketjump" "500" be_aas_move.c -"rs_bfgjump" "500" be_aas_move.c -"rs_jumppad" "250" be_aas_move.c -"rs_aircontrolledjumppad" "300" be_aas_move.c -"rs_funcbob" "300" be_aas_move.c -"rs_startelevator" "50" be_aas_move.c -"rs_falldamage5" "300" be_aas_move.c -"rs_falldamage10" "500" be_aas_move.c -"rs_maxjumpfallheight" "450" be_aas_move.c - -"max_aaslinks" "4096" be_aas_sample.c maximum links in the AAS -"max_routingcache" "4096" be_aas_route.c maximum routing cache size in KB -"forceclustering" "0" be_aas_main.c force recalculation of clusters -"forcereachability" "0" be_aas_main.c force recalculation of reachabilities -"forcewrite" "0" be_aas_main.c force writing of aas file -"aasoptimize" "0" be_aas_main.c enable aas optimization -"sv_mapChecksum" "0" be_aas_main.c BSP file checksum -"bot_visualizejumppads" "0" be_aas_reach.c visualize jump pads - -"bot_reloadcharacters" "0" - reload bot character files -"ai_gametype" "0" be_ai_goal.c game type -"droppedweight" "1000" be_ai_goal.c additional dropped item weight -"weapindex_rocketlauncher" "5" be_ai_move.c rl weapon index for rocket jumping -"weapindex_bfg10k" "9" be_ai_move.c bfg weapon index for bfg jumping -"weapindex_grapple" "10" be_ai_move.c grapple weapon index for grappling -"entitytypemissile" "3" be_ai_move.c ET_MISSILE -"offhandgrapple" "0" be_ai_move.c enable off hand grapple hook -"cmd_grappleon" "grappleon" be_ai_move.c command to activate off hand grapple -"cmd_grappleoff" "grappleoff" be_ai_move.c command to deactivate off hand grapple -"itemconfig" "items.c" be_ai_goal.c item configuration file -"weaponconfig" "weapons.c" be_ai_weap.c weapon configuration file -"synfile" "syn.c" be_ai_chat.c file with synonyms -"rndfile" "rnd.c" be_ai_chat.c file with random strings -"matchfile" "match.c" be_ai_chat.c file with match strings -"nochat" "0" be_ai_chat.c disable chats -"max_messages" "1024" be_ai_chat.c console message heap size -"max_weaponinfo" "32" be_ai_weap.c maximum number of weapon info -"max_projectileinfo" "32" be_ai_weap.c maximum number of projectile info -"max_iteminfo" "256" be_ai_goal.c maximum number of item info -"max_levelitems" "256" be_ai_goal.c maximum number of level items - -*/ - diff --git a/code/game/g_local.h b/code/game/g_local.h index 4ae76fc..7e20d36 100644 --- a/code/game/g_local.h +++ b/code/game/g_local.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // // g_local.h -- local definitions for game module -#include "q_shared.h" +#include "../qcommon/q_shared.h" #include "bg_public.h" #include "g_public.h" diff --git a/code/game/q_math.c b/code/game/q_math.c deleted file mode 100644 index fd835df..0000000 --- a/code/game/q_math.c +++ /dev/null @@ -1,1307 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code 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. - -Quake III Arena source code 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 Foobar; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// -// q_math.c -- stateless support routines that are included in each code module -#include "q_shared.h" - - -vec3_t vec3_origin = {0,0,0}; -vec3_t axisDefault[3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; - - -vec4_t colorBlack = {0, 0, 0, 1}; -vec4_t colorRed = {1, 0, 0, 1}; -vec4_t colorGreen = {0, 1, 0, 1}; -vec4_t colorBlue = {0, 0, 1, 1}; -vec4_t colorYellow = {1, 1, 0, 1}; -vec4_t colorMagenta= {1, 0, 1, 1}; -vec4_t colorCyan = {0, 1, 1, 1}; -vec4_t colorWhite = {1, 1, 1, 1}; -vec4_t colorLtGrey = {0.75, 0.75, 0.75, 1}; -vec4_t colorMdGrey = {0.5, 0.5, 0.5, 1}; -vec4_t colorDkGrey = {0.25, 0.25, 0.25, 1}; - -vec4_t g_color_table[8] = - { - {0.0, 0.0, 0.0, 1.0}, - {1.0, 0.0, 0.0, 1.0}, - {0.0, 1.0, 0.0, 1.0}, - {1.0, 1.0, 0.0, 1.0}, - {0.0, 0.0, 1.0, 1.0}, - {0.0, 1.0, 1.0, 1.0}, - {1.0, 0.0, 1.0, 1.0}, - {1.0, 1.0, 1.0, 1.0}, - }; - - -vec3_t bytedirs[NUMVERTEXNORMALS] = -{ -{-0.525731f, 0.000000f, 0.850651f}, {-0.442863f, 0.238856f, 0.864188f}, -{-0.295242f, 0.000000f, 0.955423f}, {-0.309017f, 0.500000f, 0.809017f}, -{-0.162460f, 0.262866f, 0.951056f}, {0.000000f, 0.000000f, 1.000000f}, -{0.000000f, 0.850651f, 0.525731f}, {-0.147621f, 0.716567f, 0.681718f}, -{0.147621f, 0.716567f, 0.681718f}, {0.000000f, 0.525731f, 0.850651f}, -{0.309017f, 0.500000f, 0.809017f}, {0.525731f, 0.000000f, 0.850651f}, -{0.295242f, 0.000000f, 0.955423f}, {0.442863f, 0.238856f, 0.864188f}, -{0.162460f, 0.262866f, 0.951056f}, {-0.681718f, 0.147621f, 0.716567f}, -{-0.809017f, 0.309017f, 0.500000f},{-0.587785f, 0.425325f, 0.688191f}, -{-0.850651f, 0.525731f, 0.000000f},{-0.864188f, 0.442863f, 0.238856f}, -{-0.716567f, 0.681718f, 0.147621f},{-0.688191f, 0.587785f, 0.425325f}, -{-0.500000f, 0.809017f, 0.309017f}, {-0.238856f, 0.864188f, 0.442863f}, -{-0.425325f, 0.688191f, 0.587785f}, {-0.716567f, 0.681718f, -0.147621f}, -{-0.500000f, 0.809017f, -0.309017f}, {-0.525731f, 0.850651f, 0.000000f}, -{0.000000f, 0.850651f, -0.525731f}, {-0.238856f, 0.864188f, -0.442863f}, -{0.000000f, 0.955423f, -0.295242f}, {-0.262866f, 0.951056f, -0.162460f}, -{0.000000f, 1.000000f, 0.000000f}, {0.000000f, 0.955423f, 0.295242f}, -{-0.262866f, 0.951056f, 0.162460f}, {0.238856f, 0.864188f, 0.442863f}, -{0.262866f, 0.951056f, 0.162460f}, {0.500000f, 0.809017f, 0.309017f}, -{0.238856f, 0.864188f, -0.442863f},{0.262866f, 0.951056f, -0.162460f}, -{0.500000f, 0.809017f, -0.309017f},{0.850651f, 0.525731f, 0.000000f}, -{0.716567f, 0.681718f, 0.147621f}, {0.716567f, 0.681718f, -0.147621f}, -{0.525731f, 0.850651f, 0.000000f}, {0.425325f, 0.688191f, 0.587785f}, -{0.864188f, 0.442863f, 0.238856f}, {0.688191f, 0.587785f, 0.425325f}, -{0.809017f, 0.309017f, 0.500000f}, {0.681718f, 0.147621f, 0.716567f}, -{0.587785f, 0.425325f, 0.688191f}, {0.955423f, 0.295242f, 0.000000f}, -{1.000000f, 0.000000f, 0.000000f}, {0.951056f, 0.162460f, 0.262866f}, -{0.850651f, -0.525731f, 0.000000f},{0.955423f, -0.295242f, 0.000000f}, -{0.864188f, -0.442863f, 0.238856f}, {0.951056f, -0.162460f, 0.262866f}, -{0.809017f, -0.309017f, 0.500000f}, {0.681718f, -0.147621f, 0.716567f}, -{0.850651f, 0.000000f, 0.525731f}, {0.864188f, 0.442863f, -0.238856f}, -{0.809017f, 0.309017f, -0.500000f}, {0.951056f, 0.162460f, -0.262866f}, -{0.525731f, 0.000000f, -0.850651f}, {0.681718f, 0.147621f, -0.716567f}, -{0.681718f, -0.147621f, -0.716567f},{0.850651f, 0.000000f, -0.525731f}, -{0.809017f, -0.309017f, -0.500000f}, {0.864188f, -0.442863f, -0.238856f}, -{0.951056f, -0.162460f, -0.262866f}, {0.147621f, 0.716567f, -0.681718f}, -{0.309017f, 0.500000f, -0.809017f}, {0.425325f, 0.688191f, -0.587785f}, -{0.442863f, 0.238856f, -0.864188f}, {0.587785f, 0.425325f, -0.688191f}, -{0.688191f, 0.587785f, -0.425325f}, {-0.147621f, 0.716567f, -0.681718f}, -{-0.309017f, 0.500000f, -0.809017f}, {0.000000f, 0.525731f, -0.850651f}, -{-0.525731f, 0.000000f, -0.850651f}, {-0.442863f, 0.238856f, -0.864188f}, -{-0.295242f, 0.000000f, -0.955423f}, {-0.162460f, 0.262866f, -0.951056f}, -{0.000000f, 0.000000f, -1.000000f}, {0.295242f, 0.000000f, -0.955423f}, -{0.162460f, 0.262866f, -0.951056f}, {-0.442863f, -0.238856f, -0.864188f}, -{-0.309017f, -0.500000f, -0.809017f}, {-0.162460f, -0.262866f, -0.951056f}, -{0.000000f, -0.850651f, -0.525731f}, {-0.147621f, -0.716567f, -0.681718f}, -{0.147621f, -0.716567f, -0.681718f}, {0.000000f, -0.525731f, -0.850651f}, -{0.309017f, -0.500000f, -0.809017f}, {0.442863f, -0.238856f, -0.864188f}, -{0.162460f, -0.262866f, -0.951056f}, {0.238856f, -0.864188f, -0.442863f}, -{0.500000f, -0.809017f, -0.309017f}, {0.425325f, -0.688191f, -0.587785f}, -{0.716567f, -0.681718f, -0.147621f}, {0.688191f, -0.587785f, -0.425325f}, -{0.587785f, -0.425325f, -0.688191f}, {0.000000f, -0.955423f, -0.295242f}, -{0.000000f, -1.000000f, 0.000000f}, {0.262866f, -0.951056f, -0.162460f}, -{0.000000f, -0.850651f, 0.525731f}, {0.000000f, -0.955423f, 0.295242f}, -{0.238856f, -0.864188f, 0.442863f}, {0.262866f, -0.951056f, 0.162460f}, -{0.500000f, -0.809017f, 0.309017f}, {0.716567f, -0.681718f, 0.147621f}, -{0.525731f, -0.850651f, 0.000000f}, {-0.238856f, -0.864188f, -0.442863f}, -{-0.500000f, -0.809017f, -0.309017f}, {-0.262866f, -0.951056f, -0.162460f}, -{-0.850651f, -0.525731f, 0.000000f}, {-0.716567f, -0.681718f, -0.147621f}, -{-0.716567f, -0.681718f, 0.147621f}, {-0.525731f, -0.850651f, 0.000000f}, -{-0.500000f, -0.809017f, 0.309017f}, {-0.238856f, -0.864188f, 0.442863f}, -{-0.262866f, -0.951056f, 0.162460f}, {-0.864188f, -0.442863f, 0.238856f}, -{-0.809017f, -0.309017f, 0.500000f}, {-0.688191f, -0.587785f, 0.425325f}, -{-0.681718f, -0.147621f, 0.716567f}, {-0.442863f, -0.238856f, 0.864188f}, -{-0.587785f, -0.425325f, 0.688191f}, {-0.309017f, -0.500000f, 0.809017f}, -{-0.147621f, -0.716567f, 0.681718f}, {-0.425325f, -0.688191f, 0.587785f}, -{-0.162460f, -0.262866f, 0.951056f}, {0.442863f, -0.238856f, 0.864188f}, -{0.162460f, -0.262866f, 0.951056f}, {0.309017f, -0.500000f, 0.809017f}, -{0.147621f, -0.716567f, 0.681718f}, {0.000000f, -0.525731f, 0.850651f}, -{0.425325f, -0.688191f, 0.587785f}, {0.587785f, -0.425325f, 0.688191f}, -{0.688191f, -0.587785f, 0.425325f}, {-0.955423f, 0.295242f, 0.000000f}, -{-0.951056f, 0.162460f, 0.262866f}, {-1.000000f, 0.000000f, 0.000000f}, -{-0.850651f, 0.000000f, 0.525731f}, {-0.955423f, -0.295242f, 0.000000f}, -{-0.951056f, -0.162460f, 0.262866f}, {-0.864188f, 0.442863f, -0.238856f}, -{-0.951056f, 0.162460f, -0.262866f}, {-0.809017f, 0.309017f, -0.500000f}, -{-0.864188f, -0.442863f, -0.238856f}, {-0.951056f, -0.162460f, -0.262866f}, -{-0.809017f, -0.309017f, -0.500000f}, {-0.681718f, 0.147621f, -0.716567f}, -{-0.681718f, -0.147621f, -0.716567f}, {-0.850651f, 0.000000f, -0.525731f}, -{-0.688191f, 0.587785f, -0.425325f}, {-0.587785f, 0.425325f, -0.688191f}, -{-0.425325f, 0.688191f, -0.587785f}, {-0.425325f, -0.688191f, -0.587785f}, -{-0.587785f, -0.425325f, -0.688191f}, {-0.688191f, -0.587785f, -0.425325f} -}; - -//============================================================== - -int Q_rand( int *seed ) { - *seed = (69069 * *seed + 1); - return *seed; -} - -float Q_random( int *seed ) { - return ( Q_rand( seed ) & 0xffff ) / (float)0x10000; -} - -float Q_crandom( int *seed ) { - return 2.0 * ( Q_random( seed ) - 0.5 ); -} - -#ifdef __LCC__ - -int VectorCompare( const vec3_t v1, const vec3_t v2 ) { - if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) { - return 0; - } - return 1; -} - -vec_t VectorLength( const vec3_t v ) { - return (vec_t)sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); -} - -vec_t VectorLengthSquared( const vec3_t v ) { - return (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); -} - -vec_t Distance( const vec3_t p1, const vec3_t p2 ) { - vec3_t v; - - VectorSubtract (p2, p1, v); - return VectorLength( v ); -} - -vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ) { - vec3_t v; - - VectorSubtract (p2, p1, v); - return v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; -} - -// fast vector normalize routine that does not check to make sure -// that length != 0, nor does it return length, uses rsqrt approximation -void VectorNormalizeFast( vec3_t v ) -{ - float ilength; - - ilength = Q_rsqrt( DotProduct( v, v ) ); - - v[0] *= ilength; - v[1] *= ilength; - v[2] *= ilength; -} - -void VectorInverse( vec3_t v ){ - v[0] = -v[0]; - v[1] = -v[1]; - v[2] = -v[2]; -} - -void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) { - cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; - cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; - cross[2] = v1[0]*v2[1] - v1[1]*v2[0]; -} -#endif - -//======================================================= - -signed char ClampChar( int i ) { - if ( i < -128 ) { - return -128; - } - if ( i > 127 ) { - return 127; - } - return i; -} - -signed short ClampShort( int i ) { - if ( i < -32768 ) { - return -32768; - } - if ( i > 0x7fff ) { - return 0x7fff; - } - return i; -} - - -// this isn't a real cheap function to call! -int DirToByte( vec3_t dir ) { - int i, best; - float d, bestd; - - if ( !dir ) { - return 0; - } - - bestd = 0; - best = 0; - for (i=0 ; i bestd) - { - bestd = d; - best = i; - } - } - - return best; -} - -void ByteToDir( int b, vec3_t dir ) { - if ( b < 0 || b >= NUMVERTEXNORMALS ) { - VectorCopy( vec3_origin, dir ); - return; - } - VectorCopy (bytedirs[b], dir); -} - - -unsigned ColorBytes3 (float r, float g, float b) { - unsigned i; - - ( (byte *)&i )[0] = r * 255; - ( (byte *)&i )[1] = g * 255; - ( (byte *)&i )[2] = b * 255; - - return i; -} - -unsigned ColorBytes4 (float r, float g, float b, float a) { - unsigned i; - - ( (byte *)&i )[0] = r * 255; - ( (byte *)&i )[1] = g * 255; - ( (byte *)&i )[2] = b * 255; - ( (byte *)&i )[3] = a * 255; - - return i; -} - -float NormalizeColor( const vec3_t in, vec3_t out ) { - float max; - - max = in[0]; - if ( in[1] > max ) { - max = in[1]; - } - if ( in[2] > max ) { - max = in[2]; - } - - if ( !max ) { - VectorClear( out ); - } else { - out[0] = in[0] / max; - out[1] = in[1] / max; - out[2] = in[2] / max; - } - return max; -} - - -/* -===================== -PlaneFromPoints - -Returns false if the triangle is degenrate. -The normal will point out of the clock for clockwise ordered points -===================== -*/ -qboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c ) { - vec3_t d1, d2; - - VectorSubtract( b, a, d1 ); - VectorSubtract( c, a, d2 ); - CrossProduct( d2, d1, plane ); - if ( VectorNormalize( plane ) == 0 ) { - return qfalse; - } - - plane[3] = DotProduct( a, plane ); - return qtrue; -} - -/* -=============== -RotatePointAroundVector - -This is not implemented very well... -=============== -*/ -void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, - float degrees ) { - float m[3][3]; - float im[3][3]; - float zrot[3][3]; - float tmpmat[3][3]; - float rot[3][3]; - int i; - vec3_t vr, vup, vf; - float rad; - - vf[0] = dir[0]; - vf[1] = dir[1]; - vf[2] = dir[2]; - - PerpendicularVector( vr, dir ); - CrossProduct( vr, vf, vup ); - - m[0][0] = vr[0]; - m[1][0] = vr[1]; - m[2][0] = vr[2]; - - m[0][1] = vup[0]; - m[1][1] = vup[1]; - m[2][1] = vup[2]; - - m[0][2] = vf[0]; - m[1][2] = vf[1]; - m[2][2] = vf[2]; - - memcpy( im, m, sizeof( im ) ); - - im[0][1] = m[1][0]; - im[0][2] = m[2][0]; - im[1][0] = m[0][1]; - im[1][2] = m[2][1]; - im[2][0] = m[0][2]; - im[2][1] = m[1][2]; - - memset( zrot, 0, sizeof( zrot ) ); - zrot[0][0] = zrot[1][1] = zrot[2][2] = 1.0F; - - rad = DEG2RAD( degrees ); - zrot[0][0] = cos( rad ); - zrot[0][1] = sin( rad ); - zrot[1][0] = -sin( rad ); - zrot[1][1] = cos( rad ); - - MatrixMultiply( m, zrot, tmpmat ); - MatrixMultiply( tmpmat, im, rot ); - - for ( i = 0; i < 3; i++ ) { - dst[i] = rot[i][0] * point[0] + rot[i][1] * point[1] + rot[i][2] * point[2]; - } -} - -/* -=============== -RotateAroundDirection -=============== -*/ -void RotateAroundDirection( vec3_t axis[3], float yaw ) { - - // create an arbitrary axis[1] - PerpendicularVector( axis[1], axis[0] ); - - // rotate it around axis[0] by yaw - if ( yaw ) { - vec3_t temp; - - VectorCopy( axis[1], temp ); - RotatePointAroundVector( axis[1], axis[0], temp, yaw ); - } - - // cross to get axis[2] - CrossProduct( axis[0], axis[1], axis[2] ); -} - - - -void vectoangles( const vec3_t value1, vec3_t angles ) { - float forward; - float yaw, pitch; - - if ( value1[1] == 0 && value1[0] == 0 ) { - yaw = 0; - if ( value1[2] > 0 ) { - pitch = 90; - } - else { - pitch = 270; - } - } - else { - if ( value1[0] ) { - yaw = ( atan2 ( value1[1], value1[0] ) * 180 / M_PI ); - } - else if ( value1[1] > 0 ) { - yaw = 90; - } - else { - yaw = 270; - } - if ( yaw < 0 ) { - yaw += 360; - } - - forward = sqrt ( value1[0]*value1[0] + value1[1]*value1[1] ); - pitch = ( atan2(value1[2], forward) * 180 / M_PI ); - if ( pitch < 0 ) { - pitch += 360; - } - } - - angles[PITCH] = -pitch; - angles[YAW] = yaw; - angles[ROLL] = 0; -} - - -/* -================= -AnglesToAxis -================= -*/ -void AnglesToAxis( const vec3_t angles, vec3_t axis[3] ) { - vec3_t right; - - // angle vectors returns "right" instead of "y axis" - AngleVectors( angles, axis[0], right, axis[2] ); - VectorSubtract( vec3_origin, right, axis[1] ); -} - -void AxisClear( vec3_t axis[3] ) { - axis[0][0] = 1; - axis[0][1] = 0; - axis[0][2] = 0; - axis[1][0] = 0; - axis[1][1] = 1; - axis[1][2] = 0; - axis[2][0] = 0; - axis[2][1] = 0; - axis[2][2] = 1; -} - -void AxisCopy( vec3_t in[3], vec3_t out[3] ) { - VectorCopy( in[0], out[0] ); - VectorCopy( in[1], out[1] ); - VectorCopy( in[2], out[2] ); -} - -void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal ) -{ - float d; - vec3_t n; - float inv_denom; - - inv_denom = DotProduct( normal, normal ); -#ifndef Q3_VM - assert( Q_fabs(inv_denom) != 0.0f ); // bk010122 - zero vectors get here -#endif - inv_denom = 1.0f / inv_denom; - - d = DotProduct( normal, p ) * inv_denom; - - n[0] = normal[0] * inv_denom; - n[1] = normal[1] * inv_denom; - n[2] = normal[2] * inv_denom; - - dst[0] = p[0] - d * n[0]; - dst[1] = p[1] - d * n[1]; - dst[2] = p[2] - d * n[2]; -} - -/* -================ -MakeNormalVectors - -Given a normalized forward vector, create two -other perpendicular vectors -================ -*/ -void MakeNormalVectors( const vec3_t forward, vec3_t right, vec3_t up) { - float d; - - // this rotate and negate guarantees a vector - // not colinear with the original - right[1] = -forward[0]; - right[2] = forward[1]; - right[0] = forward[2]; - - d = DotProduct (right, forward); - VectorMA (right, -d, forward, right); - VectorNormalize (right); - CrossProduct (right, forward, up); -} - - -void VectorRotate( vec3_t in, vec3_t matrix[3], vec3_t out ) -{ - out[0] = DotProduct( in, matrix[0] ); - out[1] = DotProduct( in, matrix[1] ); - out[2] = DotProduct( in, matrix[2] ); -} - -//============================================================================ - -#if !idppc -/* -** float q_rsqrt( float number ) -*/ -float Q_rsqrt( float number ) -{ - union { - float f; - int i; - } t; - float x2, y; - const float threehalfs = 1.5F; - - x2 = number * 0.5F; - t.f = number; - t.i = 0x5f3759df - ( t.i >> 1 ); // what the fuck? - y = t.f; - y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration -// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed - - //assert( !isnan(y) ); // bk010122 - FPE? - return y; -} - -float Q_fabs( float f ) { - int tmp = * ( int * ) &f; - tmp &= 0x7FFFFFFF; - return * ( float * ) &tmp; -} -#endif - -//============================================================ - -/* -=============== -LerpAngle - -=============== -*/ -float LerpAngle (float from, float to, float frac) { - float a; - - if ( to - from > 180 ) { - to -= 360; - } - if ( to - from < -180 ) { - to += 360; - } - a = from + frac * (to - from); - - return a; -} - - -/* -================= -AngleSubtract - -Always returns a value from -180 to 180 -================= -*/ -float AngleSubtract( float a1, float a2 ) { - float a; - - a = a1 - a2; - while ( a > 180 ) { - a -= 360; - } - while ( a < -180 ) { - a += 360; - } - return a; -} - - -void AnglesSubtract( vec3_t v1, vec3_t v2, vec3_t v3 ) { - v3[0] = AngleSubtract( v1[0], v2[0] ); - v3[1] = AngleSubtract( v1[1], v2[1] ); - v3[2] = AngleSubtract( v1[2], v2[2] ); -} - - -float AngleMod(float a) { - a = (360.0/65536) * ((int)(a*(65536/360.0)) & 65535); - return a; -} - - -/* -================= -AngleNormalize360 - -returns angle normalized to the range [0 <= angle < 360] -================= -*/ -float AngleNormalize360 ( float angle ) { - return (360.0 / 65536) * ((int)(angle * (65536 / 360.0)) & 65535); -} - - -/* -================= -AngleNormalize180 - -returns angle normalized to the range [-180 < angle <= 180] -================= -*/ -float AngleNormalize180 ( float angle ) { - angle = AngleNormalize360( angle ); - if ( angle > 180.0 ) { - angle -= 360.0; - } - return angle; -} - - -/* -================= -AngleDelta - -returns the normalized delta from angle1 to angle2 -================= -*/ -float AngleDelta ( float angle1, float angle2 ) { - return AngleNormalize180( angle1 - angle2 ); -} - - -//============================================================ - - -/* -================= -SetPlaneSignbits -================= -*/ -void SetPlaneSignbits (cplane_t *out) { - int bits, j; - - // for fast box on planeside test - bits = 0; - for (j=0 ; j<3 ; j++) { - if (out->normal[j] < 0) { - bits |= 1<signbits = bits; -} - - -/* -================== -BoxOnPlaneSide - -Returns 1, 2, or 1 + 2 - -// this is the slow, general version -int BoxOnPlaneSide2 (vec3_t emins, vec3_t emaxs, struct cplane_s *p) -{ - int i; - float dist1, dist2; - int sides; - vec3_t corners[2]; - - for (i=0 ; i<3 ; i++) - { - if (p->normal[i] < 0) - { - corners[0][i] = emins[i]; - corners[1][i] = emaxs[i]; - } - else - { - corners[1][i] = emins[i]; - corners[0][i] = emaxs[i]; - } - } - dist1 = DotProduct (p->normal, corners[0]) - p->dist; - dist2 = DotProduct (p->normal, corners[1]) - p->dist; - sides = 0; - if (dist1 >= 0) - sides = 1; - if (dist2 < 0) - sides |= 2; - - return sides; -} - -================== -*/ - -// if not GNU x86 and configured to use asm -#if !( (defined __GNUC__) && (defined __i386__) && (!defined C_ONLY)) - -#if defined __LCC__ || defined C_ONLY || !id386 || defined __VECTORC - -int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p) -{ - float dist1, dist2; - int sides; - -// fast axial cases - if (p->type < 3) - { - if (p->dist <= emins[p->type]) - return 1; - if (p->dist >= emaxs[p->type]) - return 2; - return 3; - } - -// general case - switch (p->signbits) - { - case 0: - dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; - dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; - break; - case 1: - dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; - dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; - break; - case 2: - dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; - dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; - break; - case 3: - dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; - dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; - break; - case 4: - dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; - dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; - break; - case 5: - dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; - dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; - break; - case 6: - dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; - dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; - break; - case 7: - dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; - dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; - break; - default: - dist1 = dist2 = 0; // shut up compiler - break; - } - - sides = 0; - if (dist1 >= p->dist) - sides = 1; - if (dist2 < p->dist) - sides |= 2; - - return sides; -} -#else -#pragma warning( disable: 4035 ) - -__declspec( naked ) int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p) -{ - static int bops_initialized; - static int Ljmptab[8]; - - __asm { - - push ebx - - cmp bops_initialized, 1 - je initialized - mov bops_initialized, 1 - - mov Ljmptab[0*4], offset Lcase0 - mov Ljmptab[1*4], offset Lcase1 - mov Ljmptab[2*4], offset Lcase2 - mov Ljmptab[3*4], offset Lcase3 - mov Ljmptab[4*4], offset Lcase4 - mov Ljmptab[5*4], offset Lcase5 - mov Ljmptab[6*4], offset Lcase6 - mov Ljmptab[7*4], offset Lcase7 - -initialized: - - mov edx,dword ptr[4+12+esp] - mov ecx,dword ptr[4+4+esp] - xor eax,eax - mov ebx,dword ptr[4+8+esp] - mov al,byte ptr[17+edx] - cmp al,8 - jge Lerror - fld dword ptr[0+edx] - fld st(0) - jmp dword ptr[Ljmptab+eax*4] -Lcase0: - fmul dword ptr[ebx] - fld dword ptr[0+4+edx] - fxch st(2) - fmul dword ptr[ecx] - fxch st(2) - fld st(0) - fmul dword ptr[4+ebx] - fld dword ptr[0+8+edx] - fxch st(2) - fmul dword ptr[4+ecx] - fxch st(2) - fld st(0) - fmul dword ptr[8+ebx] - fxch st(5) - faddp st(3),st(0) - fmul dword ptr[8+ecx] - fxch st(1) - faddp st(3),st(0) - fxch st(3) - faddp st(2),st(0) - jmp LSetSides -Lcase1: - fmul dword ptr[ecx] - fld dword ptr[0+4+edx] - fxch st(2) - fmul dword ptr[ebx] - fxch st(2) - fld st(0) - fmul dword ptr[4+ebx] - fld dword ptr[0+8+edx] - fxch st(2) - fmul dword ptr[4+ecx] - fxch st(2) - fld st(0) - fmul dword ptr[8+ebx] - fxch st(5) - faddp st(3),st(0) - fmul dword ptr[8+ecx] - fxch st(1) - faddp st(3),st(0) - fxch st(3) - faddp st(2),st(0) - jmp LSetSides -Lcase2: - fmul dword ptr[ebx] - fld dword ptr[0+4+edx] - fxch st(2) - fmul dword ptr[ecx] - fxch st(2) - fld st(0) - fmul dword ptr[4+ecx] - fld dword ptr[0+8+edx] - fxch st(2) - fmul dword ptr[4+ebx] - fxch st(2) - fld st(0) - fmul dword ptr[8+ebx] - fxch st(5) - faddp st(3),st(0) - fmul dword ptr[8+ecx] - fxch st(1) - faddp st(3),st(0) - fxch st(3) - faddp st(2),st(0) - jmp LSetSides -Lcase3: - fmul dword ptr[ecx] - fld dword ptr[0+4+edx] - fxch st(2) - fmul dword ptr[ebx] - fxch st(2) - fld st(0) - fmul dword ptr[4+ecx] - fld dword ptr[0+8+edx] - fxch st(2) - fmul dword ptr[4+ebx] - fxch st(2) - fld st(0) - fmul dword ptr[8+ebx] - fxch st(5) - faddp st(3),st(0) - fmul dword ptr[8+ecx] - fxch st(1) - faddp st(3),st(0) - fxch st(3) - faddp st(2),st(0) - jmp LSetSides -Lcase4: - fmul dword ptr[ebx] - fld dword ptr[0+4+edx] - fxch st(2) - fmul dword ptr[ecx] - fxch st(2) - fld st(0) - fmul dword ptr[4+ebx] - fld dword ptr[0+8+edx] - fxch st(2) - fmul dword ptr[4+ecx] - fxch st(2) - fld st(0) - fmul dword ptr[8+ecx] - fxch st(5) - faddp st(3),st(0) - fmul dword ptr[8+ebx] - fxch st(1) - faddp st(3),st(0) - fxch st(3) - faddp st(2),st(0) - jmp LSetSides -Lcase5: - fmul dword ptr[ecx] - fld dword ptr[0+4+edx] - fxch st(2) - fmul dword ptr[ebx] - fxch st(2) - fld st(0) - fmul dword ptr[4+ebx] - fld dword ptr[0+8+edx] - fxch st(2) - fmul dword ptr[4+ecx] - fxch st(2) - fld st(0) - fmul dword ptr[8+ecx] - fxch st(5) - faddp st(3),st(0) - fmul dword ptr[8+ebx] - fxch st(1) - faddp st(3),st(0) - fxch st(3) - faddp st(2),st(0) - jmp LSetSides -Lcase6: - fmul dword ptr[ebx] - fld dword ptr[0+4+edx] - fxch st(2) - fmul dword ptr[ecx] - fxch st(2) - fld st(0) - fmul dword ptr[4+ecx] - fld dword ptr[0+8+edx] - fxch st(2) - fmul dword ptr[4+ebx] - fxch st(2) - fld st(0) - fmul dword ptr[8+ecx] - fxch st(5) - faddp st(3),st(0) - fmul dword ptr[8+ebx] - fxch st(1) - faddp st(3),st(0) - fxch st(3) - faddp st(2),st(0) - jmp LSetSides -Lcase7: - fmul dword ptr[ecx] - fld dword ptr[0+4+edx] - fxch st(2) - fmul dword ptr[ebx] - fxch st(2) - fld st(0) - fmul dword ptr[4+ecx] - fld dword ptr[0+8+edx] - fxch st(2) - fmul dword ptr[4+ebx] - fxch st(2) - fld st(0) - fmul dword ptr[8+ecx] - fxch st(5) - faddp st(3),st(0) - fmul dword ptr[8+ebx] - fxch st(1) - faddp st(3),st(0) - fxch st(3) - faddp st(2),st(0) -LSetSides: - faddp st(2),st(0) - fcomp dword ptr[12+edx] - xor ecx,ecx - fnstsw ax - fcomp dword ptr[12+edx] - and ah,1 - xor ah,1 - add cl,ah - fnstsw ax - and ah,1 - add ah,ah - add cl,ah - pop ebx - mov eax,ecx - ret -Lerror: - int 3 - } -} -#pragma warning( default: 4035 ) - -#endif -#endif - -/* -================= -RadiusFromBounds -================= -*/ -float RadiusFromBounds( const vec3_t mins, const vec3_t maxs ) { - int i; - vec3_t corner; - float a, b; - - for (i=0 ; i<3 ; i++) { - a = fabs( mins[i] ); - b = fabs( maxs[i] ); - corner[i] = a > b ? a : b; - } - - return VectorLength (corner); -} - - -void ClearBounds( vec3_t mins, vec3_t maxs ) { - mins[0] = mins[1] = mins[2] = 99999; - maxs[0] = maxs[1] = maxs[2] = -99999; -} - -void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs ) { - if ( v[0] < mins[0] ) { - mins[0] = v[0]; - } - if ( v[0] > maxs[0]) { - maxs[0] = v[0]; - } - - if ( v[1] < mins[1] ) { - mins[1] = v[1]; - } - if ( v[1] > maxs[1]) { - maxs[1] = v[1]; - } - - if ( v[2] < mins[2] ) { - mins[2] = v[2]; - } - if ( v[2] > maxs[2]) { - maxs[2] = v[2]; - } -} - - -vec_t VectorNormalize( vec3_t v ) { - // NOTE: TTimo - Apple G4 altivec source uses double? - float length, ilength; - - length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; - length = sqrt (length); - - if ( length ) { - ilength = 1/length; - v[0] *= ilength; - v[1] *= ilength; - v[2] *= ilength; - } - - return length; -} - -vec_t VectorNormalize2( const vec3_t v, vec3_t out) { - float length, ilength; - - length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; - length = sqrt (length); - - if (length) - { -#ifndef Q3_VM // bk0101022 - FPE related -// assert( ((Q_fabs(v[0])!=0.0f) || (Q_fabs(v[1])!=0.0f) || (Q_fabs(v[2])!=0.0f)) ); -#endif - ilength = 1/length; - out[0] = v[0]*ilength; - out[1] = v[1]*ilength; - out[2] = v[2]*ilength; - } else { -#ifndef Q3_VM // bk0101022 - FPE related -// assert( ((Q_fabs(v[0])==0.0f) && (Q_fabs(v[1])==0.0f) && (Q_fabs(v[2])==0.0f)) ); -#endif - VectorClear( out ); - } - - return length; - -} - -void _VectorMA( const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc) { - vecc[0] = veca[0] + scale*vecb[0]; - vecc[1] = veca[1] + scale*vecb[1]; - vecc[2] = veca[2] + scale*vecb[2]; -} - - -vec_t _DotProduct( const vec3_t v1, const vec3_t v2 ) { - return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]; -} - -void _VectorSubtract( const vec3_t veca, const vec3_t vecb, vec3_t out ) { - out[0] = veca[0]-vecb[0]; - out[1] = veca[1]-vecb[1]; - out[2] = veca[2]-vecb[2]; -} - -void _VectorAdd( const vec3_t veca, const vec3_t vecb, vec3_t out ) { - out[0] = veca[0]+vecb[0]; - out[1] = veca[1]+vecb[1]; - out[2] = veca[2]+vecb[2]; -} - -void _VectorCopy( const vec3_t in, vec3_t out ) { - out[0] = in[0]; - out[1] = in[1]; - out[2] = in[2]; -} - -void _VectorScale( const vec3_t in, vec_t scale, vec3_t out ) { - out[0] = in[0]*scale; - out[1] = in[1]*scale; - out[2] = in[2]*scale; -} - -void Vector4Scale( const vec4_t in, vec_t scale, vec4_t out ) { - out[0] = in[0]*scale; - out[1] = in[1]*scale; - out[2] = in[2]*scale; - out[3] = in[3]*scale; -} - - -int Q_log2( int val ) { - int answer; - - answer = 0; - while ( ( val>>=1 ) != 0 ) { - answer++; - } - return answer; -} - - - -/* -================= -PlaneTypeForNormal -================= -*/ -/* -int PlaneTypeForNormal (vec3_t normal) { - if ( normal[0] == 1.0 ) - return PLANE_X; - if ( normal[1] == 1.0 ) - return PLANE_Y; - if ( normal[2] == 1.0 ) - return PLANE_Z; - - return PLANE_NON_AXIAL; -} -*/ - - -/* -================ -MatrixMultiply -================ -*/ -void MatrixMultiply(float in1[3][3], float in2[3][3], float out[3][3]) { - out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] + - in1[0][2] * in2[2][0]; - out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] + - in1[0][2] * in2[2][1]; - out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] + - in1[0][2] * in2[2][2]; - out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] + - in1[1][2] * in2[2][0]; - out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] + - in1[1][2] * in2[2][1]; - out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] + - in1[1][2] * in2[2][2]; - out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] + - in1[2][2] * in2[2][0]; - out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] + - in1[2][2] * in2[2][1]; - out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + - in1[2][2] * in2[2][2]; -} - - -void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) { - float angle; - static float sr, sp, sy, cr, cp, cy; - // static to help MS compiler fp bugs - - angle = angles[YAW] * (M_PI*2 / 360); - sy = sin(angle); - cy = cos(angle); - angle = angles[PITCH] * (M_PI*2 / 360); - sp = sin(angle); - cp = cos(angle); - angle = angles[ROLL] * (M_PI*2 / 360); - sr = sin(angle); - cr = cos(angle); - - if (forward) - { - forward[0] = cp*cy; - forward[1] = cp*sy; - forward[2] = -sp; - } - if (right) - { - right[0] = (-1*sr*sp*cy+-1*cr*-sy); - right[1] = (-1*sr*sp*sy+-1*cr*cy); - right[2] = -1*sr*cp; - } - if (up) - { - up[0] = (cr*sp*cy+-sr*-sy); - up[1] = (cr*sp*sy+-sr*cy); - up[2] = cr*cp; - } -} - -/* -** assumes "src" is normalized -*/ -void PerpendicularVector( vec3_t dst, const vec3_t src ) -{ - int pos; - int i; - float minelem = 1.0F; - vec3_t tempvec; - - /* - ** find the smallest magnitude axially aligned vector - */ - for ( pos = 0, i = 0; i < 3; i++ ) - { - if ( fabs( src[i] ) < minelem ) - { - pos = i; - minelem = fabs( src[i] ); - } - } - tempvec[0] = tempvec[1] = tempvec[2] = 0.0F; - tempvec[pos] = 1.0F; - - /* - ** project the point onto the plane defined by src - */ - ProjectPointOnPlane( dst, tempvec, src ); - - /* - ** normalize the result - */ - VectorNormalize( dst ); -} - - diff --git a/code/game/q_shared.c b/code/game/q_shared.c deleted file mode 100644 index bd8daa5..0000000 --- a/code/game/q_shared.c +++ /dev/null @@ -1,1252 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code 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. - -Quake III Arena source code 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 Foobar; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// -// q_shared.c -- stateless support routines that are included in each code dll -#include "q_shared.h" - -float Com_Clamp( float min, float max, float value ) { - if ( value < min ) { - return min; - } - if ( value > max ) { - return max; - } - return value; -} - - -/* -============ -COM_SkipPath -============ -*/ -char *COM_SkipPath (char *pathname) -{ - char *last; - - last = pathname; - while (*pathname) - { - if (*pathname=='/') - last = pathname+1; - pathname++; - } - return last; -} - -/* -============ -COM_StripExtension -============ -*/ -void COM_StripExtension( const char *in, char *out ) { - while ( *in && *in != '.' ) { - *out++ = *in++; - } - *out = 0; -} - - -/* -================== -COM_DefaultExtension -================== -*/ -void COM_DefaultExtension (char *path, int maxSize, const char *extension ) { - char oldPath[MAX_QPATH]; - char *src; - -// -// if path doesn't have a .EXT, append extension -// (extension should include the .) -// - src = path + strlen(path) - 1; - - while (*src != '/' && src != path) { - if ( *src == '.' ) { - return; // it has an extension - } - src--; - } - - Q_strncpyz( oldPath, path, sizeof( oldPath ) ); - Com_sprintf( path, maxSize, "%s%s", oldPath, extension ); -} - -/* -============================================================================ - - BYTE ORDER FUNCTIONS - -============================================================================ -*/ -/* -// can't just use function pointers, or dll linkage can -// mess up when qcommon is included in multiple places -static short (*_BigShort) (short l); -static short (*_LittleShort) (short l); -static int (*_BigLong) (int l); -static int (*_LittleLong) (int l); -static qint64 (*_BigLong64) (qint64 l); -static qint64 (*_LittleLong64) (qint64 l); -static float (*_BigFloat) (const float *l); -static float (*_LittleFloat) (const float *l); - -short BigShort(short l){return _BigShort(l);} -short LittleShort(short l) {return _LittleShort(l);} -int BigLong (int l) {return _BigLong(l);} -int LittleLong (int l) {return _LittleLong(l);} -qint64 BigLong64 (qint64 l) {return _BigLong64(l);} -qint64 LittleLong64 (qint64 l) {return _LittleLong64(l);} -float BigFloat (const float *l) {return _BigFloat(l);} -float LittleFloat (const float *l) {return _LittleFloat(l);} -*/ - -short ShortSwap (short l) -{ - byte b1,b2; - - b1 = l&255; - b2 = (l>>8)&255; - - return (b1<<8) + b2; -} - -short ShortNoSwap (short l) -{ - return l; -} - -int LongSwap (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 LongNoSwap (int l) -{ - return l; -} - -qint64 Long64Swap (qint64 ll) -{ - qint64 result; - - result.b0 = ll.b7; - result.b1 = ll.b6; - result.b2 = ll.b5; - result.b3 = ll.b4; - result.b4 = ll.b3; - result.b5 = ll.b2; - result.b6 = ll.b1; - result.b7 = ll.b0; - - return result; -} - -qint64 Long64NoSwap (qint64 ll) -{ - return ll; -} - -typedef union { - float f; - unsigned int i; -} _FloatByteUnion; - -float FloatSwap (const float *f) { - _FloatByteUnion out; - - out.f = *f; - out.i = LongSwap(out.i); - - return out.f; -} - -float FloatNoSwap (const float *f) -{ - return *f; -} - -/* -================ -Swap_Init -================ -*/ -/* -void Swap_Init (void) -{ - byte swaptest[2] = {1,0}; - -// set the byte swapping variables in a portable manner - if ( *(short *)swaptest == 1) - { - _BigShort = ShortSwap; - _LittleShort = ShortNoSwap; - _BigLong = LongSwap; - _LittleLong = LongNoSwap; - _BigLong64 = Long64Swap; - _LittleLong64 = Long64NoSwap; - _BigFloat = FloatSwap; - _LittleFloat = FloatNoSwap; - } - else - { - _BigShort = ShortNoSwap; - _LittleShort = ShortSwap; - _BigLong = LongNoSwap; - _LittleLong = LongSwap; - _BigLong64 = Long64NoSwap; - _LittleLong64 = Long64Swap; - _BigFloat = FloatNoSwap; - _LittleFloat = FloatSwap; - } - -} -*/ - -/* -============================================================================ - -PARSING - -============================================================================ -*/ - -static char com_token[MAX_TOKEN_CHARS]; -static char com_parsename[MAX_TOKEN_CHARS]; -static int com_lines; - -void COM_BeginParseSession( const char *name ) -{ - com_lines = 0; - Com_sprintf(com_parsename, sizeof(com_parsename), "%s", name); -} - -int COM_GetCurrentParseLine( void ) -{ - return com_lines; -} - -char *COM_Parse( char **data_p ) -{ - return COM_ParseExt( data_p, qtrue ); -} - -void COM_ParseError( char *format, ... ) -{ - va_list argptr; - static char string[4096]; - - va_start (argptr, format); - vsprintf (string, format, argptr); - va_end (argptr); - - Com_Printf("ERROR: %s, line %d: %s\n", com_parsename, com_lines, string); -} - -void COM_ParseWarning( char *format, ... ) -{ - va_list argptr; - static char string[4096]; - - va_start (argptr, format); - vsprintf (string, format, argptr); - va_end (argptr); - - Com_Printf("WARNING: %s, line %d: %s\n", com_parsename, com_lines, string); -} - -/* -============== -COM_Parse - -Parse a token out of a string -Will never return NULL, just empty strings - -If "allowLineBreaks" is qtrue then an empty -string will be returned if the next token is -a newline. -============== -*/ -static char *SkipWhitespace( char *data, qboolean *hasNewLines ) { - int c; - - while( (c = *data) <= ' ') { - if( !c ) { - return NULL; - } - if( c == '\n' ) { - com_lines++; - *hasNewLines = qtrue; - } - data++; - } - - return data; -} - -int COM_Compress( char *data_p ) { - char *in, *out; - int c; - qboolean newline = qfalse, whitespace = qfalse; - - in = out = data_p; - if (in) { - while ((c = *in) != 0) { - // skip double slash comments - if ( c == '/' && in[1] == '/' ) { - while (*in && *in != '\n') { - in++; - } - // skip /* */ comments - } else if ( c == '/' && in[1] == '*' ) { - while ( *in && ( *in != '*' || in[1] != '/' ) ) - in++; - if ( *in ) - in += 2; - // record when we hit a newline - } else if ( c == '\n' || c == '\r' ) { - newline = qtrue; - in++; - // record when we hit whitespace - } else if ( c == ' ' || c == '\t') { - whitespace = qtrue; - in++; - // an actual token - } else { - // if we have a pending newline, emit it (and it counts as whitespace) - if (newline) { - *out++ = '\n'; - newline = qfalse; - whitespace = qfalse; - } if (whitespace) { - *out++ = ' '; - whitespace = qfalse; - } - - // copy quoted strings unmolested - if (c == '"') { - *out++ = c; - in++; - while (1) { - c = *in; - if (c && c != '"') { - *out++ = c; - in++; - } else { - break; - } - } - if (c == '"') { - *out++ = c; - in++; - } - } else { - *out = c; - out++; - in++; - } - } - } - } - *out = 0; - return out - data_p; -} - -char *COM_ParseExt( char **data_p, qboolean allowLineBreaks ) -{ - int c = 0, len; - qboolean hasNewLines = qfalse; - char *data; - - data = *data_p; - len = 0; - com_token[0] = 0; - - // make sure incoming data is valid - if ( !data ) - { - *data_p = NULL; - return com_token; - } - - while ( 1 ) - { - // skip whitespace - data = SkipWhitespace( data, &hasNewLines ); - if ( !data ) - { - *data_p = NULL; - return com_token; - } - if ( hasNewLines && !allowLineBreaks ) - { - *data_p = data; - return com_token; - } - - c = *data; - - // skip double slash comments - if ( c == '/' && data[1] == '/' ) - { - data += 2; - while (*data && *data != '\n') { - data++; - } - } - // skip /* */ comments - else if ( c=='/' && data[1] == '*' ) - { - data += 2; - while ( *data && ( *data != '*' || data[1] != '/' ) ) - { - data++; - } - if ( *data ) - { - data += 2; - } - } - else - { - break; - } - } - - // handle quoted strings - if (c == '\"') - { - data++; - while (1) - { - c = *data++; - if (c=='\"' || !c) - { - com_token[len] = 0; - *data_p = ( char * ) data; - return com_token; - } - if (len < MAX_TOKEN_CHARS - 1) - { - com_token[len] = c; - len++; - } - } - } - - // parse a regular word - do - { - if (len < MAX_TOKEN_CHARS - 1) - { - com_token[len] = c; - len++; - } - data++; - c = *data; - if ( c == '\n' ) - com_lines++; - } while (c>32); - - com_token[len] = 0; - - *data_p = ( char * ) data; - return com_token; -} - - -#if 0 -// no longer used -/* -=============== -COM_ParseInfos -=============== -*/ -int COM_ParseInfos( char *buf, int max, char infos[][MAX_INFO_STRING] ) { - char *token; - int count; - char key[MAX_TOKEN_CHARS]; - - count = 0; - - while ( 1 ) { - token = COM_Parse( &buf ); - if ( !token[0] ) { - break; - } - if ( strcmp( token, "{" ) ) { - Com_Printf( "Missing { in info file\n" ); - break; - } - - if ( count == max ) { - Com_Printf( "Max infos exceeded\n" ); - break; - } - - infos[count][0] = 0; - while ( 1 ) { - token = COM_ParseExt( &buf, qtrue ); - if ( !token[0] ) { - Com_Printf( "Unexpected end of info file\n" ); - break; - } - if ( !strcmp( token, "}" ) ) { - break; - } - Q_strncpyz( key, token, sizeof( key ) ); - - token = COM_ParseExt( &buf, qfalse ); - if ( !token[0] ) { - strcpy( token, "" ); - } - Info_SetValueForKey( infos[count], key, token ); - } - count++; - } - - return count; -} -#endif - - -/* -================== -COM_MatchToken -================== -*/ -void COM_MatchToken( char **buf_p, char *match ) { - char *token; - - token = COM_Parse( buf_p ); - if ( strcmp( token, match ) ) { - Com_Error( ERR_DROP, "MatchToken: %s != %s", token, match ); - } -} - - -/* -================= -SkipBracedSection - -The next token should be an open brace. -Skips until a matching close brace is found. -Internal brace depths are properly skipped. -================= -*/ -void SkipBracedSection (char **program) { - char *token; - int depth; - - depth = 0; - do { - token = COM_ParseExt( program, qtrue ); - if( token[1] == 0 ) { - if( token[0] == '{' ) { - depth++; - } - else if( token[0] == '}' ) { - depth--; - } - } - } while( depth && *program ); -} - -/* -================= -SkipRestOfLine -================= -*/ -void SkipRestOfLine ( char **data ) { - char *p; - int c; - - p = *data; - while ( (c = *p++) != 0 ) { - if ( c == '\n' ) { - com_lines++; - break; - } - } - - *data = p; -} - - -void Parse1DMatrix (char **buf_p, int x, float *m) { - char *token; - int i; - - COM_MatchToken( buf_p, "(" ); - - for (i = 0 ; i < x ; i++) { - token = COM_Parse(buf_p); - m[i] = atof(token); - } - - COM_MatchToken( buf_p, ")" ); -} - -void Parse2DMatrix (char **buf_p, int y, int x, float *m) { - int i; - - COM_MatchToken( buf_p, "(" ); - - for (i = 0 ; i < y ; i++) { - Parse1DMatrix (buf_p, x, m + i * x); - } - - COM_MatchToken( buf_p, ")" ); -} - -void Parse3DMatrix (char **buf_p, int z, int y, int x, float *m) { - int i; - - COM_MatchToken( buf_p, "(" ); - - for (i = 0 ; i < z ; i++) { - Parse2DMatrix (buf_p, y, x, m + i * x*y); - } - - COM_MatchToken( buf_p, ")" ); -} - - -/* -============================================================================ - - LIBRARY REPLACEMENT FUNCTIONS - -============================================================================ -*/ - -int Q_isprint( int c ) -{ - if ( c >= 0x20 && c <= 0x7E ) - return ( 1 ); - return ( 0 ); -} - -int Q_islower( int c ) -{ - if (c >= 'a' && c <= 'z') - return ( 1 ); - return ( 0 ); -} - -int Q_isupper( int c ) -{ - if (c >= 'A' && c <= 'Z') - return ( 1 ); - return ( 0 ); -} - -int Q_isalpha( int c ) -{ - if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) - return ( 1 ); - return ( 0 ); -} - -char* Q_strrchr( const char* string, int c ) -{ - char cc = c; - char *s; - char *sp=(char *)0; - - s = (char*)string; - - while (*s) - { - if (*s == cc) - sp = s; - s++; - } - if (cc == 0) - sp = s; - - return sp; -} - -/* -============= -Q_strncpyz - -Safe strncpy that ensures a trailing zero -============= -*/ -void Q_strncpyz( char *dest, const char *src, int destsize ) { - // bk001129 - also NULL dest - if ( !dest ) { - Com_Error( ERR_FATAL, "Q_strncpyz: NULL dest" ); - } - if ( !src ) { - Com_Error( ERR_FATAL, "Q_strncpyz: NULL src" ); - } - if ( destsize < 1 ) { - Com_Error(ERR_FATAL,"Q_strncpyz: destsize < 1" ); - } - - strncpy( dest, src, destsize-1 ); - dest[destsize-1] = 0; -} - -int Q_stricmpn (const char *s1, const char *s2, int n) { - int c1, c2; - - // bk001129 - moved in 1.17 fix not in id codebase - if ( s1 == NULL ) { - if ( s2 == NULL ) - return 0; - else - return -1; - } - else if ( s2==NULL ) - return 1; - - - - do { - c1 = *s1++; - c2 = *s2++; - - if (!n--) { - return 0; // strings are equal until end point - } - - if (c1 != c2) { - if (c1 >= 'a' && c1 <= 'z') { - c1 -= ('a' - 'A'); - } - if (c2 >= 'a' && c2 <= 'z') { - c2 -= ('a' - 'A'); - } - if (c1 != c2) { - return c1 < c2 ? -1 : 1; - } - } - } while (c1); - - return 0; // strings are equal -} - -int Q_strncmp (const char *s1, const char *s2, int n) { - int c1, c2; - - do { - c1 = *s1++; - c2 = *s2++; - - if (!n--) { - return 0; // strings are equal until end point - } - - if (c1 != c2) { - return c1 < c2 ? -1 : 1; - } - } while (c1); - - return 0; // strings are equal -} - -int Q_stricmp (const char *s1, const char *s2) { - return (s1 && s2) ? Q_stricmpn (s1, s2, 99999) : -1; -} - - -char *Q_strlwr( char *s1 ) { - char *s; - - s = s1; - while ( *s ) { - *s = tolower(*s); - s++; - } - return s1; -} - -char *Q_strupr( char *s1 ) { - char *s; - - s = s1; - while ( *s ) { - *s = toupper(*s); - s++; - } - return s1; -} - - -// never goes past bounds or leaves without a terminating 0 -void Q_strcat( char *dest, int size, const char *src ) { - int l1; - - l1 = strlen( dest ); - if ( l1 >= size ) { - Com_Error( ERR_FATAL, "Q_strcat: already overflowed" ); - } - Q_strncpyz( dest + l1, src, size - l1 ); -} - - -int Q_PrintStrlen( const char *string ) { - int len; - const char *p; - - if( !string ) { - return 0; - } - - len = 0; - p = string; - while( *p ) { - if( Q_IsColorString( p ) ) { - p += 2; - continue; - } - p++; - len++; - } - - return len; -} - - -char *Q_CleanStr( char *string ) { - char* d; - char* s; - int c; - - s = string; - d = string; - while ((c = *s) != 0 ) { - if ( Q_IsColorString( s ) ) { - s++; - } - else if ( c >= 0x20 && c <= 0x7E ) { - *d++ = c; - } - s++; - } - *d = '\0'; - - return string; -} - - -void QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) { - int len; - va_list argptr; - char bigbuffer[32000]; // big, but small enough to fit in PPC stack - - va_start (argptr,fmt); - len = vsprintf (bigbuffer,fmt,argptr); - va_end (argptr); - if ( len >= sizeof( bigbuffer ) ) { - Com_Error( ERR_FATAL, "Com_sprintf: overflowed bigbuffer" ); - } - if (len >= size) { - Com_Printf ("Com_sprintf: overflow of %i in %i\n", len, size); -#ifdef _DEBUG - __asm { - int 3; - } -#endif - } - Q_strncpyz (dest, bigbuffer, size ); -} - - -/* -============ -va - -does a varargs printf into a temp buffer, so I don't need to have -varargs versions of all text functions. -FIXME: make this buffer size safe someday -============ -*/ -char * QDECL va( char *format, ... ) { - va_list argptr; - static char string[2][32000]; // in case va is called by nested functions - static int index = 0; - char *buf; - - buf = string[index & 1]; - index++; - - va_start (argptr, format); - vsprintf (buf, format,argptr); - va_end (argptr); - - return buf; -} - - -/* -===================================================================== - - INFO STRINGS - -===================================================================== -*/ - -/* -=============== -Info_ValueForKey - -Searches the string for the given -key and returns the associated value, or an empty string. -FIXME: overflow check? -=============== -*/ -char *Info_ValueForKey( const char *s, const char *key ) { - char pkey[BIG_INFO_KEY]; - static char value[2][BIG_INFO_VALUE]; // use two buffers so compares - // work without stomping on each other - static int valueindex = 0; - char *o; - - if ( !s || !key ) { - return ""; - } - - if ( strlen( s ) >= BIG_INFO_STRING ) { - Com_Error( ERR_DROP, "Info_ValueForKey: oversize infostring" ); - } - - valueindex ^= 1; - if (*s == '\\') - s++; - while (1) - { - o = pkey; - while (*s != '\\') - { - if (!*s) - return ""; - *o++ = *s++; - } - *o = 0; - s++; - - o = value[valueindex]; - - while (*s != '\\' && *s) - { - *o++ = *s++; - } - *o = 0; - - if (!Q_stricmp (key, pkey) ) - return value[valueindex]; - - if (!*s) - break; - s++; - } - - return ""; -} - - -/* -=================== -Info_NextPair - -Used to itterate through all the key/value pairs in an info string -=================== -*/ -void Info_NextPair( const char **head, char *key, char *value ) { - char *o; - const char *s; - - s = *head; - - if ( *s == '\\' ) { - s++; - } - key[0] = 0; - value[0] = 0; - - o = key; - while ( *s != '\\' ) { - if ( !*s ) { - *o = 0; - *head = s; - return; - } - *o++ = *s++; - } - *o = 0; - s++; - - o = value; - while ( *s != '\\' && *s ) { - *o++ = *s++; - } - *o = 0; - - *head = s; -} - - -/* -=================== -Info_RemoveKey -=================== -*/ -void Info_RemoveKey( char *s, const char *key ) { - char *start; - char pkey[MAX_INFO_KEY]; - char value[MAX_INFO_VALUE]; - char *o; - - if ( strlen( s ) >= MAX_INFO_STRING ) { - Com_Error( ERR_DROP, "Info_RemoveKey: oversize infostring" ); - } - - if (strchr (key, '\\')) { - return; - } - - while (1) - { - start = s; - if (*s == '\\') - s++; - o = pkey; - while (*s != '\\') - { - if (!*s) - return; - *o++ = *s++; - } - *o = 0; - s++; - - o = value; - while (*s != '\\' && *s) - { - if (!*s) - return; - *o++ = *s++; - } - *o = 0; - - if (!strcmp (key, pkey) ) - { - strcpy (start, s); // remove this part - return; - } - - if (!*s) - return; - } - -} - -/* -=================== -Info_RemoveKey_Big -=================== -*/ -void Info_RemoveKey_Big( char *s, const char *key ) { - char *start; - char pkey[BIG_INFO_KEY]; - char value[BIG_INFO_VALUE]; - char *o; - - if ( strlen( s ) >= BIG_INFO_STRING ) { - Com_Error( ERR_DROP, "Info_RemoveKey_Big: oversize infostring" ); - } - - if (strchr (key, '\\')) { - return; - } - - while (1) - { - start = s; - if (*s == '\\') - s++; - o = pkey; - while (*s != '\\') - { - if (!*s) - return; - *o++ = *s++; - } - *o = 0; - s++; - - o = value; - while (*s != '\\' && *s) - { - if (!*s) - return; - *o++ = *s++; - } - *o = 0; - - if (!strcmp (key, pkey) ) - { - strcpy (start, s); // remove this part - return; - } - - if (!*s) - return; - } - -} - - - - -/* -================== -Info_Validate - -Some characters are illegal in info strings because they -can mess up the server's parsing -================== -*/ -qboolean Info_Validate( const char *s ) { - if ( strchr( s, '\"' ) ) { - return qfalse; - } - if ( strchr( s, ';' ) ) { - return qfalse; - } - return qtrue; -} - -/* -================== -Info_SetValueForKey - -Changes or adds a key/value pair -================== -*/ -void Info_SetValueForKey( char *s, const char *key, const char *value ) { - char newi[MAX_INFO_STRING]; - - if ( strlen( s ) >= MAX_INFO_STRING ) { - Com_Error( ERR_DROP, "Info_SetValueForKey: oversize infostring" ); - } - - if (strchr (key, '\\') || strchr (value, '\\')) - { - Com_Printf ("Can't use keys or values with a \\\n"); - return; - } - - if (strchr (key, ';') || strchr (value, ';')) - { - Com_Printf ("Can't use keys or values with a semicolon\n"); - return; - } - - if (strchr (key, '\"') || strchr (value, '\"')) - { - Com_Printf ("Can't use keys or values with a \"\n"); - return; - } - - Info_RemoveKey (s, key); - if (!value || !strlen(value)) - return; - - Com_sprintf (newi, sizeof(newi), "\\%s\\%s", key, value); - - if (strlen(newi) + strlen(s) >= MAX_INFO_STRING) - { - Com_Printf ("Info string length exceeded\n"); - return; - } - - strcat (newi, s); - strcpy (s, newi); -} - -/* -================== -Info_SetValueForKey_Big - -Changes or adds a key/value pair -================== -*/ -void Info_SetValueForKey_Big( char *s, const char *key, const char *value ) { - char newi[BIG_INFO_STRING]; - - if ( strlen( s ) >= BIG_INFO_STRING ) { - Com_Error( ERR_DROP, "Info_SetValueForKey: oversize infostring" ); - } - - if (strchr (key, '\\') || strchr (value, '\\')) - { - Com_Printf ("Can't use keys or values with a \\\n"); - return; - } - - if (strchr (key, ';') || strchr (value, ';')) - { - Com_Printf ("Can't use keys or values with a semicolon\n"); - return; - } - - if (strchr (key, '\"') || strchr (value, '\"')) - { - Com_Printf ("Can't use keys or values with a \"\n"); - return; - } - - Info_RemoveKey_Big (s, key); - if (!value || !strlen(value)) - return; - - Com_sprintf (newi, sizeof(newi), "\\%s\\%s", key, value); - - if (strlen(newi) + strlen(s) >= BIG_INFO_STRING) - { - Com_Printf ("BIG Info string length exceeded\n"); - return; - } - - strcat (s, newi); -} - - - - -//==================================================================== - - diff --git a/code/game/q_shared.h b/code/game/q_shared.h deleted file mode 100644 index 212e04c..0000000 --- a/code/game/q_shared.h +++ /dev/null @@ -1,1456 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code 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. - -Quake III Arena source code 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 Foobar; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// -#ifndef __Q_SHARED_H -#define __Q_SHARED_H - -// q_shared.h -- included first by ALL program modules. -// A user mod should never modify this file - -#define Q3_VERSION "ioQ3 1.33" -// 1.32 released 7-10-2002 - -#define MAX_TEAMNAME 32 - -#ifdef _MSC_VER - -#pragma warning(disable : 4018) // signed/unsigned mismatch -#pragma warning(disable : 4032) -#pragma warning(disable : 4051) -#pragma warning(disable : 4057) // slightly different base types -#pragma warning(disable : 4100) // unreferenced formal parameter -#pragma warning(disable : 4115) -#pragma warning(disable : 4125) // decimal digit terminates octal escape sequence -#pragma warning(disable : 4127) // conditional expression is constant -#pragma warning(disable : 4136) -#pragma warning(disable : 4152) // nonstandard extension, function/data pointer conversion in expression -//#pragma warning(disable : 4201) -//#pragma warning(disable : 4214) -#pragma warning(disable : 4244) -#pragma warning(disable : 4142) // benign redefinition -//#pragma warning(disable : 4305) // truncation from const double to float -//#pragma warning(disable : 4310) // cast truncates constant value -//#pragma warning(disable: 4505) // unreferenced local function has been removed -#pragma warning(disable : 4514) -#pragma warning(disable : 4702) // unreachable code -#pragma warning(disable : 4711) // selected for automatic inline expansion -#pragma warning(disable : 4220) // varargs matches remaining parameters -#endif - -/********************************************************************** - VM Considerations - - The VM can not use the standard system headers because we aren't really - using the compiler they were meant for. We use bg_lib.h which contains - prototypes for the functions we define for our own use in bg_lib.c. - - When writing mods, please add needed headers HERE, do not start including - stuff like in the various .c files that make up each of the VMs - since you will be including system headers files can will have issues. - - Remember, if you use a C library function that is not defined in bg_lib.c, - you will have to add your own version for support in the VM. - - **********************************************************************/ - -#ifdef Q3_VM - -#include "bg_lib.h" - -#else - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif - -#ifdef _MSC_VER - -//#pragma intrinsic( memset, memcpy ) - -#endif - - -// this is the define for determining if we have an asm version of a C function -#if (defined _M_IX86 || defined __i386__) && !defined __sun__ && !defined __LCC__ -#define id386 1 -#else -#define id386 0 -#endif - -#if (defined(powerc) || defined(powerpc) || defined(ppc) || defined(__ppc) || defined(__ppc__)) && !defined(C_ONLY) -#define idppc 1 -#if defined(__VEC__) -#define idppc_altivec 1 -#else -#define idppc_altivec 0 -#endif -#else -#define idppc 0 -#define idppc_altivec 0 -#endif - -// for windows fastcall option - -#define QDECL - -short ShortSwap (short l); -int LongSwap (int l); -float FloatSwap (const float *f); - -//======================= WIN32 DEFINES ================================= - -#ifdef WIN32 - -#define MAC_STATIC - -#undef QDECL -#define QDECL __cdecl - -// buildstring will be incorporated into the version string -#ifdef _MSC_VER -#ifdef NDEBUG -#ifdef _M_IX86 -#define CPUSTRING "win-x86" -#elif defined _M_ALPHA -#define CPUSTRING "win-AXP" -#endif -#else -#ifdef _M_IX86 -#define CPUSTRING "win-x86-debug" -#elif defined _M_ALPHA -#define CPUSTRING "win-AXP-debug" -#endif -#endif -#elif defined __MINGW32__ -#ifdef NDEBUG -#ifdef __i386__ -#define CPUSTRING "mingw-x86" -#endif -#else -#ifdef __i386__ -#define CPUSTRING "mingw-x86-debug" -#endif -#endif -#endif - -#define ID_INLINE __inline - -static ID_INLINE short BigShort( short l) { return ShortSwap(l); } -#define LittleShort -static ID_INLINE int BigLong(int l) { return LongSwap(l); } -#define LittleLong -static ID_INLINE float BigFloat(const float l) { return FloatSwap(&l); } -#define LittleFloat - -#define PATH_SEP '\\' - -#endif - -//======================= MAC OS X DEFINES ===================== - -#if defined(MACOS_X) - -#define MAC_STATIC -#define __cdecl -#define __declspec(x) -#define stricmp strcasecmp -#define ID_INLINE inline - -#ifdef __ppc__ -#define CPUSTRING "MacOSX-ppc" -#elif defined __i386__ -#define CPUSTRING "MacOSX-i386" -#else -#define CPUSTRING "MacOSX-other" -#endif - -#define PATH_SEP '/' - -#define __rlwimi(out, in, shift, maskBegin, maskEnd) asm("rlwimi %0,%1,%2,%3,%4" : "=r" (out) : "r" (in), "i" (shift), "i" (maskBegin), "i" (maskEnd)) -#define __dcbt(addr, offset) asm("dcbt %0,%1" : : "b" (addr), "r" (offset)) - -static inline unsigned int __lwbrx(register void *addr, register int offset) { - register unsigned int word; - - asm("lwbrx %0,%2,%1" : "=r" (word) : "r" (addr), "b" (offset)); - return word; -} - -static inline unsigned short __lhbrx(register void *addr, register int offset) { - register unsigned short halfword; - - asm("lhbrx %0,%2,%1" : "=r" (halfword) : "r" (addr), "b" (offset)); - return halfword; -} - -static inline float __fctiw(register float f) { - register float fi; - - asm("fctiw %0,%1" : "=f" (fi) : "f" (f)); - - return fi; -} - -#define BigShort -static inline short LittleShort(short l) { return ShortSwap(l); } -#define BigLong -static inline int LittleLong (int l) { return LongSwap(l); } -#define BigFloat -static inline float LittleFloat (const float l) { return FloatSwap(&l); } - -#endif - -//======================= MAC DEFINES ================================= - -#ifdef __MACOS__ - -#include -#define MAC_STATIC -#define ID_INLINE inline - -#define CPUSTRING "MacOS-PPC" - -#define PATH_SEP ':' - -void Sys_PumpEvents( void ); - -#define BigShort -static inline short LittleShort(short l) { return ShortSwap(l); } -#define BigLong -static inline int LittleLong (int l) { return LongSwap(l); } -#define BigFloat -static inline float LittleFloat (const float l) { return FloatSwap(&l); } - -#endif - -//======================= LINUX DEFINES ================================= - -// the mac compiler can't handle >32k of locals, so we -// just waste space and make big arrays static... -#ifdef __linux__ - -// bk001205 - from Makefile -#define stricmp strcasecmp - -#define MAC_STATIC // bk: FIXME -#define ID_INLINE inline - -#ifdef __i386__ -#define CPUSTRING "linux-i386" -#elif defined __axp__ -#define CPUSTRING "linux-alpha" -#elif defined __x86_64__ -#define CPUSTRING "linux-x86_64" -#elif defined __powerpc64__ -#define CPUSTRING "linux-ppc64" -#elif defined __powerpc__ -#define CPUSTRING "linux-ppc" -#elif defined __s390__ -#define CPUSTRING "linux-s390" -#elif defined __s390x__ -#define CPUSTRING "linux-s390x" -#elif defined __ia64__ -#define CPUSTRING "linux-ia64" -#else -#define CPUSTRING "linux-other" -#endif - -#define PATH_SEP '/' - -// bk001205 - try -#ifdef Q3_STATIC -#define GAME_HARD_LINKED -#define CGAME_HARD_LINKED -#define UI_HARD_LINKED -#define BOTLIB_HARD_LINKED -#endif - -#if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN -inline static short BigShort( short l) { return ShortSwap(l); } -#define LittleShort -inline static int BigLong(int l) { return LongSwap(l); } -#define LittleLong -inline static float BigFloat(const float l) { return FloatSwap(&l); } -#define LittleFloat -#else -#define BigShort -inline static short LittleShort(short l) { return ShortSwap(l); } -#define BigLong -inline static int LittleLong (int l) { return LongSwap(l); } -#define BigFloat -inline static float LittleFloat (const float l) { return FloatSwap(&l); } -#endif - -#endif - -//======================= FreeBSD DEFINES ===================== -#ifdef __FreeBSD__ // rb010123 - -#define stricmp strcasecmp - -#define MAC_STATIC -#define ID_INLINE inline - -#ifdef __i386__ -#define CPUSTRING "freebsd-i386" -#elif defined __axp__ -#define CPUSTRING "freebsd-alpha" -#else -#define CPUSTRING "freebsd-other" -#endif - -#define PATH_SEP '/' - -// bk010116 - omitted Q3STATIC (see Linux above), broken target - -#if !idppc -static short BigShort( short l) { return ShortSwap(l); } -#define LittleShort -static int BigLong(int l) { return LongSwap(l); } -#define LittleLong -static float BigFloat(const float l) { return FloatSwap(&l); } -#define LittleFloat -#else -#define BigShort -static short LittleShort(short l) { return ShortSwap(l); } -#define BigLong -static int LittleLong (int l) { return LongSwap(l); } -#define BigFloat -static float LittleFloat (const float l) { return FloatSwap(&l); } -#endif - -#endif - -//============================================================= - -typedef unsigned char byte; - -typedef enum {qfalse, qtrue} qboolean; - -typedef int qhandle_t; -typedef int sfxHandle_t; -typedef int fileHandle_t; -typedef int clipHandle_t; - - -#ifndef NULL -#define NULL ((void *)0) -#endif - -#define MAX_QINT 0x7fffffff -#define MIN_QINT (-MAX_QINT-1) - - -// angle indexes -#define PITCH 0 // up / down -#define YAW 1 // left / right -#define ROLL 2 // fall over - -// the game guarantees that no string from the network will ever -// exceed MAX_STRING_CHARS -#define MAX_STRING_CHARS 1024 // max length of a string passed to Cmd_TokenizeString -#define MAX_STRING_TOKENS 1024 // max tokens resulting from Cmd_TokenizeString -#define MAX_TOKEN_CHARS 1024 // max length of an individual token - -#define MAX_INFO_STRING 1024 -#define MAX_INFO_KEY 1024 -#define MAX_INFO_VALUE 1024 - -#define BIG_INFO_STRING 8192 // used for system info key only -#define BIG_INFO_KEY 8192 -#define BIG_INFO_VALUE 8192 - - -#define MAX_QPATH 64 // max length of a quake game pathname -#ifdef PATH_MAX -#define MAX_OSPATH PATH_MAX -#else -#define MAX_OSPATH 256 // max length of a filesystem pathname -#endif - -#define MAX_NAME_LENGTH 32 // max length of a client name - -#define MAX_SAY_TEXT 150 - -// paramters for command buffer stuffing -typedef enum { - EXEC_NOW, // don't return until completed, a VM should NEVER use this, - // because some commands might cause the VM to be unloaded... - EXEC_INSERT, // insert at current position, but don't run yet - EXEC_APPEND // add to end of the command buffer (normal case) -} cbufExec_t; - - -// -// these aren't needed by any of the VMs. put in another header? -// -#define MAX_MAP_AREA_BYTES 32 // bit vector of area visibility - - -// print levels from renderer (FIXME: set up for game / cgame?) -typedef enum { - PRINT_ALL, - PRINT_DEVELOPER, // only print when "developer 1" - PRINT_WARNING, - PRINT_ERROR -} printParm_t; - - -#ifdef ERR_FATAL -#undef ERR_FATAL // this is be defined in malloc.h -#endif - -// parameters to the main Error routine -typedef enum { - ERR_FATAL, // exit the entire game with a popup window - ERR_DROP, // print to console and disconnect from game - ERR_SERVERDISCONNECT, // don't kill server - ERR_DISCONNECT, // client disconnected from the server - ERR_NEED_CD // pop up the need-cd dialog -} errorParm_t; - - -// font rendering values used by ui and cgame - -#define PROP_GAP_WIDTH 3 -#define PROP_SPACE_WIDTH 8 -#define PROP_HEIGHT 27 -#define PROP_SMALL_SIZE_SCALE 0.75 - -#define BLINK_DIVISOR 200 -#define PULSE_DIVISOR 75 - -#define UI_LEFT 0x00000000 // default -#define UI_CENTER 0x00000001 -#define UI_RIGHT 0x00000002 -#define UI_FORMATMASK 0x00000007 -#define UI_SMALLFONT 0x00000010 -#define UI_BIGFONT 0x00000020 // default -#define UI_GIANTFONT 0x00000040 -#define UI_DROPSHADOW 0x00000800 -#define UI_BLINK 0x00001000 -#define UI_INVERSE 0x00002000 -#define UI_PULSE 0x00004000 - -#if defined(_DEBUG) && !defined(BSPC) - #define HUNK_DEBUG -#endif - -typedef enum { - h_high, - h_low, - h_dontcare -} ha_pref; - -#ifdef HUNK_DEBUG -#define Hunk_Alloc( size, preference ) Hunk_AllocDebug(size, preference, #size, __FILE__, __LINE__) -void *Hunk_AllocDebug( int size, ha_pref preference, char *label, char *file, int line ); -#else -void *Hunk_Alloc( int size, ha_pref preference ); -#endif - -#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(MACOS_X) -// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=371 -// custom Snd_Memset implementation for glibc memset bug workaround -void Snd_Memset (void* dest, const int val, const size_t count); -#else -#define Snd_Memset Com_Memset -#endif - -#if !( defined __VECTORC ) -void Com_Memset (void* dest, const int val, const size_t count); -void Com_Memcpy (void* dest, const void* src, const size_t count); -#else -#define Com_Memset memset -#define Com_Memcpy memcpy -#endif - -#define CIN_system 1 -#define CIN_loop 2 -#define CIN_hold 4 -#define CIN_silent 8 -#define CIN_shader 16 - -/* -============================================================== - -MATHLIB - -============================================================== -*/ - - -typedef float vec_t; -typedef vec_t vec2_t[2]; -typedef vec_t vec3_t[3]; -typedef vec_t vec4_t[4]; -typedef vec_t vec5_t[5]; - -typedef int fixed4_t; -typedef int fixed8_t; -typedef int fixed16_t; - -#ifndef M_PI -#define M_PI 3.14159265358979323846f // matches value in gcc v2 math.h -#endif - -#define NUMVERTEXNORMALS 162 -extern vec3_t bytedirs[NUMVERTEXNORMALS]; - -// all drawing is done to a 640*480 virtual screen size -// and will be automatically scaled to the real resolution -#define SCREEN_WIDTH 640 -#define SCREEN_HEIGHT 480 - -#define TINYCHAR_WIDTH (SMALLCHAR_WIDTH) -#define TINYCHAR_HEIGHT (SMALLCHAR_HEIGHT/2) - -#define SMALLCHAR_WIDTH 8 -#define SMALLCHAR_HEIGHT 16 - -#define BIGCHAR_WIDTH 16 -#define BIGCHAR_HEIGHT 16 - -#define GIANTCHAR_WIDTH 32 -#define GIANTCHAR_HEIGHT 48 - -extern vec4_t colorBlack; -extern vec4_t colorRed; -extern vec4_t colorGreen; -extern vec4_t colorBlue; -extern vec4_t colorYellow; -extern vec4_t colorMagenta; -extern vec4_t colorCyan; -extern vec4_t colorWhite; -extern vec4_t colorLtGrey; -extern vec4_t colorMdGrey; -extern vec4_t colorDkGrey; - -#define Q_COLOR_ESCAPE '^' -#define Q_IsColorString(p) ( p && *(p) == Q_COLOR_ESCAPE && *((p)+1) && *((p)+1) != Q_COLOR_ESCAPE ) - -#define COLOR_BLACK '0' -#define COLOR_RED '1' -#define COLOR_GREEN '2' -#define COLOR_YELLOW '3' -#define COLOR_BLUE '4' -#define COLOR_CYAN '5' -#define COLOR_MAGENTA '6' -#define COLOR_WHITE '7' -#define ColorIndex(c) ( ( (c) - '0' ) & 7 ) - -#define S_COLOR_BLACK "^0" -#define S_COLOR_RED "^1" -#define S_COLOR_GREEN "^2" -#define S_COLOR_YELLOW "^3" -#define S_COLOR_BLUE "^4" -#define S_COLOR_CYAN "^5" -#define S_COLOR_MAGENTA "^6" -#define S_COLOR_WHITE "^7" - -extern vec4_t g_color_table[8]; - -#define MAKERGB( v, r, g, b ) v[0]=r;v[1]=g;v[2]=b -#define MAKERGBA( v, r, g, b, a ) v[0]=r;v[1]=g;v[2]=b;v[3]=a - -#define DEG2RAD( a ) ( ( (a) * M_PI ) / 180.0F ) -#define RAD2DEG( a ) ( ( (a) * 180.0f ) / M_PI ) - -struct cplane_s; - -extern vec3_t vec3_origin; -extern vec3_t axisDefault[3]; - -#define nanmask (255<<23) - -#define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask) - -#if idppc - -static inline float Q_rsqrt( float number ) { - float x = 0.5f * number; - float y; -#ifdef __GNUC__ - asm("frsqrte %0,%1" : "=f" (y) : "f" (number)); -#else - y = __frsqrte( number ); -#endif - return y * (1.5f - (x * y * y)); - } - -#ifdef __GNUC__ -static inline float Q_fabs(float x) { - float abs_x; - - asm("fabs %0,%1" : "=f" (abs_x) : "f" (x)); - return abs_x; -} -#else -#define Q_fabs __fabsf -#endif - -#else -float Q_fabs( float f ); -float Q_rsqrt( float f ); // reciprocal square root -#endif - -#define SQRTFAST( x ) ( (x) * Q_rsqrt( x ) ) - -signed char ClampChar( int i ); -signed short ClampShort( int i ); - -// this isn't a real cheap function to call! -int DirToByte( vec3_t dir ); -void ByteToDir( int b, vec3_t dir ); - -#if 1 - -#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]) -#define VectorSubtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2]) -#define VectorAdd(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2]) -#define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2]) -#define VectorScale(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s)) -#define VectorMA(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s)) - -#else - -#define DotProduct(x,y) _DotProduct(x,y) -#define VectorSubtract(a,b,c) _VectorSubtract(a,b,c) -#define VectorAdd(a,b,c) _VectorAdd(a,b,c) -#define VectorCopy(a,b) _VectorCopy(a,b) -#define VectorScale(v, s, o) _VectorScale(v,s,o) -#define VectorMA(v, s, b, o) _VectorMA(v,s,b,o) - -#endif - -#ifdef __LCC__ -#ifdef VectorCopy -#undef VectorCopy -// this is a little hack to get more efficient copies in our interpreter -typedef struct { - float v[3]; -} vec3struct_t; -#define VectorCopy(a,b) (*(vec3struct_t *)b=*(vec3struct_t *)a) -#define ID_INLINE static -#endif -#endif - -#define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0) -#define VectorNegate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2]) -#define VectorSet(v, x, y, z) ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z)) -#define Vector4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3]) - -#define SnapVector(v) {v[0]=((int)(v[0]));v[1]=((int)(v[1]));v[2]=((int)(v[2]));} -// just in case you do't want to use the macros -vec_t _DotProduct( const vec3_t v1, const vec3_t v2 ); -void _VectorSubtract( const vec3_t veca, const vec3_t vecb, vec3_t out ); -void _VectorAdd( const vec3_t veca, const vec3_t vecb, vec3_t out ); -void _VectorCopy( const vec3_t in, vec3_t out ); -void _VectorScale( const vec3_t in, float scale, vec3_t out ); -void _VectorMA( const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc ); - -unsigned ColorBytes3 (float r, float g, float b); -unsigned ColorBytes4 (float r, float g, float b, float a); - -float NormalizeColor( const vec3_t in, vec3_t out ); - -float RadiusFromBounds( const vec3_t mins, const vec3_t maxs ); -void ClearBounds( vec3_t mins, vec3_t maxs ); -void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs ); - -#ifndef __LCC__ -static ID_INLINE int VectorCompare( const vec3_t v1, const vec3_t v2 ) { - if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) { - return 0; - } - return 1; -} - -static ID_INLINE vec_t VectorLength( const vec3_t v ) { - return (vec_t)sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); -} - -static ID_INLINE vec_t VectorLengthSquared( const vec3_t v ) { - return (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); -} - -static ID_INLINE vec_t Distance( const vec3_t p1, const vec3_t p2 ) { - vec3_t v; - - VectorSubtract (p2, p1, v); - return VectorLength( v ); -} - -static ID_INLINE vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ) { - vec3_t v; - - VectorSubtract (p2, p1, v); - return v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; -} - -// fast vector normalize routine that does not check to make sure -// that length != 0, nor does it return length, uses rsqrt approximation -static ID_INLINE void VectorNormalizeFast( vec3_t v ) -{ - float ilength; - - ilength = Q_rsqrt( DotProduct( v, v ) ); - - v[0] *= ilength; - v[1] *= ilength; - v[2] *= ilength; -} - -static ID_INLINE void VectorInverse( vec3_t v ){ - v[0] = -v[0]; - v[1] = -v[1]; - v[2] = -v[2]; -} - -static ID_INLINE void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) { - cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; - cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; - cross[2] = v1[0]*v2[1] - v1[1]*v2[0]; -} - -#else -int VectorCompare( const vec3_t v1, const vec3_t v2 ); - -vec_t VectorLength( const vec3_t v ); - -vec_t VectorLengthSquared( const vec3_t v ); - -vec_t Distance( const vec3_t p1, const vec3_t p2 ); - -vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ); - -void VectorNormalizeFast( vec3_t v ); - -void VectorInverse( vec3_t v ); - -void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ); - -#endif - -vec_t VectorNormalize (vec3_t v); // returns vector length -vec_t VectorNormalize2( const vec3_t v, vec3_t out ); -void Vector4Scale( const vec4_t in, vec_t scale, vec4_t out ); -void VectorRotate( vec3_t in, vec3_t matrix[3], vec3_t out ); -int Q_log2(int val); - -float Q_acos(float c); - -int Q_rand( int *seed ); -float Q_random( int *seed ); -float Q_crandom( int *seed ); - -#define random() ((rand () & 0x7fff) / ((float)0x7fff)) -#define crandom() (2.0 * (random() - 0.5)) - -void vectoangles( const vec3_t value1, vec3_t angles); -void AnglesToAxis( const vec3_t angles, vec3_t axis[3] ); - -void AxisClear( vec3_t axis[3] ); -void AxisCopy( vec3_t in[3], vec3_t out[3] ); - -void SetPlaneSignbits( struct cplane_s *out ); -int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *plane); - -float AngleMod(float a); -float LerpAngle (float from, float to, float frac); -float AngleSubtract( float a1, float a2 ); -void AnglesSubtract( vec3_t v1, vec3_t v2, vec3_t v3 ); - -float AngleNormalize360 ( float angle ); -float AngleNormalize180 ( float angle ); -float AngleDelta ( float angle1, float angle2 ); - -qboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c ); -void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal ); -void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees ); -void RotateAroundDirection( vec3_t axis[3], float yaw ); -void MakeNormalVectors( const vec3_t forward, vec3_t right, vec3_t up ); -// perpendicular vector could be replaced by this - -//int PlaneTypeForNormal (vec3_t normal); - -void MatrixMultiply(float in1[3][3], float in2[3][3], float out[3][3]); -void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); -void PerpendicularVector( vec3_t dst, const vec3_t src ); - - -//============================================= - -float Com_Clamp( float min, float max, float value ); - -char *COM_SkipPath( char *pathname ); -void COM_StripExtension( const char *in, char *out ); -void COM_DefaultExtension( char *path, int maxSize, const char *extension ); - -void COM_BeginParseSession( const char *name ); -int COM_GetCurrentParseLine( void ); -char *COM_Parse( char **data_p ); -char *COM_ParseExt( char **data_p, qboolean allowLineBreak ); -int COM_Compress( char *data_p ); -void COM_ParseError( char *format, ... ); -void COM_ParseWarning( char *format, ... ); -//int COM_ParseInfos( char *buf, int max, char infos[][MAX_INFO_STRING] ); - -#define MAX_TOKENLENGTH 1024 - -#ifndef TT_STRING -//token types -#define TT_STRING 1 // string -#define TT_LITERAL 2 // literal -#define TT_NUMBER 3 // number -#define TT_NAME 4 // name -#define TT_PUNCTUATION 5 // punctuation -#endif - -typedef struct pc_token_s -{ - int type; - int subtype; - int intvalue; - float floatvalue; - char string[MAX_TOKENLENGTH]; -} pc_token_t; - -// data is an in/out parm, returns a parsed out token - -void COM_MatchToken( char**buf_p, char *match ); - -void SkipBracedSection (char **program); -void SkipRestOfLine ( char **data ); - -void Parse1DMatrix (char **buf_p, int x, float *m); -void Parse2DMatrix (char **buf_p, int y, int x, float *m); -void Parse3DMatrix (char **buf_p, int z, int y, int x, float *m); - -void QDECL Com_sprintf (char *dest, int size, const char *fmt, ...); - - -// mode parm for FS_FOpenFile -typedef enum { - FS_READ, - FS_WRITE, - FS_APPEND, - FS_APPEND_SYNC -} fsMode_t; - -typedef enum { - FS_SEEK_CUR, - FS_SEEK_END, - FS_SEEK_SET -} fsOrigin_t; - -//============================================= - -int Q_isprint( int c ); -int Q_islower( int c ); -int Q_isupper( int c ); -int Q_isalpha( int c ); - -// portable case insensitive compare -int Q_stricmp (const char *s1, const char *s2); -int Q_strncmp (const char *s1, const char *s2, int n); -int Q_stricmpn (const char *s1, const char *s2, int n); -char *Q_strlwr( char *s1 ); -char *Q_strupr( char *s1 ); -char *Q_strrchr( const char* string, int c ); - -// buffer size safe library replacements -void Q_strncpyz( char *dest, const char *src, int destsize ); -void Q_strcat( char *dest, int size, const char *src ); - -// strlen that discounts Quake color sequences -int Q_PrintStrlen( const char *string ); -// removes color sequences from string -char *Q_CleanStr( char *string ); - -//============================================= - -// 64-bit integers for global rankings interface -// implemented as a struct for qvm compatibility -typedef struct -{ - byte b0; - byte b1; - byte b2; - byte b3; - byte b4; - byte b5; - byte b6; - byte b7; -} qint64; - -//============================================= -/* -short BigShort(short l); -short LittleShort(short l); -int BigLong (int l); -int LittleLong (int l); -qint64 BigLong64 (qint64 l); -qint64 LittleLong64 (qint64 l); -float BigFloat (const float *l); -float LittleFloat (const float *l); - -void Swap_Init (void); -*/ -char * QDECL va(char *format, ...); - -//============================================= - -// -// key / value info strings -// -char *Info_ValueForKey( const char *s, const char *key ); -void Info_RemoveKey( char *s, const char *key ); -void Info_RemoveKey_big( char *s, const char *key ); -void Info_SetValueForKey( char *s, const char *key, const char *value ); -void Info_SetValueForKey_Big( char *s, const char *key, const char *value ); -qboolean Info_Validate( const char *s ); -void Info_NextPair( const char **s, char *key, char *value ); - -// this is only here so the functions in q_shared.c and bg_*.c can link -void QDECL Com_Error( int level, const char *error, ... ); -void QDECL Com_Printf( const char *msg, ... ); - - -/* -========================================================== - -CVARS (console variables) - -Many variables can be used for cheating purposes, so when -cheats is zero, force all unspecified variables to their -default values. -========================================================== -*/ - -#define CVAR_ARCHIVE 1 // set to cause it to be saved to vars.rc - // used for system variables, not for player - // specific configurations -#define CVAR_USERINFO 2 // sent to server on connect or change -#define CVAR_SERVERINFO 4 // sent in response to front end requests -#define CVAR_SYSTEMINFO 8 // these cvars will be duplicated on all clients -#define CVAR_INIT 16 // don't allow change from console at all, - // but can be set from the command line -#define CVAR_LATCH 32 // will only change when C code next does - // a Cvar_Get(), so it can't be changed - // without proper initialization. modified - // will be set, even though the value hasn't - // changed yet -#define CVAR_ROM 64 // display only, cannot be set by user at all -#define CVAR_USER_CREATED 128 // created by a set command -#define CVAR_TEMP 256 // can be set even when cheats are disabled, but is not archived -#define CVAR_CHEAT 512 // can not be changed if cheats are disabled -#define CVAR_NORESTART 1024 // do not clear when a cvar_restart is issued - -// nothing outside the Cvar_*() functions should modify these fields! -typedef struct cvar_s { - char *name; - char *string; - char *resetString; // cvar_restart will reset to this value - char *latchedString; // for CVAR_LATCH vars - int flags; - qboolean modified; // set each time the cvar is changed - int modificationCount; // incremented each time the cvar is changed - float value; // atof( string ) - int integer; // atoi( string ) - struct cvar_s *next; - struct cvar_s *hashNext; -} cvar_t; - -#define MAX_CVAR_VALUE_STRING 256 - -typedef int cvarHandle_t; - -// the modules that run in the virtual machine can't access the cvar_t directly, -// so they must ask for structured updates -typedef struct { - cvarHandle_t handle; - int modificationCount; - float value; - int integer; - char string[MAX_CVAR_VALUE_STRING]; -} vmCvar_t; - -/* -============================================================== - -COLLISION DETECTION - -============================================================== -*/ - -#include "surfaceflags.h" // shared with the q3map utility - -// plane types are used to speed some tests -// 0-2 are axial planes -#define PLANE_X 0 -#define PLANE_Y 1 -#define PLANE_Z 2 -#define PLANE_NON_AXIAL 3 - - -/* -================= -PlaneTypeForNormal -================= -*/ - -#define PlaneTypeForNormal(x) (x[0] == 1.0 ? PLANE_X : (x[1] == 1.0 ? PLANE_Y : (x[2] == 1.0 ? PLANE_Z : PLANE_NON_AXIAL) ) ) - -// plane_t structure -// !!! if this is changed, it must be changed in asm code too !!! -typedef struct cplane_s { - vec3_t normal; - float dist; - byte type; // for fast side tests: 0,1,2 = axial, 3 = nonaxial - byte signbits; // signx + (signy<<1) + (signz<<2), used as lookup during collision - byte pad[2]; -} cplane_t; - - -// a trace is returned when a box is swept through the world -typedef struct { - qboolean allsolid; // if true, plane is not valid - qboolean startsolid; // if true, the initial point was in a solid area - float fraction; // time completed, 1.0 = didn't hit anything - vec3_t endpos; // final position - cplane_t plane; // surface normal at impact, transformed to world space - int surfaceFlags; // surface hit - int contents; // contents on other side of surface hit - int entityNum; // entity the contacted sirface is a part of -} trace_t; - -// trace->entityNum can also be 0 to (MAX_GENTITIES-1) -// or ENTITYNUM_NONE, ENTITYNUM_WORLD - - -// markfragments are returned by CM_MarkFragments() -typedef struct { - int firstPoint; - int numPoints; -} markFragment_t; - - - -typedef struct { - vec3_t origin; - vec3_t axis[3]; -} orientation_t; - -//===================================================================== - - -// in order from highest priority to lowest -// if none of the catchers are active, bound key strings will be executed -#define KEYCATCH_CONSOLE 0x0001 -#define KEYCATCH_UI 0x0002 -#define KEYCATCH_MESSAGE 0x0004 -#define KEYCATCH_CGAME 0x0008 - - -// sound channels -// channel 0 never willingly overrides -// other channels will allways override a playing sound on that channel -typedef enum { - CHAN_AUTO, - CHAN_LOCAL, // menu sounds, etc - CHAN_WEAPON, - CHAN_VOICE, - CHAN_ITEM, - CHAN_BODY, - CHAN_LOCAL_SOUND, // chat messages, etc - CHAN_ANNOUNCER // announcer voices, etc -} soundChannel_t; - - -/* -======================================================================== - - ELEMENTS COMMUNICATED ACROSS THE NET - -======================================================================== -*/ - -#define ANGLE2SHORT(x) ((int)((x)*65536/360) & 65535) -#define SHORT2ANGLE(x) ((x)*(360.0/65536)) - -#define SNAPFLAG_RATE_DELAYED 1 -#define SNAPFLAG_NOT_ACTIVE 2 // snapshot used during connection and for zombies -#define SNAPFLAG_SERVERCOUNT 4 // toggled every map_restart so transitions can be detected - -// -// per-level limits -// -#define MAX_CLIENTS 64 // absolute limit -#define MAX_LOCATIONS 64 - -#define GENTITYNUM_BITS 10 // don't need to send any more -#define MAX_GENTITIES (1<serverTime of last executed command - int pm_type; - int bobCycle; // for view bobbing and footstep generation - int pm_flags; // ducked, jump_held, etc - int pm_time; - - vec3_t origin; - vec3_t velocity; - int weaponTime; - int gravity; - int speed; - int delta_angles[3]; // add to command angles to get view direction - // changed by spawns, rotating objects, and teleporters - - int groundEntityNum;// ENTITYNUM_NONE = in air - - int legsTimer; // don't change low priority animations until this runs out - int legsAnim; // mask off ANIM_TOGGLEBIT - - int torsoTimer; // don't change low priority animations until this runs out - int torsoAnim; // mask off ANIM_TOGGLEBIT - - int movementDir; // a number 0 to 7 that represents the reletive angle - // of movement to the view angle (axial and diagonals) - // when at rest, the value will remain unchanged - // used to twist the legs during strafing - - vec3_t grapplePoint; // location of grapple to pull towards if PMF_GRAPPLE_PULL - - int eFlags; // copied to entityState_t->eFlags - - int eventSequence; // pmove generated events - int events[MAX_PS_EVENTS]; - int eventParms[MAX_PS_EVENTS]; - - int externalEvent; // events set on player from another source - int externalEventParm; - int externalEventTime; - - int clientNum; // ranges from 0 to MAX_CLIENTS-1 - int weapon; // copied to entityState_t->weapon - int weaponstate; - - vec3_t viewangles; // for fixed views - int viewheight; - - // damage feedback - int damageEvent; // when it changes, latch the other parms - int damageYaw; - int damagePitch; - int damageCount; - - int stats[MAX_STATS]; - int persistant[MAX_PERSISTANT]; // stats that aren't cleared on death - int powerups[MAX_POWERUPS]; // level.time that the powerup runs out - int ammo[MAX_WEAPONS]; - - int generic1; - int loopSound; - int jumppad_ent; // jumppad entity hit this frame - - // not communicated over the net at all - int ping; // server to game info for scoreboard - int pmove_framecount; // FIXME: don't transmit over the network - int jumppad_frame; - int entityEventSequence; -} playerState_t; - - -//==================================================================== - - -// -// usercmd_t->button bits, many of which are generated by the client system, -// so they aren't game/cgame only definitions -// -#define BUTTON_ATTACK 1 -#define BUTTON_TALK 2 // displays talk balloon and disables actions -#define BUTTON_USE_HOLDABLE 4 -#define BUTTON_GESTURE 8 -#define BUTTON_WALKING 16 // walking can't just be infered from MOVE_RUN - // because a key pressed late in the frame will - // only generate a small move value for that frame - // walking will use different animations and - // won't generate footsteps -#define BUTTON_AFFIRMATIVE 32 -#define BUTTON_NEGATIVE 64 - -#define BUTTON_GETFLAG 128 -#define BUTTON_GUARDBASE 256 -#define BUTTON_PATROL 512 -#define BUTTON_FOLLOWME 1024 - -#define BUTTON_ANY 2048 // any key whatsoever - -#define MOVE_RUN 120 // if forwardmove or rightmove are >= MOVE_RUN, - // then BUTTON_WALKING should be set - -// usercmd_t is sent to the server each client frame -typedef struct usercmd_s { - int serverTime; - int angles[3]; - int buttons; - byte weapon; // weapon - signed char forwardmove, rightmove, upmove; -} usercmd_t; - -//=================================================================== - -// if entityState->solid == SOLID_BMODEL, modelindex is an inline model number -#define SOLID_BMODEL 0xffffff - -typedef enum { - TR_STATIONARY, - TR_INTERPOLATE, // non-parametric, but interpolate between snapshots - TR_LINEAR, - TR_LINEAR_STOP, - TR_SINE, // value = base + sin( time / duration ) * delta - TR_GRAVITY -} trType_t; - -typedef struct { - trType_t trType; - int trTime; - int trDuration; // if non 0, trTime + trDuration = stop time - vec3_t trBase; - vec3_t trDelta; // velocity, etc -} trajectory_t; - -// entityState_t is the information conveyed from the server -// in an update message about entities that the client will -// need to render in some way -// Different eTypes may use the information in different ways -// The messages are delta compressed, so it doesn't really matter if -// the structure size is fairly large - -typedef struct entityState_s { - int number; // entity index - int eType; // entityType_t - int eFlags; - - trajectory_t pos; // for calculating position - trajectory_t apos; // for calculating angles - - int time; - int time2; - - vec3_t origin; - vec3_t origin2; - - vec3_t angles; - vec3_t angles2; - - int otherEntityNum; // shotgun sources, etc - int otherEntityNum2; - - int groundEntityNum; // -1 = in air - - int constantLight; // r + (g<<8) + (b<<16) + (intensity<<24) - int loopSound; // constantly loop this sound - - int modelindex; - int modelindex2; - int clientNum; // 0 to (MAX_CLIENTS - 1), for players and corpses - int frame; - - int solid; // for client side prediction, trap_linkentity sets this properly - - int event; // impulse events -- muzzle flashes, footsteps, etc - int eventParm; - - // for players - int powerups; // bit flags - int weapon; // determines weapon and flash model, etc - int legsAnim; // mask off ANIM_TOGGLEBIT - int torsoAnim; // mask off ANIM_TOGGLEBIT - - int generic1; -} entityState_t; - -typedef enum { - CA_UNINITIALIZED, - CA_DISCONNECTED, // not talking to a server - CA_AUTHORIZING, // not used any more, was checking cd key - CA_CONNECTING, // sending request packets to the server - CA_CHALLENGING, // sending challenge packets to the server - CA_CONNECTED, // netchan_t established, getting gamestate - CA_LOADING, // only during cgame initialization, never during main loop - CA_PRIMED, // got gamestate, waiting for first frame - CA_ACTIVE, // game views should be displayed - CA_CINEMATIC // playing a cinematic or a static pic, not connected to a server -} connstate_t; - -// font support - -#define GLYPH_START 0 -#define GLYPH_END 255 -#define GLYPH_CHARSTART 32 -#define GLYPH_CHAREND 127 -#define GLYPHS_PER_FONT GLYPH_END - GLYPH_START + 1 -typedef struct { - int height; // number of scan lines - int top; // top of glyph in buffer - int bottom; // bottom of glyph in buffer - int pitch; // width for copying - int xSkip; // x adjustment - int imageWidth; // width of actual image - int imageHeight; // height of actual image - float s; // x offset in image where glyph starts - float t; // y offset in image where glyph starts - float s2; - float t2; - qhandle_t glyph; // handle to the shader with the glyph - char shaderName[32]; -} glyphInfo_t; - -typedef struct { - glyphInfo_t glyphs [GLYPHS_PER_FONT]; - float glyphScale; - char name[MAX_QPATH]; -} fontInfo_t; - -#define Square(x) ((x)*(x)) - -// real time -//============================================= - - -typedef struct qtime_s { - int tm_sec; /* seconds after the minute - [0,59] */ - int tm_min; /* minutes after the hour - [0,59] */ - int tm_hour; /* hours since midnight - [0,23] */ - int tm_mday; /* day of the month - [1,31] */ - int tm_mon; /* months since January - [0,11] */ - int tm_year; /* years since 1900 */ - int tm_wday; /* days since Sunday - [0,6] */ - int tm_yday; /* days since January 1 - [0,365] */ - int tm_isdst; /* daylight savings time flag */ -} qtime_t; - - -// server browser sources -// TTimo: AS_MPLAYER is no longer used -#define AS_LOCAL 0 -#define AS_MPLAYER 1 -#define AS_GLOBAL 2 -#define AS_FAVORITES 3 - - -// cinematic states -typedef enum { - FMV_IDLE, - FMV_PLAY, // play - FMV_EOF, // all other conditions, i.e. stop/EOF/abort - FMV_ID_BLT, - FMV_ID_IDLE, - FMV_LOOPED, - FMV_ID_WAIT -} e_status; - -typedef enum _flag_status { - FLAG_ATBASE = 0, - FLAG_TAKEN, // CTF - FLAG_TAKEN_RED, // One Flag CTF - FLAG_TAKEN_BLUE, // One Flag CTF - FLAG_DROPPED -} flagStatus_t; - - - -#define MAX_GLOBAL_SERVERS 4096 -#define MAX_OTHER_SERVERS 128 -#define MAX_PINGREQUESTS 32 -#define MAX_SERVERSTATUSREQUESTS 16 - -#define SAY_ALL 0 -#define SAY_TEAM 1 -#define SAY_TELL 2 - -#define CDKEY_LEN 16 -#define CDCHKSUM_LEN 2 - - -#endif // __Q_SHARED_H diff --git a/code/game/surfaceflags.h b/code/game/surfaceflags.h deleted file mode 100644 index 92e28d2..0000000 --- a/code/game/surfaceflags.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code 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. - -Quake III Arena source code 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 Foobar; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// -// This file must be identical in the quake and utils directories - -// contents flags are seperate bits -// a given brush can contribute multiple content bits - -// these definitions also need to be in q_shared.h! - -#define CONTENTS_SOLID 1 // an eye is never valid in a solid -#define CONTENTS_LAVA 8 -#define CONTENTS_SLIME 16 -#define CONTENTS_WATER 32 -#define CONTENTS_FOG 64 - -#define CONTENTS_NOTTEAM1 0x0080 -#define CONTENTS_NOTTEAM2 0x0100 -#define CONTENTS_NOBOTCLIP 0x0200 - -#define CONTENTS_AREAPORTAL 0x8000 - -#define CONTENTS_PLAYERCLIP 0x10000 -#define CONTENTS_MONSTERCLIP 0x20000 -//bot specific contents types -#define CONTENTS_TELEPORTER 0x40000 -#define CONTENTS_JUMPPAD 0x80000 -#define CONTENTS_CLUSTERPORTAL 0x100000 -#define CONTENTS_DONOTENTER 0x200000 -#define CONTENTS_BOTCLIP 0x400000 -#define CONTENTS_MOVER 0x800000 - -#define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity - -#define CONTENTS_BODY 0x2000000 // should never be on a brush, only in game -#define CONTENTS_CORPSE 0x4000000 -#define CONTENTS_DETAIL 0x8000000 // brushes not used for the bsp -#define CONTENTS_STRUCTURAL 0x10000000 // brushes used for the bsp -#define CONTENTS_TRANSLUCENT 0x20000000 // don't consume surface fragments inside -#define CONTENTS_TRIGGER 0x40000000 -#define CONTENTS_NODROP 0x80000000 // don't leave bodies or items (death fog, lava) - -#define SURF_NODAMAGE 0x1 // never give falling damage -#define SURF_SLICK 0x2 // effects game physics -#define SURF_SKY 0x4 // lighting from environment map -#define SURF_LADDER 0x8 -#define SURF_NOIMPACT 0x10 // don't make missile explosions -#define SURF_NOMARKS 0x20 // don't leave missile marks -#define SURF_FLESH 0x40 // make flesh sounds and effects -#define SURF_NODRAW 0x80 // don't generate a drawsurface at all -#define SURF_HINT 0x100 // make a primary bsp splitter -#define SURF_SKIP 0x200 // completely ignore, allowing non-closed brushes -#define SURF_NOLIGHTMAP 0x400 // surface doesn't need a lightmap -#define SURF_POINTLIGHT 0x800 // generate lighting info at vertexes -#define SURF_METALSTEPS 0x1000 // clanking footsteps -#define SURF_NOSTEPS 0x2000 // no footstep sounds -#define SURF_NONSOLID 0x4000 // don't collide against curves with this set -#define SURF_LIGHTFILTER 0x8000 // act as a light filter during q3map -light -#define SURF_ALPHASHADOW 0x10000 // do per-pixel light shadow casting in q3map -#define SURF_NODLIGHT 0x20000 // don't dlight even if solid (solid lava, skies) -#define SURF_DUST 0x40000 // leave a dust trail when walking on this surface diff --git a/code/jpeg-6/jload.c b/code/jpeg-6/jload.c index dc82555..29e750b 100644 --- a/code/jpeg-6/jload.c +++ b/code/jpeg-6/jload.c @@ -1,5 +1,5 @@ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" /* diff --git a/code/null/mac_net.c b/code/null/mac_net.c index 5dbb5dd..486cacd 100644 --- a/code/null/mac_net.c +++ b/code/null/mac_net.c @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" /* diff --git a/code/q3_ui/keycodes.h b/code/q3_ui/keycodes.h deleted file mode 100644 index 8f58482..0000000 --- a/code/q3_ui/keycodes.h +++ /dev/null @@ -1,163 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code 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. - -Quake III Arena source code 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 Foobar; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// -#ifndef __KEYCODES_H__ -#define __KEYCODES_H__ - -// -// these are the key numbers that should be passed to KeyEvent -// - -// normal keys should be passed as lowercased ascii - -typedef enum { - K_TAB = 9, - K_ENTER = 13, - K_ESCAPE = 27, - K_SPACE = 32, - - K_BACKSPACE = 127, - - K_COMMAND = 128, - K_CAPSLOCK, - K_POWER, - K_PAUSE, - - K_UPARROW, - K_DOWNARROW, - K_LEFTARROW, - K_RIGHTARROW, - - K_ALT, - K_CTRL, - K_SHIFT, - K_INS, - K_DEL, - K_PGDN, - K_PGUP, - K_HOME, - K_END, - - K_F1, - K_F2, - K_F3, - K_F4, - K_F5, - K_F6, - K_F7, - K_F8, - K_F9, - K_F10, - K_F11, - K_F12, - K_F13, - K_F14, - K_F15, - - K_KP_HOME, - K_KP_UPARROW, - K_KP_PGUP, - K_KP_LEFTARROW, - K_KP_5, - K_KP_RIGHTARROW, - K_KP_END, - K_KP_DOWNARROW, - K_KP_PGDN, - K_KP_ENTER, - K_KP_INS, - K_KP_DEL, - K_KP_SLASH, - K_KP_MINUS, - K_KP_PLUS, - K_KP_NUMLOCK, - K_KP_STAR, - K_KP_EQUALS, - - K_MOUSE1, - K_MOUSE2, - K_MOUSE3, - K_MOUSE4, - K_MOUSE5, - - K_MWHEELDOWN, - K_MWHEELUP, - - K_JOY1, - K_JOY2, - K_JOY3, - K_JOY4, - K_JOY5, - K_JOY6, - K_JOY7, - K_JOY8, - K_JOY9, - K_JOY10, - K_JOY11, - K_JOY12, - K_JOY13, - K_JOY14, - K_JOY15, - K_JOY16, - K_JOY17, - K_JOY18, - K_JOY19, - K_JOY20, - K_JOY21, - K_JOY22, - K_JOY23, - K_JOY24, - K_JOY25, - K_JOY26, - K_JOY27, - K_JOY28, - K_JOY29, - K_JOY30, - K_JOY31, - K_JOY32, - - K_AUX1, - K_AUX2, - K_AUX3, - K_AUX4, - K_AUX5, - K_AUX6, - K_AUX7, - K_AUX8, - K_AUX9, - K_AUX10, - K_AUX11, - K_AUX12, - K_AUX13, - K_AUX14, - K_AUX15, - K_AUX16, - - K_LAST_KEY // this had better be <256! -} keyNum_t; - - -// The menu code needs to get both key and char events, but -// to avoid duplicating the paths, the char events are just -// distinguished by or'ing in K_CHAR_FLAG (ugly) -#define K_CHAR_FLAG 1024 - -#endif diff --git a/code/q3_ui/ui_local.h b/code/q3_ui/ui_local.h index 5d66770..e140190 100644 --- a/code/q3_ui/ui_local.h +++ b/code/q3_ui/ui_local.h @@ -23,14 +23,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef __UI_LOCAL_H__ #define __UI_LOCAL_H__ -#include "../game/q_shared.h" -#include "../cgame/tr_types.h" +#include "../qcommon/q_shared.h" +#include "../renderer/tr_types.h" //NOTE: include the ui_public.h from the new UI #include "../ui/ui_public.h" // bk001205 - yes, do have to use this //redefine to old API version #undef UI_API_VERSION #define UI_API_VERSION 4 -#include "keycodes.h" +#include "../client/keycodes.h" #include "../game/bg_public.h" typedef void (*voidfunc_f)(void); diff --git a/code/qcommon/cm_local.h b/code/qcommon/cm_local.h index 1c3a632..492a1bc 100644 --- a/code/qcommon/cm_local.h +++ b/code/qcommon/cm_local.h @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#include "../game/q_shared.h" +#include "q_shared.h" #include "qcommon.h" #include "cm_polylib.h" diff --git a/code/qcommon/cmd.c b/code/qcommon/cmd.c index 92b6e73..052c4e3 100644 --- a/code/qcommon/cmd.c +++ b/code/qcommon/cmd.c @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // cmd.c -- Quake script command processing module -#include "../game/q_shared.h" +#include "q_shared.h" #include "qcommon.h" #define MAX_CMD_BUFFER 16384 diff --git a/code/qcommon/cmd.c.save b/code/qcommon/cmd.c.save deleted file mode 100644 index 47f8eb9..0000000 --- a/code/qcommon/cmd.c.save +++ /dev/null @@ -1,636 +0,0 @@ -// cmd.c -- Quake script command processing module - -#include "../game/q_shared.h" -#include "qcommon.h" - -#define MAX_CMD_BUFFER 8192 -int cmd_wait; -msg_t cmd_text; -byte cmd_text_buf[MAX_CMD_BUFFER]; -char cmd_defer_text_buf[MAX_CMD_BUFFER]; - - -//============================================================================= - -/* -============ -Cmd_Wait_f - -Causes execution of the remainder of the command buffer to be delayed until -next frame. This allows commands like: -bind g "cmd use rocket ; +attack ; wait ; -attack ; cmd use blaster" -============ -*/ -void Cmd_Wait_f( void ) { - if ( Cmd_Argc() == 2 ) { - cmd_wait = atoi( Cmd_Argv( 1 ) ); - } else { - cmd_wait = 1; - } -} - - -/* -============================================================================= - - COMMAND BUFFER - -============================================================================= -*/ - -/* -============ -Cbuf_Init -============ -*/ -void Cbuf_Init (void) -{ - MSG_Init (&cmd_text, cmd_text_buf, sizeof(cmd_text_buf)); -} - -/* -============ -Cbuf_AddText - -Adds command text at the end of the buffer, does NOT add a final \n -============ -*/ -void Cbuf_AddText( const char *text ) { - int l; - - l = strlen (text); - - if (cmd_text.cursize + l >= cmd_text.maxsize) - { - Com_Printf ("Cbuf_AddText: overflow\n"); - return; - } - MSG_WriteData (&cmd_text, text, strlen (text)); -} - - -/* -============ -Cbuf_InsertText - -Adds command text immediately after the current command -Adds a \n to the text -============ -*/ -void Cbuf_InsertText( const char *text ) { - int len; - int i; - - len = strlen( text ) + 1; - if ( len + cmd_text.cursize > cmd_text.maxsize ) { - Com_Printf( "Cbuf_InsertText overflowed\n" ); - return; - } - - // move the existing command text - for ( i = cmd_text.cursize - 1 ; i >= 0 ; i-- ) { - cmd_text.data[ i + len ] = cmd_text.data[ i ]; - } - - // copy the new text in - memcpy( cmd_text.data, text, len - 1 ); - - // add a \n - cmd_text.data[ len - 1 ] = '\n'; - - cmd_text.cursize += len; -} - - -/* -============ -Cbuf_ExecuteText -============ -*/ -void Cbuf_ExecuteText (int exec_when, const char *text) -{ - switch (exec_when) - { - case EXEC_NOW: - Cmd_ExecuteString (text); - break; - case EXEC_INSERT: - Cbuf_InsertText (text); - break; - case EXEC_APPEND: - Cbuf_AddText (text); - break; - default: - Com_Error (ERR_FATAL, "Cbuf_ExecuteText: bad exec_when"); - } -} - -/* -============ -Cbuf_Execute -============ -*/ -void Cbuf_Execute (void) -{ - int i; - char *text; - char line[MAX_CMD_BUFFER]; - int quotes; - - while (cmd_text.cursize) - { - if ( cmd_wait ) { - // skip out while text still remains in buffer, leaving it - // for next frame - cmd_wait--; - break; - } - - // find a \n or ; line break - text = (char *)cmd_text.data; - - quotes = 0; - for (i=0 ; i< cmd_text.cursize ; i++) - { - if (text[i] == '"') - quotes++; - if ( !(quotes&1) && text[i] == ';') - break; // don't break if inside a quoted string - if (text[i] == '\n' || text[i] == '\r' ) - break; - } - - - memcpy (line, text, i); - line[i] = 0; - -// delete the text from the command buffer and move remaining commands down -// this is necessary because commands (exec) can insert data at the -// beginning of the text buffer - - if (i == cmd_text.cursize) - cmd_text.cursize = 0; - else - { - i++; - cmd_text.cursize -= i; - memmove (text, text+i, cmd_text.cursize); - text[cmd_text.cursize] = 0; - } - -// execute the command line - Cmd_ExecuteString (line); - } -} - - -/* -============================================================================== - - SCRIPT COMMANDS - -============================================================================== -*/ - - -/* -=============== -Cmd_Exec_f -=============== -*/ -void Cmd_Exec_f( void ) { - fileHandle_t f; - int len; - char filename[MAX_QPATH]; - char *buffer; - - if (Cmd_Argc () != 2) { - Com_Printf ("exec : execute a script file\n"); - return; - } - - Q_strncpyz( filename, Cmd_Argv(1), sizeof( filename ) ); - COM_DefaultExtension( filename, sizeof( filename ), ".cfg" ); - len = FS_FOpenFileRead( filename, &f, qfalse ); - if ( len <= 0 ) { - Com_Printf ("Couldn't read %s.\n", filename ); - return; - } - - buffer = Z_Malloc(len+1); - - if (FS_Read(buffer, len, f) == len) { - FS_FCloseFile( f ); - buffer[len] = 0; - Com_Printf ("execing %s\n",Cmd_Argv(1)); - Cbuf_InsertText (buffer); - } - else { - Com_Printf ("couldn't exec %s\n",Cmd_Argv(1)); - } - - Z_Free(buffer); -} - - -/* -=============== -Cmd_Vstr_f - -Inserts the current value of a variable as command text -=============== -*/ -void Cmd_Vstr_f( void ) { - char *v; - - if (Cmd_Argc () != 2) { - Com_Printf ("vstr : execute a variable command\n"); - return; - } - - v = Cvar_VariableString( Cmd_Argv( 1 ) ); - Cbuf_InsertText( va("%s\n", v ) ); -} - - -/* -=============== -Cmd_Echo_f - -Just prints the rest of the line to the console -=============== -*/ -void Cmd_Echo_f (void) -{ - int i; - - for (i=1 ; i= cmd_argc ) { - return ""; - } - return cmd_argv[arg]; -} - -/* -============ -Cmd_ArgvBuffer - -The interpreted versions use this because -they can't have pointers returned to them -============ -*/ -void Cmd_ArgvBuffer( int arg, char *buffer, int bufferLength ) { - Q_strncpyz( buffer, Cmd_Argv( arg ), bufferLength ); -} - - -/* -============ -Cmd_Args - -Returns a single string containing argv(1) to argv(argc()-1) -============ -*/ -char *Cmd_Args( void ) { - static char cmd_args[MAX_STRING_CHARS]; - int i; - - cmd_args[0] = 0; - for ( i = 1 ; i < cmd_argc ; i++ ) { - strcat( cmd_args, cmd_argv[i] ); - if ( i != cmd_argc ) { - strcat( cmd_args, " " ); - } - } - - return cmd_args; -} - - -/* -============ -Cmd_ArgsBuffer - -The interpreted versions use this because -they can't have pointers returned to them -============ -*/ -void Cmd_ArgsBuffer( char *buffer, int bufferLength ) { - Q_strncpyz( buffer, Cmd_Args(), bufferLength ); -} - - -/* -============ -Cmd_TokenizeString - -Parses the given string into command line tokens. -The text is copied to a seperate buffer and 0 characters -are inserted in the apropriate place, The argv array -will point into this temporary buffer. -============ -*/ -void Cmd_TokenizeString( const char *text_in ) { - const char *text; - char *textOut; - - // clear previous args - cmd_argc = 0; - - if ( !text_in ) { - return; - } - - text = text_in; - textOut = cmd_tokenized; - - while ( 1 ) { - if ( cmd_argc == MAX_STRING_TOKENS ) { - return; // this is usually something malicious - } - - while ( 1 ) { - // skip whitespace - while ( *text && *text <= ' ' ) { - text++; - } - if ( !*text ) { - return; // all tokens parsed - } - - // skip // comments - if ( text[0] == '/' && text[1] == '/' ) { - return; // all tokens parsed - } - - // skip /* */ comments - if ( text[0] == '/' && text[1] =='*' ) { - while ( *text && ( text[0] != '*' || text[1] != '/' ) ) { - text++; - } - if ( !*text ) { - return; // all tokens parsed - } - text += 2; - } else { - break; // we are ready to parse a token - } - } - - // handle quoted strings - if ( *text == '"' ) { - cmd_argv[cmd_argc] = textOut; - cmd_argc++; - text++; - while ( *text && *text != '"' ) { - *textOut++ = *text++; - } - *textOut++ = 0; - if ( !*text ) { - return; // all tokens parsed - } - text++; - continue; - } - - // regular token - cmd_argv[cmd_argc] = textOut; - cmd_argc++; - - // skip until whitespace, quote, or command - while ( *text > ' ' ) { - if ( text[0] == '"' ) { - break; - } - - if ( text[0] == '/' && text[1] == '/' ) { - break; - } - - // skip /* */ comments - if ( text[0] == '/' && text[1] =='*' ) { - break; - } - - *textOut++ = *text++; - } - - *textOut++ = 0; - - if ( !*text ) { - return; // all tokens parsed - } - } - -} - - -/* -============ -Cmd_AddCommand -============ -*/ -void Cmd_AddCommand( const char *cmd_name, xcommand_t function ) { - cmd_function_t *cmd; - - // fail if the command already exists - for ( cmd = cmd_functions ; cmd ; cmd=cmd->next ) { - if ( !strcmp( cmd_name, cmd->name ) ) { - // allow completion-only commands to be silently doubled - if ( function != NULL ) { - Com_Printf ("Cmd_AddCommand: %s already defined\n", cmd_name); - } - return; - } - } - - cmd = Z_Malloc (sizeof(cmd_function_t)); - cmd->name = CopyString( cmd_name ); - cmd->function = function; - cmd->next = cmd_functions; - cmd_functions = cmd; -} - -/* -============ -Cmd_RemoveCommand -============ -*/ -void Cmd_RemoveCommand( const char *cmd_name ) { - cmd_function_t *cmd, **back; - - back = &cmd_functions; - while( 1 ) { - cmd = *back; - if ( !cmd ) { - // command wasn't active - return; - } - if ( !strcmp( cmd_name, cmd->name ) ) { - *back = cmd->next; - Z_Free (cmd); - return; - } - back = &cmd->next; - } -} - - -/* -============ -Cmd_CommandCompletion -============ -*/ -void Cmd_CommandCompletion( void(*callback)(const char *s) ) { - cmd_function_t *cmd; - - for (cmd=cmd_functions ; cmd ; cmd=cmd->next) { - callback( cmd->name ); - } -} - - -/* -============ -Cmd_ExecuteString - -A complete command line has been parsed, so try to execute it -============ -*/ -void Cmd_ExecuteString( const char *text ) { - cmd_function_t *cmd, **prev; - - // execute the command line - Cmd_TokenizeString( text ); - if ( !Cmd_Argc() ) { - return; // no tokens - } - - // check registered command functions - for ( prev = &cmd_functions ; *prev ; prev = &cmd->next ) { - cmd = *prev; - if ( !Q_stricmp( cmd_argv[0],cmd->name ) ) { - // rearrange the links so that the command will be - // near the head of the list next time it is used - *prev = cmd->next; - cmd->next = cmd_functions; - cmd_functions = cmd; - - // perform the action - if ( !cmd->function ) { - // let the cgame or game handle it - break; - } else { - cmd->function (); - } - return; - } - } - - // check cvars - if ( Cvar_Command() ) { - return; - } - - // check client game commands - if ( com_cl_running && com_cl_running->integer && CL_GameCommand() ) { - return; - } - - // check server game commands - if ( com_sv_running && com_sv_running->integer && SV_GameCommand() ) { - return; - } - - // check ui commands - if ( com_cl_running && com_cl_running->integer && UI_GameCommand() ) { - return; - } - - // send it as a server command if we are connected - // this will usually result in a chat message - CL_ForwardCommandToServer (); -} - -/* -============ -Cmd_List_f -============ -*/ -void Cmd_List_f (void) -{ - cmd_function_t *cmd; - int i; - char *match; - - if ( Cmd_Argc() > 1 ) { - match = Cmd_Argv( 1 ); - } else { - match = NULL; - } - - i = 0; - for (cmd=cmd_functions ; cmd ; cmd=cmd->next) { - if (match && !Com_Filter(match, cmd->name, qfalse)) continue; - - Com_Printf ("%s\n", cmd->name); - i++; - } - Com_Printf ("%i commands\n", i); -} - -/* -============ -Cmd_Init -============ -*/ -void Cmd_Init (void) { - Cmd_AddCommand ("cmdlist",Cmd_List_f); - Cmd_AddCommand ("exec",Cmd_Exec_f); - Cmd_AddCommand ("vstr",Cmd_Vstr_f); - Cmd_AddCommand ("echo",Cmd_Echo_f); - Cmd_AddCommand ("wait", Cmd_Wait_f); -} - diff --git a/code/qcommon/common.c b/code/qcommon/common.c index ac9b210..4447527 100644 --- a/code/qcommon/common.c +++ b/code/qcommon/common.c @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // common.c -- misc functions used in client and server -#include "../game/q_shared.h" +#include "q_shared.h" #include "qcommon.h" #include #if defined __linux__ || defined MACOS_X || defined __FreeBSD__ diff --git a/code/qcommon/cvar.c b/code/qcommon/cvar.c index 8b38712..f954f0d 100644 --- a/code/qcommon/cvar.c +++ b/code/qcommon/cvar.c @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // cvar.c -- dynamic variable tracking -#include "../game/q_shared.h" +#include "q_shared.h" #include "qcommon.h" cvar_t *cvar_vars; diff --git a/code/qcommon/files.c b/code/qcommon/files.c index c560cc3..401127f 100644 --- a/code/qcommon/files.c +++ b/code/qcommon/files.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ -#include "../game/q_shared.h" +#include "q_shared.h" #include "qcommon.h" #include "unzip.h" diff --git a/code/qcommon/huffman.c b/code/qcommon/huffman.c index 1dcaf3f..dd8da98 100644 --- a/code/qcommon/huffman.c +++ b/code/qcommon/huffman.c @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Compression book. The ranks are not actually stored, but implicitly defined * by the location of a node within a doubly-linked list */ -#include "../game/q_shared.h" +#include "q_shared.h" #include "qcommon.h" static int bloc = 0; diff --git a/code/qcommon/msg.c b/code/qcommon/msg.c index 8c8afe8..4f918f5 100644 --- a/code/qcommon/msg.c +++ b/code/qcommon/msg.c @@ -19,7 +19,7 @@ along with Foobar; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#include "../game/q_shared.h" +#include "q_shared.h" #include "qcommon.h" static huffman_t msgHuff; diff --git a/code/qcommon/net_chan.c b/code/qcommon/net_chan.c index b8a9bc1..941dda9 100644 --- a/code/qcommon/net_chan.c +++ b/code/qcommon/net_chan.c @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#include "../game/q_shared.h" +#include "q_shared.h" #include "qcommon.h" /* diff --git a/code/qcommon/q_math.c b/code/qcommon/q_math.c new file mode 100644 index 0000000..fd835df --- /dev/null +++ b/code/qcommon/q_math.c @@ -0,0 +1,1307 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code 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. + +Quake III Arena source code 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 Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// q_math.c -- stateless support routines that are included in each code module +#include "q_shared.h" + + +vec3_t vec3_origin = {0,0,0}; +vec3_t axisDefault[3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; + + +vec4_t colorBlack = {0, 0, 0, 1}; +vec4_t colorRed = {1, 0, 0, 1}; +vec4_t colorGreen = {0, 1, 0, 1}; +vec4_t colorBlue = {0, 0, 1, 1}; +vec4_t colorYellow = {1, 1, 0, 1}; +vec4_t colorMagenta= {1, 0, 1, 1}; +vec4_t colorCyan = {0, 1, 1, 1}; +vec4_t colorWhite = {1, 1, 1, 1}; +vec4_t colorLtGrey = {0.75, 0.75, 0.75, 1}; +vec4_t colorMdGrey = {0.5, 0.5, 0.5, 1}; +vec4_t colorDkGrey = {0.25, 0.25, 0.25, 1}; + +vec4_t g_color_table[8] = + { + {0.0, 0.0, 0.0, 1.0}, + {1.0, 0.0, 0.0, 1.0}, + {0.0, 1.0, 0.0, 1.0}, + {1.0, 1.0, 0.0, 1.0}, + {0.0, 0.0, 1.0, 1.0}, + {0.0, 1.0, 1.0, 1.0}, + {1.0, 0.0, 1.0, 1.0}, + {1.0, 1.0, 1.0, 1.0}, + }; + + +vec3_t bytedirs[NUMVERTEXNORMALS] = +{ +{-0.525731f, 0.000000f, 0.850651f}, {-0.442863f, 0.238856f, 0.864188f}, +{-0.295242f, 0.000000f, 0.955423f}, {-0.309017f, 0.500000f, 0.809017f}, +{-0.162460f, 0.262866f, 0.951056f}, {0.000000f, 0.000000f, 1.000000f}, +{0.000000f, 0.850651f, 0.525731f}, {-0.147621f, 0.716567f, 0.681718f}, +{0.147621f, 0.716567f, 0.681718f}, {0.000000f, 0.525731f, 0.850651f}, +{0.309017f, 0.500000f, 0.809017f}, {0.525731f, 0.000000f, 0.850651f}, +{0.295242f, 0.000000f, 0.955423f}, {0.442863f, 0.238856f, 0.864188f}, +{0.162460f, 0.262866f, 0.951056f}, {-0.681718f, 0.147621f, 0.716567f}, +{-0.809017f, 0.309017f, 0.500000f},{-0.587785f, 0.425325f, 0.688191f}, +{-0.850651f, 0.525731f, 0.000000f},{-0.864188f, 0.442863f, 0.238856f}, +{-0.716567f, 0.681718f, 0.147621f},{-0.688191f, 0.587785f, 0.425325f}, +{-0.500000f, 0.809017f, 0.309017f}, {-0.238856f, 0.864188f, 0.442863f}, +{-0.425325f, 0.688191f, 0.587785f}, {-0.716567f, 0.681718f, -0.147621f}, +{-0.500000f, 0.809017f, -0.309017f}, {-0.525731f, 0.850651f, 0.000000f}, +{0.000000f, 0.850651f, -0.525731f}, {-0.238856f, 0.864188f, -0.442863f}, +{0.000000f, 0.955423f, -0.295242f}, {-0.262866f, 0.951056f, -0.162460f}, +{0.000000f, 1.000000f, 0.000000f}, {0.000000f, 0.955423f, 0.295242f}, +{-0.262866f, 0.951056f, 0.162460f}, {0.238856f, 0.864188f, 0.442863f}, +{0.262866f, 0.951056f, 0.162460f}, {0.500000f, 0.809017f, 0.309017f}, +{0.238856f, 0.864188f, -0.442863f},{0.262866f, 0.951056f, -0.162460f}, +{0.500000f, 0.809017f, -0.309017f},{0.850651f, 0.525731f, 0.000000f}, +{0.716567f, 0.681718f, 0.147621f}, {0.716567f, 0.681718f, -0.147621f}, +{0.525731f, 0.850651f, 0.000000f}, {0.425325f, 0.688191f, 0.587785f}, +{0.864188f, 0.442863f, 0.238856f}, {0.688191f, 0.587785f, 0.425325f}, +{0.809017f, 0.309017f, 0.500000f}, {0.681718f, 0.147621f, 0.716567f}, +{0.587785f, 0.425325f, 0.688191f}, {0.955423f, 0.295242f, 0.000000f}, +{1.000000f, 0.000000f, 0.000000f}, {0.951056f, 0.162460f, 0.262866f}, +{0.850651f, -0.525731f, 0.000000f},{0.955423f, -0.295242f, 0.000000f}, +{0.864188f, -0.442863f, 0.238856f}, {0.951056f, -0.162460f, 0.262866f}, +{0.809017f, -0.309017f, 0.500000f}, {0.681718f, -0.147621f, 0.716567f}, +{0.850651f, 0.000000f, 0.525731f}, {0.864188f, 0.442863f, -0.238856f}, +{0.809017f, 0.309017f, -0.500000f}, {0.951056f, 0.162460f, -0.262866f}, +{0.525731f, 0.000000f, -0.850651f}, {0.681718f, 0.147621f, -0.716567f}, +{0.681718f, -0.147621f, -0.716567f},{0.850651f, 0.000000f, -0.525731f}, +{0.809017f, -0.309017f, -0.500000f}, {0.864188f, -0.442863f, -0.238856f}, +{0.951056f, -0.162460f, -0.262866f}, {0.147621f, 0.716567f, -0.681718f}, +{0.309017f, 0.500000f, -0.809017f}, {0.425325f, 0.688191f, -0.587785f}, +{0.442863f, 0.238856f, -0.864188f}, {0.587785f, 0.425325f, -0.688191f}, +{0.688191f, 0.587785f, -0.425325f}, {-0.147621f, 0.716567f, -0.681718f}, +{-0.309017f, 0.500000f, -0.809017f}, {0.000000f, 0.525731f, -0.850651f}, +{-0.525731f, 0.000000f, -0.850651f}, {-0.442863f, 0.238856f, -0.864188f}, +{-0.295242f, 0.000000f, -0.955423f}, {-0.162460f, 0.262866f, -0.951056f}, +{0.000000f, 0.000000f, -1.000000f}, {0.295242f, 0.000000f, -0.955423f}, +{0.162460f, 0.262866f, -0.951056f}, {-0.442863f, -0.238856f, -0.864188f}, +{-0.309017f, -0.500000f, -0.809017f}, {-0.162460f, -0.262866f, -0.951056f}, +{0.000000f, -0.850651f, -0.525731f}, {-0.147621f, -0.716567f, -0.681718f}, +{0.147621f, -0.716567f, -0.681718f}, {0.000000f, -0.525731f, -0.850651f}, +{0.309017f, -0.500000f, -0.809017f}, {0.442863f, -0.238856f, -0.864188f}, +{0.162460f, -0.262866f, -0.951056f}, {0.238856f, -0.864188f, -0.442863f}, +{0.500000f, -0.809017f, -0.309017f}, {0.425325f, -0.688191f, -0.587785f}, +{0.716567f, -0.681718f, -0.147621f}, {0.688191f, -0.587785f, -0.425325f}, +{0.587785f, -0.425325f, -0.688191f}, {0.000000f, -0.955423f, -0.295242f}, +{0.000000f, -1.000000f, 0.000000f}, {0.262866f, -0.951056f, -0.162460f}, +{0.000000f, -0.850651f, 0.525731f}, {0.000000f, -0.955423f, 0.295242f}, +{0.238856f, -0.864188f, 0.442863f}, {0.262866f, -0.951056f, 0.162460f}, +{0.500000f, -0.809017f, 0.309017f}, {0.716567f, -0.681718f, 0.147621f}, +{0.525731f, -0.850651f, 0.000000f}, {-0.238856f, -0.864188f, -0.442863f}, +{-0.500000f, -0.809017f, -0.309017f}, {-0.262866f, -0.951056f, -0.162460f}, +{-0.850651f, -0.525731f, 0.000000f}, {-0.716567f, -0.681718f, -0.147621f}, +{-0.716567f, -0.681718f, 0.147621f}, {-0.525731f, -0.850651f, 0.000000f}, +{-0.500000f, -0.809017f, 0.309017f}, {-0.238856f, -0.864188f, 0.442863f}, +{-0.262866f, -0.951056f, 0.162460f}, {-0.864188f, -0.442863f, 0.238856f}, +{-0.809017f, -0.309017f, 0.500000f}, {-0.688191f, -0.587785f, 0.425325f}, +{-0.681718f, -0.147621f, 0.716567f}, {-0.442863f, -0.238856f, 0.864188f}, +{-0.587785f, -0.425325f, 0.688191f}, {-0.309017f, -0.500000f, 0.809017f}, +{-0.147621f, -0.716567f, 0.681718f}, {-0.425325f, -0.688191f, 0.587785f}, +{-0.162460f, -0.262866f, 0.951056f}, {0.442863f, -0.238856f, 0.864188f}, +{0.162460f, -0.262866f, 0.951056f}, {0.309017f, -0.500000f, 0.809017f}, +{0.147621f, -0.716567f, 0.681718f}, {0.000000f, -0.525731f, 0.850651f}, +{0.425325f, -0.688191f, 0.587785f}, {0.587785f, -0.425325f, 0.688191f}, +{0.688191f, -0.587785f, 0.425325f}, {-0.955423f, 0.295242f, 0.000000f}, +{-0.951056f, 0.162460f, 0.262866f}, {-1.000000f, 0.000000f, 0.000000f}, +{-0.850651f, 0.000000f, 0.525731f}, {-0.955423f, -0.295242f, 0.000000f}, +{-0.951056f, -0.162460f, 0.262866f}, {-0.864188f, 0.442863f, -0.238856f}, +{-0.951056f, 0.162460f, -0.262866f}, {-0.809017f, 0.309017f, -0.500000f}, +{-0.864188f, -0.442863f, -0.238856f}, {-0.951056f, -0.162460f, -0.262866f}, +{-0.809017f, -0.309017f, -0.500000f}, {-0.681718f, 0.147621f, -0.716567f}, +{-0.681718f, -0.147621f, -0.716567f}, {-0.850651f, 0.000000f, -0.525731f}, +{-0.688191f, 0.587785f, -0.425325f}, {-0.587785f, 0.425325f, -0.688191f}, +{-0.425325f, 0.688191f, -0.587785f}, {-0.425325f, -0.688191f, -0.587785f}, +{-0.587785f, -0.425325f, -0.688191f}, {-0.688191f, -0.587785f, -0.425325f} +}; + +//============================================================== + +int Q_rand( int *seed ) { + *seed = (69069 * *seed + 1); + return *seed; +} + +float Q_random( int *seed ) { + return ( Q_rand( seed ) & 0xffff ) / (float)0x10000; +} + +float Q_crandom( int *seed ) { + return 2.0 * ( Q_random( seed ) - 0.5 ); +} + +#ifdef __LCC__ + +int VectorCompare( const vec3_t v1, const vec3_t v2 ) { + if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) { + return 0; + } + return 1; +} + +vec_t VectorLength( const vec3_t v ) { + return (vec_t)sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); +} + +vec_t VectorLengthSquared( const vec3_t v ) { + return (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); +} + +vec_t Distance( const vec3_t p1, const vec3_t p2 ) { + vec3_t v; + + VectorSubtract (p2, p1, v); + return VectorLength( v ); +} + +vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ) { + vec3_t v; + + VectorSubtract (p2, p1, v); + return v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; +} + +// fast vector normalize routine that does not check to make sure +// that length != 0, nor does it return length, uses rsqrt approximation +void VectorNormalizeFast( vec3_t v ) +{ + float ilength; + + ilength = Q_rsqrt( DotProduct( v, v ) ); + + v[0] *= ilength; + v[1] *= ilength; + v[2] *= ilength; +} + +void VectorInverse( vec3_t v ){ + v[0] = -v[0]; + v[1] = -v[1]; + v[2] = -v[2]; +} + +void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) { + cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; + cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; + cross[2] = v1[0]*v2[1] - v1[1]*v2[0]; +} +#endif + +//======================================================= + +signed char ClampChar( int i ) { + if ( i < -128 ) { + return -128; + } + if ( i > 127 ) { + return 127; + } + return i; +} + +signed short ClampShort( int i ) { + if ( i < -32768 ) { + return -32768; + } + if ( i > 0x7fff ) { + return 0x7fff; + } + return i; +} + + +// this isn't a real cheap function to call! +int DirToByte( vec3_t dir ) { + int i, best; + float d, bestd; + + if ( !dir ) { + return 0; + } + + bestd = 0; + best = 0; + for (i=0 ; i bestd) + { + bestd = d; + best = i; + } + } + + return best; +} + +void ByteToDir( int b, vec3_t dir ) { + if ( b < 0 || b >= NUMVERTEXNORMALS ) { + VectorCopy( vec3_origin, dir ); + return; + } + VectorCopy (bytedirs[b], dir); +} + + +unsigned ColorBytes3 (float r, float g, float b) { + unsigned i; + + ( (byte *)&i )[0] = r * 255; + ( (byte *)&i )[1] = g * 255; + ( (byte *)&i )[2] = b * 255; + + return i; +} + +unsigned ColorBytes4 (float r, float g, float b, float a) { + unsigned i; + + ( (byte *)&i )[0] = r * 255; + ( (byte *)&i )[1] = g * 255; + ( (byte *)&i )[2] = b * 255; + ( (byte *)&i )[3] = a * 255; + + return i; +} + +float NormalizeColor( const vec3_t in, vec3_t out ) { + float max; + + max = in[0]; + if ( in[1] > max ) { + max = in[1]; + } + if ( in[2] > max ) { + max = in[2]; + } + + if ( !max ) { + VectorClear( out ); + } else { + out[0] = in[0] / max; + out[1] = in[1] / max; + out[2] = in[2] / max; + } + return max; +} + + +/* +===================== +PlaneFromPoints + +Returns false if the triangle is degenrate. +The normal will point out of the clock for clockwise ordered points +===================== +*/ +qboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c ) { + vec3_t d1, d2; + + VectorSubtract( b, a, d1 ); + VectorSubtract( c, a, d2 ); + CrossProduct( d2, d1, plane ); + if ( VectorNormalize( plane ) == 0 ) { + return qfalse; + } + + plane[3] = DotProduct( a, plane ); + return qtrue; +} + +/* +=============== +RotatePointAroundVector + +This is not implemented very well... +=============== +*/ +void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, + float degrees ) { + float m[3][3]; + float im[3][3]; + float zrot[3][3]; + float tmpmat[3][3]; + float rot[3][3]; + int i; + vec3_t vr, vup, vf; + float rad; + + vf[0] = dir[0]; + vf[1] = dir[1]; + vf[2] = dir[2]; + + PerpendicularVector( vr, dir ); + CrossProduct( vr, vf, vup ); + + m[0][0] = vr[0]; + m[1][0] = vr[1]; + m[2][0] = vr[2]; + + m[0][1] = vup[0]; + m[1][1] = vup[1]; + m[2][1] = vup[2]; + + m[0][2] = vf[0]; + m[1][2] = vf[1]; + m[2][2] = vf[2]; + + memcpy( im, m, sizeof( im ) ); + + im[0][1] = m[1][0]; + im[0][2] = m[2][0]; + im[1][0] = m[0][1]; + im[1][2] = m[2][1]; + im[2][0] = m[0][2]; + im[2][1] = m[1][2]; + + memset( zrot, 0, sizeof( zrot ) ); + zrot[0][0] = zrot[1][1] = zrot[2][2] = 1.0F; + + rad = DEG2RAD( degrees ); + zrot[0][0] = cos( rad ); + zrot[0][1] = sin( rad ); + zrot[1][0] = -sin( rad ); + zrot[1][1] = cos( rad ); + + MatrixMultiply( m, zrot, tmpmat ); + MatrixMultiply( tmpmat, im, rot ); + + for ( i = 0; i < 3; i++ ) { + dst[i] = rot[i][0] * point[0] + rot[i][1] * point[1] + rot[i][2] * point[2]; + } +} + +/* +=============== +RotateAroundDirection +=============== +*/ +void RotateAroundDirection( vec3_t axis[3], float yaw ) { + + // create an arbitrary axis[1] + PerpendicularVector( axis[1], axis[0] ); + + // rotate it around axis[0] by yaw + if ( yaw ) { + vec3_t temp; + + VectorCopy( axis[1], temp ); + RotatePointAroundVector( axis[1], axis[0], temp, yaw ); + } + + // cross to get axis[2] + CrossProduct( axis[0], axis[1], axis[2] ); +} + + + +void vectoangles( const vec3_t value1, vec3_t angles ) { + float forward; + float yaw, pitch; + + if ( value1[1] == 0 && value1[0] == 0 ) { + yaw = 0; + if ( value1[2] > 0 ) { + pitch = 90; + } + else { + pitch = 270; + } + } + else { + if ( value1[0] ) { + yaw = ( atan2 ( value1[1], value1[0] ) * 180 / M_PI ); + } + else if ( value1[1] > 0 ) { + yaw = 90; + } + else { + yaw = 270; + } + if ( yaw < 0 ) { + yaw += 360; + } + + forward = sqrt ( value1[0]*value1[0] + value1[1]*value1[1] ); + pitch = ( atan2(value1[2], forward) * 180 / M_PI ); + if ( pitch < 0 ) { + pitch += 360; + } + } + + angles[PITCH] = -pitch; + angles[YAW] = yaw; + angles[ROLL] = 0; +} + + +/* +================= +AnglesToAxis +================= +*/ +void AnglesToAxis( const vec3_t angles, vec3_t axis[3] ) { + vec3_t right; + + // angle vectors returns "right" instead of "y axis" + AngleVectors( angles, axis[0], right, axis[2] ); + VectorSubtract( vec3_origin, right, axis[1] ); +} + +void AxisClear( vec3_t axis[3] ) { + axis[0][0] = 1; + axis[0][1] = 0; + axis[0][2] = 0; + axis[1][0] = 0; + axis[1][1] = 1; + axis[1][2] = 0; + axis[2][0] = 0; + axis[2][1] = 0; + axis[2][2] = 1; +} + +void AxisCopy( vec3_t in[3], vec3_t out[3] ) { + VectorCopy( in[0], out[0] ); + VectorCopy( in[1], out[1] ); + VectorCopy( in[2], out[2] ); +} + +void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal ) +{ + float d; + vec3_t n; + float inv_denom; + + inv_denom = DotProduct( normal, normal ); +#ifndef Q3_VM + assert( Q_fabs(inv_denom) != 0.0f ); // bk010122 - zero vectors get here +#endif + inv_denom = 1.0f / inv_denom; + + d = DotProduct( normal, p ) * inv_denom; + + n[0] = normal[0] * inv_denom; + n[1] = normal[1] * inv_denom; + n[2] = normal[2] * inv_denom; + + dst[0] = p[0] - d * n[0]; + dst[1] = p[1] - d * n[1]; + dst[2] = p[2] - d * n[2]; +} + +/* +================ +MakeNormalVectors + +Given a normalized forward vector, create two +other perpendicular vectors +================ +*/ +void MakeNormalVectors( const vec3_t forward, vec3_t right, vec3_t up) { + float d; + + // this rotate and negate guarantees a vector + // not colinear with the original + right[1] = -forward[0]; + right[2] = forward[1]; + right[0] = forward[2]; + + d = DotProduct (right, forward); + VectorMA (right, -d, forward, right); + VectorNormalize (right); + CrossProduct (right, forward, up); +} + + +void VectorRotate( vec3_t in, vec3_t matrix[3], vec3_t out ) +{ + out[0] = DotProduct( in, matrix[0] ); + out[1] = DotProduct( in, matrix[1] ); + out[2] = DotProduct( in, matrix[2] ); +} + +//============================================================================ + +#if !idppc +/* +** float q_rsqrt( float number ) +*/ +float Q_rsqrt( float number ) +{ + union { + float f; + int i; + } t; + float x2, y; + const float threehalfs = 1.5F; + + x2 = number * 0.5F; + t.f = number; + t.i = 0x5f3759df - ( t.i >> 1 ); // what the fuck? + y = t.f; + y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration +// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed + + //assert( !isnan(y) ); // bk010122 - FPE? + return y; +} + +float Q_fabs( float f ) { + int tmp = * ( int * ) &f; + tmp &= 0x7FFFFFFF; + return * ( float * ) &tmp; +} +#endif + +//============================================================ + +/* +=============== +LerpAngle + +=============== +*/ +float LerpAngle (float from, float to, float frac) { + float a; + + if ( to - from > 180 ) { + to -= 360; + } + if ( to - from < -180 ) { + to += 360; + } + a = from + frac * (to - from); + + return a; +} + + +/* +================= +AngleSubtract + +Always returns a value from -180 to 180 +================= +*/ +float AngleSubtract( float a1, float a2 ) { + float a; + + a = a1 - a2; + while ( a > 180 ) { + a -= 360; + } + while ( a < -180 ) { + a += 360; + } + return a; +} + + +void AnglesSubtract( vec3_t v1, vec3_t v2, vec3_t v3 ) { + v3[0] = AngleSubtract( v1[0], v2[0] ); + v3[1] = AngleSubtract( v1[1], v2[1] ); + v3[2] = AngleSubtract( v1[2], v2[2] ); +} + + +float AngleMod(float a) { + a = (360.0/65536) * ((int)(a*(65536/360.0)) & 65535); + return a; +} + + +/* +================= +AngleNormalize360 + +returns angle normalized to the range [0 <= angle < 360] +================= +*/ +float AngleNormalize360 ( float angle ) { + return (360.0 / 65536) * ((int)(angle * (65536 / 360.0)) & 65535); +} + + +/* +================= +AngleNormalize180 + +returns angle normalized to the range [-180 < angle <= 180] +================= +*/ +float AngleNormalize180 ( float angle ) { + angle = AngleNormalize360( angle ); + if ( angle > 180.0 ) { + angle -= 360.0; + } + return angle; +} + + +/* +================= +AngleDelta + +returns the normalized delta from angle1 to angle2 +================= +*/ +float AngleDelta ( float angle1, float angle2 ) { + return AngleNormalize180( angle1 - angle2 ); +} + + +//============================================================ + + +/* +================= +SetPlaneSignbits +================= +*/ +void SetPlaneSignbits (cplane_t *out) { + int bits, j; + + // for fast box on planeside test + bits = 0; + for (j=0 ; j<3 ; j++) { + if (out->normal[j] < 0) { + bits |= 1<signbits = bits; +} + + +/* +================== +BoxOnPlaneSide + +Returns 1, 2, or 1 + 2 + +// this is the slow, general version +int BoxOnPlaneSide2 (vec3_t emins, vec3_t emaxs, struct cplane_s *p) +{ + int i; + float dist1, dist2; + int sides; + vec3_t corners[2]; + + for (i=0 ; i<3 ; i++) + { + if (p->normal[i] < 0) + { + corners[0][i] = emins[i]; + corners[1][i] = emaxs[i]; + } + else + { + corners[1][i] = emins[i]; + corners[0][i] = emaxs[i]; + } + } + dist1 = DotProduct (p->normal, corners[0]) - p->dist; + dist2 = DotProduct (p->normal, corners[1]) - p->dist; + sides = 0; + if (dist1 >= 0) + sides = 1; + if (dist2 < 0) + sides |= 2; + + return sides; +} + +================== +*/ + +// if not GNU x86 and configured to use asm +#if !( (defined __GNUC__) && (defined __i386__) && (!defined C_ONLY)) + +#if defined __LCC__ || defined C_ONLY || !id386 || defined __VECTORC + +int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p) +{ + float dist1, dist2; + int sides; + +// fast axial cases + if (p->type < 3) + { + if (p->dist <= emins[p->type]) + return 1; + if (p->dist >= emaxs[p->type]) + return 2; + return 3; + } + +// general case + switch (p->signbits) + { + case 0: + dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; + dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; + break; + case 1: + dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; + dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; + break; + case 2: + dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; + dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; + break; + case 3: + dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; + dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; + break; + case 4: + dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; + dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; + break; + case 5: + dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; + dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; + break; + case 6: + dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; + dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; + break; + case 7: + dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; + dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; + break; + default: + dist1 = dist2 = 0; // shut up compiler + break; + } + + sides = 0; + if (dist1 >= p->dist) + sides = 1; + if (dist2 < p->dist) + sides |= 2; + + return sides; +} +#else +#pragma warning( disable: 4035 ) + +__declspec( naked ) int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p) +{ + static int bops_initialized; + static int Ljmptab[8]; + + __asm { + + push ebx + + cmp bops_initialized, 1 + je initialized + mov bops_initialized, 1 + + mov Ljmptab[0*4], offset Lcase0 + mov Ljmptab[1*4], offset Lcase1 + mov Ljmptab[2*4], offset Lcase2 + mov Ljmptab[3*4], offset Lcase3 + mov Ljmptab[4*4], offset Lcase4 + mov Ljmptab[5*4], offset Lcase5 + mov Ljmptab[6*4], offset Lcase6 + mov Ljmptab[7*4], offset Lcase7 + +initialized: + + mov edx,dword ptr[4+12+esp] + mov ecx,dword ptr[4+4+esp] + xor eax,eax + mov ebx,dword ptr[4+8+esp] + mov al,byte ptr[17+edx] + cmp al,8 + jge Lerror + fld dword ptr[0+edx] + fld st(0) + jmp dword ptr[Ljmptab+eax*4] +Lcase0: + fmul dword ptr[ebx] + fld dword ptr[0+4+edx] + fxch st(2) + fmul dword ptr[ecx] + fxch st(2) + fld st(0) + fmul dword ptr[4+ebx] + fld dword ptr[0+8+edx] + fxch st(2) + fmul dword ptr[4+ecx] + fxch st(2) + fld st(0) + fmul dword ptr[8+ebx] + fxch st(5) + faddp st(3),st(0) + fmul dword ptr[8+ecx] + fxch st(1) + faddp st(3),st(0) + fxch st(3) + faddp st(2),st(0) + jmp LSetSides +Lcase1: + fmul dword ptr[ecx] + fld dword ptr[0+4+edx] + fxch st(2) + fmul dword ptr[ebx] + fxch st(2) + fld st(0) + fmul dword ptr[4+ebx] + fld dword ptr[0+8+edx] + fxch st(2) + fmul dword ptr[4+ecx] + fxch st(2) + fld st(0) + fmul dword ptr[8+ebx] + fxch st(5) + faddp st(3),st(0) + fmul dword ptr[8+ecx] + fxch st(1) + faddp st(3),st(0) + fxch st(3) + faddp st(2),st(0) + jmp LSetSides +Lcase2: + fmul dword ptr[ebx] + fld dword ptr[0+4+edx] + fxch st(2) + fmul dword ptr[ecx] + fxch st(2) + fld st(0) + fmul dword ptr[4+ecx] + fld dword ptr[0+8+edx] + fxch st(2) + fmul dword ptr[4+ebx] + fxch st(2) + fld st(0) + fmul dword ptr[8+ebx] + fxch st(5) + faddp st(3),st(0) + fmul dword ptr[8+ecx] + fxch st(1) + faddp st(3),st(0) + fxch st(3) + faddp st(2),st(0) + jmp LSetSides +Lcase3: + fmul dword ptr[ecx] + fld dword ptr[0+4+edx] + fxch st(2) + fmul dword ptr[ebx] + fxch st(2) + fld st(0) + fmul dword ptr[4+ecx] + fld dword ptr[0+8+edx] + fxch st(2) + fmul dword ptr[4+ebx] + fxch st(2) + fld st(0) + fmul dword ptr[8+ebx] + fxch st(5) + faddp st(3),st(0) + fmul dword ptr[8+ecx] + fxch st(1) + faddp st(3),st(0) + fxch st(3) + faddp st(2),st(0) + jmp LSetSides +Lcase4: + fmul dword ptr[ebx] + fld dword ptr[0+4+edx] + fxch st(2) + fmul dword ptr[ecx] + fxch st(2) + fld st(0) + fmul dword ptr[4+ebx] + fld dword ptr[0+8+edx] + fxch st(2) + fmul dword ptr[4+ecx] + fxch st(2) + fld st(0) + fmul dword ptr[8+ecx] + fxch st(5) + faddp st(3),st(0) + fmul dword ptr[8+ebx] + fxch st(1) + faddp st(3),st(0) + fxch st(3) + faddp st(2),st(0) + jmp LSetSides +Lcase5: + fmul dword ptr[ecx] + fld dword ptr[0+4+edx] + fxch st(2) + fmul dword ptr[ebx] + fxch st(2) + fld st(0) + fmul dword ptr[4+ebx] + fld dword ptr[0+8+edx] + fxch st(2) + fmul dword ptr[4+ecx] + fxch st(2) + fld st(0) + fmul dword ptr[8+ecx] + fxch st(5) + faddp st(3),st(0) + fmul dword ptr[8+ebx] + fxch st(1) + faddp st(3),st(0) + fxch st(3) + faddp st(2),st(0) + jmp LSetSides +Lcase6: + fmul dword ptr[ebx] + fld dword ptr[0+4+edx] + fxch st(2) + fmul dword ptr[ecx] + fxch st(2) + fld st(0) + fmul dword ptr[4+ecx] + fld dword ptr[0+8+edx] + fxch st(2) + fmul dword ptr[4+ebx] + fxch st(2) + fld st(0) + fmul dword ptr[8+ecx] + fxch st(5) + faddp st(3),st(0) + fmul dword ptr[8+ebx] + fxch st(1) + faddp st(3),st(0) + fxch st(3) + faddp st(2),st(0) + jmp LSetSides +Lcase7: + fmul dword ptr[ecx] + fld dword ptr[0+4+edx] + fxch st(2) + fmul dword ptr[ebx] + fxch st(2) + fld st(0) + fmul dword ptr[4+ecx] + fld dword ptr[0+8+edx] + fxch st(2) + fmul dword ptr[4+ebx] + fxch st(2) + fld st(0) + fmul dword ptr[8+ecx] + fxch st(5) + faddp st(3),st(0) + fmul dword ptr[8+ebx] + fxch st(1) + faddp st(3),st(0) + fxch st(3) + faddp st(2),st(0) +LSetSides: + faddp st(2),st(0) + fcomp dword ptr[12+edx] + xor ecx,ecx + fnstsw ax + fcomp dword ptr[12+edx] + and ah,1 + xor ah,1 + add cl,ah + fnstsw ax + and ah,1 + add ah,ah + add cl,ah + pop ebx + mov eax,ecx + ret +Lerror: + int 3 + } +} +#pragma warning( default: 4035 ) + +#endif +#endif + +/* +================= +RadiusFromBounds +================= +*/ +float RadiusFromBounds( const vec3_t mins, const vec3_t maxs ) { + int i; + vec3_t corner; + float a, b; + + for (i=0 ; i<3 ; i++) { + a = fabs( mins[i] ); + b = fabs( maxs[i] ); + corner[i] = a > b ? a : b; + } + + return VectorLength (corner); +} + + +void ClearBounds( vec3_t mins, vec3_t maxs ) { + mins[0] = mins[1] = mins[2] = 99999; + maxs[0] = maxs[1] = maxs[2] = -99999; +} + +void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs ) { + if ( v[0] < mins[0] ) { + mins[0] = v[0]; + } + if ( v[0] > maxs[0]) { + maxs[0] = v[0]; + } + + if ( v[1] < mins[1] ) { + mins[1] = v[1]; + } + if ( v[1] > maxs[1]) { + maxs[1] = v[1]; + } + + if ( v[2] < mins[2] ) { + mins[2] = v[2]; + } + if ( v[2] > maxs[2]) { + maxs[2] = v[2]; + } +} + + +vec_t VectorNormalize( vec3_t v ) { + // NOTE: TTimo - Apple G4 altivec source uses double? + float length, ilength; + + length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; + length = sqrt (length); + + if ( length ) { + ilength = 1/length; + v[0] *= ilength; + v[1] *= ilength; + v[2] *= ilength; + } + + return length; +} + +vec_t VectorNormalize2( const vec3_t v, vec3_t out) { + float length, ilength; + + length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; + length = sqrt (length); + + if (length) + { +#ifndef Q3_VM // bk0101022 - FPE related +// assert( ((Q_fabs(v[0])!=0.0f) || (Q_fabs(v[1])!=0.0f) || (Q_fabs(v[2])!=0.0f)) ); +#endif + ilength = 1/length; + out[0] = v[0]*ilength; + out[1] = v[1]*ilength; + out[2] = v[2]*ilength; + } else { +#ifndef Q3_VM // bk0101022 - FPE related +// assert( ((Q_fabs(v[0])==0.0f) && (Q_fabs(v[1])==0.0f) && (Q_fabs(v[2])==0.0f)) ); +#endif + VectorClear( out ); + } + + return length; + +} + +void _VectorMA( const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc) { + vecc[0] = veca[0] + scale*vecb[0]; + vecc[1] = veca[1] + scale*vecb[1]; + vecc[2] = veca[2] + scale*vecb[2]; +} + + +vec_t _DotProduct( const vec3_t v1, const vec3_t v2 ) { + return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]; +} + +void _VectorSubtract( const vec3_t veca, const vec3_t vecb, vec3_t out ) { + out[0] = veca[0]-vecb[0]; + out[1] = veca[1]-vecb[1]; + out[2] = veca[2]-vecb[2]; +} + +void _VectorAdd( const vec3_t veca, const vec3_t vecb, vec3_t out ) { + out[0] = veca[0]+vecb[0]; + out[1] = veca[1]+vecb[1]; + out[2] = veca[2]+vecb[2]; +} + +void _VectorCopy( const vec3_t in, vec3_t out ) { + out[0] = in[0]; + out[1] = in[1]; + out[2] = in[2]; +} + +void _VectorScale( const vec3_t in, vec_t scale, vec3_t out ) { + out[0] = in[0]*scale; + out[1] = in[1]*scale; + out[2] = in[2]*scale; +} + +void Vector4Scale( const vec4_t in, vec_t scale, vec4_t out ) { + out[0] = in[0]*scale; + out[1] = in[1]*scale; + out[2] = in[2]*scale; + out[3] = in[3]*scale; +} + + +int Q_log2( int val ) { + int answer; + + answer = 0; + while ( ( val>>=1 ) != 0 ) { + answer++; + } + return answer; +} + + + +/* +================= +PlaneTypeForNormal +================= +*/ +/* +int PlaneTypeForNormal (vec3_t normal) { + if ( normal[0] == 1.0 ) + return PLANE_X; + if ( normal[1] == 1.0 ) + return PLANE_Y; + if ( normal[2] == 1.0 ) + return PLANE_Z; + + return PLANE_NON_AXIAL; +} +*/ + + +/* +================ +MatrixMultiply +================ +*/ +void MatrixMultiply(float in1[3][3], float in2[3][3], float out[3][3]) { + out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] + + in1[0][2] * in2[2][0]; + out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] + + in1[0][2] * in2[2][1]; + out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] + + in1[0][2] * in2[2][2]; + out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] + + in1[1][2] * in2[2][0]; + out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] + + in1[1][2] * in2[2][1]; + out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] + + in1[1][2] * in2[2][2]; + out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] + + in1[2][2] * in2[2][0]; + out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] + + in1[2][2] * in2[2][1]; + out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + + in1[2][2] * in2[2][2]; +} + + +void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) { + float angle; + static float sr, sp, sy, cr, cp, cy; + // static to help MS compiler fp bugs + + angle = angles[YAW] * (M_PI*2 / 360); + sy = sin(angle); + cy = cos(angle); + angle = angles[PITCH] * (M_PI*2 / 360); + sp = sin(angle); + cp = cos(angle); + angle = angles[ROLL] * (M_PI*2 / 360); + sr = sin(angle); + cr = cos(angle); + + if (forward) + { + forward[0] = cp*cy; + forward[1] = cp*sy; + forward[2] = -sp; + } + if (right) + { + right[0] = (-1*sr*sp*cy+-1*cr*-sy); + right[1] = (-1*sr*sp*sy+-1*cr*cy); + right[2] = -1*sr*cp; + } + if (up) + { + up[0] = (cr*sp*cy+-sr*-sy); + up[1] = (cr*sp*sy+-sr*cy); + up[2] = cr*cp; + } +} + +/* +** assumes "src" is normalized +*/ +void PerpendicularVector( vec3_t dst, const vec3_t src ) +{ + int pos; + int i; + float minelem = 1.0F; + vec3_t tempvec; + + /* + ** find the smallest magnitude axially aligned vector + */ + for ( pos = 0, i = 0; i < 3; i++ ) + { + if ( fabs( src[i] ) < minelem ) + { + pos = i; + minelem = fabs( src[i] ); + } + } + tempvec[0] = tempvec[1] = tempvec[2] = 0.0F; + tempvec[pos] = 1.0F; + + /* + ** project the point onto the plane defined by src + */ + ProjectPointOnPlane( dst, tempvec, src ); + + /* + ** normalize the result + */ + VectorNormalize( dst ); +} + + diff --git a/code/qcommon/q_shared.c b/code/qcommon/q_shared.c new file mode 100644 index 0000000..bd8daa5 --- /dev/null +++ b/code/qcommon/q_shared.c @@ -0,0 +1,1252 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code 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. + +Quake III Arena source code 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 Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// q_shared.c -- stateless support routines that are included in each code dll +#include "q_shared.h" + +float Com_Clamp( float min, float max, float value ) { + if ( value < min ) { + return min; + } + if ( value > max ) { + return max; + } + return value; +} + + +/* +============ +COM_SkipPath +============ +*/ +char *COM_SkipPath (char *pathname) +{ + char *last; + + last = pathname; + while (*pathname) + { + if (*pathname=='/') + last = pathname+1; + pathname++; + } + return last; +} + +/* +============ +COM_StripExtension +============ +*/ +void COM_StripExtension( const char *in, char *out ) { + while ( *in && *in != '.' ) { + *out++ = *in++; + } + *out = 0; +} + + +/* +================== +COM_DefaultExtension +================== +*/ +void COM_DefaultExtension (char *path, int maxSize, const char *extension ) { + char oldPath[MAX_QPATH]; + char *src; + +// +// if path doesn't have a .EXT, append extension +// (extension should include the .) +// + src = path + strlen(path) - 1; + + while (*src != '/' && src != path) { + if ( *src == '.' ) { + return; // it has an extension + } + src--; + } + + Q_strncpyz( oldPath, path, sizeof( oldPath ) ); + Com_sprintf( path, maxSize, "%s%s", oldPath, extension ); +} + +/* +============================================================================ + + BYTE ORDER FUNCTIONS + +============================================================================ +*/ +/* +// can't just use function pointers, or dll linkage can +// mess up when qcommon is included in multiple places +static short (*_BigShort) (short l); +static short (*_LittleShort) (short l); +static int (*_BigLong) (int l); +static int (*_LittleLong) (int l); +static qint64 (*_BigLong64) (qint64 l); +static qint64 (*_LittleLong64) (qint64 l); +static float (*_BigFloat) (const float *l); +static float (*_LittleFloat) (const float *l); + +short BigShort(short l){return _BigShort(l);} +short LittleShort(short l) {return _LittleShort(l);} +int BigLong (int l) {return _BigLong(l);} +int LittleLong (int l) {return _LittleLong(l);} +qint64 BigLong64 (qint64 l) {return _BigLong64(l);} +qint64 LittleLong64 (qint64 l) {return _LittleLong64(l);} +float BigFloat (const float *l) {return _BigFloat(l);} +float LittleFloat (const float *l) {return _LittleFloat(l);} +*/ + +short ShortSwap (short l) +{ + byte b1,b2; + + b1 = l&255; + b2 = (l>>8)&255; + + return (b1<<8) + b2; +} + +short ShortNoSwap (short l) +{ + return l; +} + +int LongSwap (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 LongNoSwap (int l) +{ + return l; +} + +qint64 Long64Swap (qint64 ll) +{ + qint64 result; + + result.b0 = ll.b7; + result.b1 = ll.b6; + result.b2 = ll.b5; + result.b3 = ll.b4; + result.b4 = ll.b3; + result.b5 = ll.b2; + result.b6 = ll.b1; + result.b7 = ll.b0; + + return result; +} + +qint64 Long64NoSwap (qint64 ll) +{ + return ll; +} + +typedef union { + float f; + unsigned int i; +} _FloatByteUnion; + +float FloatSwap (const float *f) { + _FloatByteUnion out; + + out.f = *f; + out.i = LongSwap(out.i); + + return out.f; +} + +float FloatNoSwap (const float *f) +{ + return *f; +} + +/* +================ +Swap_Init +================ +*/ +/* +void Swap_Init (void) +{ + byte swaptest[2] = {1,0}; + +// set the byte swapping variables in a portable manner + if ( *(short *)swaptest == 1) + { + _BigShort = ShortSwap; + _LittleShort = ShortNoSwap; + _BigLong = LongSwap; + _LittleLong = LongNoSwap; + _BigLong64 = Long64Swap; + _LittleLong64 = Long64NoSwap; + _BigFloat = FloatSwap; + _LittleFloat = FloatNoSwap; + } + else + { + _BigShort = ShortNoSwap; + _LittleShort = ShortSwap; + _BigLong = LongNoSwap; + _LittleLong = LongSwap; + _BigLong64 = Long64NoSwap; + _LittleLong64 = Long64Swap; + _BigFloat = FloatNoSwap; + _LittleFloat = FloatSwap; + } + +} +*/ + +/* +============================================================================ + +PARSING + +============================================================================ +*/ + +static char com_token[MAX_TOKEN_CHARS]; +static char com_parsename[MAX_TOKEN_CHARS]; +static int com_lines; + +void COM_BeginParseSession( const char *name ) +{ + com_lines = 0; + Com_sprintf(com_parsename, sizeof(com_parsename), "%s", name); +} + +int COM_GetCurrentParseLine( void ) +{ + return com_lines; +} + +char *COM_Parse( char **data_p ) +{ + return COM_ParseExt( data_p, qtrue ); +} + +void COM_ParseError( char *format, ... ) +{ + va_list argptr; + static char string[4096]; + + va_start (argptr, format); + vsprintf (string, format, argptr); + va_end (argptr); + + Com_Printf("ERROR: %s, line %d: %s\n", com_parsename, com_lines, string); +} + +void COM_ParseWarning( char *format, ... ) +{ + va_list argptr; + static char string[4096]; + + va_start (argptr, format); + vsprintf (string, format, argptr); + va_end (argptr); + + Com_Printf("WARNING: %s, line %d: %s\n", com_parsename, com_lines, string); +} + +/* +============== +COM_Parse + +Parse a token out of a string +Will never return NULL, just empty strings + +If "allowLineBreaks" is qtrue then an empty +string will be returned if the next token is +a newline. +============== +*/ +static char *SkipWhitespace( char *data, qboolean *hasNewLines ) { + int c; + + while( (c = *data) <= ' ') { + if( !c ) { + return NULL; + } + if( c == '\n' ) { + com_lines++; + *hasNewLines = qtrue; + } + data++; + } + + return data; +} + +int COM_Compress( char *data_p ) { + char *in, *out; + int c; + qboolean newline = qfalse, whitespace = qfalse; + + in = out = data_p; + if (in) { + while ((c = *in) != 0) { + // skip double slash comments + if ( c == '/' && in[1] == '/' ) { + while (*in && *in != '\n') { + in++; + } + // skip /* */ comments + } else if ( c == '/' && in[1] == '*' ) { + while ( *in && ( *in != '*' || in[1] != '/' ) ) + in++; + if ( *in ) + in += 2; + // record when we hit a newline + } else if ( c == '\n' || c == '\r' ) { + newline = qtrue; + in++; + // record when we hit whitespace + } else if ( c == ' ' || c == '\t') { + whitespace = qtrue; + in++; + // an actual token + } else { + // if we have a pending newline, emit it (and it counts as whitespace) + if (newline) { + *out++ = '\n'; + newline = qfalse; + whitespace = qfalse; + } if (whitespace) { + *out++ = ' '; + whitespace = qfalse; + } + + // copy quoted strings unmolested + if (c == '"') { + *out++ = c; + in++; + while (1) { + c = *in; + if (c && c != '"') { + *out++ = c; + in++; + } else { + break; + } + } + if (c == '"') { + *out++ = c; + in++; + } + } else { + *out = c; + out++; + in++; + } + } + } + } + *out = 0; + return out - data_p; +} + +char *COM_ParseExt( char **data_p, qboolean allowLineBreaks ) +{ + int c = 0, len; + qboolean hasNewLines = qfalse; + char *data; + + data = *data_p; + len = 0; + com_token[0] = 0; + + // make sure incoming data is valid + if ( !data ) + { + *data_p = NULL; + return com_token; + } + + while ( 1 ) + { + // skip whitespace + data = SkipWhitespace( data, &hasNewLines ); + if ( !data ) + { + *data_p = NULL; + return com_token; + } + if ( hasNewLines && !allowLineBreaks ) + { + *data_p = data; + return com_token; + } + + c = *data; + + // skip double slash comments + if ( c == '/' && data[1] == '/' ) + { + data += 2; + while (*data && *data != '\n') { + data++; + } + } + // skip /* */ comments + else if ( c=='/' && data[1] == '*' ) + { + data += 2; + while ( *data && ( *data != '*' || data[1] != '/' ) ) + { + data++; + } + if ( *data ) + { + data += 2; + } + } + else + { + break; + } + } + + // handle quoted strings + if (c == '\"') + { + data++; + while (1) + { + c = *data++; + if (c=='\"' || !c) + { + com_token[len] = 0; + *data_p = ( char * ) data; + return com_token; + } + if (len < MAX_TOKEN_CHARS - 1) + { + com_token[len] = c; + len++; + } + } + } + + // parse a regular word + do + { + if (len < MAX_TOKEN_CHARS - 1) + { + com_token[len] = c; + len++; + } + data++; + c = *data; + if ( c == '\n' ) + com_lines++; + } while (c>32); + + com_token[len] = 0; + + *data_p = ( char * ) data; + return com_token; +} + + +#if 0 +// no longer used +/* +=============== +COM_ParseInfos +=============== +*/ +int COM_ParseInfos( char *buf, int max, char infos[][MAX_INFO_STRING] ) { + char *token; + int count; + char key[MAX_TOKEN_CHARS]; + + count = 0; + + while ( 1 ) { + token = COM_Parse( &buf ); + if ( !token[0] ) { + break; + } + if ( strcmp( token, "{" ) ) { + Com_Printf( "Missing { in info file\n" ); + break; + } + + if ( count == max ) { + Com_Printf( "Max infos exceeded\n" ); + break; + } + + infos[count][0] = 0; + while ( 1 ) { + token = COM_ParseExt( &buf, qtrue ); + if ( !token[0] ) { + Com_Printf( "Unexpected end of info file\n" ); + break; + } + if ( !strcmp( token, "}" ) ) { + break; + } + Q_strncpyz( key, token, sizeof( key ) ); + + token = COM_ParseExt( &buf, qfalse ); + if ( !token[0] ) { + strcpy( token, "" ); + } + Info_SetValueForKey( infos[count], key, token ); + } + count++; + } + + return count; +} +#endif + + +/* +================== +COM_MatchToken +================== +*/ +void COM_MatchToken( char **buf_p, char *match ) { + char *token; + + token = COM_Parse( buf_p ); + if ( strcmp( token, match ) ) { + Com_Error( ERR_DROP, "MatchToken: %s != %s", token, match ); + } +} + + +/* +================= +SkipBracedSection + +The next token should be an open brace. +Skips until a matching close brace is found. +Internal brace depths are properly skipped. +================= +*/ +void SkipBracedSection (char **program) { + char *token; + int depth; + + depth = 0; + do { + token = COM_ParseExt( program, qtrue ); + if( token[1] == 0 ) { + if( token[0] == '{' ) { + depth++; + } + else if( token[0] == '}' ) { + depth--; + } + } + } while( depth && *program ); +} + +/* +================= +SkipRestOfLine +================= +*/ +void SkipRestOfLine ( char **data ) { + char *p; + int c; + + p = *data; + while ( (c = *p++) != 0 ) { + if ( c == '\n' ) { + com_lines++; + break; + } + } + + *data = p; +} + + +void Parse1DMatrix (char **buf_p, int x, float *m) { + char *token; + int i; + + COM_MatchToken( buf_p, "(" ); + + for (i = 0 ; i < x ; i++) { + token = COM_Parse(buf_p); + m[i] = atof(token); + } + + COM_MatchToken( buf_p, ")" ); +} + +void Parse2DMatrix (char **buf_p, int y, int x, float *m) { + int i; + + COM_MatchToken( buf_p, "(" ); + + for (i = 0 ; i < y ; i++) { + Parse1DMatrix (buf_p, x, m + i * x); + } + + COM_MatchToken( buf_p, ")" ); +} + +void Parse3DMatrix (char **buf_p, int z, int y, int x, float *m) { + int i; + + COM_MatchToken( buf_p, "(" ); + + for (i = 0 ; i < z ; i++) { + Parse2DMatrix (buf_p, y, x, m + i * x*y); + } + + COM_MatchToken( buf_p, ")" ); +} + + +/* +============================================================================ + + LIBRARY REPLACEMENT FUNCTIONS + +============================================================================ +*/ + +int Q_isprint( int c ) +{ + if ( c >= 0x20 && c <= 0x7E ) + return ( 1 ); + return ( 0 ); +} + +int Q_islower( int c ) +{ + if (c >= 'a' && c <= 'z') + return ( 1 ); + return ( 0 ); +} + +int Q_isupper( int c ) +{ + if (c >= 'A' && c <= 'Z') + return ( 1 ); + return ( 0 ); +} + +int Q_isalpha( int c ) +{ + if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) + return ( 1 ); + return ( 0 ); +} + +char* Q_strrchr( const char* string, int c ) +{ + char cc = c; + char *s; + char *sp=(char *)0; + + s = (char*)string; + + while (*s) + { + if (*s == cc) + sp = s; + s++; + } + if (cc == 0) + sp = s; + + return sp; +} + +/* +============= +Q_strncpyz + +Safe strncpy that ensures a trailing zero +============= +*/ +void Q_strncpyz( char *dest, const char *src, int destsize ) { + // bk001129 - also NULL dest + if ( !dest ) { + Com_Error( ERR_FATAL, "Q_strncpyz: NULL dest" ); + } + if ( !src ) { + Com_Error( ERR_FATAL, "Q_strncpyz: NULL src" ); + } + if ( destsize < 1 ) { + Com_Error(ERR_FATAL,"Q_strncpyz: destsize < 1" ); + } + + strncpy( dest, src, destsize-1 ); + dest[destsize-1] = 0; +} + +int Q_stricmpn (const char *s1, const char *s2, int n) { + int c1, c2; + + // bk001129 - moved in 1.17 fix not in id codebase + if ( s1 == NULL ) { + if ( s2 == NULL ) + return 0; + else + return -1; + } + else if ( s2==NULL ) + return 1; + + + + do { + c1 = *s1++; + c2 = *s2++; + + if (!n--) { + return 0; // strings are equal until end point + } + + if (c1 != c2) { + if (c1 >= 'a' && c1 <= 'z') { + c1 -= ('a' - 'A'); + } + if (c2 >= 'a' && c2 <= 'z') { + c2 -= ('a' - 'A'); + } + if (c1 != c2) { + return c1 < c2 ? -1 : 1; + } + } + } while (c1); + + return 0; // strings are equal +} + +int Q_strncmp (const char *s1, const char *s2, int n) { + int c1, c2; + + do { + c1 = *s1++; + c2 = *s2++; + + if (!n--) { + return 0; // strings are equal until end point + } + + if (c1 != c2) { + return c1 < c2 ? -1 : 1; + } + } while (c1); + + return 0; // strings are equal +} + +int Q_stricmp (const char *s1, const char *s2) { + return (s1 && s2) ? Q_stricmpn (s1, s2, 99999) : -1; +} + + +char *Q_strlwr( char *s1 ) { + char *s; + + s = s1; + while ( *s ) { + *s = tolower(*s); + s++; + } + return s1; +} + +char *Q_strupr( char *s1 ) { + char *s; + + s = s1; + while ( *s ) { + *s = toupper(*s); + s++; + } + return s1; +} + + +// never goes past bounds or leaves without a terminating 0 +void Q_strcat( char *dest, int size, const char *src ) { + int l1; + + l1 = strlen( dest ); + if ( l1 >= size ) { + Com_Error( ERR_FATAL, "Q_strcat: already overflowed" ); + } + Q_strncpyz( dest + l1, src, size - l1 ); +} + + +int Q_PrintStrlen( const char *string ) { + int len; + const char *p; + + if( !string ) { + return 0; + } + + len = 0; + p = string; + while( *p ) { + if( Q_IsColorString( p ) ) { + p += 2; + continue; + } + p++; + len++; + } + + return len; +} + + +char *Q_CleanStr( char *string ) { + char* d; + char* s; + int c; + + s = string; + d = string; + while ((c = *s) != 0 ) { + if ( Q_IsColorString( s ) ) { + s++; + } + else if ( c >= 0x20 && c <= 0x7E ) { + *d++ = c; + } + s++; + } + *d = '\0'; + + return string; +} + + +void QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) { + int len; + va_list argptr; + char bigbuffer[32000]; // big, but small enough to fit in PPC stack + + va_start (argptr,fmt); + len = vsprintf (bigbuffer,fmt,argptr); + va_end (argptr); + if ( len >= sizeof( bigbuffer ) ) { + Com_Error( ERR_FATAL, "Com_sprintf: overflowed bigbuffer" ); + } + if (len >= size) { + Com_Printf ("Com_sprintf: overflow of %i in %i\n", len, size); +#ifdef _DEBUG + __asm { + int 3; + } +#endif + } + Q_strncpyz (dest, bigbuffer, size ); +} + + +/* +============ +va + +does a varargs printf into a temp buffer, so I don't need to have +varargs versions of all text functions. +FIXME: make this buffer size safe someday +============ +*/ +char * QDECL va( char *format, ... ) { + va_list argptr; + static char string[2][32000]; // in case va is called by nested functions + static int index = 0; + char *buf; + + buf = string[index & 1]; + index++; + + va_start (argptr, format); + vsprintf (buf, format,argptr); + va_end (argptr); + + return buf; +} + + +/* +===================================================================== + + INFO STRINGS + +===================================================================== +*/ + +/* +=============== +Info_ValueForKey + +Searches the string for the given +key and returns the associated value, or an empty string. +FIXME: overflow check? +=============== +*/ +char *Info_ValueForKey( const char *s, const char *key ) { + char pkey[BIG_INFO_KEY]; + static char value[2][BIG_INFO_VALUE]; // use two buffers so compares + // work without stomping on each other + static int valueindex = 0; + char *o; + + if ( !s || !key ) { + return ""; + } + + if ( strlen( s ) >= BIG_INFO_STRING ) { + Com_Error( ERR_DROP, "Info_ValueForKey: oversize infostring" ); + } + + valueindex ^= 1; + if (*s == '\\') + s++; + while (1) + { + o = pkey; + while (*s != '\\') + { + if (!*s) + return ""; + *o++ = *s++; + } + *o = 0; + s++; + + o = value[valueindex]; + + while (*s != '\\' && *s) + { + *o++ = *s++; + } + *o = 0; + + if (!Q_stricmp (key, pkey) ) + return value[valueindex]; + + if (!*s) + break; + s++; + } + + return ""; +} + + +/* +=================== +Info_NextPair + +Used to itterate through all the key/value pairs in an info string +=================== +*/ +void Info_NextPair( const char **head, char *key, char *value ) { + char *o; + const char *s; + + s = *head; + + if ( *s == '\\' ) { + s++; + } + key[0] = 0; + value[0] = 0; + + o = key; + while ( *s != '\\' ) { + if ( !*s ) { + *o = 0; + *head = s; + return; + } + *o++ = *s++; + } + *o = 0; + s++; + + o = value; + while ( *s != '\\' && *s ) { + *o++ = *s++; + } + *o = 0; + + *head = s; +} + + +/* +=================== +Info_RemoveKey +=================== +*/ +void Info_RemoveKey( char *s, const char *key ) { + char *start; + char pkey[MAX_INFO_KEY]; + char value[MAX_INFO_VALUE]; + char *o; + + if ( strlen( s ) >= MAX_INFO_STRING ) { + Com_Error( ERR_DROP, "Info_RemoveKey: oversize infostring" ); + } + + if (strchr (key, '\\')) { + return; + } + + while (1) + { + start = s; + if (*s == '\\') + s++; + o = pkey; + while (*s != '\\') + { + if (!*s) + return; + *o++ = *s++; + } + *o = 0; + s++; + + o = value; + while (*s != '\\' && *s) + { + if (!*s) + return; + *o++ = *s++; + } + *o = 0; + + if (!strcmp (key, pkey) ) + { + strcpy (start, s); // remove this part + return; + } + + if (!*s) + return; + } + +} + +/* +=================== +Info_RemoveKey_Big +=================== +*/ +void Info_RemoveKey_Big( char *s, const char *key ) { + char *start; + char pkey[BIG_INFO_KEY]; + char value[BIG_INFO_VALUE]; + char *o; + + if ( strlen( s ) >= BIG_INFO_STRING ) { + Com_Error( ERR_DROP, "Info_RemoveKey_Big: oversize infostring" ); + } + + if (strchr (key, '\\')) { + return; + } + + while (1) + { + start = s; + if (*s == '\\') + s++; + o = pkey; + while (*s != '\\') + { + if (!*s) + return; + *o++ = *s++; + } + *o = 0; + s++; + + o = value; + while (*s != '\\' && *s) + { + if (!*s) + return; + *o++ = *s++; + } + *o = 0; + + if (!strcmp (key, pkey) ) + { + strcpy (start, s); // remove this part + return; + } + + if (!*s) + return; + } + +} + + + + +/* +================== +Info_Validate + +Some characters are illegal in info strings because they +can mess up the server's parsing +================== +*/ +qboolean Info_Validate( const char *s ) { + if ( strchr( s, '\"' ) ) { + return qfalse; + } + if ( strchr( s, ';' ) ) { + return qfalse; + } + return qtrue; +} + +/* +================== +Info_SetValueForKey + +Changes or adds a key/value pair +================== +*/ +void Info_SetValueForKey( char *s, const char *key, const char *value ) { + char newi[MAX_INFO_STRING]; + + if ( strlen( s ) >= MAX_INFO_STRING ) { + Com_Error( ERR_DROP, "Info_SetValueForKey: oversize infostring" ); + } + + if (strchr (key, '\\') || strchr (value, '\\')) + { + Com_Printf ("Can't use keys or values with a \\\n"); + return; + } + + if (strchr (key, ';') || strchr (value, ';')) + { + Com_Printf ("Can't use keys or values with a semicolon\n"); + return; + } + + if (strchr (key, '\"') || strchr (value, '\"')) + { + Com_Printf ("Can't use keys or values with a \"\n"); + return; + } + + Info_RemoveKey (s, key); + if (!value || !strlen(value)) + return; + + Com_sprintf (newi, sizeof(newi), "\\%s\\%s", key, value); + + if (strlen(newi) + strlen(s) >= MAX_INFO_STRING) + { + Com_Printf ("Info string length exceeded\n"); + return; + } + + strcat (newi, s); + strcpy (s, newi); +} + +/* +================== +Info_SetValueForKey_Big + +Changes or adds a key/value pair +================== +*/ +void Info_SetValueForKey_Big( char *s, const char *key, const char *value ) { + char newi[BIG_INFO_STRING]; + + if ( strlen( s ) >= BIG_INFO_STRING ) { + Com_Error( ERR_DROP, "Info_SetValueForKey: oversize infostring" ); + } + + if (strchr (key, '\\') || strchr (value, '\\')) + { + Com_Printf ("Can't use keys or values with a \\\n"); + return; + } + + if (strchr (key, ';') || strchr (value, ';')) + { + Com_Printf ("Can't use keys or values with a semicolon\n"); + return; + } + + if (strchr (key, '\"') || strchr (value, '\"')) + { + Com_Printf ("Can't use keys or values with a \"\n"); + return; + } + + Info_RemoveKey_Big (s, key); + if (!value || !strlen(value)) + return; + + Com_sprintf (newi, sizeof(newi), "\\%s\\%s", key, value); + + if (strlen(newi) + strlen(s) >= BIG_INFO_STRING) + { + Com_Printf ("BIG Info string length exceeded\n"); + return; + } + + strcat (s, newi); +} + + + + +//==================================================================== + + diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h new file mode 100644 index 0000000..212e04c --- /dev/null +++ b/code/qcommon/q_shared.h @@ -0,0 +1,1456 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code 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. + +Quake III Arena source code 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 Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +#ifndef __Q_SHARED_H +#define __Q_SHARED_H + +// q_shared.h -- included first by ALL program modules. +// A user mod should never modify this file + +#define Q3_VERSION "ioQ3 1.33" +// 1.32 released 7-10-2002 + +#define MAX_TEAMNAME 32 + +#ifdef _MSC_VER + +#pragma warning(disable : 4018) // signed/unsigned mismatch +#pragma warning(disable : 4032) +#pragma warning(disable : 4051) +#pragma warning(disable : 4057) // slightly different base types +#pragma warning(disable : 4100) // unreferenced formal parameter +#pragma warning(disable : 4115) +#pragma warning(disable : 4125) // decimal digit terminates octal escape sequence +#pragma warning(disable : 4127) // conditional expression is constant +#pragma warning(disable : 4136) +#pragma warning(disable : 4152) // nonstandard extension, function/data pointer conversion in expression +//#pragma warning(disable : 4201) +//#pragma warning(disable : 4214) +#pragma warning(disable : 4244) +#pragma warning(disable : 4142) // benign redefinition +//#pragma warning(disable : 4305) // truncation from const double to float +//#pragma warning(disable : 4310) // cast truncates constant value +//#pragma warning(disable: 4505) // unreferenced local function has been removed +#pragma warning(disable : 4514) +#pragma warning(disable : 4702) // unreachable code +#pragma warning(disable : 4711) // selected for automatic inline expansion +#pragma warning(disable : 4220) // varargs matches remaining parameters +#endif + +/********************************************************************** + VM Considerations + + The VM can not use the standard system headers because we aren't really + using the compiler they were meant for. We use bg_lib.h which contains + prototypes for the functions we define for our own use in bg_lib.c. + + When writing mods, please add needed headers HERE, do not start including + stuff like in the various .c files that make up each of the VMs + since you will be including system headers files can will have issues. + + Remember, if you use a C library function that is not defined in bg_lib.c, + you will have to add your own version for support in the VM. + + **********************************************************************/ + +#ifdef Q3_VM + +#include "bg_lib.h" + +#else + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif + +#ifdef _MSC_VER + +//#pragma intrinsic( memset, memcpy ) + +#endif + + +// this is the define for determining if we have an asm version of a C function +#if (defined _M_IX86 || defined __i386__) && !defined __sun__ && !defined __LCC__ +#define id386 1 +#else +#define id386 0 +#endif + +#if (defined(powerc) || defined(powerpc) || defined(ppc) || defined(__ppc) || defined(__ppc__)) && !defined(C_ONLY) +#define idppc 1 +#if defined(__VEC__) +#define idppc_altivec 1 +#else +#define idppc_altivec 0 +#endif +#else +#define idppc 0 +#define idppc_altivec 0 +#endif + +// for windows fastcall option + +#define QDECL + +short ShortSwap (short l); +int LongSwap (int l); +float FloatSwap (const float *f); + +//======================= WIN32 DEFINES ================================= + +#ifdef WIN32 + +#define MAC_STATIC + +#undef QDECL +#define QDECL __cdecl + +// buildstring will be incorporated into the version string +#ifdef _MSC_VER +#ifdef NDEBUG +#ifdef _M_IX86 +#define CPUSTRING "win-x86" +#elif defined _M_ALPHA +#define CPUSTRING "win-AXP" +#endif +#else +#ifdef _M_IX86 +#define CPUSTRING "win-x86-debug" +#elif defined _M_ALPHA +#define CPUSTRING "win-AXP-debug" +#endif +#endif +#elif defined __MINGW32__ +#ifdef NDEBUG +#ifdef __i386__ +#define CPUSTRING "mingw-x86" +#endif +#else +#ifdef __i386__ +#define CPUSTRING "mingw-x86-debug" +#endif +#endif +#endif + +#define ID_INLINE __inline + +static ID_INLINE short BigShort( short l) { return ShortSwap(l); } +#define LittleShort +static ID_INLINE int BigLong(int l) { return LongSwap(l); } +#define LittleLong +static ID_INLINE float BigFloat(const float l) { return FloatSwap(&l); } +#define LittleFloat + +#define PATH_SEP '\\' + +#endif + +//======================= MAC OS X DEFINES ===================== + +#if defined(MACOS_X) + +#define MAC_STATIC +#define __cdecl +#define __declspec(x) +#define stricmp strcasecmp +#define ID_INLINE inline + +#ifdef __ppc__ +#define CPUSTRING "MacOSX-ppc" +#elif defined __i386__ +#define CPUSTRING "MacOSX-i386" +#else +#define CPUSTRING "MacOSX-other" +#endif + +#define PATH_SEP '/' + +#define __rlwimi(out, in, shift, maskBegin, maskEnd) asm("rlwimi %0,%1,%2,%3,%4" : "=r" (out) : "r" (in), "i" (shift), "i" (maskBegin), "i" (maskEnd)) +#define __dcbt(addr, offset) asm("dcbt %0,%1" : : "b" (addr), "r" (offset)) + +static inline unsigned int __lwbrx(register void *addr, register int offset) { + register unsigned int word; + + asm("lwbrx %0,%2,%1" : "=r" (word) : "r" (addr), "b" (offset)); + return word; +} + +static inline unsigned short __lhbrx(register void *addr, register int offset) { + register unsigned short halfword; + + asm("lhbrx %0,%2,%1" : "=r" (halfword) : "r" (addr), "b" (offset)); + return halfword; +} + +static inline float __fctiw(register float f) { + register float fi; + + asm("fctiw %0,%1" : "=f" (fi) : "f" (f)); + + return fi; +} + +#define BigShort +static inline short LittleShort(short l) { return ShortSwap(l); } +#define BigLong +static inline int LittleLong (int l) { return LongSwap(l); } +#define BigFloat +static inline float LittleFloat (const float l) { return FloatSwap(&l); } + +#endif + +//======================= MAC DEFINES ================================= + +#ifdef __MACOS__ + +#include +#define MAC_STATIC +#define ID_INLINE inline + +#define CPUSTRING "MacOS-PPC" + +#define PATH_SEP ':' + +void Sys_PumpEvents( void ); + +#define BigShort +static inline short LittleShort(short l) { return ShortSwap(l); } +#define BigLong +static inline int LittleLong (int l) { return LongSwap(l); } +#define BigFloat +static inline float LittleFloat (const float l) { return FloatSwap(&l); } + +#endif + +//======================= LINUX DEFINES ================================= + +// the mac compiler can't handle >32k of locals, so we +// just waste space and make big arrays static... +#ifdef __linux__ + +// bk001205 - from Makefile +#define stricmp strcasecmp + +#define MAC_STATIC // bk: FIXME +#define ID_INLINE inline + +#ifdef __i386__ +#define CPUSTRING "linux-i386" +#elif defined __axp__ +#define CPUSTRING "linux-alpha" +#elif defined __x86_64__ +#define CPUSTRING "linux-x86_64" +#elif defined __powerpc64__ +#define CPUSTRING "linux-ppc64" +#elif defined __powerpc__ +#define CPUSTRING "linux-ppc" +#elif defined __s390__ +#define CPUSTRING "linux-s390" +#elif defined __s390x__ +#define CPUSTRING "linux-s390x" +#elif defined __ia64__ +#define CPUSTRING "linux-ia64" +#else +#define CPUSTRING "linux-other" +#endif + +#define PATH_SEP '/' + +// bk001205 - try +#ifdef Q3_STATIC +#define GAME_HARD_LINKED +#define CGAME_HARD_LINKED +#define UI_HARD_LINKED +#define BOTLIB_HARD_LINKED +#endif + +#if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN +inline static short BigShort( short l) { return ShortSwap(l); } +#define LittleShort +inline static int BigLong(int l) { return LongSwap(l); } +#define LittleLong +inline static float BigFloat(const float l) { return FloatSwap(&l); } +#define LittleFloat +#else +#define BigShort +inline static short LittleShort(short l) { return ShortSwap(l); } +#define BigLong +inline static int LittleLong (int l) { return LongSwap(l); } +#define BigFloat +inline static float LittleFloat (const float l) { return FloatSwap(&l); } +#endif + +#endif + +//======================= FreeBSD DEFINES ===================== +#ifdef __FreeBSD__ // rb010123 + +#define stricmp strcasecmp + +#define MAC_STATIC +#define ID_INLINE inline + +#ifdef __i386__ +#define CPUSTRING "freebsd-i386" +#elif defined __axp__ +#define CPUSTRING "freebsd-alpha" +#else +#define CPUSTRING "freebsd-other" +#endif + +#define PATH_SEP '/' + +// bk010116 - omitted Q3STATIC (see Linux above), broken target + +#if !idppc +static short BigShort( short l) { return ShortSwap(l); } +#define LittleShort +static int BigLong(int l) { return LongSwap(l); } +#define LittleLong +static float BigFloat(const float l) { return FloatSwap(&l); } +#define LittleFloat +#else +#define BigShort +static short LittleShort(short l) { return ShortSwap(l); } +#define BigLong +static int LittleLong (int l) { return LongSwap(l); } +#define BigFloat +static float LittleFloat (const float l) { return FloatSwap(&l); } +#endif + +#endif + +//============================================================= + +typedef unsigned char byte; + +typedef enum {qfalse, qtrue} qboolean; + +typedef int qhandle_t; +typedef int sfxHandle_t; +typedef int fileHandle_t; +typedef int clipHandle_t; + + +#ifndef NULL +#define NULL ((void *)0) +#endif + +#define MAX_QINT 0x7fffffff +#define MIN_QINT (-MAX_QINT-1) + + +// angle indexes +#define PITCH 0 // up / down +#define YAW 1 // left / right +#define ROLL 2 // fall over + +// the game guarantees that no string from the network will ever +// exceed MAX_STRING_CHARS +#define MAX_STRING_CHARS 1024 // max length of a string passed to Cmd_TokenizeString +#define MAX_STRING_TOKENS 1024 // max tokens resulting from Cmd_TokenizeString +#define MAX_TOKEN_CHARS 1024 // max length of an individual token + +#define MAX_INFO_STRING 1024 +#define MAX_INFO_KEY 1024 +#define MAX_INFO_VALUE 1024 + +#define BIG_INFO_STRING 8192 // used for system info key only +#define BIG_INFO_KEY 8192 +#define BIG_INFO_VALUE 8192 + + +#define MAX_QPATH 64 // max length of a quake game pathname +#ifdef PATH_MAX +#define MAX_OSPATH PATH_MAX +#else +#define MAX_OSPATH 256 // max length of a filesystem pathname +#endif + +#define MAX_NAME_LENGTH 32 // max length of a client name + +#define MAX_SAY_TEXT 150 + +// paramters for command buffer stuffing +typedef enum { + EXEC_NOW, // don't return until completed, a VM should NEVER use this, + // because some commands might cause the VM to be unloaded... + EXEC_INSERT, // insert at current position, but don't run yet + EXEC_APPEND // add to end of the command buffer (normal case) +} cbufExec_t; + + +// +// these aren't needed by any of the VMs. put in another header? +// +#define MAX_MAP_AREA_BYTES 32 // bit vector of area visibility + + +// print levels from renderer (FIXME: set up for game / cgame?) +typedef enum { + PRINT_ALL, + PRINT_DEVELOPER, // only print when "developer 1" + PRINT_WARNING, + PRINT_ERROR +} printParm_t; + + +#ifdef ERR_FATAL +#undef ERR_FATAL // this is be defined in malloc.h +#endif + +// parameters to the main Error routine +typedef enum { + ERR_FATAL, // exit the entire game with a popup window + ERR_DROP, // print to console and disconnect from game + ERR_SERVERDISCONNECT, // don't kill server + ERR_DISCONNECT, // client disconnected from the server + ERR_NEED_CD // pop up the need-cd dialog +} errorParm_t; + + +// font rendering values used by ui and cgame + +#define PROP_GAP_WIDTH 3 +#define PROP_SPACE_WIDTH 8 +#define PROP_HEIGHT 27 +#define PROP_SMALL_SIZE_SCALE 0.75 + +#define BLINK_DIVISOR 200 +#define PULSE_DIVISOR 75 + +#define UI_LEFT 0x00000000 // default +#define UI_CENTER 0x00000001 +#define UI_RIGHT 0x00000002 +#define UI_FORMATMASK 0x00000007 +#define UI_SMALLFONT 0x00000010 +#define UI_BIGFONT 0x00000020 // default +#define UI_GIANTFONT 0x00000040 +#define UI_DROPSHADOW 0x00000800 +#define UI_BLINK 0x00001000 +#define UI_INVERSE 0x00002000 +#define UI_PULSE 0x00004000 + +#if defined(_DEBUG) && !defined(BSPC) + #define HUNK_DEBUG +#endif + +typedef enum { + h_high, + h_low, + h_dontcare +} ha_pref; + +#ifdef HUNK_DEBUG +#define Hunk_Alloc( size, preference ) Hunk_AllocDebug(size, preference, #size, __FILE__, __LINE__) +void *Hunk_AllocDebug( int size, ha_pref preference, char *label, char *file, int line ); +#else +void *Hunk_Alloc( int size, ha_pref preference ); +#endif + +#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(MACOS_X) +// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=371 +// custom Snd_Memset implementation for glibc memset bug workaround +void Snd_Memset (void* dest, const int val, const size_t count); +#else +#define Snd_Memset Com_Memset +#endif + +#if !( defined __VECTORC ) +void Com_Memset (void* dest, const int val, const size_t count); +void Com_Memcpy (void* dest, const void* src, const size_t count); +#else +#define Com_Memset memset +#define Com_Memcpy memcpy +#endif + +#define CIN_system 1 +#define CIN_loop 2 +#define CIN_hold 4 +#define CIN_silent 8 +#define CIN_shader 16 + +/* +============================================================== + +MATHLIB + +============================================================== +*/ + + +typedef float vec_t; +typedef vec_t vec2_t[2]; +typedef vec_t vec3_t[3]; +typedef vec_t vec4_t[4]; +typedef vec_t vec5_t[5]; + +typedef int fixed4_t; +typedef int fixed8_t; +typedef int fixed16_t; + +#ifndef M_PI +#define M_PI 3.14159265358979323846f // matches value in gcc v2 math.h +#endif + +#define NUMVERTEXNORMALS 162 +extern vec3_t bytedirs[NUMVERTEXNORMALS]; + +// all drawing is done to a 640*480 virtual screen size +// and will be automatically scaled to the real resolution +#define SCREEN_WIDTH 640 +#define SCREEN_HEIGHT 480 + +#define TINYCHAR_WIDTH (SMALLCHAR_WIDTH) +#define TINYCHAR_HEIGHT (SMALLCHAR_HEIGHT/2) + +#define SMALLCHAR_WIDTH 8 +#define SMALLCHAR_HEIGHT 16 + +#define BIGCHAR_WIDTH 16 +#define BIGCHAR_HEIGHT 16 + +#define GIANTCHAR_WIDTH 32 +#define GIANTCHAR_HEIGHT 48 + +extern vec4_t colorBlack; +extern vec4_t colorRed; +extern vec4_t colorGreen; +extern vec4_t colorBlue; +extern vec4_t colorYellow; +extern vec4_t colorMagenta; +extern vec4_t colorCyan; +extern vec4_t colorWhite; +extern vec4_t colorLtGrey; +extern vec4_t colorMdGrey; +extern vec4_t colorDkGrey; + +#define Q_COLOR_ESCAPE '^' +#define Q_IsColorString(p) ( p && *(p) == Q_COLOR_ESCAPE && *((p)+1) && *((p)+1) != Q_COLOR_ESCAPE ) + +#define COLOR_BLACK '0' +#define COLOR_RED '1' +#define COLOR_GREEN '2' +#define COLOR_YELLOW '3' +#define COLOR_BLUE '4' +#define COLOR_CYAN '5' +#define COLOR_MAGENTA '6' +#define COLOR_WHITE '7' +#define ColorIndex(c) ( ( (c) - '0' ) & 7 ) + +#define S_COLOR_BLACK "^0" +#define S_COLOR_RED "^1" +#define S_COLOR_GREEN "^2" +#define S_COLOR_YELLOW "^3" +#define S_COLOR_BLUE "^4" +#define S_COLOR_CYAN "^5" +#define S_COLOR_MAGENTA "^6" +#define S_COLOR_WHITE "^7" + +extern vec4_t g_color_table[8]; + +#define MAKERGB( v, r, g, b ) v[0]=r;v[1]=g;v[2]=b +#define MAKERGBA( v, r, g, b, a ) v[0]=r;v[1]=g;v[2]=b;v[3]=a + +#define DEG2RAD( a ) ( ( (a) * M_PI ) / 180.0F ) +#define RAD2DEG( a ) ( ( (a) * 180.0f ) / M_PI ) + +struct cplane_s; + +extern vec3_t vec3_origin; +extern vec3_t axisDefault[3]; + +#define nanmask (255<<23) + +#define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask) + +#if idppc + +static inline float Q_rsqrt( float number ) { + float x = 0.5f * number; + float y; +#ifdef __GNUC__ + asm("frsqrte %0,%1" : "=f" (y) : "f" (number)); +#else + y = __frsqrte( number ); +#endif + return y * (1.5f - (x * y * y)); + } + +#ifdef __GNUC__ +static inline float Q_fabs(float x) { + float abs_x; + + asm("fabs %0,%1" : "=f" (abs_x) : "f" (x)); + return abs_x; +} +#else +#define Q_fabs __fabsf +#endif + +#else +float Q_fabs( float f ); +float Q_rsqrt( float f ); // reciprocal square root +#endif + +#define SQRTFAST( x ) ( (x) * Q_rsqrt( x ) ) + +signed char ClampChar( int i ); +signed short ClampShort( int i ); + +// this isn't a real cheap function to call! +int DirToByte( vec3_t dir ); +void ByteToDir( int b, vec3_t dir ); + +#if 1 + +#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]) +#define VectorSubtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2]) +#define VectorAdd(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2]) +#define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2]) +#define VectorScale(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s)) +#define VectorMA(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s)) + +#else + +#define DotProduct(x,y) _DotProduct(x,y) +#define VectorSubtract(a,b,c) _VectorSubtract(a,b,c) +#define VectorAdd(a,b,c) _VectorAdd(a,b,c) +#define VectorCopy(a,b) _VectorCopy(a,b) +#define VectorScale(v, s, o) _VectorScale(v,s,o) +#define VectorMA(v, s, b, o) _VectorMA(v,s,b,o) + +#endif + +#ifdef __LCC__ +#ifdef VectorCopy +#undef VectorCopy +// this is a little hack to get more efficient copies in our interpreter +typedef struct { + float v[3]; +} vec3struct_t; +#define VectorCopy(a,b) (*(vec3struct_t *)b=*(vec3struct_t *)a) +#define ID_INLINE static +#endif +#endif + +#define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0) +#define VectorNegate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2]) +#define VectorSet(v, x, y, z) ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z)) +#define Vector4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3]) + +#define SnapVector(v) {v[0]=((int)(v[0]));v[1]=((int)(v[1]));v[2]=((int)(v[2]));} +// just in case you do't want to use the macros +vec_t _DotProduct( const vec3_t v1, const vec3_t v2 ); +void _VectorSubtract( const vec3_t veca, const vec3_t vecb, vec3_t out ); +void _VectorAdd( const vec3_t veca, const vec3_t vecb, vec3_t out ); +void _VectorCopy( const vec3_t in, vec3_t out ); +void _VectorScale( const vec3_t in, float scale, vec3_t out ); +void _VectorMA( const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc ); + +unsigned ColorBytes3 (float r, float g, float b); +unsigned ColorBytes4 (float r, float g, float b, float a); + +float NormalizeColor( const vec3_t in, vec3_t out ); + +float RadiusFromBounds( const vec3_t mins, const vec3_t maxs ); +void ClearBounds( vec3_t mins, vec3_t maxs ); +void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs ); + +#ifndef __LCC__ +static ID_INLINE int VectorCompare( const vec3_t v1, const vec3_t v2 ) { + if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) { + return 0; + } + return 1; +} + +static ID_INLINE vec_t VectorLength( const vec3_t v ) { + return (vec_t)sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); +} + +static ID_INLINE vec_t VectorLengthSquared( const vec3_t v ) { + return (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); +} + +static ID_INLINE vec_t Distance( const vec3_t p1, const vec3_t p2 ) { + vec3_t v; + + VectorSubtract (p2, p1, v); + return VectorLength( v ); +} + +static ID_INLINE vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ) { + vec3_t v; + + VectorSubtract (p2, p1, v); + return v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; +} + +// fast vector normalize routine that does not check to make sure +// that length != 0, nor does it return length, uses rsqrt approximation +static ID_INLINE void VectorNormalizeFast( vec3_t v ) +{ + float ilength; + + ilength = Q_rsqrt( DotProduct( v, v ) ); + + v[0] *= ilength; + v[1] *= ilength; + v[2] *= ilength; +} + +static ID_INLINE void VectorInverse( vec3_t v ){ + v[0] = -v[0]; + v[1] = -v[1]; + v[2] = -v[2]; +} + +static ID_INLINE void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) { + cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; + cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; + cross[2] = v1[0]*v2[1] - v1[1]*v2[0]; +} + +#else +int VectorCompare( const vec3_t v1, const vec3_t v2 ); + +vec_t VectorLength( const vec3_t v ); + +vec_t VectorLengthSquared( const vec3_t v ); + +vec_t Distance( const vec3_t p1, const vec3_t p2 ); + +vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ); + +void VectorNormalizeFast( vec3_t v ); + +void VectorInverse( vec3_t v ); + +void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ); + +#endif + +vec_t VectorNormalize (vec3_t v); // returns vector length +vec_t VectorNormalize2( const vec3_t v, vec3_t out ); +void Vector4Scale( const vec4_t in, vec_t scale, vec4_t out ); +void VectorRotate( vec3_t in, vec3_t matrix[3], vec3_t out ); +int Q_log2(int val); + +float Q_acos(float c); + +int Q_rand( int *seed ); +float Q_random( int *seed ); +float Q_crandom( int *seed ); + +#define random() ((rand () & 0x7fff) / ((float)0x7fff)) +#define crandom() (2.0 * (random() - 0.5)) + +void vectoangles( const vec3_t value1, vec3_t angles); +void AnglesToAxis( const vec3_t angles, vec3_t axis[3] ); + +void AxisClear( vec3_t axis[3] ); +void AxisCopy( vec3_t in[3], vec3_t out[3] ); + +void SetPlaneSignbits( struct cplane_s *out ); +int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *plane); + +float AngleMod(float a); +float LerpAngle (float from, float to, float frac); +float AngleSubtract( float a1, float a2 ); +void AnglesSubtract( vec3_t v1, vec3_t v2, vec3_t v3 ); + +float AngleNormalize360 ( float angle ); +float AngleNormalize180 ( float angle ); +float AngleDelta ( float angle1, float angle2 ); + +qboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c ); +void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal ); +void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees ); +void RotateAroundDirection( vec3_t axis[3], float yaw ); +void MakeNormalVectors( const vec3_t forward, vec3_t right, vec3_t up ); +// perpendicular vector could be replaced by this + +//int PlaneTypeForNormal (vec3_t normal); + +void MatrixMultiply(float in1[3][3], float in2[3][3], float out[3][3]); +void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); +void PerpendicularVector( vec3_t dst, const vec3_t src ); + + +//============================================= + +float Com_Clamp( float min, float max, float value ); + +char *COM_SkipPath( char *pathname ); +void COM_StripExtension( const char *in, char *out ); +void COM_DefaultExtension( char *path, int maxSize, const char *extension ); + +void COM_BeginParseSession( const char *name ); +int COM_GetCurrentParseLine( void ); +char *COM_Parse( char **data_p ); +char *COM_ParseExt( char **data_p, qboolean allowLineBreak ); +int COM_Compress( char *data_p ); +void COM_ParseError( char *format, ... ); +void COM_ParseWarning( char *format, ... ); +//int COM_ParseInfos( char *buf, int max, char infos[][MAX_INFO_STRING] ); + +#define MAX_TOKENLENGTH 1024 + +#ifndef TT_STRING +//token types +#define TT_STRING 1 // string +#define TT_LITERAL 2 // literal +#define TT_NUMBER 3 // number +#define TT_NAME 4 // name +#define TT_PUNCTUATION 5 // punctuation +#endif + +typedef struct pc_token_s +{ + int type; + int subtype; + int intvalue; + float floatvalue; + char string[MAX_TOKENLENGTH]; +} pc_token_t; + +// data is an in/out parm, returns a parsed out token + +void COM_MatchToken( char**buf_p, char *match ); + +void SkipBracedSection (char **program); +void SkipRestOfLine ( char **data ); + +void Parse1DMatrix (char **buf_p, int x, float *m); +void Parse2DMatrix (char **buf_p, int y, int x, float *m); +void Parse3DMatrix (char **buf_p, int z, int y, int x, float *m); + +void QDECL Com_sprintf (char *dest, int size, const char *fmt, ...); + + +// mode parm for FS_FOpenFile +typedef enum { + FS_READ, + FS_WRITE, + FS_APPEND, + FS_APPEND_SYNC +} fsMode_t; + +typedef enum { + FS_SEEK_CUR, + FS_SEEK_END, + FS_SEEK_SET +} fsOrigin_t; + +//============================================= + +int Q_isprint( int c ); +int Q_islower( int c ); +int Q_isupper( int c ); +int Q_isalpha( int c ); + +// portable case insensitive compare +int Q_stricmp (const char *s1, const char *s2); +int Q_strncmp (const char *s1, const char *s2, int n); +int Q_stricmpn (const char *s1, const char *s2, int n); +char *Q_strlwr( char *s1 ); +char *Q_strupr( char *s1 ); +char *Q_strrchr( const char* string, int c ); + +// buffer size safe library replacements +void Q_strncpyz( char *dest, const char *src, int destsize ); +void Q_strcat( char *dest, int size, const char *src ); + +// strlen that discounts Quake color sequences +int Q_PrintStrlen( const char *string ); +// removes color sequences from string +char *Q_CleanStr( char *string ); + +//============================================= + +// 64-bit integers for global rankings interface +// implemented as a struct for qvm compatibility +typedef struct +{ + byte b0; + byte b1; + byte b2; + byte b3; + byte b4; + byte b5; + byte b6; + byte b7; +} qint64; + +//============================================= +/* +short BigShort(short l); +short LittleShort(short l); +int BigLong (int l); +int LittleLong (int l); +qint64 BigLong64 (qint64 l); +qint64 LittleLong64 (qint64 l); +float BigFloat (const float *l); +float LittleFloat (const float *l); + +void Swap_Init (void); +*/ +char * QDECL va(char *format, ...); + +//============================================= + +// +// key / value info strings +// +char *Info_ValueForKey( const char *s, const char *key ); +void Info_RemoveKey( char *s, const char *key ); +void Info_RemoveKey_big( char *s, const char *key ); +void Info_SetValueForKey( char *s, const char *key, const char *value ); +void Info_SetValueForKey_Big( char *s, const char *key, const char *value ); +qboolean Info_Validate( const char *s ); +void Info_NextPair( const char **s, char *key, char *value ); + +// this is only here so the functions in q_shared.c and bg_*.c can link +void QDECL Com_Error( int level, const char *error, ... ); +void QDECL Com_Printf( const char *msg, ... ); + + +/* +========================================================== + +CVARS (console variables) + +Many variables can be used for cheating purposes, so when +cheats is zero, force all unspecified variables to their +default values. +========================================================== +*/ + +#define CVAR_ARCHIVE 1 // set to cause it to be saved to vars.rc + // used for system variables, not for player + // specific configurations +#define CVAR_USERINFO 2 // sent to server on connect or change +#define CVAR_SERVERINFO 4 // sent in response to front end requests +#define CVAR_SYSTEMINFO 8 // these cvars will be duplicated on all clients +#define CVAR_INIT 16 // don't allow change from console at all, + // but can be set from the command line +#define CVAR_LATCH 32 // will only change when C code next does + // a Cvar_Get(), so it can't be changed + // without proper initialization. modified + // will be set, even though the value hasn't + // changed yet +#define CVAR_ROM 64 // display only, cannot be set by user at all +#define CVAR_USER_CREATED 128 // created by a set command +#define CVAR_TEMP 256 // can be set even when cheats are disabled, but is not archived +#define CVAR_CHEAT 512 // can not be changed if cheats are disabled +#define CVAR_NORESTART 1024 // do not clear when a cvar_restart is issued + +// nothing outside the Cvar_*() functions should modify these fields! +typedef struct cvar_s { + char *name; + char *string; + char *resetString; // cvar_restart will reset to this value + char *latchedString; // for CVAR_LATCH vars + int flags; + qboolean modified; // set each time the cvar is changed + int modificationCount; // incremented each time the cvar is changed + float value; // atof( string ) + int integer; // atoi( string ) + struct cvar_s *next; + struct cvar_s *hashNext; +} cvar_t; + +#define MAX_CVAR_VALUE_STRING 256 + +typedef int cvarHandle_t; + +// the modules that run in the virtual machine can't access the cvar_t directly, +// so they must ask for structured updates +typedef struct { + cvarHandle_t handle; + int modificationCount; + float value; + int integer; + char string[MAX_CVAR_VALUE_STRING]; +} vmCvar_t; + +/* +============================================================== + +COLLISION DETECTION + +============================================================== +*/ + +#include "surfaceflags.h" // shared with the q3map utility + +// plane types are used to speed some tests +// 0-2 are axial planes +#define PLANE_X 0 +#define PLANE_Y 1 +#define PLANE_Z 2 +#define PLANE_NON_AXIAL 3 + + +/* +================= +PlaneTypeForNormal +================= +*/ + +#define PlaneTypeForNormal(x) (x[0] == 1.0 ? PLANE_X : (x[1] == 1.0 ? PLANE_Y : (x[2] == 1.0 ? PLANE_Z : PLANE_NON_AXIAL) ) ) + +// plane_t structure +// !!! if this is changed, it must be changed in asm code too !!! +typedef struct cplane_s { + vec3_t normal; + float dist; + byte type; // for fast side tests: 0,1,2 = axial, 3 = nonaxial + byte signbits; // signx + (signy<<1) + (signz<<2), used as lookup during collision + byte pad[2]; +} cplane_t; + + +// a trace is returned when a box is swept through the world +typedef struct { + qboolean allsolid; // if true, plane is not valid + qboolean startsolid; // if true, the initial point was in a solid area + float fraction; // time completed, 1.0 = didn't hit anything + vec3_t endpos; // final position + cplane_t plane; // surface normal at impact, transformed to world space + int surfaceFlags; // surface hit + int contents; // contents on other side of surface hit + int entityNum; // entity the contacted sirface is a part of +} trace_t; + +// trace->entityNum can also be 0 to (MAX_GENTITIES-1) +// or ENTITYNUM_NONE, ENTITYNUM_WORLD + + +// markfragments are returned by CM_MarkFragments() +typedef struct { + int firstPoint; + int numPoints; +} markFragment_t; + + + +typedef struct { + vec3_t origin; + vec3_t axis[3]; +} orientation_t; + +//===================================================================== + + +// in order from highest priority to lowest +// if none of the catchers are active, bound key strings will be executed +#define KEYCATCH_CONSOLE 0x0001 +#define KEYCATCH_UI 0x0002 +#define KEYCATCH_MESSAGE 0x0004 +#define KEYCATCH_CGAME 0x0008 + + +// sound channels +// channel 0 never willingly overrides +// other channels will allways override a playing sound on that channel +typedef enum { + CHAN_AUTO, + CHAN_LOCAL, // menu sounds, etc + CHAN_WEAPON, + CHAN_VOICE, + CHAN_ITEM, + CHAN_BODY, + CHAN_LOCAL_SOUND, // chat messages, etc + CHAN_ANNOUNCER // announcer voices, etc +} soundChannel_t; + + +/* +======================================================================== + + ELEMENTS COMMUNICATED ACROSS THE NET + +======================================================================== +*/ + +#define ANGLE2SHORT(x) ((int)((x)*65536/360) & 65535) +#define SHORT2ANGLE(x) ((x)*(360.0/65536)) + +#define SNAPFLAG_RATE_DELAYED 1 +#define SNAPFLAG_NOT_ACTIVE 2 // snapshot used during connection and for zombies +#define SNAPFLAG_SERVERCOUNT 4 // toggled every map_restart so transitions can be detected + +// +// per-level limits +// +#define MAX_CLIENTS 64 // absolute limit +#define MAX_LOCATIONS 64 + +#define GENTITYNUM_BITS 10 // don't need to send any more +#define MAX_GENTITIES (1<serverTime of last executed command + int pm_type; + int bobCycle; // for view bobbing and footstep generation + int pm_flags; // ducked, jump_held, etc + int pm_time; + + vec3_t origin; + vec3_t velocity; + int weaponTime; + int gravity; + int speed; + int delta_angles[3]; // add to command angles to get view direction + // changed by spawns, rotating objects, and teleporters + + int groundEntityNum;// ENTITYNUM_NONE = in air + + int legsTimer; // don't change low priority animations until this runs out + int legsAnim; // mask off ANIM_TOGGLEBIT + + int torsoTimer; // don't change low priority animations until this runs out + int torsoAnim; // mask off ANIM_TOGGLEBIT + + int movementDir; // a number 0 to 7 that represents the reletive angle + // of movement to the view angle (axial and diagonals) + // when at rest, the value will remain unchanged + // used to twist the legs during strafing + + vec3_t grapplePoint; // location of grapple to pull towards if PMF_GRAPPLE_PULL + + int eFlags; // copied to entityState_t->eFlags + + int eventSequence; // pmove generated events + int events[MAX_PS_EVENTS]; + int eventParms[MAX_PS_EVENTS]; + + int externalEvent; // events set on player from another source + int externalEventParm; + int externalEventTime; + + int clientNum; // ranges from 0 to MAX_CLIENTS-1 + int weapon; // copied to entityState_t->weapon + int weaponstate; + + vec3_t viewangles; // for fixed views + int viewheight; + + // damage feedback + int damageEvent; // when it changes, latch the other parms + int damageYaw; + int damagePitch; + int damageCount; + + int stats[MAX_STATS]; + int persistant[MAX_PERSISTANT]; // stats that aren't cleared on death + int powerups[MAX_POWERUPS]; // level.time that the powerup runs out + int ammo[MAX_WEAPONS]; + + int generic1; + int loopSound; + int jumppad_ent; // jumppad entity hit this frame + + // not communicated over the net at all + int ping; // server to game info for scoreboard + int pmove_framecount; // FIXME: don't transmit over the network + int jumppad_frame; + int entityEventSequence; +} playerState_t; + + +//==================================================================== + + +// +// usercmd_t->button bits, many of which are generated by the client system, +// so they aren't game/cgame only definitions +// +#define BUTTON_ATTACK 1 +#define BUTTON_TALK 2 // displays talk balloon and disables actions +#define BUTTON_USE_HOLDABLE 4 +#define BUTTON_GESTURE 8 +#define BUTTON_WALKING 16 // walking can't just be infered from MOVE_RUN + // because a key pressed late in the frame will + // only generate a small move value for that frame + // walking will use different animations and + // won't generate footsteps +#define BUTTON_AFFIRMATIVE 32 +#define BUTTON_NEGATIVE 64 + +#define BUTTON_GETFLAG 128 +#define BUTTON_GUARDBASE 256 +#define BUTTON_PATROL 512 +#define BUTTON_FOLLOWME 1024 + +#define BUTTON_ANY 2048 // any key whatsoever + +#define MOVE_RUN 120 // if forwardmove or rightmove are >= MOVE_RUN, + // then BUTTON_WALKING should be set + +// usercmd_t is sent to the server each client frame +typedef struct usercmd_s { + int serverTime; + int angles[3]; + int buttons; + byte weapon; // weapon + signed char forwardmove, rightmove, upmove; +} usercmd_t; + +//=================================================================== + +// if entityState->solid == SOLID_BMODEL, modelindex is an inline model number +#define SOLID_BMODEL 0xffffff + +typedef enum { + TR_STATIONARY, + TR_INTERPOLATE, // non-parametric, but interpolate between snapshots + TR_LINEAR, + TR_LINEAR_STOP, + TR_SINE, // value = base + sin( time / duration ) * delta + TR_GRAVITY +} trType_t; + +typedef struct { + trType_t trType; + int trTime; + int trDuration; // if non 0, trTime + trDuration = stop time + vec3_t trBase; + vec3_t trDelta; // velocity, etc +} trajectory_t; + +// entityState_t is the information conveyed from the server +// in an update message about entities that the client will +// need to render in some way +// Different eTypes may use the information in different ways +// The messages are delta compressed, so it doesn't really matter if +// the structure size is fairly large + +typedef struct entityState_s { + int number; // entity index + int eType; // entityType_t + int eFlags; + + trajectory_t pos; // for calculating position + trajectory_t apos; // for calculating angles + + int time; + int time2; + + vec3_t origin; + vec3_t origin2; + + vec3_t angles; + vec3_t angles2; + + int otherEntityNum; // shotgun sources, etc + int otherEntityNum2; + + int groundEntityNum; // -1 = in air + + int constantLight; // r + (g<<8) + (b<<16) + (intensity<<24) + int loopSound; // constantly loop this sound + + int modelindex; + int modelindex2; + int clientNum; // 0 to (MAX_CLIENTS - 1), for players and corpses + int frame; + + int solid; // for client side prediction, trap_linkentity sets this properly + + int event; // impulse events -- muzzle flashes, footsteps, etc + int eventParm; + + // for players + int powerups; // bit flags + int weapon; // determines weapon and flash model, etc + int legsAnim; // mask off ANIM_TOGGLEBIT + int torsoAnim; // mask off ANIM_TOGGLEBIT + + int generic1; +} entityState_t; + +typedef enum { + CA_UNINITIALIZED, + CA_DISCONNECTED, // not talking to a server + CA_AUTHORIZING, // not used any more, was checking cd key + CA_CONNECTING, // sending request packets to the server + CA_CHALLENGING, // sending challenge packets to the server + CA_CONNECTED, // netchan_t established, getting gamestate + CA_LOADING, // only during cgame initialization, never during main loop + CA_PRIMED, // got gamestate, waiting for first frame + CA_ACTIVE, // game views should be displayed + CA_CINEMATIC // playing a cinematic or a static pic, not connected to a server +} connstate_t; + +// font support + +#define GLYPH_START 0 +#define GLYPH_END 255 +#define GLYPH_CHARSTART 32 +#define GLYPH_CHAREND 127 +#define GLYPHS_PER_FONT GLYPH_END - GLYPH_START + 1 +typedef struct { + int height; // number of scan lines + int top; // top of glyph in buffer + int bottom; // bottom of glyph in buffer + int pitch; // width for copying + int xSkip; // x adjustment + int imageWidth; // width of actual image + int imageHeight; // height of actual image + float s; // x offset in image where glyph starts + float t; // y offset in image where glyph starts + float s2; + float t2; + qhandle_t glyph; // handle to the shader with the glyph + char shaderName[32]; +} glyphInfo_t; + +typedef struct { + glyphInfo_t glyphs [GLYPHS_PER_FONT]; + float glyphScale; + char name[MAX_QPATH]; +} fontInfo_t; + +#define Square(x) ((x)*(x)) + +// real time +//============================================= + + +typedef struct qtime_s { + int tm_sec; /* seconds after the minute - [0,59] */ + int tm_min; /* minutes after the hour - [0,59] */ + int tm_hour; /* hours since midnight - [0,23] */ + int tm_mday; /* day of the month - [1,31] */ + int tm_mon; /* months since January - [0,11] */ + int tm_year; /* years since 1900 */ + int tm_wday; /* days since Sunday - [0,6] */ + int tm_yday; /* days since January 1 - [0,365] */ + int tm_isdst; /* daylight savings time flag */ +} qtime_t; + + +// server browser sources +// TTimo: AS_MPLAYER is no longer used +#define AS_LOCAL 0 +#define AS_MPLAYER 1 +#define AS_GLOBAL 2 +#define AS_FAVORITES 3 + + +// cinematic states +typedef enum { + FMV_IDLE, + FMV_PLAY, // play + FMV_EOF, // all other conditions, i.e. stop/EOF/abort + FMV_ID_BLT, + FMV_ID_IDLE, + FMV_LOOPED, + FMV_ID_WAIT +} e_status; + +typedef enum _flag_status { + FLAG_ATBASE = 0, + FLAG_TAKEN, // CTF + FLAG_TAKEN_RED, // One Flag CTF + FLAG_TAKEN_BLUE, // One Flag CTF + FLAG_DROPPED +} flagStatus_t; + + + +#define MAX_GLOBAL_SERVERS 4096 +#define MAX_OTHER_SERVERS 128 +#define MAX_PINGREQUESTS 32 +#define MAX_SERVERSTATUSREQUESTS 16 + +#define SAY_ALL 0 +#define SAY_TEAM 1 +#define SAY_TELL 2 + +#define CDKEY_LEN 16 +#define CDCHKSUM_LEN 2 + + +#endif // __Q_SHARED_H diff --git a/code/qcommon/surfaceflags.h b/code/qcommon/surfaceflags.h new file mode 100644 index 0000000..92e28d2 --- /dev/null +++ b/code/qcommon/surfaceflags.h @@ -0,0 +1,80 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code 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. + +Quake III Arena source code 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 Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +// This file must be identical in the quake and utils directories + +// contents flags are seperate bits +// a given brush can contribute multiple content bits + +// these definitions also need to be in q_shared.h! + +#define CONTENTS_SOLID 1 // an eye is never valid in a solid +#define CONTENTS_LAVA 8 +#define CONTENTS_SLIME 16 +#define CONTENTS_WATER 32 +#define CONTENTS_FOG 64 + +#define CONTENTS_NOTTEAM1 0x0080 +#define CONTENTS_NOTTEAM2 0x0100 +#define CONTENTS_NOBOTCLIP 0x0200 + +#define CONTENTS_AREAPORTAL 0x8000 + +#define CONTENTS_PLAYERCLIP 0x10000 +#define CONTENTS_MONSTERCLIP 0x20000 +//bot specific contents types +#define CONTENTS_TELEPORTER 0x40000 +#define CONTENTS_JUMPPAD 0x80000 +#define CONTENTS_CLUSTERPORTAL 0x100000 +#define CONTENTS_DONOTENTER 0x200000 +#define CONTENTS_BOTCLIP 0x400000 +#define CONTENTS_MOVER 0x800000 + +#define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity + +#define CONTENTS_BODY 0x2000000 // should never be on a brush, only in game +#define CONTENTS_CORPSE 0x4000000 +#define CONTENTS_DETAIL 0x8000000 // brushes not used for the bsp +#define CONTENTS_STRUCTURAL 0x10000000 // brushes used for the bsp +#define CONTENTS_TRANSLUCENT 0x20000000 // don't consume surface fragments inside +#define CONTENTS_TRIGGER 0x40000000 +#define CONTENTS_NODROP 0x80000000 // don't leave bodies or items (death fog, lava) + +#define SURF_NODAMAGE 0x1 // never give falling damage +#define SURF_SLICK 0x2 // effects game physics +#define SURF_SKY 0x4 // lighting from environment map +#define SURF_LADDER 0x8 +#define SURF_NOIMPACT 0x10 // don't make missile explosions +#define SURF_NOMARKS 0x20 // don't leave missile marks +#define SURF_FLESH 0x40 // make flesh sounds and effects +#define SURF_NODRAW 0x80 // don't generate a drawsurface at all +#define SURF_HINT 0x100 // make a primary bsp splitter +#define SURF_SKIP 0x200 // completely ignore, allowing non-closed brushes +#define SURF_NOLIGHTMAP 0x400 // surface doesn't need a lightmap +#define SURF_POINTLIGHT 0x800 // generate lighting info at vertexes +#define SURF_METALSTEPS 0x1000 // clanking footsteps +#define SURF_NOSTEPS 0x2000 // no footstep sounds +#define SURF_NONSOLID 0x4000 // don't collide against curves with this set +#define SURF_LIGHTFILTER 0x8000 // act as a light filter during q3map -light +#define SURF_ALPHASHADOW 0x10000 // do per-pixel light shadow casting in q3map +#define SURF_NODLIGHT 0x20000 // don't dlight even if solid (solid lava, skies) +#define SURF_DUST 0x40000 // leave a dust trail when walking on this surface diff --git a/code/qcommon/vm_local.h b/code/qcommon/vm_local.h index eb58fff..952639b 100644 --- a/code/qcommon/vm_local.h +++ b/code/qcommon/vm_local.h @@ -19,7 +19,7 @@ along with Foobar; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#include "../game/q_shared.h" +#include "q_shared.h" #include "qcommon.h" typedef enum { diff --git a/code/renderer/tr_local.h b/code/renderer/tr_local.h index e9de83a..060b4b5 100644 --- a/code/renderer/tr_local.h +++ b/code/renderer/tr_local.h @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef TR_LOCAL_H #define TR_LOCAL_H -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../qcommon/qfiles.h" #include "../qcommon/qcommon.h" #include "tr_public.h" diff --git a/code/renderer/tr_public.h b/code/renderer/tr_public.h index fa20531..6dec3a5 100644 --- a/code/renderer/tr_public.h +++ b/code/renderer/tr_public.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef __TR_PUBLIC_H #define __TR_PUBLIC_H -#include "../cgame/tr_types.h" +#include "tr_types.h" #define REF_API_VERSION 8 diff --git a/code/renderer/tr_types.h b/code/renderer/tr_types.h new file mode 100644 index 0000000..d68a174 --- /dev/null +++ b/code/renderer/tr_types.h @@ -0,0 +1,229 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code 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. + +Quake III Arena source code 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 Foobar; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// +#ifndef __TR_TYPES_H +#define __TR_TYPES_H + + +#define MAX_DLIGHTS 32 // can't be increased, because bit flags are used on surfaces +#define MAX_ENTITIES 1023 // can't be increased without changing drawsurf bit packing + +// renderfx flags +#define RF_MINLIGHT 1 // allways have some light (viewmodel, some items) +#define RF_THIRD_PERSON 2 // don't draw through eyes, only mirrors (player bodies, chat sprites) +#define RF_FIRST_PERSON 4 // only draw through eyes (view weapon, damage blood blob) +#define RF_DEPTHHACK 8 // for view weapon Z crunching +#define RF_NOSHADOW 64 // don't add stencil shadows + +#define RF_LIGHTING_ORIGIN 128 // use refEntity->lightingOrigin instead of refEntity->origin + // for lighting. This allows entities to sink into the floor + // with their origin going solid, and allows all parts of a + // player to get the same lighting +#define RF_SHADOW_PLANE 256 // use refEntity->shadowPlane +#define RF_WRAP_FRAMES 512 // mod the model frames by the maxframes to allow continuous + // animation without needing to know the frame count + +// refdef flags +#define RDF_NOWORLDMODEL 1 // used for player configuration screen +#define RDF_HYPERSPACE 4 // teleportation effect + +typedef struct { + vec3_t xyz; + float st[2]; + byte modulate[4]; +} polyVert_t; + +typedef struct poly_s { + qhandle_t hShader; + int numVerts; + polyVert_t *verts; +} poly_t; + +typedef enum { + RT_MODEL, + RT_POLY, + RT_SPRITE, + RT_BEAM, + RT_RAIL_CORE, + RT_RAIL_RINGS, + RT_LIGHTNING, + RT_PORTALSURFACE, // doesn't draw anything, just info for portals + + RT_MAX_REF_ENTITY_TYPE +} refEntityType_t; + +typedef struct { + refEntityType_t reType; + int renderfx; + + qhandle_t hModel; // opaque type outside refresh + + // most recent data + vec3_t lightingOrigin; // so multi-part models can be lit identically (RF_LIGHTING_ORIGIN) + float shadowPlane; // projection shadows go here, stencils go slightly lower + + vec3_t axis[3]; // rotation vectors + qboolean nonNormalizedAxes; // axis are not normalized, i.e. they have scale + float origin[3]; // also used as MODEL_BEAM's "from" + int frame; // also used as MODEL_BEAM's diameter + + // previous data for frame interpolation + float oldorigin[3]; // also used as MODEL_BEAM's "to" + int oldframe; + float backlerp; // 0.0 = current, 1.0 = old + + // texturing + int skinNum; // inline skin index + qhandle_t customSkin; // NULL for default skin + qhandle_t customShader; // use one image for the entire thing + + // misc + byte shaderRGBA[4]; // colors used by rgbgen entity shaders + float shaderTexCoord[2]; // texture coordinates used by tcMod entity modifiers + float shaderTime; // subtracted from refdef time to control effect start times + + // extra sprite information + float radius; + float rotation; +} refEntity_t; + + +#define MAX_RENDER_STRINGS 8 +#define MAX_RENDER_STRING_LENGTH 32 + +typedef struct { + int x, y, width, height; + float fov_x, fov_y; + vec3_t vieworg; + vec3_t viewaxis[3]; // transformation matrix + + // time in milliseconds for shader effects and other time dependent rendering issues + int time; + + int rdflags; // RDF_NOWORLDMODEL, etc + + // 1 bits will prevent the associated area from rendering at all + byte areamask[MAX_MAP_AREA_BYTES]; + + // text messages for deform text shaders + char text[MAX_RENDER_STRINGS][MAX_RENDER_STRING_LENGTH]; +} refdef_t; + + +typedef enum { + STEREO_CENTER, + STEREO_LEFT, + STEREO_RIGHT +} stereoFrame_t; + + +/* +** glconfig_t +** +** Contains variables specific to the OpenGL configuration +** being run right now. These are constant once the OpenGL +** subsystem is initialized. +*/ +typedef enum { + TC_NONE, + TC_S3TC +} textureCompression_t; + +typedef enum { + GLDRV_ICD, // driver is integrated with window system + // WARNING: there are tests that check for + // > GLDRV_ICD for minidriverness, so this + // should always be the lowest value in this + // enum set + GLDRV_STANDALONE, // driver is a non-3Dfx standalone driver + GLDRV_VOODOO // driver is a 3Dfx standalone driver +} glDriverType_t; + +typedef enum { + GLHW_GENERIC, // where everthing works the way it should + GLHW_3DFX_2D3D, // Voodoo Banshee or Voodoo3, relevant since if this is + // the hardware type then there can NOT exist a secondary + // display adapter + GLHW_RIVA128, // where you can't interpolate alpha + GLHW_RAGEPRO, // where you can't modulate alpha on alpha textures + GLHW_PERMEDIA2 // where you don't have src*dst +} glHardwareType_t; + +typedef struct { + char renderer_string[MAX_STRING_CHARS]; + char vendor_string[MAX_STRING_CHARS]; + char version_string[MAX_STRING_CHARS]; + char extensions_string[BIG_INFO_STRING]; + + int maxTextureSize; // queried from GL + int maxActiveTextures; // multitexture ability + + int colorBits, depthBits, stencilBits; + + glDriverType_t driverType; + glHardwareType_t hardwareType; + + qboolean deviceSupportsGamma; + textureCompression_t textureCompression; + qboolean textureEnvAddAvailable; + + int vidWidth, vidHeight; + // aspect is the screen's physical width / height, which may be different + // than scrWidth / scrHeight if the pixels are non-square + // normal screens should be 4/3, but wide aspect monitors may be 16/9 + float windowAspect; + + int displayFrequency; + + // synonymous with "does rendering consume the entire screen?", therefore + // a Voodoo or Voodoo2 will have this set to TRUE, as will a Win32 ICD that + // used CDS. + qboolean isFullscreen; + qboolean stereoEnabled; + qboolean smpActive; // dual processor +} glconfig_t; + +// FIXME: VM should be OS agnostic .. in theory + +/* +#ifdef Q3_VM + +#define _3DFX_DRIVER_NAME "Voodoo" +#define OPENGL_DRIVER_NAME "Default" + +#elif defined(_WIN32) +*/ + +#if defined(Q3_VM) || defined(_WIN32) + +#define _3DFX_DRIVER_NAME "3dfxvgl" +#define OPENGL_DRIVER_NAME "opengl32" + +#else + +#define _3DFX_DRIVER_NAME "libMesaVoodooGL.so" +// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=524 +#define OPENGL_DRIVER_NAME "libGL.so.1" + +#endif // !defined _WIN32 + +#endif // __TR_TYPES_H diff --git a/code/server/server.h b/code/server/server.h index b025c98..e58bddb 100644 --- a/code/server/server.h +++ b/code/server/server.h @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // server.h -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" #include "../game/g_public.h" #include "../game/bg_public.h" diff --git a/code/server/sv_bot.c b/code/server/sv_bot.c index 0442d46..2923c4f 100644 --- a/code/server/sv_bot.c +++ b/code/server/sv_bot.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // sv_bot.c #include "server.h" -#include "../game/botlib.h" +#include "../botlib/botlib.h" typedef struct bot_debugpoly_s { diff --git a/code/server/sv_game.c b/code/server/sv_game.c index 86b1ee1..42e8b83 100644 --- a/code/server/sv_game.c +++ b/code/server/sv_game.c @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "server.h" -#include "../game/botlib.h" +#include "../botlib/botlib.h" botlib_export_t *botlib_export; diff --git a/code/server/sv_net_chan.c b/code/server/sv_net_chan.c index feab271..701ea53 100644 --- a/code/server/sv_net_chan.c +++ b/code/server/sv_net_chan.c @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" #include "server.h" diff --git a/code/ui/keycodes.h b/code/ui/keycodes.h deleted file mode 100644 index 8f58482..0000000 --- a/code/ui/keycodes.h +++ /dev/null @@ -1,163 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code 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. - -Quake III Arena source code 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 Foobar; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// -#ifndef __KEYCODES_H__ -#define __KEYCODES_H__ - -// -// these are the key numbers that should be passed to KeyEvent -// - -// normal keys should be passed as lowercased ascii - -typedef enum { - K_TAB = 9, - K_ENTER = 13, - K_ESCAPE = 27, - K_SPACE = 32, - - K_BACKSPACE = 127, - - K_COMMAND = 128, - K_CAPSLOCK, - K_POWER, - K_PAUSE, - - K_UPARROW, - K_DOWNARROW, - K_LEFTARROW, - K_RIGHTARROW, - - K_ALT, - K_CTRL, - K_SHIFT, - K_INS, - K_DEL, - K_PGDN, - K_PGUP, - K_HOME, - K_END, - - K_F1, - K_F2, - K_F3, - K_F4, - K_F5, - K_F6, - K_F7, - K_F8, - K_F9, - K_F10, - K_F11, - K_F12, - K_F13, - K_F14, - K_F15, - - K_KP_HOME, - K_KP_UPARROW, - K_KP_PGUP, - K_KP_LEFTARROW, - K_KP_5, - K_KP_RIGHTARROW, - K_KP_END, - K_KP_DOWNARROW, - K_KP_PGDN, - K_KP_ENTER, - K_KP_INS, - K_KP_DEL, - K_KP_SLASH, - K_KP_MINUS, - K_KP_PLUS, - K_KP_NUMLOCK, - K_KP_STAR, - K_KP_EQUALS, - - K_MOUSE1, - K_MOUSE2, - K_MOUSE3, - K_MOUSE4, - K_MOUSE5, - - K_MWHEELDOWN, - K_MWHEELUP, - - K_JOY1, - K_JOY2, - K_JOY3, - K_JOY4, - K_JOY5, - K_JOY6, - K_JOY7, - K_JOY8, - K_JOY9, - K_JOY10, - K_JOY11, - K_JOY12, - K_JOY13, - K_JOY14, - K_JOY15, - K_JOY16, - K_JOY17, - K_JOY18, - K_JOY19, - K_JOY20, - K_JOY21, - K_JOY22, - K_JOY23, - K_JOY24, - K_JOY25, - K_JOY26, - K_JOY27, - K_JOY28, - K_JOY29, - K_JOY30, - K_JOY31, - K_JOY32, - - K_AUX1, - K_AUX2, - K_AUX3, - K_AUX4, - K_AUX5, - K_AUX6, - K_AUX7, - K_AUX8, - K_AUX9, - K_AUX10, - K_AUX11, - K_AUX12, - K_AUX13, - K_AUX14, - K_AUX15, - K_AUX16, - - K_LAST_KEY // this had better be <256! -} keyNum_t; - - -// The menu code needs to get both key and char events, but -// to avoid duplicating the paths, the char events are just -// distinguished by or'ing in K_CHAR_FLAG (ugly) -#define K_CHAR_FLAG 1024 - -#endif diff --git a/code/ui/ui_local.h b/code/ui/ui_local.h index 7e640d2..ee6ca23 100644 --- a/code/ui/ui_local.h +++ b/code/ui/ui_local.h @@ -23,10 +23,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef __UI_LOCAL_H__ #define __UI_LOCAL_H__ -#include "../game/q_shared.h" -#include "../cgame/tr_types.h" +#include "../qcommon/q_shared.h" +#include "../renderer/tr_types.h" #include "ui_public.h" -#include "keycodes.h" +#include "../client/keycodes.h" #include "../game/bg_public.h" #include "ui_shared.h" diff --git a/code/ui/ui_shared.h b/code/ui/ui_shared.h index 2010571..0e545c5 100644 --- a/code/ui/ui_shared.h +++ b/code/ui/ui_shared.h @@ -23,9 +23,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define __UI_SHARED_H -#include "../game/q_shared.h" -#include "../cgame/tr_types.h" -#include "keycodes.h" +#include "../qcommon/q_shared.h" +#include "../renderer/tr_types.h" +#include "../client/keycodes.h" #include "../../ui/menudef.h" diff --git a/code/unix/Makefile b/code/unix/Makefile index 4c2846c..71db2bd 100644 --- a/code/unix/Makefile +++ b/code/unix/Makefile @@ -75,7 +75,7 @@ JPDIR=$(MOUNT_DIR)/jpeg-6 SPLNDIR=$(MOUNT_DIR)/splines # extract version info -VERSION=$(shell grep Q3_VERSION ../game/q_shared.h | \ +VERSION=$(shell grep Q3_VERSION ../qcommon/q_shared.h | \ sed -e 's/.*Q3\ \(.*\)"/\1/') ############################################################################# @@ -444,11 +444,13 @@ makedirs: @if [ ! -d $(B)/baseq3/cgame ];then mkdir $(B)/baseq3/cgame;fi @if [ ! -d $(B)/baseq3/game ];then mkdir $(B)/baseq3/game;fi @if [ ! -d $(B)/baseq3/ui ];then mkdir $(B)/baseq3/ui;fi + @if [ ! -d $(B)/baseq3/qcommon ];then mkdir $(B)/baseq3/qcommon;fi @if [ ! -d $(B)/baseq3/vm ];then mkdir $(B)/baseq3/vm;fi @if [ ! -d $(B)/missionpack ];then mkdir $(B)/missionpack;fi @if [ ! -d $(B)/missionpack/cgame ];then mkdir $(B)/missionpack/cgame;fi @if [ ! -d $(B)/missionpack/game ];then mkdir $(B)/missionpack/game;fi @if [ ! -d $(B)/missionpack/ui ];then mkdir $(B)/missionpack/ui;fi + @if [ ! -d $(B)/missionpack/qcommon ];then mkdir $(B)/missionpack/qcommon;fi @if [ ! -d $(B)/missionpack/vm ];then mkdir $(B)/missionpack/vm;fi @if [ ! -d $(B)/q3static ];then mkdir $(B)/q3static;fi @@ -465,7 +467,7 @@ $(Q3LCC): $(Q3ASM): $(MAKE) -C ../tools/asm install -DO_Q3LCC=$(Q3LCC) -o $@ -S -DQ3_VM -I$(CGDIR) -I$(GDIR) -I$(UIDIR) $< +DO_Q3LCC=$(Q3LCC) -o $@ -S -DQ3_VM -I$(CGDIR) -I$(GDIR) -I$(UIDIR) -I$(CMDIR) $< ############################################################################# # CLIENT/SERVER @@ -769,8 +771,8 @@ $(B)/client/md4.o : $(CMDIR)/md4.c; $(DO_CC) $(B)/client/msg.o : $(CMDIR)/msg.c; $(DO_CC) $(B)/client/net_chan.o : $(CMDIR)/net_chan.c; $(DO_CC) $(B)/client/huffman.o : $(CMDIR)/huffman.c; $(DO_CC) -$(B)/client/q_shared.o : $(GDIR)/q_shared.c; $(DO_CC) -$(B)/client/q_math.o : $(GDIR)/q_math.c; $(DO_CC) +$(B)/client/q_shared.o : $(CMDIR)/q_shared.c; $(DO_CC) +$(B)/client/q_math.o : $(CMDIR)/q_math.c; $(DO_CC) $(B)/client/be_aas_bspq3.o : $(BLIBDIR)/be_aas_bspq3.c; $(DO_BOT_CC) $(B)/client/be_aas_cluster.o : $(BLIBDIR)/be_aas_cluster.c; $(DO_BOT_CC) @@ -1018,8 +1020,8 @@ $(B)/ded/md4.o : $(CMDIR)/md4.c; $(DO_DED_CC) $(B)/ded/msg.o : $(CMDIR)/msg.c; $(DO_DED_CC) $(B)/ded/net_chan.o : $(CMDIR)/net_chan.c; $(DO_DED_CC) $(B)/ded/huffman.o : $(CMDIR)/huffman.c; $(DO_DED_CC) -$(B)/ded/q_shared.o : $(GDIR)/q_shared.c; $(DO_DED_CC) -$(B)/ded/q_math.o : $(GDIR)/q_math.c; $(DO_DED_CC) +$(B)/ded/q_shared.o : $(CMDIR)/q_shared.c; $(DO_DED_CC) +$(B)/ded/q_math.o : $(CMDIR)/q_math.c; $(DO_DED_CC) $(B)/ded/be_aas_bspq3.o : $(BLIBDIR)/be_aas_bspq3.c; $(DO_BOT_CC) $(B)/ded/be_aas_cluster.o : $(BLIBDIR)/be_aas_cluster.c; $(DO_BOT_CC) @@ -1099,8 +1101,9 @@ Q3CGOBJ_ = \ $(B)/baseq3/cgame/cg_snapshot.o \ $(B)/baseq3/cgame/cg_view.o \ $(B)/baseq3/cgame/cg_weapons.o \ - $(B)/baseq3/game/q_math.o \ - $(B)/baseq3/game/q_shared.o + \ + $(B)/baseq3/qcommon/q_math.o \ + $(B)/baseq3/qcommon/q_shared.o Q3CGOBJ = $(Q3CGOBJ_) $(B)/baseq3/cgame/cg_syscalls.o Q3CGVMOBJ = $(Q3CGOBJ_:%.o=%.asm) $(B)/baseq3/game/bg_lib.asm @@ -1138,9 +1141,10 @@ MPCGOBJ_ = \ $(B)/missionpack/cgame/cg_snapshot.o \ $(B)/missionpack/cgame/cg_view.o \ $(B)/missionpack/cgame/cg_weapons.o \ - $(B)/missionpack/game/q_math.o \ - $(B)/missionpack/game/q_shared.o \ - $(B)/missionpack/ui/ui_shared.o + $(B)/missionpack/ui/ui_shared.o \ + \ + $(B)/missionpack/qcommon/q_math.o \ + $(B)/missionpack/qcommon/q_shared.o MPCGOBJ = $(MPCGOBJ_) $(B)/missionpack/cgame/cg_syscalls.o MPCGVMOBJ = $(MPCGOBJ_:%.o=%.asm) $(B)/missionpack/game/bg_lib.asm @@ -1189,8 +1193,8 @@ Q3GOBJ_ = \ $(B)/baseq3/game/g_utils.o \ $(B)/baseq3/game/g_weapon.o \ \ - $(B)/baseq3/game/q_math.o \ - $(B)/baseq3/game/q_shared.o + $(B)/baseq3/qcommon/q_math.o \ + $(B)/baseq3/qcommon/q_shared.o Q3GOBJ = $(Q3GOBJ_) $(B)/baseq3/game/g_syscalls.o Q3GVMOBJ = $(Q3GOBJ_:%.o=%.asm) $(B)/baseq3/game/bg_lib.asm @@ -1237,8 +1241,8 @@ MPGOBJ_ = \ $(B)/missionpack/game/g_utils.o \ $(B)/missionpack/game/g_weapon.o \ \ - $(B)/missionpack/game/q_math.o \ - $(B)/missionpack/game/q_shared.o + $(B)/missionpack/qcommon/q_math.o \ + $(B)/missionpack/qcommon/q_shared.o MPGOBJ = $(MPGOBJ_) $(B)/missionpack/game/g_syscalls.o MPGVMOBJ = $(MPGOBJ_:%.o=%.asm) $(B)/missionpack/game/bg_lib.asm @@ -1297,8 +1301,8 @@ Q3UIOBJ_ = \ $(B)/baseq3/ui/ui_teamorders.o \ $(B)/baseq3/ui/ui_video.o \ \ - $(B)/baseq3/game/q_math.o \ - $(B)/baseq3/game/q_shared.o + $(B)/baseq3/qcommon/q_math.o \ + $(B)/baseq3/qcommon/q_shared.o Q3UIOBJ = $(Q3UIOBJ_) $(B)/missionpack/ui/ui_syscalls.o Q3UIVMOBJ = $(Q3UIOBJ_:%.o=%.asm) $(B)/baseq3/game/bg_lib.asm @@ -1322,8 +1326,8 @@ MPUIOBJ_ = \ \ $(B)/missionpack/game/bg_misc.o \ \ - $(B)/missionpack/game/q_math.o \ - $(B)/missionpack/game/q_shared.o + $(B)/missionpack/qcommon/q_math.o \ + $(B)/missionpack/qcommon/q_shared.o MPUIOBJ = $(MPUIOBJ_) $(B)/missionpack/ui/ui_syscalls.o MPUIVMOBJ = $(MPUIOBJ_:%.o=%.asm) $(B)/baseq3/game/bg_lib.asm @@ -1379,6 +1383,18 @@ $(B)/missionpack/ui/%.asm: $(UIDIR)/%.c $(Q3LCC) $(DO_Q3LCC) -DMISSIONPACK +$(B)/baseq3/qcommon/%.o: $(CMDIR)/%.c + $(DO_SHLIB_CC) + +$(B)/baseq3/qcommon/%.asm: $(CMDIR)/%.c $(Q3LCC) + $(DO_Q3LCC) + +$(B)/missionpack/qcommon/%.o: $(CMDIR)/%.c + $(DO_SHLIB_CC) -DMISSIONPACK + +$(B)/missionpack/qcommon/%.asm: $(CMDIR)/%.c $(Q3LCC) + $(DO_Q3LCC) -DMISSIONPACK + ############################################################################# # MISC diff --git a/code/unix/linux_signals.c b/code/unix/linux_signals.c index 686c947..c1bd330 100644 --- a/code/unix/linux_signals.c +++ b/code/unix/linux_signals.c @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" #ifndef DEDICATED #include "../renderer/tr_local.h" diff --git a/code/unix/linux_snd.c b/code/unix/linux_snd.c index 676b7d5..c9355c0 100644 --- a/code/unix/linux_snd.c +++ b/code/unix/linux_snd.c @@ -38,7 +38,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif #include -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../client/snd_local.h" int audio_fd; diff --git a/code/unix/sdl_snd.c b/code/unix/sdl_snd.c index d614c27..4107f81 100644 --- a/code/unix/sdl_snd.c +++ b/code/unix/sdl_snd.c @@ -53,7 +53,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "SDL.h" -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../client/snd_local.h" int snd_inited=0; diff --git a/code/unix/unix_main.c b/code/unix/unix_main.c index 95e4689..d8c9496 100644 --- a/code/unix/unix_main.c +++ b/code/unix/unix_main.c @@ -50,7 +50,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // FIXME TTimo should we gard this? most *nix system should comply? #include -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" #include "../renderer/tr_public.h" diff --git a/code/unix/unix_net.c b/code/unix/unix_net.c index 7eda309..93a47d0 100644 --- a/code/unix/unix_net.c +++ b/code/unix/unix_net.c @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // unix_net.c -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" #include diff --git a/code/unix/unix_shared.c b/code/unix/unix_shared.c index b39abc8..39c1550 100644 --- a/code/unix/unix_shared.c +++ b/code/unix/unix_shared.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" //============================================================================= diff --git a/code/win32/win_net.c b/code/win32/win_net.c index deadbbf..930ef7b 100644 --- a/code/win32/win_net.c +++ b/code/win32/win_net.c @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // net_wins.c -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" #include "win_local.h" diff --git a/code/win32/win_shared.c b/code/win32/win_shared.c index cbaa8d4..43ff321 100644 --- a/code/win32/win_shared.c +++ b/code/win32/win_shared.c @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#include "../game/q_shared.h" +#include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" #include "win_local.h" #include -- cgit v1.2.3