#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
int edict;
} prvm_eval_t;
-typedef struct prvm_required_field_s
+typedef struct prvm_required_field_s
{
int type;
const char *name;
// However, the first one should be preferred.
} priv;
// QuakeC fields (stored in dynamically resized array)
- union
+ 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)
/*// this struct is the basic requirement for a qc prog
typedef struct prvm_pr_globalvars_s
int edict_size; // in bytes
int edictareasize; // LordHavoc: in bytes (for bound checking)
+ int *statement_linenums; // NULL if not available
+
union {
float *generic;
globalvars_t *server;
+ cl_globalvars_t *client;
} globals;
int maxknownstrings;
int numknownstrings;
+ // this is updated whenever a string is removed or added
+ // (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]
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]
void (*init_cmd)(void); // [INIT] used by PRVM_InitProg
void (*reset_cmd)(void); // [INIT] used by PRVM_ResetProg
- void (*error_cmd)(void); // [INIT]
+ void (*error_cmd)(const char *format, ...); // [INIT]
} prvm_prog_t;
void PRVM_ED_PrintNum (int ent);
const char *PRVM_GetString(int num);
-int PRVM_SetQCString(const char *s);
int PRVM_SetEngineString(const char *s);
-char *PRVM_AllocString(int bufferlength);
-void PRVM_FreeString(char *s);
+int PRVM_AllocString(size_t bufferlength, char **pointer);
+void PRVM_FreeString(int num);
//============================================================================
// used as replacement for a prog stack
-#define PRVM_DEBUGPRSTACK
+//#define PRVM_DEBUGPRSTACK
#ifdef PRVM_DEBUGPRSTACK
-#define PRVM_Begin if(prog != 0) Host_Error("prog not 0(prog = %i) in file: %s line: %i!\n", PRVM_GetProgNr(), __FILE__, __LINE__)
+#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
//#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
#define PRVM_GCALL(func) if(prog->func) prog->func
-#define PRVM_ERROR Host_Error
+#define PRVM_ERROR prog->error_cmd
// other prog handling functions
qboolean PRVM_SetProgFromString(const char *str);