X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=progs.h;h=f08a73fc481aebcb5150f50f11c99f001cf289c4;hb=ed94238a0d022888f0e309b00d1f06ecbb497907;hp=874ba9f93ab0ed89102f198d44ae96d15defe326;hpb=dbce962f09403fd5888d0bd858ceefc90bc3ea2b;p=xonotic%2Fdarkplaces.git diff --git a/progs.h b/progs.h index 874ba9f9..f08a73fc 100644 --- a/progs.h +++ b/progs.h @@ -43,18 +43,17 @@ typedef struct link_s #define MAX_ENT_LEAFS 256 typedef struct edict_s { - qboolean free; - link_t area; + qboolean free; // true if this edict is unused + link_t area; // physics area this edict is linked into #ifdef QUAKEENTITIES - entity_state_t baseline; - entity_state_t deltabaseline; // LordHavoc: previous frame + entity_state_t baseline; // baseline values + entity_state_t deltabaseline; // LordHavoc: previous frame #endif - int suspendedinairflag; // LordHavoc: gross hack to make floating items still work - float freetime; // sv.time when the object was freed - entvars_t v; // C exported fields from progs -// other fields from progs come immediately after + 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. @@ -93,7 +92,7 @@ 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; @@ -117,7 +116,7 @@ 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); @@ -127,42 +126,43 @@ 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 *)((qbyte *)sv.edicts + (n) * pr_edict_size) : EDICT_NUM_ERROR(n)) : EDICT_NUM_ERROR(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) ((edict_t *)( (qbyte *)e + pr_edict_size)) +#define NEXT_EDICT(e) ((e) + 1) -#define EDICT_TO_PROG(e) ((qbyte *)e - (qbyte *)sv.edicts) -#define PROG_TO_EDICT(e) ((edict_t *)((qbyte *)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 *)((qbyte *)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]; @@ -172,7 +172,7 @@ 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; @@ -183,5 +183,8 @@ void PR_Execute_ProgsLoaded(void); void ED_PrintEdicts (void); void ED_PrintNum (int ent); +char *PR_GetString (int num); +int PR_SetString (char *s); + #endif