]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - progs.h
qdefs: Define separate FLOAT_ and DOUBLE_ versions of lossless format and true for...
[xonotic/darkplaces.git] / progs.h
diff --git a/progs.h b/progs.h
index 485280f6188925a9f88abd5354f044cdfb3a5211..466521a7530cdc1cc3cd1f7e9b6a53e073c7c65b 100644 (file)
--- a/progs.h
+++ b/progs.h
@@ -8,7 +8,7 @@ of the License, or (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 See the GNU General Public License for more details.
 
@@ -18,166 +18,146 @@ 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
-
-typedef union eval_s
+#include "qtypes.h"
+
+
+#define ENTITYGRIDAREAS 16
+#define MAX_ENTITYCLUSTERS 16
+
+#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
+
+#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
 {
-       string_t                string;
-       float                   _float;
-       float                   vector[3];
-       func_t                  function;
-       int                             _int;
-       int                             edict;
-} eval_t;      
-
-// LordHavoc: increased number of leafs per entity limit from 16 to 64
-#define        MAX_ENT_LEAFS   64
-typedef struct edict_s
+       int type;
+       vec3_t v1;
+       vec3_t v2;
+       struct edict_odefunc_s *next;
+}edict_odefunc_t;
+#endif
+
+typedef struct edict_engineprivate_s
 {
-       qboolean        free;
-       link_t          area;                           // linked to a division node or leaf
-       
-       int                     num_leafs;
-       short           leafnums[MAX_ENT_LEAFS];
-
-       entity_state_t  baseline;
-       entity_state_t  deltabaseline; // LordHavoc: previous frame
-       
-       float           freetime;                       // sv.time when the object was freed
-       // LordHavoc: for MOVETYPE_STEP interpolation
-       vec3_t          steporigin;
-       vec3_t          stepangles;
-       vec3_t          stepoldorigin;
-       vec3_t          stepoldangles;
-       float           steplerptime;
-       // LordHavoc: delta compression
-       float           nextfullupdate; // every second a full update is forced
-       entvars_t       v;                                      // C exported fields from progs
-// other fields from progs come immediately after
-} edict_t;
-#define        EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area)
-
-// 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_drawonlytoclient;
-extern int eval_colormod;
-extern int eval_ping;
-extern int eval_movement;
-extern int eval_pmodel;
-
-#define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t*)((char*)&ed->v + fieldoffset) : NULL)
-
-//============================================================================
-
-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);
-void PR_LoadProgs (void);
-
-void PR_Profile_f (void);
-
-edict_t *ED_Alloc (void);
-void ED_Free (edict_t *ed);
-
-char   *ED_NewString (char *string);
-// returns a copy of the string allocated from the server's string heap
-
-void ED_Print (edict_t *ed);
-void ED_Write (FILE *f, edict_t *ed);
-char *ED_ParseEdict (char *data, edict_t *ent);
-
-void ED_WriteGlobals (FILE *f);
-void ED_ParseGlobals (char *data);
-
-void ED_LoadFromFile (char *data);
-
-edict_t *EDICT_NUM_ERROR(int n);
-#define EDICT_NUM(n) (n >= 0 ? (n < sv.max_edicts ? (edict_t *)((byte *)sv.edicts + (n) * pr_edict_size) : EDICT_NUM_ERROR(n)) : EDICT_NUM_ERROR(n))
-//define EDICT_NUM(n) ((edict_t *)(sv.edicts+ (n)*pr_edict_size))
-//define NUM_FOR_EDICT(e) (((byte *)(e) - sv.edicts)/pr_edict_size)
-
-//edict_t *EDICT_NUM(int n);
-int NUM_FOR_EDICT(edict_t *e);
-
-#define        NEXT_EDICT(e) ((edict_t *)( (byte *)e + pr_edict_size))
-
-#define        EDICT_TO_PROG(e) ((byte *)e - (byte *)sv.edicts)
-#define PROG_TO_EDICT(e) ((edict_t *)((byte *)sv.edicts + e))
-
-//============================================================================
-
-#define        G_FLOAT(o) (pr_globals[o])
-#define        G_INT(o) (*(int *)&pr_globals[o])
-#define        G_EDICT(o) ((edict_t *)((byte *)sv.edicts+ *(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_strings + *(string_t *)&pr_globals[o])
-#define        G_FUNCTION(o) (*(func_t *)&pr_globals[o])
-
-#define        E_FLOAT(e,o) (((float*)&e->v)[o])
-#define        E_INT(e,o) (*(int *)&((float*)&e->v)[o])
-#define        E_VECTOR(e,o) (&((float*)&e->v)[o])
-#define        E_STRING(e,o) (pr_strings + *(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 qboolean        pr_trace;
-extern dfunction_t     *pr_xfunction;
-extern int                     pr_xstatement;
-
-extern unsigned short          pr_crc;
-
-void PR_RunError (char *error, ...);
-
-void ED_PrintEdicts (void);
-void ED_PrintNum (int ent);
-
-//eval_t *GetEdictFieldValue(edict_t *ed, char *field);
-
+       // 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