2930 lines · 77.5 KB · C
RawDownload
//#define PARANOID	// speed sapping error checking//#define SMALL_FINALVERT typedef uchar byte;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;typedef uchar pixel_t; typedef enum qboolean {false, true} qboolean; typedef struct edict_t edict_t;typedef struct cvar_t cvar_t;typedef struct cplane_t cplane_t;typedef struct cmodel_t cmodel_t;typedef struct csurface_t csurface_t;typedef struct mapsurface_t mapsurface_t;typedef struct trace_t trace_t;typedef struct pmove_state_t pmove_state_t;typedef struct usercmd_t usercmd_t;typedef struct pmove_t pmove_t;typedef struct entity_state_t entity_state_t;typedef struct player_state_t player_state_t;typedef struct sizebuf_t sizebuf_t;typedef struct netadr_t netadr_t;typedef struct netchan_t netchan_t;typedef struct dpackfile_t dpackfile_t;typedef struct dpackheader_t dpackheader_t;typedef struct pcx_t pcx_t;typedef struct dstvert_t dstvert_t;typedef struct dtriangle_t dtriangle_t;typedef struct dtrivertx_t dtrivertx_t;typedef struct daliasframe_t daliasframe_t;typedef struct dmdl_t dmdl_t;typedef struct dsprframe_t dsprframe_t;typedef struct dsprite_t dsprite_t;typedef struct miptex_t miptex_t;typedef struct lump_t lump_t;typedef struct dheader_t dheader_t;typedef struct dmodel_t dmodel_t;typedef struct dvertex_t dvertex_t;typedef struct dplane_t dplane_t;typedef struct dnode_t dnode_t;typedef struct texinfo_t texinfo_t;typedef struct dedge_t dedge_t;typedef struct dface_t dface_t;typedef struct dleaf_t dleaf_t;typedef struct dbrushside_t dbrushside_t;typedef struct dbrush_t dbrush_t;typedef struct dvis_t dvis_t;typedef struct dareaportal_t dareaportal_t;typedef struct darea_t darea_t;typedef struct vrect_t vrect_t;typedef struct viddef_t viddef_t;typedef struct image_t image_t;typedef struct oldrefdef_t oldrefdef_t;typedef struct mvertex_t mvertex_t;typedef struct mplane_t mplane_t;typedef struct medge_t medge_t;typedef struct mtexinfo_t mtexinfo_t;typedef struct msurface_t msurface_t;typedef struct mnode_t mnode_t;typedef struct mleaf_t mleaf_t;typedef struct model_t model_t;typedef struct emitpoint_t emitpoint_t;typedef struct finalvert_t finalvert_t;typedef struct affinetridesc_t affinetridesc_t;typedef struct drawsurf_t drawsurf_t;typedef struct alight_t alight_t;typedef struct bedge_t bedge_t;typedef struct clipplane_t clipplane_t;typedef struct surfcache_t surfcache_t;typedef struct espan_t espan_t;typedef struct polydesc_t polydesc_t;typedef struct surf_t surf_t;typedef struct edge_t edge_t;typedef struct aliastriangleparms_t aliastriangleparms_t;typedef struct swstate_t swstate_t;typedef struct entity_t entity_t;typedef struct dlight_t dlight_t;typedef struct particle_t particle_t;typedef struct lightstyle_t lightstyle_t;typedef struct refdef_t refdef_t;typedef struct refexport_t refexport_t;typedef struct refimport_t refimport_t;typedef struct portable_samplepair_t portable_samplepair_t;typedef struct sfxcache_t sfxcache_t;typedef struct sfx_t sfx_t;typedef struct playsound_t playsound_t;typedef struct dma_t dma_t;typedef struct channel_t channel_t;typedef struct wavinfo_t wavinfo_t;typedef struct console_t console_t;typedef struct frame_t frame_t;typedef struct centity_t centity_t;typedef struct clientinfo_t clientinfo_t;typedef struct client_state_t client_state_t;typedef struct client_static_t client_static_t;typedef struct cdlight_t cdlight_t;typedef struct cl_sustain_t cl_sustain_t;typedef struct cparticle_t cparticle_t;typedef struct kbutton_t kbutton_t;typedef struct menuframework_t menuframework_t;typedef struct menucommon_t menucommon_t;typedef struct menufield_t menufield_t;typedef struct menuslider_t menuslider_t;typedef struct menulist_t menulist_t;typedef struct menuaction_t menuaction_t;typedef struct menuseparator_t menuseparator_t;typedef struct server_t server_t;typedef struct client_frame_t client_frame_t;typedef struct client_t client_t;typedef struct challenge_t challenge_t;typedef struct server_static_t server_static_t; typedef void	(*xcommand_t)(void);typedef	refexport_t	(*GetRefAPI_t)(refimport_t); enum{	/* angle indexes */	PITCH = 0,	YAW = 1,	ROLL = 2, 	MAX_STRING_CHARS = 1024,	// char* passed to Cmd_TokenizeString, max strlen	MAX_STRING_TOKENS = 80,	// max tokens resulting from Cmd_TokenizeString	MAX_TOKEN_CHARS = 128,	// max length of an individual token 	/* max length of quake game and fs pathname */	MAX_QPATH = 64,	MAX_OSPATH = 128, 	/* per-level limits */	MAX_CLIENTS = 256,	// absolute limit	MAX_EDICTS = 1024,	// must change protocol to increase more	MAX_LIGHTSTYLES = 256, 	/* these are sent over the net as bytes so they cannot be blindly increased */	MAX_MODELS = 256,	MAX_SOUNDS = 256,	MAX_IMAGES = 256,	MAX_ITEMS = 256, 	MAX_GENERAL = MAX_CLIENTS*2,	// general config strings 	/* game print flags */	PRINT_LOW = 0,		// pickup messages	PRINT_MEDIUM = 1,	// death messages	PRINT_HIGH = 2,		// critical messages	PRINT_CHAT = 3,		// chat messages 	/* key / value info strings */	MAX_INFO_KEY = 64,	MAX_INFO_VALUE = 64,	MAX_INFO_STRING = 512, 	MAX_PARSE_ENTITIES = 1024,}; /* destination class for gi.multicast() */typedef enum multicast_t{	MULTICAST_ALL,	MULTICAST_PHS,	MULTICAST_PVS,	MULTICAST_ALL_R,	MULTICAST_PHS_R,	MULTICAST_PVS_R}multicast_t; #define M_PI		3.14159265358979323846	// matches value in gcc v2 math.h extern vec3_t vec3_origin; #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))#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))) extern int curtime;	// current time in ms, from Sys_Milliseconds()extern qboolean debug; enum{	CVAR_ARCHIVE = 1<<0,	// save to vars.rc	CVAR_USERINFO = 1<<1,	// add to userinfo on change	CVAR_SERVERINFO = 1<<2,	// add to serverinfo on change	CVAR_NOSET = 1<<3,	// only allow setting from commandline	CVAR_LATCH= 1<<4	// save changes until server restart};/* nothing outside the Cvar_*() functions should modify these fields! */struct cvar_t{	char *name;	char *string;	char *latched_string;	// for CVAR_LATCH vars	int flags;	qboolean modified;	// set each time the cvar is changed	float value;	cvar_t *next;};extern cvar_t *cvar_vars;extern qboolean userinfo_modified; enum{	/* contents flags are separate bits. a given brush can contribute	 * multiple content bits. multiple brushes can be in a single leaf	 * lower bits are stronger, and will eat weaker brushes completely */	CONTENTS_SOLID = 1<<0,	// an eye is never valid in a solid	CONTENTS_WINDOW = 1<<1,	// translucent, but not watery	CONTENTS_AUX = 1<<2,	CONTENTS_LAVA = 1<<3,	CONTENTS_SLIME = 1<<4,	CONTENTS_WATER = 1<<5,	CONTENTS_MIST = 1<<6,	LAST_VISIBLE_CONTENTS = 1<<6,	/* remaining contents are non-visible, and don't eat brushes */	CONTENTS_AREAPORTAL = 1<<15,	CONTENTS_PLAYERCLIP = 1<<16,	CONTENTS_MONSTERCLIP = 1<<17,	/* currents can be added to any other contents, and may be mixed */	CONTENTS_CURRENT_0 = 1<<18,	CONTENTS_CURRENT_90 = 1<<19,	CONTENTS_CURRENT_180 = 1<<20,	CONTENTS_CURRENT_270 = 1<<21,	CONTENTS_CURRENT_UP = 1<<22,	CONTENTS_CURRENT_DOWN = 1<<23,	CONTENTS_ORIGIN = 1<<24,	// removed before bsping an entity	CONTENTS_MONSTER = 1<<25,	// should never be on a brush, only in game	CONTENTS_DEADMONSTER = 1<<26,	CONTENTS_DETAIL = 1<<27,	// brushes to be added after vis leafs	CONTENTS_TRANSLUCENT = 1<<28,	// auto set if any surface has trans	CONTENTS_LADDER = 1<<29, 	SURF_LIGHT = 1<<0,	// value will hold the light strength	SURF_SLICK = 1<<1,	// effects game physics	SURF_SKY = 1<<2,	// don't draw, but add to skybox	SURF_WARP = 1<<3,	// turbulent water warp	SURF_TRANS33 = 1<<4,	SURF_TRANS66 = 1<<5,	SURF_FLOWING = 1<<6,	// scroll towards angle	SURF_NODRAW = 1<<7,	// don't bother referencing the texture 	/* content masks */	MASK_ALL = -1,	MASK_SOLID = CONTENTS_SOLID|CONTENTS_WINDOW,	MASK_PLAYERSOLID = CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER,	MASK_DEADSOLID = CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW,	MASK_MONSTERSOLID = CONTENTS_SOLID|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER,	MASK_WATER = CONTENTS_WATER|CONTENTS_LAVA|CONTENTS_SLIME,	MASK_OPAQUE = CONTENTS_SOLID|CONTENTS_SLIME|CONTENTS_LAVA,	MASK_SHOT = CONTENTS_SOLID|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEADMONSTER,	MASK_CURRENT = CONTENTS_CURRENT_0|CONTENTS_CURRENT_90|CONTENTS_CURRENT_180|CONTENTS_CURRENT_270|CONTENTS_CURRENT_UP|CONTENTS_CURRENT_DOWN, 	// FIXME: eliminate AREA_ distinction?	/* SV_AreaEdicts() can return a list of either solid or trigger entities */	AREA_SOLID = 1<<0,	AREA_TRIGGERS = 1<<1}; /* !!! if this is changed, it must be changed in asm code too !!! */struct cplane_t{	vec3_t normal;	float dist;	uchar type;	// for fast side tests	uchar signbits;	// signx + (signy<<1) + (signz<<1)	uchar pad[2];};struct cmodel_t{	vec3_t mins;	vec3_t maxs;	vec3_t origin;	// for sounds or lights	int headnode;};struct csurface_t{	char name[16];	int flags;	int value;};/* used internally due to name len probs */struct mapsurface_t{	csurface_t c;	char rname[32];};/* a trace is returned when a box is swept through the world */struct trace_t{	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	csurface_t *surface;	// surface hit	int contents;	// contents on other side of surface hit	edict_t	*ent;	// not set by CM_*() functions}; /* information necessary for client side movement prediction */typedef enum pmtype_t{	/* can accelerate and turn */	PM_NORMAL,	PM_SPECTATOR,	/* no acceleration or turning */	PM_DEAD,	PM_GIB,	// different bounding box	PM_FREEZE}pmtype_t; enum{	PMF_DUCKED = 1<<0,	PMF_JUMP_HELD = 1<<1,	PMF_ON_GROUND = 1<<2,	PMF_TIME_WATERJUMP = 1<<3,	// pm_time is waterjump	PMF_TIME_LAND = 1<<4,	// pm_time is time before rejump	PMF_TIME_TELEPORT = 1<<5,	// pm_time is non-moving time	/* temporarily disables prediction (used for grappling hook) */	PMF_NO_PREDICTION = 1<<6,};/* this structure needs to be communicated bit-accurate from the server to the * client to guarantee that prediction stays in sync, so no floats are used. * if any part of the game code modifies this struct, it will result in a * prediction error of some degree. */struct pmove_state_t{	pmtype_t pm_type;	short origin[3];	// 12.3	short velocity[3];	// 12.3	uchar pm_flags;	// ducked, jump_held, etc	uchar pm_time;	// each unit = 8 ms	short gravity;	/* add to command angles to get view direction changed by spawns,	 * rotating objects and teleporters */	short delta_angles[3];}; enum{	BUTTON_ATTACK = 1<<0,	BUTTON_USE = 1<<1,	BUTTON_ANY = 1<<7,	// any key whatsoever 	MAXTOUCH = 32};/* sent to the server each client frame */struct usercmd_t{	uchar msec;	uchar buttons;	short angles[3];	short forwardmove;	short sidemove;	short upmove;	uchar impulse;	// remove?	uchar lightlevel;	// light level the player is standing on};struct pmove_t{	pmove_state_t s;	// state (in / out)	/* command (in) */	usercmd_t cmd;	qboolean snapinitial;	// if s has been changed outside pmove	/* results (out) */	int numtouch;	edict_t	*touchents[MAXTOUCH]; 	vec3_t viewangles;	// clamped	float viewheight;	vec3_t mins;	// bounding box size	vec3_t maxs;	edict_t	*groundentity;	int watertype;	int waterlevel;	/* callbacks to test the world */	trace_t	(*trace)(vec3_t, vec3_t, vec3_t, vec3_t);	int	(*pointcontents)(vec3_t);}; enum{	/* entity_state_t->effects	 * Effects are things handled on the client side (lights, particles, frame	 * animations) that happen constantly on the given entity. An entity that has	 * effects will be sent to the client even if it has a zero index model. */	EF_ROTATE = 1<<0,	// rotate (bonus items)	EF_GIB = 1<<1,	// leave a trail	EF_BLASTER = 1<<3,	// redlight + trail	EF_ROCKET = 1<<4,	// redlight + trail	EF_GRENADE = 1<<5,	EF_HYPERBLASTER = 1<<6,	EF_BFG = 1<<7,	EF_COLOR_SHELL = 1<<8,	EF_POWERSCREEN = 1<<9,	EF_ANIM01 = 1<<10,	// automatically cycle between frames 0 and 1 at 2 hz	EF_ANIM23 = 1<<11,	// automatically cycle between frames 2 and 3 at 2 hz	EF_ANIM_ALL = 1<<12,	// automatically cycle through all frames at 2hz	EF_ANIM_ALLFAST = 1<<13,	// automatically cycle through all frames at 10hz	EF_FLIES = 1<<14,	EF_QUAD = 1<<15,	EF_PENT = 1<<16,	EF_TELEPORTER = 1<<17,	// particle fountain	EF_FLAG1 = 1<<18,	EF_FLAG2 = 1<<19,	EF_IONRIPPER = 1<<20,	EF_GREENGIB = 1<<21,	EF_BLUEHYPERBLASTER = 1<<22,	EF_SPINNINGLIGHTS = 1<<23,	EF_PLASMA = 1<<24,	EF_TRAP = 1<<25,	/* ROGUE */	EF_TRACKER = 1<<26,	EF_DOUBLE = 1<<27,	EF_SPHERETRANS = 1<<28,	EF_TAGTRAIL = 1<<29,	EF_HALF_DAMAGE = 1<<30,	EF_TRACKERTRAIL = 1<<31, 	/* entity_state_t->renderfx */	RF_MINLIGHT = 1<<0,	// allways have some light (viewmodel)	RF_VIEWERMODEL = 1<<1,	// don't draw through eyes, only mirrors	RF_WEAPONMODEL = 1<<2,	// only draw through eyes	RF_FULLBRIGHT = 1<<3,	// allways draw full intensity	RF_DEPTHHACK = 1<<4,	// for view weapon Z crunching	RF_TRANSLUCENT = 1<<5,	RF_FRAMELERP = 1<<6,	RF_BEAM = 1<<7,	RF_CUSTOMSKIN = 1<<8,	// skin is an index in image_precache	RF_GLOW = 1<<9,		// pulse lighting for bonus items	RF_SHELL_RED = 1<<10,	RF_SHELL_GREEN = 1<<11,	RF_SHELL_BLUE = 1<<12,	/* ROGUE */	RF_IR_VISIBLE = 1<<15,	RF_SHELL_DOUBLE = 1<<16,	RF_SHELL_HALF_DAM = 1<<17,	RF_USE_DISGUISE = 1<<18, 	/* player_state_t->refdef */	RDF_UNDERWATER = 1<<0,	// warp the screen as apropriate	RDF_NOWORLDMODEL = 1<<1,	// used for player configuration screen	/* ROGUE */	RDF_IRGOGGLES = 1<<2,	RDF_UVGOGGLES = 1<<3, 	/* muzzle flashes, player effects */	MZ_BLASTER = 0,	MZ_MACHINEGUN = 1,	MZ_SHOTGUN = 2,	MZ_CHAINGUN1 = 3,	MZ_CHAINGUN2 = 4,	MZ_CHAINGUN3 = 5,	MZ_RAILGUN = 6,	MZ_ROCKET = 7,	MZ_GRENADE = 8,	MZ_LOGIN = 9,	MZ_LOGOUT = 10,	MZ_RESPAWN = 11,	MZ_BFG = 12,	MZ_SSHOTGUN = 13,	MZ_HYPERBLASTER = 14,	MZ_ITEMRESPAWN = 15,	MZ_IONRIPPER = 16,	MZ_BLUEHYPERBLASTER = 17,	MZ_PHALANX = 18,	MZ_SILENCED = 128,	// bit flag ORed with one of the above numbers	/* ROGUE */	MZ_ETF_RIFLE = 30,	MZ_UNUSED = 31,	MZ_SHOTGUN2 = 32,	MZ_HEATBEAM = 33,	MZ_BLASTER2 = 34,	MZ_TRACKER = 35,	MZ_NUKE1 = 36,	MZ_NUKE2 = 37,	MZ_NUKE4 = 38,	MZ_NUKE8 = 39, 	/* monster muzzle flashes */	MZ2_TANK_BLASTER_1 = 1,	MZ2_TANK_BLASTER_2 = 2,	MZ2_TANK_BLASTER_3 = 3,	MZ2_TANK_MACHINEGUN_1 = 4,	MZ2_TANK_MACHINEGUN_2 = 5,	MZ2_TANK_MACHINEGUN_3 = 6,	MZ2_TANK_MACHINEGUN_4 = 7,	MZ2_TANK_MACHINEGUN_5 = 8,	MZ2_TANK_MACHINEGUN_6 = 9,	MZ2_TANK_MACHINEGUN_7 = 10,	MZ2_TANK_MACHINEGUN_8 = 11,

Lines 1–500 of 2930.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t