⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 q_shared.h

📁 this keik game source
💻 H
📖 第 1 页 / 共 5 页
字号:
// 49    4/27/98 3:21p Jimdose
// Added DebugLines
//
// 48    4/27/98 1:52p Aldie
// Added server side consoles.
//
// 47    4/18/98 6:12p Aldie
// Added ammo stats
//
// 46    4/18/98 4:24p Aldie
// Added ammo bar to stats
//
// 45    4/16/98 1:57p Jimdose
// Added prevframe to entity_state and gunprevframe to playerstate
//
// 44    4/14/98 6:30p Aldie
// Added laser temp ent.
//
// 43    4/09/98 1:41p Markd
// Added CONTENTS_SHOOTABLE and changed MASK_SHOT
//
// 42    4/07/98 8:01p Markd
// Added CS_SOUNDTRACK
//
// 41    4/06/98 7:10p Aldie
// Added zooming for SniperRifle
//
// 40    4/04/98 5:13p Markd
// Added TE_TESSELATE
//
// 39    4/03/98 3:35p Jimdose
// Added fast weapons
// Added draw flags for layouts
//
// 38    3/30/98 11:06p Aldie
// Added consoles as configstrings.
//
// 37    3/29/98 8:33p Markd
// Added sinmdl_cmd_t structure
//
// 36    3/28/98 3:10p Markd
// Increased MAX_MODEL_GROUPS
//
// 35    3/27/98 8:50p Jimdose
// Added support for third person view
//
// 34    3/27/98 7:00p Markd
// Increased MAX_MODELS, changed bone definition, added viewangles and
// vieworigin to entity_state_t and changed TransformFromTriangle and
// OriginFromTriangle
//
// 33    3/25/98 3:25p Markd
// Expanded bone_t definition
//
// 32    3/24/98 9:59a Markd
// Added TransformFromTriangle
//
// 31    3/18/98 7:47p Markd
// Added numgroups and groups to entity_state_t
//
// 30    3/18/98 7:16p Markd
// Added bone support to the entity state for entity linking in models
//
// 29    3/18/98 6:27p Aldie
// Added console to renderfx.
//
// 28    3/13/98 7:26p Aldie
// Added some new dlight renderfx
//
// 27    3/10/98 7:44p Aldie
// Added constants for player heights here.
//
// 26    3/09/98 2:51p Jimdose
// Working on euler-quat stuff
//
// 25    3/06/98 7:16p Aldie
// Arbitrary alpha for entities & lensflare
//
// 24    3/05/98 6:47p Markd
// added scale, to entity_state
//
// 23    3/05/98 3:49p Aldie
// More support for damaged surfaces.
//
// 22    3/05/98 11:36a Markd
// Added Anim suport
//
// 21    3/04/98 7:59p Aldie
// More support for damage textures.
//
// 20    3/04/98 5:14p Aldie
// Added support for damaged surfaces.
//
// 19    3/03/98 6:04p Aldie
// Added first pass for footsteps.
//
// 18    2/28/98 5:49p Markd
// Accidentally put the wrong file in their, I meant COM_FileExtension
//
// 17    2/28/98 5:46p Markd
// forgot a ;
//
// 16    2/28/98 5:46p Markd
// Added COM_StripExtension
//
// 15    2/28/98 4:43p Aldie
// Added Matrix4TransformVector
//
// 14    2/27/98 5:46p Jimdose
// Added min and max macros
//
// 13    2/25/98 4:38p Markd
// Added COM_GetToken
//
// 12    2/25/98 2:24p Aldie
// Added texture damage threshold constants
//
// 11    2/24/98 3:42p Aldie
// Added support for groupname and updated conveyor flag
//
// 10    2/22/98 10:15p Aldie
// Added support for texinfo commands over the net
//
// 9     2/22/98 2:19p Aldie
// Added support for trans_mag and trans_angle in the surface.
//
// 8     2/21/98 7:58p Aldie
// Removed dependency on TRANS33/66
//
// 7     2/21/98 7:18p Jimdose
// Added PMF_OLDNOCLIP and PMF_OLDLADDERS for client prediction
//
// 6     2/16/98 2:09p Jimdose
// Added quaternion field to entity_state_t for proper interpolation
// Added the following math utility functions: MatrixToEulerAngles,
// TransposeMatrix, MatrixTransformVector, OrthoNormalize, QuatToMat,
// MatToQuat, SlerpQuaternion, AnglesToMat, RotateAxis, MultQuat, EulerToQuat,
// VectorsToEulerAngles
//
// 5     2/04/98 4:04p Aldie
// Removed reference to value
//
// 4     1/21/98 6:53p Jimdose
// Made compatible with C++
// Added new render flag RF_DONTDRAW for invisible items
//
// 3     12/30/97 6:04p Jimdose
// Added header text
//
// DESCRIPTION:
// included first by ALL program modules
//

