]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - progsvm.h
added Print versions of Printf functions and made all calls that do not need formatin...
[xonotic/darkplaces.git] / progsvm.h
index 77c1bce66d478a604d5dd5cd06e8fdb6a60df0ef..d461da318f6fc010346fc2c370b26fb39bf41532 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -209,7 +209,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 +242,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 +270,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 +364,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 +375,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);
 
@@ -418,20 +423,24 @@ 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)   ((int) (s) ? (s - prog->strings) : 0)
 
 //============================================================================
 
 // used as replacement for a prog stack
-#if 1
-       #define PRVM_Begin  
-       #define PRVM_End        prog = 0;
+//#define PRVM_DEBUGPRSTACK
+
+#ifdef PRVM_DEBUGPRSTACK
+#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      { prvm_prog_t *_oldprog_ = prog
-       #define PRVM_End        if(_oldprog_ != 0) Con_Print("Stack used !\n"); prog = _oldprog_;}
-#endif 
+#define PRVM_Begin  
+#define PRVM_End       prog = 0
+#endif
+
 
-#if 1
+//#define PRVM_SAFENAME
+#ifndef PRVM_SAFENAME
        #define PRVM_NAME       (prog->name)
 #else
        #define PRVM_NAME       (prog->name ? prog->name : "Unknown prog name")
@@ -440,14 +449,7 @@ 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             PRVM_GCALL(error_cmd)(),Host_Error
-
-
+#define PRVM_ERROR             Host_Error
 
 // other prog handling functions
 qboolean PRVM_SetProgFromString(const char *str);