📄 q_shared.h
字号:
unsigned short LittleUnsignedShort(unsigned short l);
#endif
#endif
void Swap_Init (void);
#ifndef _H2INC
#ifdef SIN
const char *va(const char *format, ...);
#else
char *va(char *format, ...);
#endif
#endif
//=============================================
//
// key / value info strings
//
#ifdef SIN
#define MAX_INFO_KEY 128
#define MAX_INFO_VALUE 128
#else
#define MAX_INFO_KEY 64
#define MAX_INFO_VALUE 64
#endif
#define MAX_INFO_STRING 512
#ifdef SIN
const char *Info_ValueForKey (const char *s, const char *key);
void Info_RemoveKey (char *s, const char *key);
void Info_SetValueForKey (char *s, const char *key, const char *value);
#else
char *Info_ValueForKey (char *s, char *key);
void Info_RemoveKey (char *s, char *key);
void Info_SetValueForKey (char *s, char *key, char *value);
#endif
/*
==============================================================
SYSTEM SPECIFIC
==============================================================
*/
extern int curtime; // time returned by last Sys_Milliseconds
int Sys_Milliseconds (void);
void Sys_Mkdir (char *path);
// large block stack allocation routines
void *Hunk_Begin (int maxsize);
void *Hunk_Alloc (int size);
void Hunk_Free (void *buf);
int Hunk_End (void);
// directory searching
#define SFF_ARCH 0x01
#define SFF_HIDDEN 0x02
#define SFF_RDONLY 0x04
#define SFF_SUBDIR 0x08
#define SFF_SYSTEM 0x10
/*
** pass in an attribute mask of things you wish to REJECT
*/
#ifdef SIN
const char *Sys_FindFirst (const char *path, unsigned musthave, unsigned canthave );
const char *Sys_FindNext ( unsigned musthave, unsigned canthave );
#else
char *Sys_FindFirst (char *path, unsigned musthave, unsigned canthave );
char *Sys_FindNext ( unsigned musthave, unsigned canthave );
#endif
void Sys_FindClose (void);
// this is only here so the functions in q_shared.c and q_shwin.c can link
#ifndef _H2INC
#ifdef SIN
void Sys_Error (const char *error, ...);
void Com_Printf (const char *msg, ...);
#else
void Sys_Error (char *error, ...);
void Com_Printf (char *msg, ...);
#endif
#endif
/*
==========================================================
CVARS (console variables)
==========================================================
*/
#ifndef CVAR
#define CVAR
#define CVAR_ARCHIVE 1 // set to cause it to be saved to vars.rc
#define CVAR_USERINFO 2 // added to userinfo when changed
#define CVAR_SERVERINFO 4 // added to serverinfo when changed
#define CVAR_NOSET 8 // don't allow change from console at all,
// but can be set from the command line
#define CVAR_LATCH 16 // save changes until server restart
// nothing outside the Cvar_*() functions should modify these fields!
typedef struct cvar_s
{
#ifdef _H2INC
char *AMD_name;
#else
char *name;
#endif
char *string;
char *latched_string; // for CVAR_LATCH vars
int flags;
qboolean modified; // set each time the cvar is changed
float value;
struct cvar_s *next;
} cvar_t;
#endif // CVAR
/*
==============================================================
COLLISION DETECTION
==============================================================
*/
// lower bits are stronger, and will eat weaker brushes completely
#define CONTENTS_SOLID 1 // an eye is never valid in a solid
#define CONTENTS_WINDOW 2 // translucent, but not watery
#ifdef SIN
#define CONTENTS_FENCE 4
#else
#define CONTENTS_AUX 4
#endif
#define CONTENTS_LAVA 8
#ifdef SIN
#define CONTENTS_LIGHTVOLUME 16
#else
#define CONTENTS_SLIME 16
#endif
#define CONTENTS_WATER 32
#define CONTENTS_MIST 64
#define LAST_VISIBLE_CONTENTS 64
// remaining contents are non-visible, and don't eat brushes
#ifdef SIN
#define CONTENTS_DUMMYFENCE 0x1000
#endif
#define CONTENTS_AREAPORTAL 0x8000
#define CONTENTS_PLAYERCLIP 0x10000
#define CONTENTS_MONSTERCLIP 0x20000
// currents can be added to any other contents, and may be mixed
#define CONTENTS_CURRENT_0 0x40000
#define CONTENTS_CURRENT_90 0x80000
#define CONTENTS_CURRENT_180 0x100000
#define CONTENTS_CURRENT_270 0x200000
#define CONTENTS_CURRENT_UP 0x400000
#define CONTENTS_CURRENT_DOWN 0x800000
#define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity
#define CONTENTS_MONSTER 0x2000000 // should never be on a brush, only in game
#define CONTENTS_DEADMONSTER 0x4000000
#define CONTENTS_DETAIL 0x8000000 // brushes to be added after vis leafs
#define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans
#define CONTENTS_LADDER 0x20000000
#define CONTENTS_SHOOTABLE 0x40000000 // is shootable, but may not be blocking
#define SURF_LIGHT 0x1 // value will hold the light strength
#define SURF_SLICK 0x2 // effects game physics
#define SURF_SKY 0x4 // don't draw, but add to skybox
#define SURF_WARP 0x8 // turbulent water warp
#ifdef SIN
#define SURF_NONLIT 0x10 // surface is not lit
#define SURF_NOFILTER 0x20 // surface is not filtered
#else
#define SURF_TRANS33 0x10
#define SURF_TRANS66 0x20
#endif
#ifdef SIN
#define SURF_CONVEYOR 0x40
#else
#define SURF_FLOWING 0x40 // scroll towards angle
#endif
#define SURF_NODRAW 0x80 // don't bother referencing the texture
#ifdef SIN
#define SURF_WAVY 0x400 // surface has waves
#define SURF_RICOCHET 0x800 // projectiles bounce literally bounce off this surface
#define SURF_PRELIT 0x1000 // surface has intensity information for pre-lighting
#define SURF_CONSOLE 0x4000 // surface has a console on it
#define SURF_HARDWAREONLY 0x10000 // surface should only do things in hardware
#define SURF_DAMAGE 0x20000 // surface can be damaged
#define SURF_WEAK 0x40000 // surface has weak hit points
#define SURF_NORMAL 0x80000 // surface has normal hit points
#define SURF_ADD 0x100000 // surface will be additive
#define SURF_ENVMAPPED 0x200000 // surface is envmapped
#define SURF_RANDOMANIMATE 0x400000 // surface start animating on a random frame
#define SURF_ANIMATE 0x800000 // surface animates
#define SURF_RNDTIME 0x1000000 // time between animations is random
#define SURF_TRANSLATE 0x2000000 // surface translates
#define SURF_NOMERGE 0x4000000 // surface is not merged in csg phase
#define SURF_TYPE_BIT0 0x8000000 // 0 bit of surface type
#define SURF_TYPE_BIT1 0x10000000 // 1 bit of surface type
#define SURF_TYPE_BIT2 0x20000000 // 2 bit of surface type
#define SURF_TYPE_BIT3 0x40000000 // 3 bit of surface type
#define MASK_SURF_TYPE (SURF_TYPE_BIT0|SURF_TYPE_BIT1|SURF_TYPE_BIT2|SURF_TYPE_BIT3)
#define SURF_START_BIT 27
#define SURFACETYPE_FROM_FLAGS( x ) ( ( x >> (SURF_START_BIT) ) & 0xf )
#define SURF_TYPE_SHIFT(x) ( (x) << (SURF_START_BIT) ) // macro for getting proper bit mask
#define SURF_TYPE_NONE SURF_TYPE_SHIFT(0)
#define SURF_TYPE_WOOD SURF_TYPE_SHIFT(1)
#define SURF_TYPE_METAL SURF_TYPE_SHIFT(2)
#define SURF_TYPE_STONE SURF_TYPE_SHIFT(3)
#define SURF_TYPE_CONCRETE SURF_TYPE_SHIFT(4)
#define SURF_TYPE_DIRT SURF_TYPE_SHIFT(5)
#define SURF_TYPE_FLESH SURF_TYPE_SHIFT(6)
#define SURF_TYPE_GRILL SURF_TYPE_SHIFT(7)
#define SURF_TYPE_GLASS SURF_TYPE_SHIFT(8)
#define SURF_TYPE_FABRIC SURF_TYPE_SHIFT(9)
#define SURF_TYPE_MONITOR SURF_TYPE_SHIFT(10)
#define SURF_TYPE_GRAVEL SURF_TYPE_SHIFT(11)
#define SURF_TYPE_VEGETATION SURF_TYPE_SHIFT(12)
#define SURF_TYPE_PAPER SURF_TYPE_SHIFT(13)
#define SURF_TYPE_DUCT SURF_TYPE_SHIFT(14)
#define SURF_TYPE_WATER SURF_TYPE_SHIFT(15)
#endif
#ifdef SIN
#define STRONG_DAMAGE_VALUE 200
#define NORMAL_DAMAGE_VALUE 90
#define WEAK_DAMAGE_VALUE 10
#endif
// content masks
#ifdef SIN
#define MASK_ALL (-1)
#define MASK_SOLID (CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_FENCE)
#define MASK_PLAYERSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_FENCE)
#define MASK_DEADSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_FENCE)
#define MASK_MONSTERSOLID (CONTENTS_SOLID|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_FENCE)
#define MASK_WATER (CONTENTS_WATER|CONTENTS_LAVA)
#define MASK_OPAQUE (CONTENTS_SOLID|CONTENTS_LAVA)
#define MASK_SHOT (CONTENTS_SOLID|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEADMONSTER|CONTENTS_SHOOTABLE)
#define MASK_PROJECTILE (CONTENTS_SOLID|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEADMONSTER|CONTENTS_SHOOTABLE|CONTENTS_FENCE)
#define MASK_CURRENT (CONTENTS_CURRENT_0|CONTENTS_CURRENT_90|CONTENTS_CURRENT_180|CONTENTS_CURRENT_270|CONTENTS_CURRENT_UP|CONTENTS_CURRENT_DOWN)
#define MASK_SOLIDNONFENCE (CONTENTS_SOLID|CONTENTS_WINDOW)
#else
#define MASK_ALL (-1)
#define MASK_SOLID (CONTENTS_SOLID|CONTENTS_WINDOW)
#define MASK_PLAYERSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER)
#define MASK_DEADSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW)
#define MASK_MONSTERSOLID (CONTENTS_SOLID|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER)
#define MASK_WATER (CONTENTS_WATER|CONTENTS_LAVA|CONTENTS_SLIME)
#define MASK_OPAQUE (CONTENTS_SOLID|CONTENTS_SLIME|CONTENTS_LAVA)
#define MASK_SHOT (CONTENTS_SOLID|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEADMONSTER)
#define MASK_CURRENT (CONTENTS_CURRENT_0|CONTENTS_CURRENT_90|CONTENTS_CURRENT_180|CONTENTS_CURRENT_270|CONTENTS_CURRENT_UP|CONTENTS_CURRENT_DOWN)
#endif
// gi.BoxEdicts() can return a list of either solid or trigger entities
// FIXME: eliminate AREA_ distinction?
#define AREA_SOLID 1
#define AREA_TRIGGERS 2
// plane_t structure
// !!! if this is changed, it must be changed in asm code too !!!
typedef struct cplane_s
{
vec3_t normal;
float dist;
#ifdef _H2INC
unsigned char AMD_type; // for fast side tests
unsigned char signbits; // signx + (signy<<1) + (signz<<1)
unsigned char pad[2];
#else
byte type; // for fast side tests
byte signbits; // signx + (signy<<1) + (signz<<1)
byte pad[2];
#endif
} cplane_t;
// structure offset for asm code
#define CPLANE_NORMAL_X 0
#define CPLANE_NORMAL_Y 4
#define CPLANE_NORMAL_Z 8
#define CPLANE_DIST 12
#define CPLANE_TYPE 16
#define CPLANE_SIGNBITS 17
#define CPLANE_PAD0 18
#define CPLANE_PAD1 19
typedef struct cmodel_s
{
vec3_t mins, maxs;
vec3_t origin; // for sounds or lights
int headnode;
} cmodel_t;
typedef struct csurface_s
{
#ifdef SIN
char groupname[64]; // Name of the surface
int groupnumber; // Number of the surface
int flags; // Surface flags
int style; // Style
qboolean trans_state; // Translation on/off
float trans_mag; // Translation magnitude
float trans_angle; // Translation angle
float translucence; // Translucence of the surface
float frequency; // Frequency of the wavy surface / restitution of that surface
float magnitude; // Magnitude of the wavy surface / friction of that surface
float upload_width; // Power of 2 upload width
float upload_height; // Power of 2 upload height
vec3_t transvec; // Translation vector
float nonlit; // Nonlit vale
int animation_frame; // Animation frame to display
int numframes; // Number of frames of animation
float animtime; // Animation time between frames
int frameoffset; // Offset for random start frame animation
float nextanimtime; // Time in the future to change the animation
float delta_s; // Delta s for the texture coordinates
float delta_t; // Delta t for the texture coordinates
float last_update_time; // Last time the surface was updated
vec3_t color; // Color of the surface
int leaf; // Leaf number this surface resides in
struct csurface_s *next; // Next surface in the chain
#else
char name[16];
int flags;
int value;
#endif
} csurface_t;
#ifdef SIN
typedef struct
{
qboolean valid;
#ifdef _H2INC
int AMD_group;
#else
int group;
#endif
int parentgroup;
int tri_num;
vec3_t position;
vec3_t normal;
float damage_multiplier;
} sinmdl_intersection_t;
#endif
// 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
csurface_t *surface; // surface hit
int contents; // contents on other side of surface hit
struct edict_s *ent; // not set by CM_*() functions
#ifdef SIN
vec3_t dir; // the direction of the trace
sinmdl_intersection_t intersect; // set if the trace hit a specific polygon
#endif
} trace_t;
// pmove_state_t is the information necessary for client side movement
// prediction
typedef enum
{
// can accelerate and turn
PM_NORMAL,
#ifdef SIN
PM_ZOOM,
PM_INVEHICLE_ZOOM,
#endif
PM_SPECTATOR,
#ifdef SIN
PM_INVEHICLE,
PM_LOCKVIEW,
#endif
// no acceleration or turning
PM_DEAD,
PM_GIB, // different bounding box
#ifdef SIN
PM_FREEZE,
PM_MOVECAPTURED, // using a movement capturer
PM_ONBIKE, // added for hoverbike
PM_ATTACHVIEW // added for guided missile
#else
PM_FREEZE
#endif
} pmtype_t;
// pmove->pm_flags
#define PMF_DUCKED (1<<0)
#define PMF_JUMP_HELD (1<<1)
#define PMF_ON_GROUND (1<<2)
#define PMF_TIME_WATERJUMP (1<<3) // pm_time is waterjump
#define PMF_TIME_LAND (1<<4) // pm_time is time before rejump
#define PMF_TIME_TELEPORT (1<<5) // pm_time is non-moving time
#define PMF_NO_PREDICTION (1<<6) // temporarily disables prediction (used for grappling hook)
#ifdef SIN
#define PMF_MOREBITS (1<<7)
#define PMF_OLDNOCLIP (1<<8)
#define PMF_MUTANT (1<<9)
#define PMF_ADRENALINE (1<<10)
#define PMF_NOAIRCLAMP (1<<11)
#endif
#ifdef SIN
#define CROUCH_HEIGHT 36
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -