X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=progsvm.h;h=7e6250a4f8bfa7a80fb27c9f1898ef0d5dc750c8;hp=18768887c00b9051a4f677e522b82d2cd8478605;hb=5c77268d0a473dfcf784d69343a3ddabcbd5ab33;hpb=a953951712448641f8f9263add258b6a0fa58dbc diff --git a/progsvm.h b/progsvm.h index 18768887..7e6250a4 100644 --- a/progsvm.h +++ b/progsvm.h @@ -31,6 +31,7 @@ The code uses void pointers instead. #include "pr_comp.h" // defs shared with qcc #include "progdefs.h" // generated by program cdefs +#include "clprogdefs.h" // generated by program cdefs /* typedef union vm_eval_s @@ -203,11 +204,13 @@ typedef struct prvm_edict_s union { void *vp; - entvars_t *server; + entvars_t *server; + cl_entvars_t *client; } fields; } prvm_edict_t; -#define PRVM_GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (prvm_eval_t *)((qbyte *)ed->fields.vp + fieldoffset) : NULL) +#define PRVM_GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (prvm_eval_t *)((unsigned char *)ed->fields.vp + fieldoffset) : NULL) +#define PRVM_GETGLOBALFIELDVALUE(fieldoffset) (fieldoffset ? (prvm_eval_t *)((unsigned char *)prog->globals.generic + fieldoffset) : NULL) /*// this struct is the basic requirement for a qc prog typedef struct prvm_pr_globalvars_s @@ -242,8 +245,11 @@ typedef struct prvm_builtin_mem_s #define PRVM_FE_CHAIN 4 #define PRVM_OP_STATE 1 -#define PRVM_MAX_STACK_DEPTH 256 -#define PRVM_LOCALSTACK_SIZE 2048 +#define PRVM_MAX_STACK_DEPTH 1024 +#define PRVM_LOCALSTACK_SIZE 16384 + +#define PRVM_MAX_OPENFILES 256 +#define PRVM_MAX_OPENSEARCHES 128 typedef void (*prvm_builtin_t) (void); @@ -261,9 +267,14 @@ typedef struct prvm_prog_s int edict_size; // in bytes int edictareasize; // LordHavoc: in bytes (for bound checking) + int *statement_linenums; // NULL if not available + + double *statement_profile; // only incremented if prvm_statementprofiling is on + union { float *generic; globalvars_t *server; + cl_globalvars_t *client; } globals; int maxknownstrings; @@ -272,6 +283,8 @@ typedef struct prvm_prog_s // (simple optimization of the free string search) int firstfreeknownstring; const char **knownstrings; + unsigned char *knownstrings_freeable; + const char ***stringshash; // all memory allocations related to this vm_prog (code, edicts, strings) mempool_t *progs_mempool; // [INIT] @@ -300,6 +313,9 @@ typedef struct prvm_prog_s //============================================================================ // until this point everything also exists (with the pr_ prefix) in the old vm + qfile_t *openfiles[PRVM_MAX_OPENFILES]; + fssearch_t *opensearches[PRVM_MAX_OPENSEARCHES]; + // copies of some vars that were former read from sv int num_edicts; // number of edicts for which space has been (should be) allocated @@ -310,7 +326,6 @@ typedef struct prvm_prog_s // number of reserved edicts (allocated from 1) int reserved_edicts; // [INIT] - prvm_edict_t *edicts; void *edictsfields; void *edictprivate; @@ -324,6 +339,10 @@ typedef struct prvm_prog_s float *time; float _time; + // allow writing to world entity fields, this is set by server init and + // cleared before first server frame + qboolean allowworldwrites; + // name of the prog, e.g. "Server", "Client" or "Menu" (used for text output) char *name; // [INIT] @@ -363,7 +382,7 @@ typedef struct prvm_prog_s void (*init_cmd)(void); // [INIT] used by PRVM_InitProg void (*reset_cmd)(void); // [INIT] used by PRVM_ResetProg - void (*error_cmd)(const char *format, ...); // [INIT] + void (*error_cmd)(const char *format, ...) DP_FUNC_PRINTF(1); // [INIT] } prvm_prog_t; @@ -415,13 +434,16 @@ void *_PRVM_Alloc (size_t buffersize, const char *filename, int fileline); void _PRVM_Free (void *buffer, const char *filename, int fileline); void _PRVM_FreeAll (const char *filename, int fileline); +void PRVM_Profile (int maxfunctions, int mininstructions); void PRVM_Profile_f (void); +void PRVM_PrintFunction_f (void); void PRVM_PrintState(void); void PRVM_CrashAll (void); void PRVM_Crash (void); int PRVM_ED_FindFieldOffset(const char *field); +int PRVM_ED_FindGlobalOffset(const char *global); ddef_t *PRVM_ED_FindField (const char *name); mfunction_t *PRVM_ED_FindFunction (const char *name); @@ -431,6 +453,7 @@ prvm_edict_t *PRVM_ED_Alloc (void); void PRVM_ED_Free (prvm_edict_t *ed); void PRVM_ED_ClearEdict (prvm_edict_t *e); +void PRVM_PrintFunctionStatements (const char *name); 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); @@ -481,7 +504,7 @@ void PRVM_ED_PrintNum (int ent); const char *PRVM_GetString(int num); int PRVM_SetEngineString(const char *s); -int PRVM_AllocString(int bufferlength, char **pointer); +int PRVM_AllocString(size_t bufferlength, char **pointer); void PRVM_FreeString(int num); //============================================================================ @@ -497,12 +520,11 @@ void PRVM_FreeString(int num); #define PRVM_End prog = 0 #endif - //#define PRVM_SAFENAME #ifndef PRVM_SAFENAME - #define PRVM_NAME (prog->name) +# define PRVM_NAME (prog->name) #else - #define PRVM_NAME (prog->name ? prog->name : "Unknown prog name") +# define PRVM_NAME (prog->name ? prog->name : "Unknown prog name") #endif // helper macro to make function pointer calls easier @@ -529,6 +551,7 @@ qboolean PRVM_ProgLoaded(int prognr); int PRVM_GetProgNr(void); +void VM_Warning(const char *fmt, ...) DP_FUNC_PRINTF(1); // TODO: fill in the params //void PRVM_Create();