#ifndef __Q_SHARED_H__
#define __Q_SHARED_H__

#ifdef _WIN32
// unknown pragmas are SUPPOSED to be ignored, but....
#pragma warning(disable : 4244)     // MIPS
#pragma warning(disable : 4136)     // X86
#pragma warning(disable : 4051)     // ALPHA

#pragma warning(disable : 4018)     // signed/unsigned mismatch
#pragma warning(disable : 4305)		// truncation from const double to float

#endif

#ifndef _H2INC

#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#endif

#ifndef min
#define min(a,b)  (((a) < (b)) ? (a) : (b))
#endif
#ifndef max
#define max(a,b)  (((a) > (b)) ? (a) : (b))
#endif

#ifndef _H2INC
#define bound(a,minval,maxval)  ( ((a) > (minval)) ? ( ((a) < (maxval)) ? (a) : (maxval) ) : (minval) )
#endif

#if (defined _M_IX86 || defined __i386__) && !defined C_ONLY && !defined __sun__
#define id386	1
#else
#define id386	0
#endif

#if defined _M_ALPHA && !defined C_ONLY
#define idaxp	1
#else
#define idaxp	0
#endif

#ifdef __cplusplus
extern "C" {
#endif

#ifndef _H2INC
typedef unsigned char      byte;
#endif

#ifdef __cplusplus
typedef int qboolean;
#else
typedef enum {false, true}	qboolean;
#endif

#ifndef NULL
#define NULL ((void *)0)
#endif


// angle indexes
#define	PITCH				0		// up / down
#define	YAW					1		// left / right
#define	ROLL				2		// fall over

#define	MAX_STRING_CHARS	1024	// max length of a string passed to Cmd_TokenizeString
#define	MAX_STRING_TOKENS	80		// max tokens resulting from Cmd_TokenizeString
#define	MAX_TOKEN_CHARS		128		// max length of an individual token

#define	MAX_QPATH			64		// max length of a quake game pathname
#define	MAX_OSPATH			128		// max length of a filesystem pathname

//
// per-level limits
//
#define	MAX_CLIENTS			256		// absolute limit
#ifdef SIN
#define	MAX_EDICTS			1024	// must change protocol to increase more
#else
#define	MAX_EDICTS			1024	// must change protocol to increase more
#endif
#define	MAX_LIGHTSTYLES		256
#ifdef SIN
#define	MAX_MODELS			640		// these are sent over the net as bytes
#define  MAX_CONSOLES      32
#define  MAX_SURFACES      1024
#define	MAX_SOUNDS			512		// so they cannot be blindly increased
#else
#define	MAX_MODELS			256		// these are sent over the net as bytes
#define	MAX_SOUNDS			256		// so they cannot be blindly increased
#endif
#define	MAX_IMAGES			256
#define	MAX_ITEMS			256


// game print flags
#define	PRINT_LOW			0		// pickup messages
#define	PRINT_MEDIUM		1		// death messages
#define	PRINT_HIGH			2		// critical messages
#define	PRINT_CHAT			3		// chat messages



#define	ERR_FATAL			0		// exit the entire game with a popup window
#define	ERR_DROP			1		// print to console and disconnect from game
#define	ERR_DISCONNECT		2		// don't kill server

#define	PRINT_ALL			0
#define PRINT_DEVELOPER		1		// only print when "developer 1"
#define PRINT_ALERT			2


// destination class for gi.multicast()
typedef enum
{
MULTICAST_ALL,
MULTICAST_PHS,
MULTICAST_PVS,
MULTICAST_ALL_R,
MULTICAST_PHS_R,
MULTICAST_PVS_R
} multicast_t;


/*
==============================================================

MATHLIB

==============================================================
*/

typedef float vec_t;
typedef vec_t vec3_t[3];
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.14159265358979323846	// matches value in gcc v2 math.h
#endif

struct cplane_s;

extern vec3_t vec3_origin;

#define	nanmask (255<<23)

#define	IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)

// microsoft's fabs seems to be ungodly slow...
//float Q_fabs (float f);
//#define	fabs(f) Q_fabs(f)
#if !defined C_ONLY && !defined __linux__ && !defined __sgi
extern long Q_ftol( float f );
#else
#define Q_ftol( f ) ( long ) (f)
#endif

#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 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))

void VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t vecc);

