struct cvar_t
{
//
nothing outside the Cvar_*() functions should modify these fields!
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;
};
struct cplane_t
{
//
plane_t structure
//
!!! if this is changed, it must be changed in asm code too !!!
vec3_t
normal;
float
dist;
byte
type; // for fast side tests
byte
signbits; // signx + (signy<<1)
+ (signz<<1)
byte
pad[2];
};
struct cmodel_t
{
vec3_t
mins, maxs;
vec3_t
origin; // for sounds or lights
int
headnode;
};
struct csurface_t
{
char
name[16];
int
flags;
int
value;
};
struct trace_t
{
//
a trace is returned when a box is swept through the world
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
};
struct pmove_state_t
{
//
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.
pmtype_t
pm_type;
short
origin[3]; // 12.3
short
velocity[3]; // 12.3
byte
pm_flags; // ducked, jump_held, etc
byte
teleport_time;
short
gravity;
short
delta_angles[3]; // add to command angles
to get view direction
// changed by spawns, rotating objects, and teleporters
};
struct usercmd_t
{
//
usercmd_t is sent to the server each client frame
byte
msec;
byte
buttons;
short
angles[3];
short
forwardmove, sidemove, upmove;
byte
impulse; // remove?
byte
lightlevel; // light level the player
is standing on
};
struct pmove_t
{
//
state (in / out)
pmove_state_t
s;
//
command (in)
usercmd_t
cmd;
qboolean
snapinitial; // if s has been changed outside
pmove
//
results (out)
int
numtouch;
struct
edict_s *touchents[MAXTOUCH];
vec3_t
viewangles; // clamped
float
viewheight;
vec3_t mins, maxs; // bounding box size
struct
edict_s *groundentity;
int
watertype;
int
waterlevel;
//
callbacks to test the world
trace_t
(*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end);
int
(*pointcontents) (vec3_t point);
};
struct entity_state_t
{
//
entity_state_t is the information conveyed from the server
//
in an update message about entities that the client will
//
need to render in some way
int
number; // edict index
vec3_t
origin;
vec3_t
angles;
vec3_t
old_origin; // for lerping
int
modelindex;
int
modelindex2, modelindex3, modelindex4; //
weapons, CTF flags, etc
int
frame;
int
skinnum;
int
effects;
int
renderfx;
int
solid; // for client side prediction,
8*(bits 0-4) is x/y radius
// 8*(bits 5-9) is z down distance, 8(bits10-15) is z up
// gi.linkentity sets this properly
int
sound; // for looping sounds,
to guarantee shutoff
int
event; // impulse events -- muzzle
flashes, footsteps, etc
// events only go out for a single frame,
they
// are automatically cleared each frame
};
struct player_state_t
{
//
player_state_t is the information needed in addition to pmove_state_t
//
to rendered a view. There will only be 10 player_state_t sent each
second,
//
but the number of pmove_state_t changes will be reletive to client
//
frame rates
pmove_state_t
pmove; // for prediction
// these fields do not need to be communicated bit-precise
vec3_t
viewangles; // for fixed views
vec3_t
viewoffset; // add to pmovestate->origin
vec3_t
kick_angles; // add to view direction to get
render angles
// set by weapon kicks, pain effects, etc
vec3_t
gunangles;
vec3_t
gunoffset;
int
gunindex;
int
gunframe;
float
blend[4]; // rgba full screen effect
float
fov; // horizontal field of view
int rdflags; // refdef flags
short
stats[MAX_STATS]; // fast status bar
updates
};
struct link_t
{
//
link_t is only used for entity area links now
link_t
*prev, *next;
};
struct gclient_t
{
player_state_t
ps; // communicated by server to clients
int
ping;
//
the game dll can add anything it wants after
//
this point in the structure
};
struct edict_t
{
entity_state_t
s;
gclient_t
*client;
qboolean
inuse;
int
linkcount;
//
FIXME: move these fields to a server private sv_entity_t
link_t
area; // linked to a division
node or leaf
int
num_clusters; // if -1, use headnode
instead
int
clusternums[MAX_ENT_CLUSTERS];
int
headnode; // unused if num_clusters
!= -1
int
areanum, areanum2;
//================================
int
svflags; // SVF_NOCLIENT, SVF_DEADMONSTER,
SVF_MONSTER, etc
vec3_t
mins, maxs;
vec3_t
absmin, absmax, size;
solid_t
solid;
int
clipmask;
edict_t
*owner;
//
the game dll can add anything it wants after
//
this point in the structure
};
struct game_import_t
{
//
functions provided by the main engine
// special
messages
void
(*bprintf) (int printlevel, char *fmt, ...);
void
(*dprintf) (char *fmt, ...);
void
(*cprintf) (edict_t *ent, int printlevel, char *fmt, ...);
void
(*centerprintf) (edict_t *ent, char *fmt, ...);
void
(*sound) (edict_t *ent, int channel, int soundindex, float volume, float
attenuation, float timeofs);
void
(*positioned_sound) (vec3_t origin, edict_t *ent, int channel, int soundinedex,
float volume, float attenuation, float timeofs);
//
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 num, char *string);
void (*error) (char *fmt, ...);
//
new names can only be added during spawning
//
existing names can be looked up at any time
int
(*modelindex) (char *name);
int
(*soundindex) (char *name);
int
(*imageindex) (char *name);
void (*setmodel) (edict_t *ent, char *name);
//
collision detection
trace_t
(*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *passent,
int contentmask);
int
(*pointcontents) (vec3_t point);
qboolean
(*inPVS) (vec3_t p1, vec3_t p2);
qboolean
(*inPHS) (vec3_t p1, vec3_t p2);
void
(*SetAreaPortalState) (int portalnum, qboolean open);
qboolean
(*AreasConnected) (int area1, int area2);
//
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 *ent);
void
(*unlinkentity) (edict_t *ent); // call
before removing an interactive edict
int
(*BoxEdicts) (vec3_t mins, vec3_t maxs, edict_t **list, int maxcount, int
areatype);
void
(*Pmove) (pmove_t *pmove); // player
movement code common with client prediction
//
network messaging
void
(*multicast) (vec3_t origin, multicast_t to);
void
(*unicast) (edict_t *ent, qboolean reliable);
void
(*WriteChar) (int c);
void
(*WriteByte) (int c);
void
(*WriteShort) (int c);
void
(*WriteLong) (int c);
void
(*WriteFloat) (float f);
void
(*WriteString) (char *s);
void
(*WritePosition) (vec3_t pos); // some fractional
bits
void
(*WriteDir) (vec3_t pos); // single
byte encoded, very coarse
void
(*WriteAngle) (float f);
//
managed memory allocation
void
*(*TagMalloc) (int size, int tag);
void
(*TagFree) (void *block);
void
(*FreeTags) (int tag);
//
console variable interaction
cvar_t
*(*cvar) (char *var_name, char *value, int flags);
cvar_t
*(*cvar_set) (char *var_name, char *value);
cvar_t
*(*cvar_forceset) (char *var_name, char *value);
// ClientCommand
and coneole command parameter checking
int
(*argc) (void);
char
*(*argv) (int n);
char
*(*args) (void);
//
add commands to the server console as if they were typed in
//
for map changing, etc
void
(*AddCommandString) (char *text);
void
(*DebugGraph) (float value, int color);
};
struct game_export_t
{
//
functions exported by the game subsystem
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 *mapname, char *entstring, char *spawnpoint);
//
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 *filename);
void
(*ReadGame) (char *filename);
//
ReadLevel is called after the default map information has been
//
loaded with SpawnEntities, so any stored client spawn spots will
//
be used when the clients reconnect.
void
(*WriteLevel) (char *filename);
void
(*ReadLevel) (char *filename);
qboolean
(*ClientConnect) (edict_t *ent, char *userinfo, qboolean loadgame);
void
(*ClientBegin) (edict_t *ent, qboolean loadgame);
void
(*ClientUserinfoChanged) (edict_t *ent, char *userinfo);
void
(*ClientDisconnect) (edict_t *ent);
void
(*ClientCommand) (edict_t *ent);
void
(*ClientThink) (edict_t *ent, usercmd_t *cmd);
void (*RunFrame) (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;
};
struct gitem_armor_t
{
int
base_count;
int
max_count;
float
normal_protection;
float
energy_protection;
int
armor;
};
struct gitem_t
{
char
*classname; // spawning name
qboolean
(*pickup)(struct edict_s *ent, struct edict_s *other);
void
(*use)(struct edict_s *ent, struct gitem_s *item);
void
(*drop)(struct edict_s *ent, struct gitem_s *item);
void
(*weaponthink)(struct edict_s *ent);
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
void
*info;
int
tag;
char
*precaches; // string of all models,
sounds, and images this item will use
};
struct game_locals_t
{
//
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
char
helpmessage1[512];
char
helpmessage2[512];
qboolean
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;
//
items
int
num_items;
};
struct level_locals_t
{
//
this structure is cleared as each map is entered
//
it is read/written to the level.sav file for savegames
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;
int players; // FIXME: count when needed, don't store
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
edict_t
*body_que; // looped chain of
dead bodies
};
struct spawn_temp_t
{
//
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
//
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;
};
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 *self, float dist);
float
dist;
void
(*thinkfunc)(edict_t *self);
};
struct mmove_t
{
int
firstframe;
int
lastframe;
mframe_t
*frame;
void
(*endfunc)(edict_t *self);
};
struct monsterinfo_t
{
mmove_t
*currentmove;
int
aiflags;
int
nextframe;
float
scale;
void
(*stand)(edict_t *self);
void
(*idle)(edict_t *self);
void
(*search)(edict_t *self);
void
(*walk)(edict_t *self);
void
(*run)(edict_t *self);
void
(*dodge)(edict_t *self, edict_t *other, float eta);
void
(*attack)(edict_t *self);
void
(*melee)(edict_t *self);
void
(*sight)(edict_t *self, edict_t *other);
qboolean
(*checkattack)(edict_t *self);
float
pausetime;
float
attack_finished;
vec3_t
saved_goal;
float
search_time;
float
trail_time;
vec3_t
last_sighting;
int
attack_state;
int
lefty;
float
idle_time;
int
linkcount;
int
power_armor_type;
int
power_armor_power;
};
struct field_t
{
char
*name;
int
ofs;
fieldtype_t
type;
int
flags;
};
struct client_persistant_t
{
//
client data that stays across multiple level loads
char
userinfo[MAX_INFO_STRING];
char
netname[16];
char
sounddir[MAX_QPATH]; // player/male, etc
int
hand;
//
values saved and restored from edicts when changing levels
int
health;
int
max_health;
int
selected_item;
int
inventory[MAX_ITEMS];
//
ammo capacities
int
max_bullets;
int
max_shells;
int
max_rockets;
int
max_grenades;
int
max_cells;
int
max_slugs;
gitem_t
*weapon;
};
struct client_respawn_t
{
//
client data that staus across deathmatch respawns
int
enterframe; // level.framenum
the client entered the game
int
score; // frags, etc
vec3_t
cmd_angles; // angles sent over
in the last command
};
struct gclient_t
{
//
this structure is cleared on each PutClientInServer(),
//
except for 'client->pers'
// known
to server
player_state_t
ps; // communicated by server
to clients
int
ping;
//
private to game
client_persistant_t
pers;
client_respawn_t
resp;
pmove_state_t
old_pmove; // for detecting out-of-pmove changes
qboolean
showscores; // set layout stat
qboolean
showinventory; // set layout stat
qboolean
showhelpicon;
int ammo_index;
int
buttons;
int
oldbuttons;
int
latched_buttons;
qboolean weapon_thunk;
gitem_t *newweapon;
//
sum up damage over an entire frame, so
//
shotgun blasts give a single big kick
int
damage_armor; // damage absorbed by
armor
int
damage_parmor; // damage absorbed by
power armor
int
damage_blood; // damage taken out of
health
int
damage_knockback; // impact damage
vec3_t
damage_from; // origin for vector calculation
float killer_yaw; // when dead, look at killer
weaponstate_t
weaponstate;
vec3_t
kick_angles; // weapon kicks
vec3_t
kick_origin;
float
v_dmg_roll, v_dmg_pitch, v_dmg_time; // damage
kicks
float
fall_time, fall_value; // for view drop
on fall
float
damage_alpha;
float
bonus_alpha;
vec3_t
damage_blend;
vec3_t
v_angle; // aiming direction
float
bobtime; // so off-ground doesn't
change it
vec3_t
oldviewangles;
vec3_t
oldvelocity;
float
next_drown_time;
int
old_waterlevel;
int
breather_sound;
int machinegun_shots; // for weapon raising
//
animation vars
int
anim_end;
int
anim_priority;
qboolean
anim_duck;
qboolean
anim_run;
//
powerup timers
float
quad_framenum;
float
invincible_framenum;
float
breather_framenum;
float
enviro_framenum;
qboolean
grenade_blew_up;
float
grenade_time;
int
silencer_shots;
int
weapon_sound;
float pickup_msg_time;
float
respawn_time; // can respawn when time
> this
};
struct edict_t
{
entity_state_t
s;
struct
gclient_s *client; // NULL if not a player
// the server expects the first part
// of gclient_s to be a player_state_t
// but the rest of it is opaque
qboolean
inuse;
int
linkcount;
//
FIXME: move these fields to a server private sv_entity_t
link_t
area; // linked to a division
node or leaf
int
num_clusters; // if -1, use headnode
instead
int
clusternums[MAX_ENT_CLUSTERS];
int
headnode; // unused if num_clusters
!= -1
int
areanum, areanum2;
//================================
int
svflags;
vec3_t
mins, maxs;
vec3_t
absmin, absmax, size;
solid_t
solid;
int
clipmask;
edict_t
*owner;
//
DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER
//
EXPECTS THE FIELDS IN THAT ORDER!
//================================
int
movetype;
int
flags;
char
*model;
float
freetime; // sv.time when the
object was freed
//
//
only used locally in game, not by server
//
char
*message;
char
*classname;
int
spawnflags;
float timestamp;
float
angle; // set in qe3, -1 = up,
-2 = down
char
*target;
char
*targetname;
char
*killtarget;
char
*team;
char
*pathtarget;
char
*deathtarget;
char
*combattarget;
edict_t
*target_ent;
float
speed, accel, decel;
vec3_t
movedir;
vec3_t
pos1, pos2;
vec3_t
velocity;
vec3_t
avelocity;
int
mass;
float
air_finished;
float
gravity; // per entity gravity multiplier
(1.0 is normal)
// use for lowgrav artifact, flares
edict_t
*goalentity;
edict_t
*movetarget;
float
yaw_speed;
float
ideal_yaw;
float
nextthink;
void
(*prethink) (edict_t *ent);
void
(*think)(edict_t *self);
void
(*blocked)(edict_t *self, edict_t *other); //move
to moveinfo?
void
(*touch)(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf);
void
(*use)(edict_t *self, edict_t *other, edict_t *activator);
void
(*pain)(edict_t *self, edict_t *other, float kick, int damage);
void
(*die)(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage,
vec3_t point);
float
touch_debounce_time; // are all these
legit? do we need more/less of them?
float
pain_debounce_time;
float
damage_debounce_time;
float
fly_sound_debounce_time; //move to clientinfo
float
last_move_time;
int
health;
int
max_health;
int
gib_health;
int
deadflag;
qboolean
show_hostile;
float powerarmor_time;
char *map; // target_changelevel
int
viewheight; // height above origin where
eyesight is determined
int
takedamage;
int
dmg;
int
radius_dmg;
float
dmg_radius;
int
sounds; //make this a spawntemp
var?
int
count;
edict_t
*chain;
edict_t
*enemy;
edict_t
*oldenemy;
edict_t
*activator;
edict_t
*groundentity;
int
groundentity_linkcount;
edict_t
*teamchain;
edict_t
*teammaster;
edict_t
*mynoise; // can go in client only
edict_t
*mynoise2;
int
noise_index;
int
noise_index2;
float
volume;
float
attenuation;
//
timing variables
float
wait;
float
delay; // before firing targets
float
random;
float teleport_time;
int
watertype;
int
waterlevel;
vec3_t
move_origin;
vec3_t
move_angles;
//
move this to clientinfo?
int
light_level;
int style; // also used as areaportal number
gitem_t *item; // for bonus items
//
common data blocks
moveinfo_t
moveinfo;
monsterinfo_t
monsterinfo;
};
struct spawn_t
{
char
*name;
void
(*spawn)(edict_t *ent);
};