]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - progsvm.h
redesigned csqc shared entity .Version handling, now internally uses a
[xonotic/darkplaces.git] / progsvm.h
index c6fc665370624af69c878c164b83b97a80494568..41640fc42910c913408ca9c51904f8de98817234 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -33,6 +33,9 @@ The code uses void pointers instead.
 #include "progdefs.h"                  // generated by program cdefs
 #include "clprogdefs.h"                        // generated by program cdefs
 
+// forward declaration of clgecko_t
+struct clgecko_s;
+
 typedef struct prvm_stack_s
 {
        int                             s;
@@ -64,6 +67,8 @@ typedef struct prvm_edict_private_s
 {
        qboolean free;
        float freetime;
+       int mark;
+       const char *allocation_origin;
 } prvm_edict_private_t;
 
 typedef struct prvm_edict_s
@@ -114,6 +119,7 @@ typedef struct prvm_edict_s
 
 #define PRVM_MAX_OPENFILES 256
 #define PRVM_MAX_OPENSEARCHES 128
+#define PRVM_MAX_GECKOINSTANCES 32
 
 typedef void (*prvm_builtin_t) (void);
 
@@ -122,7 +128,8 @@ typedef struct prvm_prog_fieldoffsets_s
 {
        // server and client use a lot of similar fields, so this is combined
        int SendEntity; // ssqc
-       int Version; // ssqc
+       int SendFlags; // ssqc
+       int Version; // ssqc (legacy)
        int alpha; // ssqc / csqc
        int ammo_cells1; // ssqc - Dissolution of Eternity mission pack
        int ammo_lava_nails; // ssqc - Dissolution of Eternity mission pack
@@ -188,8 +195,9 @@ typedef struct prvm_prog_fieldoffsets_s
        int message; // csqc
        int modelflags; // ssqc
        int movement; // ssqc
-       int nextthink; // common - used by OP_STATE
+       int movetypesteplandevent; // ssqc
        int netaddress; // ssqc
+       int nextthink; // common - used by OP_STATE
        int nodrawtoclient; // ssqc
        int pflags; // ssqc
        int ping; // ssqc
@@ -209,6 +217,8 @@ typedef struct prvm_prog_fieldoffsets_s
        int viewmodelforclient; // ssqc
        int viewzoom; // ssqc
        int yaw_speed; // ssqc / csqc
+       int clientcamera; // ssqc
+       int clientstatus; // ssqc
 }
 prvm_prog_fieldoffsets_t;
 
@@ -243,7 +253,9 @@ typedef struct prvm_prog_globaloffsets_s
        int dmg_save; // csqc
        int dmg_origin; // csqc
        int sb_showscores; // csqc
-       
+       int drawfont; // csqc / menu
+       int require_spawnfunc_prefix; // ssqc
+       int worldstatus; // ssqc
 }
 prvm_prog_globaloffsets_t;
 
@@ -253,6 +265,7 @@ typedef struct prvm_prog_funcoffsets_s
 {
        func_t CSQC_ConsoleCommand; // csqc
        func_t CSQC_Ent_Remove; // csqc
+       func_t CSQC_Ent_Spawn; // csqc DP_CSQC_ENT_SPAWN extension (BlackHC - TODO: needs to be added to dpextensions.qc)
        func_t CSQC_Ent_Update; // csqc
        func_t CSQC_Event; // csqc [515]: engine call this for its own needs so csqc can do some things according to what engine it's running on.  example: to say about edicts increase, whatever...
        func_t CSQC_Event_Sound; // csqc : called by engine when an incoming sound packet arrives so CSQC can act on it
@@ -264,6 +277,7 @@ typedef struct prvm_prog_funcoffsets_s
        func_t CSQC_Parse_TempEntity; // csqc [515]: very helpfull when you want to create your own particles/decals/etc for effects that already exist
        func_t CSQC_Shutdown; // csqc
        func_t CSQC_UpdateView; // csqc
+       func_t Gecko_Query; // csqc, mqc
        func_t EndFrame; // ssqc
        func_t RestoreGame; // ssqc
        func_t SV_ChangeTeam; // ssqc
@@ -271,11 +285,10 @@ typedef struct prvm_prog_funcoffsets_s
        func_t SV_PlayerPhysics; // ssqc
        func_t SV_OnEntityNoSpawnFunction; // ssqc
        func_t GameCommand; // any
+       func_t SV_Shutdown; // ssqc
 
        // menu qc only uses some functions, nothing else
-       func_t m_display; // mqc
        func_t m_draw; // mqc
-       func_t m_hide; // mqc
        func_t m_init; // mqc
        func_t m_keydown; // mqc
        func_t m_keyup; // mqc
@@ -284,6 +297,15 @@ typedef struct prvm_prog_funcoffsets_s
 }
 prvm_prog_funcoffsets_t;
 
