--- /dev/null
+/*\r
+Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
+For a list of contributors, see the accompanying CONTRIBUTORS file.\r
+\r
+This file is part of GtkRadiant.\r
+\r
+GtkRadiant is free software; you can redistribute it and/or modify\r
+it under the terms of the GNU General Public License as published by\r
+the Free Software Foundation; either version 2 of the License, or\r
+(at your option) any later version.\r
+\r
+GtkRadiant is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License\r
+along with GtkRadiant; if not, write to the Free Software\r
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\r
+*/\r
+\r
+#ifndef __Q_SHARED_H\r
+#define __Q_SHARED_H\r
+\r
+// q_shared.h -- included first by ALL program modules.\r
+// these are the definitions that have no dependance on\r
+// central system services, and can be used by any part\r
+// of the program without any state issues.\r
+\r
+// A user mod should never modify this file\r
+\r
+#define Q3_VERSION "DOOM 0.01"\r
+\r
+// alignment macros for SIMD\r
+#define ALIGN_ON\r
+#define ALIGN_OFF\r
+\r
+#ifdef _WIN32\r
+\r
+#pragma warning(disable : 4018) // signed/unsigned mismatch\r
+#pragma warning(disable : 4032)\r
+#pragma warning(disable : 4051)\r
+#pragma warning(disable : 4057) // slightly different base types\r
+#pragma warning(disable : 4100) // unreferenced formal parameter\r
+#pragma warning(disable : 4115)\r
+#pragma warning(disable : 4125) // decimal digit terminates octal escape sequence\r
+#pragma warning(disable : 4127) // conditional expression is constant\r
+#pragma warning(disable : 4136)\r
+#pragma warning(disable : 4201)\r
+#pragma warning(disable : 4214)\r
+#pragma warning(disable : 4244)\r
+#pragma warning(disable : 4305) // truncation from const double to float\r
+#pragma warning(disable : 4310) // cast truncates constant value\r
+#pragma warning(disable : 4514)\r
+#pragma warning(disable : 4711) // selected for automatic inline expansion\r
+#pragma warning(disable : 4220) // varargs matches remaining parameters\r
+\r
+#endif\r
+\r
+#include <assert.h>\r
+#include <math.h>\r
+#include <stdio.h>\r
+#include <stdarg.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <time.h>\r
+#include <ctype.h>\r
+#ifdef _WIN32 // mac doesn't have malloc.h\r
+#include <malloc.h> // for _alloca()\r
+#endif\r
+#ifdef _WIN32\r
+\r
+//#pragma intrinsic( memset, memcpy )\r
+\r
+#endif\r
+\r
+\r
+// this is the define for determining if we have an asm version of a C function\r
+#if (defined _M_IX86 || defined __i386__) && !defined __sun__ && !defined __LCC__\r
+#define id386 1\r
+#else\r
+#define id386 0\r
+#endif\r
+\r
+// for windows fastcall option\r
+\r
+#define QDECL\r
+\r
+//======================= WIN32 DEFINES =================================\r
+\r
+#ifdef _WIN32\r
+\r
+#define MAC_STATIC\r
+\r
+#undef QDECL\r
+#define QDECL __cdecl\r
+\r
+// buildstring will be incorporated into the version string\r
+#ifdef NDEBUG\r
+#ifdef _M_IX86\r
+#define CPUSTRING "win-x86"\r
+#elif defined _M_ALPHA\r
+#define CPUSTRING "win-AXP"\r
+#endif\r
+#else\r
+#ifdef _M_IX86\r
+#define CPUSTRING "win-x86-debug"\r
+#elif defined _M_ALPHA\r
+#define CPUSTRING "win-AXP-debug"\r
+#endif\r
+#endif\r
+\r
+\r
+#define PATH_SEP '\\'\r
+\r
+#endif\r
+\r
+//======================= MAC OS X SERVER DEFINES =====================\r
+\r
+#if defined(__MACH__) && defined(__APPLE__)\r
+\r
+#define MAC_STATIC\r
+\r
+#ifdef __ppc__\r
+#define CPUSTRING "MacOSXS-ppc"\r
+#elif defined __i386__\r
+#define CPUSTRING "MacOSXS-i386"\r
+#else\r
+#define CPUSTRING "MacOSXS-other"\r
+#endif\r
+\r
+#define PATH_SEP '/'\r
+\r
+#define GAME_HARD_LINKED\r
+#define CGAME_HARD_LINKED\r
+#define UI_HARD_LINKED\r
+#define _alloca alloca\r
+\r
+#undef ALIGN_ON\r
+#undef ALIGN_OFF\r
+#define ALIGN_ON #pragma align(16)\r
+#define ALIGN_OFF #pragma align()\r
+\r
+#ifdef __cplusplus\r
+ extern "C" {\r
+#endif\r
+\r
+void *osxAllocateMemory(long size);\r
+void osxFreeMemory(void *pointer);\r
+\r
+#ifdef __cplusplus\r
+ }\r
+#endif\r
+\r
+#endif\r
+\r
+//======================= MAC DEFINES =================================\r
+\r
+#ifdef __MACOS__\r
+\r
+#define MAC_STATIC static\r
+\r
+#define CPUSTRING "MacOS-PPC"\r
+\r
+#define PATH_SEP ':'\r
+\r
+void Sys_PumpEvents( void );\r
+\r
+#endif\r
+\r
+#ifdef __MRC__\r
+\r
+#define MAC_STATIC\r
+\r
+#define CPUSTRING "MacOS-PPC"\r
+\r
+#define PATH_SEP ':'\r
+\r
+void Sys_PumpEvents( void );\r
+\r
+#undef QDECL\r
+#define QDECL __cdecl\r
+\r
+#define _alloca alloca\r
+#endif\r
+\r
+//======================= LINUX DEFINES =================================\r
+\r
+// the mac compiler can't handle >32k of locals, so we\r
+// just waste space and make big arrays static...\r
+#ifdef __linux__\r
+\r
+#define MAC_STATIC\r
+\r
+#ifdef __i386__\r
+#define CPUSTRING "linux-i386"\r
+#elif defined __axp__\r
+#define CPUSTRING "linux-alpha"\r
+#else\r
+#define CPUSTRING "linux-other"\r
+#endif\r
+\r
+#define PATH_SEP '/'\r
+\r
+#endif\r
+\r
+//=============================================================\r
+ \r
+typedef enum {qfalse, qtrue} qboolean;\r
+\r
+typedef unsigned char byte;\r
+\r
+#define EQUAL_EPSILON 0.001\r
+\r
+typedef int qhandle_t;\r
+typedef int sfxHandle_t;\r
+typedef int fileHandle_t;\r
+typedef int clipHandle_t;\r
+\r
+typedef enum {\r
+ INVALID_JOINT = -1\r
+} jointHandle_t;\r
+\r
+#ifndef NULL\r
+#define NULL ((void *)0)\r
+#endif\r
+\r
+#define MAX_QINT 0x7fffffff\r
+#define MIN_QINT (-MAX_QINT-1)\r
+\r
+#ifndef max\r
+#define max( x, y ) ( ( ( x ) > ( y ) ) ? ( x ) : ( y ) )\r
+#define min( x, y ) ( ( ( x ) < ( y ) ) ? ( x ) : ( y ) )\r
+#endif\r
+\r
+#ifndef sign\r
+#define sign( f ) ( ( f > 0 ) ? 1 : ( ( f < 0 ) ? -1 : 0 ) )\r
+#endif\r
+\r
+// angle indexes\r
+#define PITCH 0 // up / down\r
+#define YAW 1 // left / right\r
+#define ROLL 2 // fall over\r
+\r
+// the game guarantees that no string from the network will ever\r
+// exceed MAX_STRING_CHARS\r
+#define MAX_STRING_CHARS 1024 // max length of a string passed to Cmd_TokenizeString\r
+#define MAX_STRING_TOKENS 256 // max tokens resulting from Cmd_TokenizeString\r
+#define MAX_TOKEN_CHARS 1024 // max length of an individual token\r
+\r
+#define MAX_INFO_STRING 1024\r
+#define MAX_INFO_KEY 1024\r
+#define MAX_INFO_VALUE 1024\r
+\r
+\r
+#define MAX_QPATH 64 // max length of a quake game pathname\r
+#define MAX_OSPATH 128 // max length of a filesystem pathname\r
+\r
+#define MAX_NAME_LENGTH 32 // max length of a client name\r
+\r
+// paramters for command buffer stuffing\r
+typedef enum {\r
+ EXEC_NOW, // don't return until completed, a VM should NEVER use this,\r
+ // because some commands might cause the VM to be unloaded...\r
+ EXEC_INSERT, // insert at current position, but don't run yet\r
+ EXEC_APPEND // add to end of the command buffer (normal case)\r
+} cbufExec_t;\r
+\r
+\r
+//\r
+// these aren't needed by any of the VMs. put in another header?\r
+//\r
+#define MAX_MAP_AREA_BYTES 32 // bit vector of area visibility\r
+\r
+#undef ERR_FATAL // malloc.h on unix\r
+\r
+// parameters to the main Error routine\r
+typedef enum {\r
+ ERR_NONE,\r
+ ERR_FATAL, // exit the entire game with a popup window\r
+ ERR_DROP, // print to console and disconnect from game\r
+ ERR_DISCONNECT, // don't kill server\r
+ ERR_NEED_CD // pop up the need-cd dialog\r
+} errorParm_t;\r
+\r
+\r
+// font rendering values used by ui and cgame\r
+\r
+#define PROP_GAP_WIDTH 3\r
+#define PROP_SPACE_WIDTH 8\r
+#define PROP_HEIGHT 27\r
+#define PROP_SMALL_SIZE_SCALE 0.75\r
+\r
+#define BLINK_DIVISOR 200\r
+#define PULSE_DIVISOR 75\r
+\r
+#define UI_LEFT 0x00000000 // default\r
+#define UI_CENTER 0x00000001\r
+#define UI_RIGHT 0x00000002\r
+#define UI_FORMATMASK 0x00000007\r
+#define UI_SMALLFONT 0x00000010\r
+#define UI_BIGFONT 0x00000020 // default\r
+#define UI_GIANTFONT 0x00000040\r
+#define UI_DROPSHADOW 0x00000800\r
+#define UI_BLINK 0x00001000\r
+#define UI_INVERSE 0x00002000\r
+#define UI_PULSE 0x00004000\r
+\r
+\r
+/*\r
+==============================================================\r
+\r
+MATHLIB\r
+\r
+==============================================================\r
+*/\r
+#ifdef __cplusplus // so we can include this in C code\r
+#define SIDE_FRONT 0\r
+#define SIDE_BACK 1\r
+#define SIDE_ON 2\r
+#define SIDE_CROSS 3\r
+\r
+#define Q_PI 3.14159265358979323846\r
+#ifndef M_PI\r
+#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h\r
+#endif\r
+\r
+#include "math_vector.h"\r
+#include "math_angles.h"\r
+#include "math_matrix.h"\r
+#include "math_quaternion.h"\r
+\r
+class idVec3; // for defining vectors\r
+typedef idVec3 &vec3_p; // for passing vectors as function arguments\r
+typedef const idVec3 &vec3_c; // for passing vectors as const function arguments\r
+ \r
+class angles_t; // for defining angle vectors\r
+typedef angles_t &angles_p; // for passing angles as function arguments\r
+typedef const angles_t &angles_c; // for passing angles as const function arguments\r
+\r
+class mat3_t; // for defining matrices\r
+typedef mat3_t &mat3_p; // for passing matrices as function arguments\r
+typedef const mat3_t &mat3_c; // for passing matrices as const function arguments\r
+\r
+\r
+\r
+#define NUMVERTEXNORMALS 162\r
+extern idVec3 bytedirs[NUMVERTEXNORMALS];\r
+\r
+// all drawing is done to a 640*480 virtual screen size\r
+// and will be automatically scaled to the real resolution\r
+#define SCREEN_WIDTH 640\r
+#define SCREEN_HEIGHT 480\r
+\r
+#define TINYCHAR_WIDTH (SMALLCHAR_WIDTH)\r
+#define TINYCHAR_HEIGHT (SMALLCHAR_HEIGHT/2)\r
+\r
+#define SMALLCHAR_WIDTH 8\r
+#define SMALLCHAR_HEIGHT 16\r
+\r
+#define BIGCHAR_WIDTH 16\r
+#define BIGCHAR_HEIGHT 16\r
+\r
+#define GIANTCHAR_WIDTH 32\r
+#define GIANTCHAR_HEIGHT 48\r
+\r
+extern idVec4 colorBlack;\r
+extern idVec4 colorRed;\r
+extern idVec4 colorGreen;\r
+extern idVec4 colorBlue;\r
+extern idVec4 colorYellow;\r
+extern idVec4 colorMagenta;\r
+extern idVec4 colorCyan;\r
+extern idVec4 colorWhite;\r
+extern idVec4 colorLtGrey;\r
+extern idVec4 colorMdGrey;\r
+extern idVec4 colorDkGrey;\r
+\r
+#define Q_COLOR_ESCAPE '^'\r
+#define Q_IsColorString(p) ( p && *(p) == Q_COLOR_ESCAPE && *((p)+1) && *((p)+1) != Q_COLOR_ESCAPE )\r
+\r
+#define COLOR_BLACK '0'\r
+#define COLOR_RED '1'\r
+#define COLOR_GREEN '2'\r
+#define COLOR_YELLOW '3'\r
+#define COLOR_BLUE '4'\r
+#define COLOR_CYAN '5'\r
+#define COLOR_MAGENTA '6'\r
+#define COLOR_WHITE '7'\r
+#define ColorIndex(c) ( ( (c) - '0' ) & 7 )\r
+\r
+#define S_COLOR_BLACK "^0"\r
+#define S_COLOR_RED "^1"\r
+#define S_COLOR_GREEN "^2"\r
+#define S_COLOR_YELLOW "^3"\r
+#define S_COLOR_BLUE "^4"\r
+#define S_COLOR_CYAN "^5"\r
+#define S_COLOR_MAGENTA "^6"\r
+#define S_COLOR_WHITE "^7"\r
+\r
+extern idVec4 g_color_table[8];\r
+\r
+#define MAKERGB( v, r, g, b ) v[0]=r;v[1]=g;v[2]=b\r
+#define MAKERGBA( v, r, g, b, a ) v[0]=r;v[1]=g;v[2]=b;v[3]=a\r
+\r
+#define DEG2RAD( a ) ( ( (a) * M_PI ) / 180.0F )\r
+#define RAD2DEG( a ) ( ( (a) * 180.0f ) / M_PI )\r
+\r
+struct cplane_s;\r
+\r
+extern idVec3 vec3_origin;\r
+extern idVec4 vec4_origin;\r
+extern mat3_t axisDefault;\r
+\r
+#define nanmask (255<<23)\r
+\r
+#define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)\r
+\r
+float Q_fabs( float f );\r
+float Q_rsqrt( float f ); // reciprocal square root\r
+\r
+#define SQRTFAST( x ) ( 1.0f / Q_rsqrt( x ) )\r
+\r
+signed char ClampChar( int i );\r
+signed short ClampShort( int i );\r
+\r
+// this isn't a real cheap function to call!\r
+int DirToByte( const idVec3 &dir );\r
+void ByteToDir( int b, vec3_p dir );\r
+\r
+#define DotProduct(a,b) ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])\r
+#define VectorSubtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])\r
+#define VectorAdd(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])\r
+#define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])\r
+//#define VectorCopy(a,b) ((b).x=(a).x,(b).y=(a).y,(b).z=(a).z])\r
+\r
+#define VectorScale(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))\r
+#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))\r
+#define CrossProduct(a,b,c) ((c)[0]=(a)[1]*(b)[2]-(a)[2]*(b)[1],(c)[1]=(a)[2]*(b)[0]-(a)[0]*(b)[2],(c)[2]=(a)[0]*(b)[1]-(a)[1]*(b)[0])\r
+\r
+#define DotProduct4(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]+(x)[3]*(y)[3])\r
+#define VectorSubtract4(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2],(c)[3]=(a)[3]-(b)[3])\r
+#define VectorAdd4(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2],(c)[3]=(a)[3]+(b)[3])\r
+#define VectorCopy4(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])\r
+#define VectorScale4(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s),(o)[3]=(v)[3]*(s))\r
+#define VectorMA4(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),(o)[3]=(v)[3]+(b)[3]*(s))\r
+\r
+\r
+#define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0)\r
+#define VectorNegate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])\r
+#define VectorSet(v, x, y, z) ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))\r
+#define Vector4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])\r
+\r
+#define SnapVector(v) {v[0]=(int)v[0];v[1]=(int)v[1];v[2]=(int)v[2];}\r
+\r
+float NormalizeColor( vec3_c in, vec3_p out );\r
+\r
+int VectorCompare( vec3_c v1, vec3_c v2 );\r
+float VectorLength( vec3_c v );\r
+float Distance( vec3_c p1, vec3_c p2 );\r
+float DistanceSquared( vec3_c p1, vec3_c p2 );\r
+float VectorNormalize (vec3_p v); // returns vector length\r
+void VectorNormalizeFast(vec3_p v); // does NOT return vector length, uses rsqrt approximation\r
+float VectorNormalize2( vec3_c v, vec3_p out );\r
+void VectorInverse (vec3_p v);\r
+void VectorRotate( vec3_c in, mat3_c matrix, vec3_p out );\r
+void VectorPolar(vec3_p v, float radius, float theta, float phi);\r
+void VectorSnap(vec3_p v);\r
+void Vector53Copy( const idVec5_t &in, vec3_p out);\r
+void Vector5Scale( const idVec5_t &v, float scale, idVec5_t &out);\r
+void Vector5Add( const idVec5_t &va, const idVec5_t &vb, idVec5_t &out);\r
+void VectorRotate3( vec3_c vIn, vec3_c vRotation, vec3_p out);\r
+void VectorRotate3Origin(vec3_c vIn, vec3_c vRotation, vec3_c vOrigin, vec3_p out);\r
+\r
+\r
+int Q_log2(int val);\r
+\r
+int Q_rand( int *seed );\r
+float Q_random( int *seed );\r
+float Q_crandom( int *seed );\r
+\r
+#define random() ((rand () & 0x7fff) / ((float)0x7fff))\r
+#define crandom() (2.0 * (random() - 0.5))\r
+\r
+float Q_rint( float in );\r
+\r
+void vectoangles( vec3_c value1, angles_p angles);\r
+void AnglesToAxis( angles_c angles, mat3_p axis );\r
+\r
+void AxisCopy( mat3_c in, mat3_p out );\r
+qboolean AxisRotated( mat3_c in ); // assumes a non-degenerate axis\r
+\r
+int SignbitsForNormal( vec3_c normal );\r
+int BoxOnPlaneSide( const Bounds &b, struct cplane_s *p );\r
+\r
+float AngleMod(float a);\r
+float LerpAngle (float from, float to, float frac);\r
+float AngleSubtract( float a1, float a2 );\r
+void AnglesSubtract( angles_c v1, angles_c v2, angles_p v3 );\r
+\r
+float AngleNormalize360 ( float angle );\r
+float AngleNormalize180 ( float angle );\r
+float AngleDelta ( float angle1, float angle2 );\r
+\r
+qboolean PlaneFromPoints( idVec4 &plane, vec3_c a, vec3_c b, vec3_c c );\r
+void ProjectPointOnPlane( vec3_p dst, vec3_c p, vec3_c normal );\r
+void RotatePointAroundVector( vec3_p dst, vec3_c dir, vec3_c point, float degrees );\r
+void RotateAroundDirection( mat3_p axis, float yaw );\r
+void MakeNormalVectors( vec3_c forward, vec3_p right, vec3_p up );\r
+// perpendicular vector could be replaced by this\r
+\r
+int PlaneTypeForNormal( vec3_c normal );\r
+\r
+void MatrixMultiply( mat3_c in1, mat3_c in2, mat3_p out );\r
+void MatrixInverseMultiply( mat3_c in1, mat3_c in2, mat3_p out ); // in2 is transposed during multiply\r
+void MatrixTransformVector( vec3_c in, mat3_c matrix, vec3_p out );\r
+void MatrixProjectVector( vec3_c in, mat3_c matrix, vec3_p out ); // Places the vector into a new coordinate system.\r
+void AngleVectors( angles_c angles, vec3_p forward, vec3_p right, vec3_p up);\r
+void PerpendicularVector( vec3_p dst, vec3_c src );\r
+\r
+float TriangleArea( vec3_c a, vec3_c b, vec3_c c );\r
+#endif // __cplusplus\r
+\r
+//=============================================\r
+\r
+float Com_Clamp( float min, float max, float value );\r
+\r
+#define FILE_HASH_SIZE 1024\r
+int Com_HashString( const char *fname );\r
+\r
+char *Com_SkipPath( char *pathname );\r
+\r
+// it is ok for out == in\r
+void Com_StripExtension( const char *in, char *out );\r
+\r
+// "extension" should include the dot: ".map"\r
+void Com_DefaultExtension( char *path, int maxSize, const char *extension );\r
+\r
+int Com_ParseInfos( const char *buf, int max, char infos[][MAX_INFO_STRING] );\r
+\r
+/*\r
+=====================================================================================\r
+\r
+SCRIPT PARSING\r
+\r
+=====================================================================================\r
+*/\r
+\r
+// this just controls the comment printing, it doesn't actually load a file\r
+void Com_BeginParseSession( const char *filename );\r
+void Com_EndParseSession( void );\r
+\r
+int Com_GetCurrentParseLine( void );\r
+\r
+// Will never return NULL, just empty strings.\r
+// An empty string will only be returned at end of file.\r
+// ParseOnLine will return empty if there isn't another token on this line\r
+\r
+// this funny typedef just means a moving pointer into a const char * buffer\r
+const char *Com_Parse( const char *(*data_p) );\r
+const char *Com_ParseOnLine( const char *(*data_p) );\r
+const char *Com_ParseRestOfLine( const char *(*data_p) );\r
+\r
+void Com_UngetToken( void );\r
+\r
+#ifdef __cplusplus\r
+void Com_MatchToken( const char *(*buf_p), const char *match, qboolean warning = qfalse );\r
+#else\r
+void Com_MatchToken( const char *(*buf_p), const char *match, qboolean warning );\r
+#endif\r
+\r
+void Com_ScriptError( const char *msg, ... );\r
+void Com_ScriptWarning( const char *msg, ... );\r
+\r
+void Com_SkipBracedSection( const char *(*program) );\r
+void Com_SkipRestOfLine( const char *(*data) );\r
+\r
+float Com_ParseFloat( const char *(*buf_p) );\r
+int Com_ParseInt( const char *(*buf_p) );\r
+\r
+void Com_Parse1DMatrix( const char *(*buf_p), int x, float *m );\r
+void Com_Parse2DMatrix( const char *(*buf_p), int y, int x, float *m );\r
+void Com_Parse3DMatrix( const char *(*buf_p), int z, int y, int x, float *m );\r
+\r
+//=====================================================================================\r
+#ifdef __cplusplus\r
+ extern "C" {\r
+#endif\r
+\r
+void QDECL Com_sprintf (char *dest, int size, const char *fmt, ...);\r
+\r
+\r
+// mode parm for FS_FOpenFile\r
+typedef enum {\r
+ FS_READ,\r
+ FS_WRITE,\r
+ FS_APPEND,\r
+ FS_APPEND_SYNC\r
+} fsMode_t;\r
+\r
+typedef enum {\r
+ FS_SEEK_CUR,\r
+ FS_SEEK_END,\r
+ FS_SEEK_SET\r
+} fsOrigin_t;\r
+\r
+//=============================================\r
+\r
+int Q_isprint( int c );\r
+int Q_islower( int c );\r
+int Q_isupper( int c );\r
+int Q_isalpha( int c );\r
+\r
+// portable case insensitive compare\r
+int Q_stricmp (const char *s1, const char *s2);\r
+int Q_strncmp (const char *s1, const char *s2, int n);\r
+int Q_stricmpn (const char *s1, const char *s2, int n);\r
+char *Q_strlwr( char *s1 );\r
+char *Q_strupr( char *s1 );\r
+char *Q_strrchr( const char* string, int c );\r
+\r
+// buffer size safe library replacements\r
+void Q_strncpyz( char *dest, const char *src, int destsize );\r
+void Q_strcat( char *dest, int size, const char *src );\r
+\r
+// strlen that discounts Quake color sequences\r
+int Q_PrintStrlen( const char *string );\r
+// removes color sequences from string\r
+char *Q_CleanStr( char *string );\r
+\r
+int Com_Filter( const char *filter, const char *name, int casesensitive );\r
+const char *Com_StringContains( const char *str1, const char *str2, int casesensitive );\r
+\r
+\r
+//=============================================\r
+\r
+short BigShort(short l);\r
+short LittleShort(short l);\r
+int BigLong (int l);\r
+int LittleLong (int l);\r
+float BigFloat (float l);\r
+float LittleFloat (float l);\r
+\r
+void Swap_Init (void);\r
+char * QDECL va(char *format, ...);\r
+\r
+#ifdef __cplusplus\r
+ }\r
+#endif\r
+\r
+\r
+//=============================================\r
+#ifdef __cplusplus\r
+//\r
+// mapfile parsing\r
+//\r
+typedef struct ePair_s {\r
+ char *key;\r
+ char *value;\r
+} ePair_t;\r
+\r
+typedef struct mapSide_s {\r
+ char material[MAX_QPATH];\r
+ idVec4 plane;\r
+ idVec4 textureVectors[2];\r
+} mapSide_t;\r
+\r
+typedef struct {\r
+ int numSides;\r
+ mapSide_t **sides;\r
+} mapBrush_t;\r
+\r
+typedef struct {\r
+ idVec3 xyz;\r
+ float st[2];\r
+} patchVertex_t;\r
+\r
+typedef struct {\r
+ char material[MAX_QPATH];\r
+ int width, height;\r
+ patchVertex_t *patchVerts;\r
+} mapPatch_t;\r
+\r
+typedef struct {\r
+ char modelName[MAX_QPATH];\r
+ float matrix[16];\r
+} mapModel_t;\r
+\r
+typedef struct mapPrimitive_s {\r
+ int numEpairs;\r
+ ePair_t **ePairs;\r
+\r
+ // only one of these will be non-NULL\r
+ mapBrush_t *brush;\r
+ mapPatch_t *patch;\r
+ mapModel_t *model;\r
+} mapPrimitive_t;\r
+\r
+typedef struct mapEntity_s {\r
+ int numPrimitives;\r
+ mapPrimitive_t **primitives;\r
+\r
+ int numEpairs;\r
+ ePair_t **ePairs;\r
+} mapEntity_t;\r
+\r
+typedef struct {\r
+ int numEntities;\r
+ mapEntity_t **entities;\r
+} mapFile_t;\r
+\r
+\r
+// the order of entities, brushes, and sides will be maintained, the\r
+// lists won't be swapped on each load or save\r
+mapFile_t *ParseMapFile( const char *text );\r
+void FreeMapFile( mapFile_t *mapFile );\r
+void WriteMapFile( const mapFile_t *mapFile, FILE *f );\r
+\r
+// key names are case-insensitive\r
+const char *ValueForMapEntityKey( const mapEntity_t *ent, const char *key );\r
+float FloatForMapEntityKey( const mapEntity_t *ent, const char *key );\r
+qboolean GetVectorForMapEntityKey( const mapEntity_t *ent, const char *key, idVec3 &vec );\r
+\r
+typedef struct {\r
+ idVec3 xyz;\r
+ idVec2 st;\r
+ idVec3 normal;\r
+ idVec3 tangents[2];\r
+ byte smoothing[4]; // colors for silhouette smoothing\r
+} drawVert_t;\r
+\r
+typedef struct {\r
+ int width, height;\r
+ drawVert_t *verts;\r
+} drawVertMesh_t;\r
+\r
+// Tesselate a map patch into smoothed, drawable vertexes\r
+// MaxError of around 4 is reasonable\r
+drawVertMesh_t *SubdivideMapPatch( const mapPatch_t *patch, float maxError );\r
+#endif // __cplusplus\r
+\r
+//=========================================\r
+\r
+#ifdef __cplusplus\r
+ extern "C" {\r
+#endif\r
+\r
+void QDECL Com_Error( int level, const char *error, ... );\r
+void QDECL Com_Printf( const char *msg, ... );\r
+void QDECL Com_DPrintf( const char *msg, ... );\r
+\r
+#ifdef __cplusplus\r
+ }\r
+#endif\r
+\r
+\r
+typedef struct {\r
+ qboolean frameMemory;\r
+ int currentElements;\r
+ int maxElements; // will reallocate and move when exceeded\r
+ void **elements;\r
+} growList_t;\r
+\r
+// you don't need to init the growlist if you don't mind it growing and moving\r
+// the list as it expands\r
+void Com_InitGrowList( growList_t *list, int maxElements );\r
+int Com_AddToGrowList( growList_t *list, void *data );\r
+void *Com_GrowListElement( const growList_t *list, int index );\r
+int Com_IndexForGrowListElement( const growList_t *list, const void *element );\r
+\r
+\r
+//\r
+// key / value info strings\r
+//\r
+char *Info_ValueForKey( const char *s, const char *key );\r
+void Info_RemoveKey( char *s, const char *key );\r
+void Info_SetValueForKey( char *s, const char *key, const char *value );\r
+qboolean Info_Validate( const char *s );\r
+void Info_NextPair( const char *(*s), char key[MAX_INFO_KEY], char value[MAX_INFO_VALUE] );\r
+\r
+// get cvar defs, collision defs, etc\r
+//#include "../shared/interface.h"\r
+\r
+// get key code numbers for events\r
+//#include "../shared/keycodes.h"\r
+\r
+#ifdef __cplusplus\r
+// get the polygon winding functions\r
+//#include "../shared/windings.h"\r
+\r
+// get the flags class\r
+//#include "../shared/idflags.h"\r
+#endif // __cplusplus\r
+\r
+#endif // __Q_SHARED_H\r
+\r