X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=progs.h;h=a8a5f3b7d0320ed07f1db3a391abae9bc9df7756;hb=7139b3ada26cb263795aa7f965197428c4c7ea7d;hp=bf960584f68d698f17001ff371d51d3c0a4320e9;hpb=eb3d71b9feaefca24fe80b9970eb11d07fd295b5;p=xonotic%2Fdarkplaces.git diff --git a/progs.h b/progs.h index bf960584..a8a5f3b7 100644 --- a/progs.h +++ b/progs.h @@ -18,6 +18,9 @@ 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 @@ -27,6 +30,7 @@ typedef union eval_s float _float; float vector[3]; func_t function; + int ivector[3]; int _int; int edict; } eval_t; @@ -36,24 +40,34 @@ 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 +// the entire server entity structure typedef struct edict_s { - qboolean free; - link_t area; + // true if this edict is unused + qboolean free; + // physics area this edict is linked into + link_t area; + // old entity protocol, not used #ifdef QUAKEENTITIES - entity_state_t baseline; - entity_state_t deltabaseline; // LordHavoc: previous frame + // baseline values + entity_state_t baseline; + // LordHavoc: previous frame + entity_state_t deltabaseline; #endif - float freetime; // sv.time when the object was freed - entvars_t v; // C exported fields from progs -// other fields from progs come immediately after + // LordHavoc: gross hack to make floating items still work + int suspendedinairflag; + // sv.time when the object was freed (to prevent early reuse which could + // mess up client interpolation or obscure severe QuakeC bugs) + float freetime; + // 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; + // edict fields (stored in another array) + entvars_t *v; } edict_t; -//#define EDICT_FROM_AREA(l) ((edict_t *)((byte *)l - (int)&(((edict_t *)0)->area))) -//#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; @@ -89,8 +103,9 @@ 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*)((char*)&ed->v + fieldoffset) : NULL) +#define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t *)((qbyte *)ed->v + fieldoffset) : NULL) extern dfunction_t *SV_PlayerPhysicsQC; @@ -114,53 +129,53 @@ extern int pr_edictareasize; // LordHavoc: for bounds checking void PR_Init (void); -void PR_ExecuteProgram (func_t fnum, char *errormessage); +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 (char *string); +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); -char *ED_ParseEdict (char *data, edict_t *ent); +const char *ED_ParseEdict (const char *data, edict_t *ent); void ED_WriteGlobals (QFile *f); -void ED_ParseGlobals (char *data); +void ED_ParseGlobals (const char *data); -void ED_LoadFromFile (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 ? (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) +#define EDICT_NUM(n) ((n >= 0 && n < sv.max_edicts) ? sv.edictstable[(n)] : EDICT_NUM_ERROR(n)) -//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 NEXT_EDICT(e) ((e) + 1) -#define EDICT_TO_PROG(e) ((byte *)e - (byte *)sv.edicts) -#define PROG_TO_EDICT(e) ((edict_t *)((byte *)sv.edicts + e)) +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) ((edict_t *)((byte *)sv.edicts+ *(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_strings + *(string_t *)&pr_globals[o]) -#define G_FUNCTION(o) (*(func_t *)&pr_globals[o]) +#define G_STRING(o) (PR_GetString(*(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]) +// 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]; @@ -170,16 +185,19 @@ extern int pr_numbuiltins; extern int pr_argc; -extern qboolean pr_trace; +extern int pr_trace; extern dfunction_t *pr_xfunction; extern int pr_xstatement; extern unsigned short pr_crc; -void PR_RunError (char *error, ...); +void PR_Execute_ProgsLoaded(void); void ED_PrintEdicts (void); void ED_PrintNum (int ent); -//eval_t *GetEdictFieldValue(edict_t *ed, char *field); +#define PR_GetString(num) (pr_strings + num) +#define PR_SetString(s) ((int) (s - pr_strings)) + +#endif