+typedef struct prvm_stringbuffer_s
+{
+       int max_strings;
+       int num_strings;
+       char **strings;
+       const char *origin;
+}
+prvm_stringbuffer_t;
+
 // [INIT] variables flagged with this token can be initialized by 'you'
 // NOTE: external code has to create and free the mempools but everything else is done by prvm !
 typedef struct prvm_prog_s
@@ -315,9 +337,12 @@ typedef struct prvm_prog_s
        // (simple optimization of the free string search)
        int                                     firstfreeknownstring;
        const char                      **knownstrings;
-       unsigned char                           *knownstrings_freeable;
+       unsigned char           *knownstrings_freeable;
+       const char          **knownstrings_origin;
        const char                      ***stringshash;
 
+       memexpandablearray_t    stringbuffersarray;
+
        // all memory allocations related to this vm_prog (code, edicts, strings)
        mempool_t                       *progs_mempool; // [INIT]
 
@@ -339,6 +364,7 @@ typedef struct prvm_prog_s
        int                                     localstack_used;
 
        unsigned short          headercrc; // [INIT]
+       unsigned short          headercrc2; // [INIT] alternate CRC for tenebrae progs.dat
 
        unsigned short          filecrc;
 
@@ -346,7 +372,10 @@ 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];
+       const char *         openfiles_origin[PRVM_MAX_OPENFILES];
        fssearch_t                      *opensearches[PRVM_MAX_OPENSEARCHES];
+       const char *         opensearches_origin[PRVM_MAX_OPENSEARCHES];
+       struct clgecko_s                *opengeckoinstances[PRVM_MAX_GECKOINSTANCES];
 
        // copies of some vars that were former read from sv
        int                                     num_edicts;
@@ -359,8 +388,8 @@ typedef struct prvm_prog_s
        int                                     reserved_edicts; // [INIT]
 
        prvm_edict_t            *edicts;
-       void                            *edictsfields;
-       void                            *edictprivate;
+       void                                    *edictsfields;
+       void                                    *edictprivate;
 
        // size of the engine private struct
        int                                     edictprivate_size; // [INIT]
@@ -377,7 +406,7 @@ typedef struct prvm_prog_s
        char                            *name; // [INIT]
 
        // flag - used to store general flags like PRVM_GE_SELF, etc.
-       int                                     flag;
+       int                             flag;
 
        char                            *extensionstring; // [INIT]
 
@@ -385,6 +414,7 @@ typedef struct prvm_prog_s
 
        // used to indicate whether a prog is loaded
        qboolean                        loaded;
+       qboolean                        leaktest_active;
 
 //     prvm_builtin_mem_t  *mem_list;
 
@@ -471,6 +501,8 @@ void PRVM_PrintFunction_f (void);
 void PRVM_PrintState(void);
 void PRVM_CrashAll (void);
 void PRVM_Crash (void);
+void PRVM_ShortStackTrace(char *buf, size_t bufsize);
+const char *PRVM_AllocationOrigin();
 
 ddef_t *PRVM_ED_FindField(const char *name);
 ddef_t *PRVM_ED_FindGlobal(const char *name);
@@ -498,8 +530,9 @@ void PRVM_ED_ParseGlobals (const char *data);
 
 void PRVM_ED_LoadFromFile (const char *data);
 
-prvm_edict_t *PRVM_EDICT_NUM_ERROR(int n, char *filename, int fileline);
-#define        PRVM_EDICT_NUM(n) (((unsigned)(n) < (unsigned int)prog->max_edicts) ? prog->edicts + (n) : PRVM_EDICT_NUM_ERROR(n, __FILE__, __LINE__))
+unsigned int PRVM_EDICT_NUM_ERROR(unsigned int n, char *filename, int fileline);
+#define        PRVM_EDICT(n) (((unsigned)(n) < (unsigned int)prog->max_edicts) ? (unsigned int)(n) : PRVM_EDICT_NUM_ERROR((unsigned int)(n), __FILE__, __LINE__))
+#define        PRVM_EDICT_NUM(n) (prog->edicts + PRVM_EDICT(n))
 
 //int NUM_FOR_EDICT_ERROR(prvm_edict_t *e);
 #define PRVM_NUM_FOR_EDICT(e) ((int)((prvm_edict_t *)(e) - prog->edicts))