X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=progs.h;h=466521a7530cdc1cc3cd1f7e9b6a53e073c7c65b;hp=f08a73fc481aebcb5150f50f11c99f001cf289c4;hb=fe7a27c1f9ee6904eddecd54f0fcae461806d43c;hpb=e5004f482e1e5ff6c17e6b9252a0ff1381ce90db diff --git a/progs.h b/progs.h index f08a73fc..466521a7 100644 --- a/progs.h +++ b/progs.h @@ -20,171 +20,144 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef PROGS_H #define PROGS_H - #include "pr_comp.h" // defs shared with qcc -#include "progdefs.h" // generated by program cdefs +#include "qtypes.h" -typedef union eval_s -{ - string_t string; - float _float; - float vector[3]; - func_t function; - int _int; - int edict; -} eval_t; - -typedef struct link_s -{ - struct link_s *prev, *next; -} link_t; -// LordHavoc: increased number of leafs per entity limit from 16 to 256 -#define MAX_ENT_LEAFS 256 -typedef struct edict_s -{ - qboolean free; // true if this edict is unused - link_t area; // physics area this edict is linked into +#define ENTITYGRIDAREAS 16 +#define MAX_ENTITYCLUSTERS 16 -#ifdef QUAKEENTITIES - entity_state_t baseline; // baseline values - entity_state_t deltabaseline; // LordHavoc: previous frame +#ifdef PRVM_64 +#define PRVM_FLOAT_IS_TRUE_FOR_INT(x) DOUBLE_IS_TRUE_FOR_INT(x) +#define PRVM_FLOAT_LOSSLESS_FORMAT DOUBLE_LOSSLESS_FORMAT +#define PRVM_VECTOR_LOSSLESS_FORMAT DOUBLE_VECTOR_LOSSLESS_FORMAT +#else +#define PRVM_FLOAT_IS_TRUE_FOR_INT(x) FLOAT_IS_TRUE_FOR_INT(x) +#define PRVM_FLOAT_LOSSLESS_FORMAT FLOAT_LOSSLESS_FORMAT +#define PRVM_VECTOR_LOSSLESS_FORMAT FLOAT_VECTOR_LOSSLESS_FORMAT #endif - int suspendedinairflag; // LordHavoc: gross hack to make floating items still work - float freetime; // sv.time when the object was freed - entvars_t *v; // edict fields -} edict_t; - -// LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue... see pr_edict.c for the functions which use these. -extern int eval_gravity; -extern int eval_button3; -extern int eval_button4; -extern int eval_button5; -extern int eval_button6; -extern int eval_button7; -extern int eval_button8; -extern int eval_glow_size; -extern int eval_glow_trail; -extern int eval_glow_color; -extern int eval_items2; -extern int eval_scale; -extern int eval_alpha; -extern int eval_renderamt; // HalfLife support -extern int eval_rendermode; // HalfLife support -extern int eval_fullbright; -extern int eval_ammo_shells1; -extern int eval_ammo_nails1; -extern int eval_ammo_lava_nails; -extern int eval_ammo_rockets1; -extern int eval_ammo_multi_rockets; -extern int eval_ammo_cells1; -extern int eval_ammo_plasma; -extern int eval_idealpitch; -extern int eval_pitch_speed; -extern int eval_viewmodelforclient; -extern int eval_nodrawtoclient; -extern int eval_exteriormodeltoclient; -extern int eval_drawonlytoclient; -extern int eval_ping; -extern int eval_movement; -extern int eval_pmodel; -extern int eval_punchvector; -extern int eval_viewzoom; - -#define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t *)((qbyte *)ed->v + fieldoffset) : NULL) - - -extern dfunction_t *SV_PlayerPhysicsQC; -extern dfunction_t *EndFrameQC; - -//============================================================================ - -extern dprograms_t *progs; -extern dfunction_t *pr_functions; -extern char *pr_strings; -extern ddef_t *pr_globaldefs; -extern ddef_t *pr_fielddefs; -extern dstatement_t *pr_statements; -extern globalvars_t *pr_global_struct; -extern float *pr_globals; // same as pr_global_struct - -extern int pr_edict_size; // in bytes -extern int pr_edictareasize; // LordHavoc: for bounds checking - -//============================================================================ - -void PR_Init (void); - -void PR_ExecuteProgram (func_t fnum, const char *errormessage); -void PR_LoadProgs (void); - -void PR_Profile_f (void); - -void PR_Crash (void); - -edict_t *ED_Alloc (void); -void ED_Free (edict_t *ed); - -char *ED_NewString (const char *string); -// returns a copy of the string allocated from the server's string heap - -void ED_Print (edict_t *ed); -void ED_Write (QFile *f, edict_t *ed); -const char *ED_ParseEdict (const char *data, edict_t *ent); - -void ED_WriteGlobals (QFile *f); -void ED_ParseGlobals (const char *data); - -void ED_LoadFromFile (const char *data); - -edict_t *EDICT_NUM_ERROR(int n); -#define EDICT_NUM(n) ((n >= 0 && n < sv.max_edicts) ? sv.edictstable[(n)] : EDICT_NUM_ERROR(n)) - -int NUM_FOR_EDICT(edict_t *e); - -#define NEXT_EDICT(e) ((e) + 1) - -int EDICT_TO_PROG(edict_t *e); -edict_t *PROG_TO_EDICT(int n); - -//============================================================================ - -#define G_FLOAT(o) (pr_globals[o]) -#define G_INT(o) (*(int *)&pr_globals[o]) -#define G_EDICT(o) (PROG_TO_EDICT(*(int *)&pr_globals[o])) -#define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o)) -#define G_VECTOR(o) (&pr_globals[o]) -#define G_STRING(o) (PR_GetString(*(string_t *)&pr_globals[o])) -//#define G_FUNCTION(o) (*(func_t *)&pr_globals[o]) - -// FIXME: make these go away? -#define E_FLOAT(e,o) (((float*)e->v)[o]) -//#define E_INT(e,o) (((int*)e->v)[o]) -//#define E_VECTOR(e,o) (&((float*)e->v)[o]) -#define E_STRING(e,o) (PR_GetString(*(string_t *)&((float*)e->v)[o])) - -extern int type_size[8]; - -typedef void (*builtin_t) (void); -extern builtin_t *pr_builtins; -extern int pr_numbuiltins; - -extern int pr_argc; - -extern int pr_trace; -extern dfunction_t *pr_xfunction; -extern int pr_xstatement; - -extern unsigned short pr_crc; - -void PR_Execute_ProgsLoaded(void); - -void ED_PrintEdicts (void); -void ED_PrintNum (int ent); - -char *PR_GetString (int num); -int PR_SetString (char *s); +#ifdef USEODE +#define GEOMTYPE_NONE -1 +#define GEOMTYPE_SOLID 0 +#define GEOMTYPE_BOX 1 +#define GEOMTYPE_SPHERE 2 +#define GEOMTYPE_CAPSULE 3 +#define GEOMTYPE_TRIMESH 4 +#define GEOMTYPE_CYLINDER 5 +#define GEOMTYPE_CAPSULE_X 6 +#define GEOMTYPE_CAPSULE_Y 7 +#define GEOMTYPE_CAPSULE_Z 8 +#define GEOMTYPE_CYLINDER_X 9 +#define GEOMTYPE_CYLINDER_Y 10 +#define GEOMTYPE_CYLINDER_Z 11 + +#define JOINTTYPE_NONE 0 +#define JOINTTYPE_POINT 1 +#define JOINTTYPE_HINGE 2 +#define JOINTTYPE_SLIDER 3 +#define JOINTTYPE_UNIVERSAL 4 +#define JOINTTYPE_HINGE2 5 +#define JOINTTYPE_FIXED -1 + +#define FORCETYPE_NONE 0 +#define FORCETYPE_FORCE 1 +#define FORCETYPE_FORCEATPOS 2 +#define FORCETYPE_TORQUE 3 + +#define ODEFUNC_ENABLE 1 +#define ODEFUNC_DISABLE 2 +#define ODEFUNC_FORCE 3 +#define ODEFUNC_TORQUE 4 + +typedef struct edict_odefunc_s +{ + int type; + vec3_t v1; + vec3_t v2; + struct edict_odefunc_s *next; +}edict_odefunc_t; +#endif +typedef struct edict_engineprivate_s +{ + // mark for the leak detector + int mark; + // place in the code where it was allocated (for the leak detector) + const char *allocation_origin; + + // initially false to prevent projectiles from moving on their first frame + // (even if they were spawned by an synchronous client think) + qbool move; + + // cached cluster links for quick stationary object visibility checking + vec3_t cullmins, cullmaxs; + int pvs_numclusters; + int pvs_clusterlist[MAX_ENTITYCLUSTERS]; + + // physics grid areas this edict is linked into + link_t areagrid[ENTITYGRIDAREAS]; + // since the areagrid can have multiple references to one entity, + // we should avoid extensive checking on entities already encountered + int areagridmarknumber; + // mins/maxs passed to World_LinkEdict + vec3_t areamins, areamaxs; + + // PROTOCOL_QUAKE, PROTOCOL_QUAKEDP, PROTOCOL_NEHAHRAMOVIE, PROTOCOL_QUAKEWORLD + // baseline values + entity_state_t baseline; + + // LadyHavoc: gross hack to make floating items still work + int suspendedinairflag; + + // cached position to avoid redundant SV_CheckWaterTransition calls on monsters + qbool waterposition_forceupdate; // force an update on this entity (set by SV_PushMove code for moving water entities) + vec3_t waterposition_origin; // updates whenever this changes + + // used by PushMove to keep track of where objects were before they were + // moved, in case they need to be moved back + vec3_t moved_from; + vec3_t moved_fromangles; + + framegroupblend_t framegroupblend[MAX_FRAMEGROUPBLENDS]; + frameblend_t frameblend[MAX_FRAMEBLENDS]; + skeleton_t skeleton; + +#ifdef USEODE + // physics parameters + qbool ode_physics; + void *ode_body; + void *ode_geom; + void *ode_joint; + float *ode_vertex3f; + int *ode_element3i; + int ode_numvertices; + int ode_numtriangles; + edict_odefunc_t *ode_func; + vec3_t ode_mins; + vec3_t ode_maxs; + vec3_t ode_scale; + vec_t ode_mass; + float ode_friction; + vec3_t ode_origin; + vec3_t ode_velocity; + vec3_t ode_angles; + vec3_t ode_avelocity; + qbool ode_gravity; + int ode_modelindex; + vec_t ode_movelimit; // smallest component of (maxs[]-mins[]) + matrix4x4_t ode_offsetmatrix; + matrix4x4_t ode_offsetimatrix; + int ode_joint_type; + int ode_joint_enemy; + int ode_joint_aiment; + vec3_t ode_joint_origin; // joint anchor + vec3_t ode_joint_angles; // joint axis + vec3_t ode_joint_velocity; // second joint axis + vec3_t ode_joint_movedir; // parameters + void *ode_massbuf; #endif +} +edict_engineprivate_t; +#endif