974 lines · 27.8 KB · C
RawDownload
typedef struct link_t link_t;typedef struct game_import_t game_import_t;typedef struct game_export_t game_export_t;typedef struct gitem_armor_t gitem_armor_t;typedef struct gitem_t gitem_t;typedef struct game_locals_t game_locals_t;typedef struct level_locals_t level_locals_t;typedef struct spawn_temp_t spawn_temp_t;typedef struct moveinfo_t moveinfo_t;typedef struct mframe_t mframe_t;typedef struct mmove_t mmove_t;typedef struct monsterinfo_t monsterinfo_t;typedef struct field_t field_t;typedef struct client_persistant_t client_persistant_t;typedef struct client_respawn_t client_respawn_t;typedef struct edict_t edict_t;typedef struct gclient_t gclient_t; extern cvar_t *maxentities;extern cvar_t *deathmatch;extern cvar_t *coop;extern cvar_t *dmflags;extern cvar_t *skill;extern cvar_t *fraglimit;extern cvar_t *timelimit;extern cvar_t *password;extern cvar_t *spectator_password;extern cvar_t *g_select_empty;extern cvar_t *dedicated;extern cvar_t *filterban;extern cvar_t *sv_gravity;extern cvar_t *sv_maxvelocity;extern cvar_t *gun_x, *gun_y, *gun_z;extern cvar_t *sv_rollspeed;extern cvar_t *sv_rollangle;extern cvar_t *run_pitch;extern cvar_t *run_roll;extern cvar_t *bob_up;extern cvar_t *bob_pitch;extern cvar_t *bob_roll;extern cvar_t *sv_cheats;extern cvar_t *maxclients;extern cvar_t *maxspectators;extern cvar_t *flood_msgs;extern cvar_t *flood_persecond;extern cvar_t *flood_waitdelay;extern cvar_t *sv_maplist; enum{	GAME_API_VERSION = 3, 	/* edict->svflags */	SVF_NOCLIENT = 1<<0,	// don't send entity to clients, even if it has effects	SVF_DEADMONSTER = 1<<1,	// treat as CONTENTS_DEADMONSTER for collision	SVF_MONSTER = 1<<2,	// treat as CONTENTS_MONSTER for collision 	MAX_ENT_CLUSTERS = 16}; /* edict->solid values */typedef enum solid_t{	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; /* link_t is only used for entity area links now */struct link_t{	link_t *prev;	link_t *next;}; struct game_import_t{	void	(*bprintf)(int, char *, ...);	void	(*dprintf)(char *, ...);	void	(*cprintf)(edict_t *, int, char *, ...);	void	(*centerprintf)(edict_t *, char *, ...);	void	(*sound)(edict_t *, int, int, float, float, float);	void	(*positioned_sound)(vec3_t, edict_t *, int, int, float, float, float);	/* config strings hold all the index strings, the lightstyles, and misc	 * data like the sky definition and cdtrack. all of the current	 * configstrings are sent to clients when they connect, and changes are	 * sent to all connected clients. */	void	(*configstring)(int, char *);	void	(*error)(char *, ...);	/* the *index functions create configstrings and some internal server	 * state */	int	(*modelindex)(char *);	int	(*soundindex)(char *);	int	(*imageindex)(char *);	void	(*setmodel)(edict_t *, char *);	/* collision detection */	trace_t	(*trace)(vec3_t, vec3_t, vec3_t, vec3_t, edict_t *, int);	int	(*pointcontents)(vec3_t);	qboolean	(*inPVS)(vec3_t, vec3_t);	qboolean	(*inPHS)(vec3_t, vec3_t);	void	(*SetAreaPortalState)(int, qboolean);	qboolean	(*AreasConnected)(int, int);	/* an entity will never be sent to a client or used for collision if it	 * is not passed to linkentity.  If the size, position, or solidity	 * changes, it must be relinked. */	void	(*linkentity)(edict_t *);	/* call before removing an interactive edict */	void	(*unlinkentity)(edict_t *);	int	(*BoxEdicts)(vec3_t, vec3_t, edict_t **, int, int);	/* player movement code common with client prediction */	void	(*Pmove)(pmove_t *);	/* network messaging */	void	(*multicast)(vec3_t, multicast_t);	void	(*unicast)(edict_t *, qboolean);	void	(*WriteChar)(int);	void	(*WriteByte)(int);	void	(*WriteShort)(int);	void	(*WriteLong)(int);	void	(*WriteFloat)(float);	void	(*WriteString)(char *);	void	(*WritePosition)(vec3_t);	// some fractional bits	void	(*WriteDir)(vec3_t);	// single byte encoded, very coarse	void	(*WriteAngle)(float);	/* managed memory allocation */	void*	(*TagMalloc)(int, int);	void	(*TagFree)(void *);	void	(*FreeTags)(int);	/* console variable interaction */	cvar_t*	(*cvar)(char *, char *, int);	cvar_t*	(*cvar_set)(char *, char *);	cvar_t*	(*cvar_forceset)(char *, char *);	/* ClientCommand and ServerCommand parameter access */	int	(*argc)(void);	char*	(*argv)(int);	char*	(*args)(void);	// concatenation of all argv >= 1	/* add commands to the server console as if they were typed in for map	 * changing, etc */	void	(*AddCommandString)(char *);	void	(*DebugGraph)(float, int);};extern game_import_t gi; struct game_export_t{	int apiversion;	/* the init function will only be called when a game starts, not each	 * time a level is loaded.  Persistant data for clients and the server	 * can be allocated in init */	void	(*Init)(void);	void	(*Shutdown)(void);	/* each new level entered will cause a call to SpawnEntities */	void	(*SpawnEntities)(char *, char *, char *);	/* Read/Write Game is for storing persistant cross level information	 * about the world state and the clients. WriteGame is called every	 * time a level is exited. ReadGame is called on a loadgame. */	void	(*WriteGame)(char *, qboolean);	void	(*ReadGame)(char *);	/* ReadLevel is called after the default map information has been	 * loaded with SpawnEntities */	void	(*WriteLevel)(char *);	void	(*ReadLevel)(char *);	qboolean	(*ClientConnect)(edict_t *, char *);	void	(*ClientBegin)(edict_t *);	void	(*ClientUserinfoChanged)(edict_t *, char *);	void	(*ClientDisconnect)(edict_t *);	void	(*ClientCommand)(edict_t *);	void	(*ClientThink)(edict_t *, usercmd_t *);	void	(*RunFrame)(void);	/* ServerCommand will be called when an "sv <command>" command is	 * issued on the server console. the game can issue gi.argc() or	 * gi.argv() commands to get the rest of the parameters */	void	(*ServerCommand)(void);	/* global variables shared between game and server: the edict array is	 * allocated in the game dll so it can vary in size from one game to	 * another. the size will be fixed when ge->Init() is called */	edict_t *edicts;	int edict_size;	int num_edicts;	// current number, <= max_edicts	int max_edicts;};extern game_export_t globals; game_export_t *GetGameAPI(game_import_t *); #define	GAMEVERSION	"baseq2"#define DAMAGE_TIME	0.5	// view pitching times#define	FALL_TIME	0.3#define	FRAMETIME	0.1enum{	/* edict->spawnflags */	SPAWNFLAG_NOT_EASY = 1<<8,	SPAWNFLAG_NOT_MEDIUM = 1<<9,	SPAWNFLAG_NOT_HARD = 1<<10,	SPAWNFLAG_NOT_DEATHMATCH = 1<<11,	SPAWNFLAG_NOT_COOP = 1<<12,	/* edict->flags */	FL_FLY = 1<<0,	FL_SWIM = 1<<1,	// implied immunity to drowining	FL_IMMUNE_LASER = 1<<2,	FL_INWATER = 1<<3,	FL_GODMODE = 1<<4,	FL_NOTARGET = 1<<5,	FL_IMMUNE_SLIME = 1<<6,	FL_IMMUNE_LAVA = 1<<7,	FL_PARTIALGROUND = 1<<8,	// not all corners are valid	FL_WATERJUMP = 1<<9,	// player jumping out of water	FL_TEAMSLAVE = 1<<10,	// not the first on the team	FL_NO_KNOCKBACK = 1<<11,	FL_POWER_ARMOR = 1<<12,	// power armor (if any) is active	FL_RESPAWN = 1<<31,	// used for item respawning 	/* memory tags to allow dynamic memory to be cleaned up */	TAG_GAME = 765,	// clear when unloading the dll	TAG_LEVEL = 766,	// clear when loading a new level	MELEE_DISTANCE = 80,	BODY_QUEUE_SIZE = 8, 	/* deadflag */	DEAD_NO = 0,	DEAD_DYING = 1,	DEAD_DEAD = 2,	DEAD_RESPAWNABLE = 3,	/* range */	RANGE_MELEE = 0,	RANGE_NEAR = 1,	RANGE_MID = 2,	RANGE_FAR = 3,	/* gib types */	GIB_ORGANIC = 0,	GIB_METALLIC = 1,	/* monster ai flags */	AI_STAND_GROUND = 1<<0,	AI_TEMP_STAND_GROUND = 1<<1,	AI_SOUND_TARGET = 1<<2,	AI_LOST_SIGHT = 1<<3,	AI_PURSUIT_LAST_SEEN = 1<<4,	AI_PURSUE_NEXT = 1<<5,	AI_PURSUE_TEMP = 1<<6,	AI_HOLD_FRAME = 1<<7,	AI_GOOD_GUY = 1<<8,	AI_BRUTAL = 1<<9,	AI_NOSTEP = 1<<10,	AI_DUCKED = 1<<11,	AI_COMBAT_POINT = 1<<12,	AI_MEDIC = 1<<13,	AI_RESURRECTING = 1<<14,	/* monster attack state */	AS_STRAIGHT = 1,	AS_SLIDING = 2,	AS_MELEE = 3,	AS_MISSILE = 4,	/* armor types */	ARMOR_NONE = 0,	ARMOR_JACKET = 1,	ARMOR_COMBAT = 2,	ARMOR_BODY = 3,	ARMOR_SHARD = 4,	/* power armor types */	POWER_ARMOR_NONE = 0,	POWER_ARMOR_SCREEN = 1,	POWER_ARMOR_SHIELD = 2,	/* handedness values */	RIGHT_HANDED = 0,	LEFT_HANDED = 1,	CENTER_HANDED = 2,	/* game.serverflags values */	SFL_CROSS_TRIGGER_1 = 1<<0,	SFL_CROSS_TRIGGER_2 = 1<<1,	SFL_CROSS_TRIGGER_3 = 1<<2,	SFL_CROSS_TRIGGER_4 = 1<<3,	SFL_CROSS_TRIGGER_5 = 1<<4,	SFL_CROSS_TRIGGER_6 = 1<<5,	SFL_CROSS_TRIGGER_7 = 1<<6,	SFL_CROSS_TRIGGER_8 = 1<<7,	SFL_CROSS_TRIGGER_MASK = 0xff,	/* noise types for PlayerNoise */	PNOISE_SELF = 0,	PNOISE_WEAPON = 1,	PNOISE_IMPACT = 2,}; typedef enum damage_t{	DAMAGE_NO,	DAMAGE_YES,	// will take damage if hit	DAMAGE_AIM	// auto targeting recognizes this}damage_t;typedef enum weaponstate_t{	WEAPON_READY, 	WEAPON_ACTIVATING,	WEAPON_DROPPING,	WEAPON_FIRING}weaponstate_t;typedef enum ammo_t{	AMMO_BULLETS,	AMMO_SHELLS,	AMMO_ROCKETS,	AMMO_GRENADES,	AMMO_CELLS,	AMMO_SLUGS}ammo_t; /* edict->movetype values */typedef enum movetype_t{	MOVETYPE_NONE,	// never moves	MOVETYPE_NOCLIP,	// origin and angles change with no interaction	MOVETYPE_PUSH,	// no clip to world, push on box contact	MOVETYPE_STOP,	// no clip to world, stops on box contact	MOVETYPE_WALK,	// gravity	MOVETYPE_STEP,	// gravity, special edge handling	MOVETYPE_FLY,	MOVETYPE_TOSS,	// gravity	MOVETYPE_FLYMISSILE,	// extra size to monsters	MOVETYPE_BOUNCE}movetype_t; struct gitem_armor_t{	int base_count;	int max_count;	float normal_protection;	float energy_protection;	int armor;}; enum{	/* gitem_t->flags */	IT_WEAPON = 1<<0,		// use makes active weapon	IT_AMMO = 1<<1,	IT_ARMOR = 1<<2,	IT_STAY_COOP = 1<<3,	IT_KEY = 1<<4,	IT_POWERUP = 1<<5,	/* gitem_t->weapmodel for weapons indicates model index */	WEAP_BLASTER = 1, 	WEAP_SHOTGUN = 2, 	WEAP_SUPERSHOTGUN = 3, 	WEAP_MACHINEGUN = 4, 	WEAP_CHAINGUN = 5, 	WEAP_GRENADES = 6, 	WEAP_GRENADELAUNCHER = 7, 	WEAP_ROCKETLAUNCHER = 8, 	WEAP_HYPERBLASTER = 9, 	WEAP_RAILGUN = 10,	WEAP_BFG = 11};struct gitem_t{	char *classname;	// spawning name	qboolean	(*pickup)(edict_t *, edict_t *);	void	(*use)(edict_t *, gitem_t *);	void	(*drop)(edict_t *, gitem_t *);	void	(*weaponthink)(edict_t *);	char *pickup_sound;	char *world_model;	int world_model_flags;	char *view_model;	/* client side info */	char *icon;	char *pickup_name;	// for printing on pickup	int count_width;	// number of digits to display by icon	int quantity;	// for ammo how much, for weapons how much is used per shot	char *ammo;	// for weapons	int flags;	// IT_* flags	int weapmodel;	// weapon model index (for weapons)	void *info;	int tag;	/* string of all models, sounds, and images this item will use */	char *precaches;};extern gitem_t itemlist[]; /* this structure is left intact through an entire game it should be * initialized at dll load time, and read/written to the server.ssv file for * savegames */struct game_locals_t{	char helpmessage1[512];	char helpmessage2[512];	/* flash F1 icon if non 0, play sound and increment only if 1, 2, or 3 */	int helpchanged;	gclient_t *clients;	// [maxclients]	/* can't store spawnpoint in level, because it would get overwritten	 * by the savegame restore */	char spawnpoint[512];	// needed for coop respawns	/* store latched cvars here that we want to get at often */	int maxclients;	int maxentities;	/* cross level triggers */	int serverflags;	int num_items;	qboolean autosaved;};extern game_locals_t game; /* this structure is cleared as each map is entered; it is read/written to the * level.sav file for savegames */struct level_locals_t{	int framenum;	float time;	char level_name[MAX_QPATH];	// the descriptive name (Outer Base, etc)	char mapname[MAX_QPATH];	// the server name (base1, etc)	char nextmap[MAX_QPATH];	// go here when fraglimit is hit	/* intermission state */	float intermissiontime;	// time the intermission was started	char *changemap;	int exitintermission;	vec3_t intermission_origin;	vec3_t intermission_angle;	edict_t *sight_client;	// changed once each frame for coop games	edict_t *sight_entity;	int sight_entity_framenum;	edict_t *sound_entity;	int sound_entity_framenum;	edict_t *sound2_entity;	int sound2_entity_framenum;	int pic_health;	int total_secrets;	int found_secrets;	int total_goals;	int found_goals;	int total_monsters;	int killed_monsters;	edict_t *current_entity;	// entity running from G_RunFrame	int body_que;	// dead bodies	int power_cubes;	// ugly necessity for coop};extern level_locals_t level; /* spawn_temp_t is only used to hold entity field values that can be set from * the editor, but aren't actualy present in edict_t during gameplay */struct spawn_temp_t{	/* world vars */	char *sky;	float skyrotate;	vec3_t skyaxis;	char *nextmap; 	int lip;	int distance;	int height;	char *noise;	float pausetime;	char *item;	char *gravity;	float minyaw;	float maxyaw;	float minpitch;	float maxpitch;};extern spawn_temp_t st; struct moveinfo_t{	/* fixed data */	vec3_t start_origin;	vec3_t start_angles;	vec3_t end_origin;	vec3_t end_angles;	int sound_start;	int sound_middle;	int sound_end;	float accel;	float speed;	float decel;	float distance;	float wait;	/* state data */	int state;	vec3_t dir;	float current_speed;	float move_speed;	float next_speed;	float remaining_distance;	float decel_distance;	void	(*endfunc)(edict_t *);}; struct mframe_t{	void	(*aifunc)(edict_t *, float);	float dist;	void	(*thinkfunc)(edict_t *);}; struct mmove_t{	int firstframe;	int lastframe;	mframe_t *frame;	void	(*endfunc)(edict_t *);}; struct monsterinfo_t{	mmove_t *currentmove;	int aiflags;	int nextframe;	float scale;	void	(*stand)(edict_t *);	void	(*idle)(edict_t *);	void	(*search)(edict_t *);	void	(*walk)(edict_t *);	void	(*run)(edict_t *);	void	(*dodge)(edict_t *, edict_t *, float);	void	(*attack)(edict_t *);	void	(*melee)(edict_t *);	void	(*sight)(edict_t *, edict_t *);	qboolean	(*checkattack)(edict_t *);	float pausetime;	float attack_finished;	vec3_t saved_goal;

Lines 1–500 of 974.

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