]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - progsvm.h
Experimental feature of saving buffers within savegame files (in extended section...
[xonotic/darkplaces.git] / progsvm.h
index 5d60d777488b5f4c4ab391c8a9db1efae5155e1a..938f29eabd6e29b1ee5c81aa435f0face6c27b2b 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -33,6 +33,10 @@ The code uses void pointers instead.
 #include "progdefs.h"                  // generated by program cdefs
 #include "clprogdefs.h"                        // generated by program cdefs
 
+#ifndef DP_SMALLMEMORY
+#define PROFILING
+#endif
+
 // forward declaration of clgecko_t
 struct clgecko_s;
 
@@ -80,7 +84,7 @@ typedef struct prvm_edict_s
        union
        {
                prvm_edict_private_t *required;
-               void *vp;
+               vec_t *vp;
                // FIXME: this server pointer really means world, not server
                // (it is used by both server qc and client qc, but not menu qc)
                edict_engineprivate_t *server;
@@ -104,7 +108,7 @@ typedef struct prvm_edict_s
        // QuakeC fields (stored in dynamically resized array)
        union
        {
-               void *vp;
+               vec_t *vp;
                entvars_t               *server;
                cl_entvars_t    *client;
        } fields;
@@ -116,12 +120,21 @@ typedef struct prvm_edict_s
 //============================================================================
 #define PRVM_OP_STATE          1
 
+#ifdef DP_SMALLMEMORY
+#define        PRVM_MAX_STACK_DEPTH            128
+#define        PRVM_LOCALSTACK_SIZE            2048
+
+#define PRVM_MAX_OPENFILES 16
+#define PRVM_MAX_OPENSEARCHES 8
+#define PRVM_MAX_GECKOINSTANCES 1
+#else
 #define        PRVM_MAX_STACK_DEPTH            1024
 #define        PRVM_LOCALSTACK_SIZE            16384
 
 #define PRVM_MAX_OPENFILES 256
 #define PRVM_MAX_OPENSEARCHES 128
 #define PRVM_MAX_GECKOINSTANCES 32
+#endif
 
 typedef void (*prvm_builtin_t) (void);
 
@@ -212,6 +225,8 @@ typedef struct prvm_prog_fieldoffsets_s
        int nodrawtoclient; // ssqc
        int pflags; // ssqc
        int ping; // ssqc
+       int packetloss; // ssqc
+       int movementloss; // ssqc
        int pitch_speed; // ssqc / csqc
        int playermodel; // ssqc
        int playerskin; // ssqc
@@ -222,6 +237,7 @@ typedef struct prvm_prog_fieldoffsets_s
        int rendermode; // ssqc - HalfLife support
        int scale; // ssqc / csqc
        int shadertime; // csqc
+       int skeletonindex; // csqc / ssqc FTE_CSQC_SKELETONOBJECTS / DP_SKELETONOBJECTS
        int style; // ssqc
        int tag_entity; // ssqc / csqc
        int tag_index; // ssqc / csqc
@@ -239,12 +255,17 @@ typedef struct prvm_prog_fieldoffsets_s
        int maxs; // ssqc / csqc (physics)
        int mass; // ssqc / csqc (physics)
        int origin; // ssqc / csqc (physics)
-       int axis_forward; // ssqc / csqc (physics)
-       int axis_left; // ssqc / csqc (physics)
-       int axis_up; // ssqc / csqc (physics)
-       //int angles; // ssqc / csqc (physics)
        int velocity; // ssqc / csqc (physics)
-       int spinvelocity; // ssqc / csqc (physics)
+       //int axis_forward; // ssqc / csqc (physics)
+       //int axis_left; // ssqc / csqc (physics)
+       //int axis_up; // ssqc / csqc (physics)
+       //int spinvelocity; // ssqc / csqc (physics)
+       //int angles; // ssqc / csqc (physics)
+       int avelocity; // ssqc / csqc (physics)
+       int jointtype; // ssqc / csqc (physics)
+       int enemy; // ssqc / csqc (physics)
+       int aiment; // ssqc / csqc (physics)
+       int movedir; // ssqc / csqc (physics)
 }
 prvm_prog_fieldoffsets_t;
 
@@ -281,6 +302,7 @@ typedef struct prvm_prog_globaloffsets_s
        int dmg_origin; // csqc
        int sb_showscores; // csqc
        int drawfont; // csqc / menu
+       int drawfontscale; // csqc / menu
        int require_spawnfunc_prefix; // ssqc
        int worldstatus; // ssqc
        int servertime; // csqc
@@ -338,12 +360,16 @@ typedef struct prvm_prog_funcoffsets_s
 }
 prvm_prog_funcoffsets_t;
 
