]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - progsvm.h
SVVM: fully shut down when stopping a server to avoid segfaulting later
[xonotic/darkplaces.git] / progsvm.h
index c2d70f144f86b3ef1905e0146e9fa7bfc3460ea2..4c6a7f4d34ea4b407bf1f8e1203d7f9dbf893338 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -74,23 +74,27 @@ typedef struct prvm_required_field_s
        const char *name;
 } prvm_required_field_t;
 
-
+#define PRVM_EDICT_MARK_WAIT_FOR_SETORIGIN -1
+#define PRVM_EDICT_MARK_SETORIGIN_CAUGHT -2
 // AK: I dont call it engine private cause it doesnt really belongs to the engine
 //     it belongs to prvm.
 typedef struct prvm_edict_private_s
 {
-       qbool free;
-       double freetime; // realtime of last change to "free" (i.e. also set on allocation)
-       int mark; // used during leaktest (0 = unref, >0 = referenced); special values during server physics:
-#define PRVM_EDICT_MARK_WAIT_FOR_SETORIGIN -1
-#define PRVM_EDICT_MARK_SETORIGIN_CAUGHT -2
+       // mark for the leak detector
+       int mark;
+       // place in the code where it was allocated (for the leak detector)
        const char *allocation_origin;
 } prvm_edict_private_t;
 
 typedef struct prvm_edict_s
 {
+       // true if this edict is unused
+       qbool free;
+       // sv.time when the object was freed (to prevent early reuse which could
+       // mess up client interpolation or obscure severe QuakeC bugs)
+       double freetime;
+
        // engine-private fields (stored in dynamically resized array)
-       //edict_engineprivate_t *e;
        union
        {
                prvm_edict_private_t *required;
@@ -631,7 +635,7 @@ typedef struct prvm_prog_s
        struct fssearch_s                       *opensearches[PRVM_MAX_OPENSEARCHES];
        const char *         opensearches_origin[PRVM_MAX_OPENSEARCHES];
        struct skeleton_s       *skeletons[MAX_EDICTS];
-       struct cmd_state_s      *console_cmd; // points to the relevant console command interpreter for this vm (cmd_client or &cmd_server), also used to access cvars
+       struct cmd_state_s      *console_cmd; // points to the relevant console command interpreter for this vm (cmd_local or &cmd_server), also used to access cvars
 
        // buffer for storing all tempstrings created during one invocation of ExecuteProgram
        sizebuf_t                       tempstringsbuf;
@@ -897,7 +901,8 @@ void PRVM_ED_PrintNum (prvm_prog_t *prog, int ent, const char *wildcard_fieldnam
 const char *PRVM_GetString(prvm_prog_t *prog, int num);
 int PRVM_SetEngineString(prvm_prog_t *prog, const char *s);
 const char *PRVM_ChangeEngineString(prvm_prog_t *prog, int i, const char *s);
-int PRVM_SetTempString(prvm_prog_t *prog, const char *s);
+/// Takes an strlen (not a buffer size).
+int PRVM_SetTempString(prvm_prog_t *prog, const char *s, size_t slen);
 int PRVM_AllocString(prvm_prog_t *prog, size_t bufferlength, char **pointer);
 void PRVM_FreeString(prvm_prog_t *prog, int num);