// just in case you do't want to use the macros
vec_t _DotProduct (vec3_t v1, vec3_t v2);
void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out);
void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out);
void _VectorCopy (vec3_t in, vec3_t out);

void ClearBounds (vec3_t mins, vec3_t maxs);
void AddPointToBounds (vec3_t v, vec3_t mins, vec3_t maxs);
int VectorCompare (vec3_t v1, vec3_t v2);
vec_t VectorLength (vec3_t v);
void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);
vec_t VectorNormalize (vec3_t v);		// returns vector length
vec_t VectorNormalize2 (vec3_t v, vec3_t out);
void VectorInverse (vec3_t v);
void VectorScale (vec3_t in, vec_t scale, vec3_t out);
int Q_log2(int val);

void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);

void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *plane);
float	anglemod(float a);
float angledist( float ang );
float LerpAngle (float a1, float a2, float frac);

#define BOX_ON_PLANE_SIDE(emins, emaxs, p)	\
	(((p)->type < 3)?						\
	(										\
		((p)->dist <= (emins)[(p)->type])?	\
			1								\
		:									\
		(									\
			((p)->dist >= (emaxs)[(p)->type])?\
				2							\
			:								\
				3							\
		)									\
	)										\
	:										\
		BoxOnPlaneSide( (emins), (emaxs), (p)))

void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal );
void PerpendicularVector( vec3_t dst, const vec3_t src );
void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees );


//=============================================

#ifdef SIN
const char *COM_SkipPath (const char *pathname);
void COM_StripExtension (const char *in, char *out);
char *COM_FileExtension (const char *in);
void COM_FileBase (const char *in, char *out);
void COM_FilePath (const char *in, char *out);
void COM_DefaultExtension (char *path, const char *extension);
int  COM_ParseHex (const char *hex);
const char *COM_GetToken(const char **data_p, qboolean crossline);
const char *COM_Parse (const char **data_p);
#ifdef SIN
const char *SIN_GetToken(const char **data_p, qboolean crossline);
const char *SIN_Parse (const char **data_p);
#endif
// data is an in/out parm, returns a parsed out token

#ifndef _H2INC
void Com_sprintf (char *dest, int size, const char *fmt, ...);
#endif
#else
char *COM_SkipPath (char *pathname);
void COM_StripExtension (char *in, char *out);
void COM_FileBase (char *in, char *out);
void COM_FilePath (char *in, char *out);
void COM_DefaultExtension (char *path, char *extension);

char *COM_Parse (char **data_p);
// data is an in/out parm, returns a parsed out token

#ifndef _H2INC
void Com_sprintf (char *dest, int size, char *fmt, ...);
#endif
#endif

#ifdef _H2INC
void Com_PageInMemory (unsigned char *buffer, int size);
#else
void Com_PageInMemory (byte *buffer, int size);
#endif

//=============================================

// portable case insensitive compare
int Q_stricmp (const char *s1, const char *s2);
int Q_strcasecmp (const char *s1, const char *s2);
int Q_strncasecmp (const char *s1, const char *s2, int n);

//=============================================

#ifndef _H2INC

short	BigShort(short l);
short	LittleShort(short l);
int		BigLong (int l);
int		LittleLong (int l);
float	BigFloat (float l);
float	LittleFloat (float l);
#ifdef SIN
unsigned short	BigUnsignedShort(unsigned short l);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -