X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=progsvm.h;h=56b832d6f8523803af338988c3b4870153772b48;hb=36d38ac2f10b1f0d4006694075e06ad284204ffe;hp=e2af3432bacd586d8035d2b5ba14b34a43f79867;hpb=9e1d9d449d3f69ade2f01e16e47d1e0ab3cf1688;p=xonotic%2Fdarkplaces.git diff --git a/progsvm.h b/progsvm.h index e2af3432..56b832d6 100644 --- a/progsvm.h +++ b/progsvm.h @@ -170,7 +170,27 @@ typedef struct prvm_edict_s { // engine-private fields (stored in dynamically resized array) //edict_engineprivate_t *e; - prvm_edict_private_t *e; + union + { + prvm_edict_private_t *e; + void *vp; + // add other private structs as you desire + // new structs have to start with the elements of prvm_edit_private_t + // e.g. a new struct has to either look like this: + // typedef struct server_edict_private_s { + // prvm_edict_private_t base; + // vec3_t moved_from; + // vec3_t moved_fromangles; + // ... } server_edict_private_t; + // or: + // typedef struct server_edict_private_s { + // qboolean free; + // float freetime; + // vec3_t moved_from; + // vec3_t moved_fromangles; + // ... } server_edict_private_t; + // However, the first one should be preferred. + } p; // QuakeC fields (stored in dynamically resized array) //entvars_t *v; void *v; @@ -209,7 +229,6 @@ typedef struct prvm_builtin_mem_s */ #define PRVM_FE_CLASSNAME 8 #define PRVM_FE_CHAIN 4 -#define PRVM_GE_TIME 2 #define PRVM_OP_STATE 1 #define PRVM_MAX_STACK_DEPTH 256 @@ -243,7 +262,9 @@ typedef struct vm_prog_s mfunction_t *xfunction; int xstatement; - prvm_stack_t stack[PRVM_MAX_STACK_DEPTH]; + // stacktrace writes into stack[MAX_STACK_DEPTH] + // thus increase the array, so depth wont be overwritten + prvm_stack_t stack[PRVM_MAX_STACK_DEPTH+1]; int depth; int localstack[PRVM_LOCALSTACK_SIZE]; @@ -269,7 +290,10 @@ typedef struct vm_prog_s mempool_t *edicts_mempool; // has to be updated every frame - so the vm time is up-to-date - double time; + // AK changed so time will point to the time field (if there is one) else it points to _time + // actually should be double, but qc doesnt support it + float *time; + float _time; // name of the prog, e.g. "Server", "Client" or "Menu" (used in for text output) char *name; @@ -360,6 +384,7 @@ void PRVM_LoadProgs (const char *filename, int numrequiredfunc, char **required_ void PRVM_Profile_f (void); +void PRVM_PrintState(void); void PRVM_CrashAll (void); void PRVM_Crash (void); @@ -370,7 +395,7 @@ void PRVM_ED_ClearEdict (prvm_edict_t *e); char *PRVM_ED_NewString (const char *string); // returns a copy of the string allocated from the server's string heap -void PRVM_ED_Print (prvm_edict_t *ed); +void PRVM_ED_Print(prvm_edict_t *ed); void PRVM_ED_Write (qfile_t *f, prvm_edict_t *ed); const char *PRVM_ED_ParseEdict (const char *data, prvm_edict_t *ent); @@ -383,7 +408,7 @@ prvm_edict_t *PRVM_EDICT_NUM_ERROR(int n, char *filename, int fileline); #define PRVM_EDICT_NUM(n) (((n) >= 0 && (n) < prog->max_edicts) ? prog->edicts + (n) : PRVM_EDICT_NUM_ERROR(n, __FILE__, __LINE__)) //int NUM_FOR_EDICT_ERROR(edict_t *e); -#define PRVM_NUM_FOR_EDICT(e) ((prvm_edict_t *)(e) - prog->edicts) +#define PRVM_NUM_FOR_EDICT(e) ((int)((prvm_edict_t *)(e) - prog->edicts)) //int NUM_FOR_EDICT(edict_t *e); #define PRVM_NEXT_EDICT(e) ((e) + 1) @@ -405,7 +430,7 @@ prvm_edict_t *PRVM_EDICT_NUM_ERROR(int n, char *filename, int fileline); // FIXME: make these go away? #define PRVM_E_FLOAT(e,o) (((float*)e->v)[o]) -//#define PRVM_E_INT(e,o) (((int*)e->v)[o]) +#define PRVM_E_INT(e,o) (((int*)e->v)[o]) //#define PRVM_E_VECTOR(e,o) (&((float*)e->v)[o]) #define PRVM_E_STRING(e,o) (PRVM_GetString(*(string_t *)&((float*)e->v)[o])) @@ -418,15 +443,15 @@ void PRVM_ED_PrintEdicts_f (void); void PRVM_ED_PrintNum (int ent); #define PRVM_GetString(num) (prog->strings + num) -#define PRVM_SetString(s) ((int) (s - prog->strings)) +#define PRVM_SetString(s) ((s) != NULL ? (int) (s - prog->strings) : 0) //============================================================================ // used as replacement for a prog stack -#define PRVM_DEBUGPRSTACK +//#define PRVM_DEBUGPRSTACK #ifdef PRVM_DEBUGPRSTACK -#define PRVM_Begin if(prog != 0) Con_Printf("prog not 0(prog = %i)!\n", PRVM_GetProgNr()) +#define PRVM_Begin if(prog != 0) Con_Printf("prog not 0(prog = %i) in file: %s line: %i!\n", PRVM_GetProgNr(), __FILE__, __LINE__) #define PRVM_End prog = 0 #else #define PRVM_Begin @@ -444,11 +469,6 @@ void PRVM_ED_PrintNum (int ent); // helper macro to make function pointer calls easier #define PRVM_GCALL(func) if(prog->func) prog->func -/*#define PRVM_ERROR if(!prog->error_cmd) \ - Sys_Error("PRVM: No error_cmd specified !\n"); \ - else \ - prog->error_cmd*/ - #define PRVM_ERROR Host_Error // other prog handling functions