+// stringbuffer flags
+#define STRINGBUFFER_SAVED     1 // saved in savegames
+
 typedef struct prvm_stringbuffer_s
 {
        int max_strings;
        int num_strings;
        char **strings;
        const char *origin;
+       unsigned char flags;
 }
 prvm_stringbuffer_t;
 
@@ -352,6 +378,7 @@ prvm_stringbuffer_t;
 typedef struct prvm_prog_s
 {
        double              starttime;
+       unsigned int            id; // increasing unique id of progs instance
        dprograms_t                     *progs;
        mfunction_t                     *functions;
        char                            *strings;
@@ -359,15 +386,15 @@ typedef struct prvm_prog_s
        ddef_t                          *fielddefs;
        ddef_t                          *globaldefs;
        dstatement_t            *statements;
-       int                                     edict_size;                     // in bytes
-       int                                     edictareasize;          // LordHavoc: in bytes (for bound checking)
+       int                                     entityfields;                   // number of vec_t fields in progs (some variables are 3)
+       int                                     entityfieldsarea;               // LordHavoc: equal to max_edicts * entityfields (for bounds checking)
 
        int                                     *statement_linenums; // NULL if not available
 
        double                          *statement_profile; // only incremented if prvm_statementprofiling is on
 
        union {
-               float *generic;
+               vec_t *generic;
                globalvars_t *server;
                cl_globalvars_t *client;
        } globals;
@@ -417,6 +444,7 @@ typedef struct prvm_prog_s
        fssearch_t                      *opensearches[PRVM_MAX_OPENSEARCHES];
        const char *         opensearches_origin[PRVM_MAX_OPENSEARCHES];
        struct clgecko_s                *opengeckoinstances[PRVM_MAX_GECKOINSTANCES];
+       skeleton_t                      *skeletons[MAX_EDICTS];
 
        // copies of some vars that were former read from sv
        int                                     num_edicts;
@@ -429,7 +457,7 @@ typedef struct prvm_prog_s
        int                                     reserved_edicts; // [INIT]
 
        prvm_edict_t            *edicts;
-       void                                    *edictsfields;
+       vec_t                           *edictsfields;
        void                                    *edictprivate;
 
        // size of the engine private struct
@@ -457,6 +485,9 @@ typedef struct prvm_prog_s
        qboolean                        loaded;
        qboolean                        leaktest_active;
 
+       // translation buffer (only needs to be freed on unloading progs, type is private to prvm_edict.c)
+       void *po;
+
        // printed together with backtraces
        const char *statestring;
 
@@ -529,9 +560,15 @@ void VM_Cmd_Reset(void);
 
 void PRVM_Init (void);
 
+#ifdef PROFILING
 void MVM_ExecuteProgram (func_t fnum, const char *errormessage);
 void CLVM_ExecuteProgram (func_t fnum, const char *errormessage);
 void SVVM_ExecuteProgram (func_t fnum, const char *errormessage);
+#else
+#define MVM_ExecuteProgram SVVM_ExecuteProgram
+#define CLVM_ExecuteProgram SVVM_ExecuteProgram
+void SVVM_ExecuteProgram (func_t fnum, const char *errormessage);
+#endif
 #define PRVM_ExecuteProgram prog->ExecuteProgram
 
 #define PRVM_Alloc(buffersize) _PRVM_Alloc(buffersize, __FILE__, __LINE__)
@@ -621,6 +658,7 @@ void PRVM_ED_PrintNum (int ent, const char *wildcard_fieldname);
 
 const char *PRVM_GetString(int num);
 int PRVM_SetEngineString(const char *s);
+const char *PRVM_ChangeEngineString(int i, const char *s);
 int PRVM_SetTempString(const char *s);
 int PRVM_AllocString(size_t bufferlength, char **pointer);
 void PRVM_FreeString(int num);
@@ -674,4 +712,9 @@ void VM_Warning(const char *fmt, ...) DP_FUNC_PRINTF(1);
 // TODO: fill in the params
 //void PRVM_Create();
 
+void VM_GenerateFrameGroupBlend(framegroupblend_t *framegroupblend, const prvm_edict_t *ed);
+void VM_FrameBlendFromFrameGroupBlend(frameblend_t *frameblend, const framegroupblend_t *framegroupblend, const dp_model_t *model);
+void VM_UpdateEdictSkeleton(prvm_edict_t *ed, const dp_model_t *edmodel, const frameblend_t *frameblend);
+void VM_RemoveEdictSkeleton(prvm_edict_t *ed);
+
 #endif