]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - progs.h
qw support is 99% working
[xonotic/darkplaces.git] / progs.h
diff --git a/progs.h b/progs.h
index 702c44594baa4ac3b8ed4c54685aa6eb60a85b59..7005deec8c3b9d82964d67c9094bd40bd9edf492 100644 (file)
--- a/progs.h
+++ b/progs.h
@@ -20,6 +20,130 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #ifndef PROGS_H
 #define PROGS_H
+#include "pr_comp.h"                   // defs shared with qcc
+
+typedef struct link_s
+{
+       int entitynumber;
+       struct link_s   *prev, *next;
+} link_t;
+
+#define ENTITYGRIDAREAS 16
+#define MAX_ENTITYCLUSTERS 16
+
+typedef struct edict_engineprivate_s
+{
+       // true if this edict is unused
+       qboolean free;
+       // sv.time when the object was freed (to prevent early reuse which could
+       // mess up client interpolation or obscure severe QuakeC bugs)
+       float freetime;
+       // initially false to prevent projectiles from moving on their first frame
+       // (even if they were spawned by an synchronous client think)
+       qboolean move;
+
+       // cached cluster links for quick stationary object visibility checking
+       vec3_t cullmins, cullmaxs;
+       int pvs_numclusters;
+       int pvs_clusterlist[MAX_ENTITYCLUSTERS];
+
+       // physics grid areas this edict is linked into
+       link_t areagrid[ENTITYGRIDAREAS];
+       // since the areagrid can have multiple references to one entity,
+       // we should avoid extensive checking on entities already encountered
+       int areagridmarknumber;
+
+       // PROTOCOL_QUAKE, PROTOCOL_QUAKEDP, PROTOCOL_NEHAHRAMOVIE, PROTOCOL_QUAKEWORLD
+       // baseline values
+       entity_state_t baseline;
+
+       // LordHavoc: gross hack to make floating items still work
+       int suspendedinairflag;
+       // used by PushMove to keep track of where objects were before they were
+       // moved, in case they need to be moved back
+       vec3_t moved_from;
+       vec3_t moved_fromangles;
+}
+edict_engineprivate_t;
+
+// LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue...  see pr_edict.c for the functions which use these.
+extern int eval_gravity;
+extern int eval_button3;
+extern int eval_button4;
+extern int eval_button5;
+extern int eval_button6;
+extern int eval_button7;
+extern int eval_button8;
+extern int eval_button9;
+extern int eval_button10;
+extern int eval_button11;
+extern int eval_button12;
+extern int eval_button13;
+extern int eval_button14;
+extern int eval_button15;
+extern int eval_button16;
+extern int eval_buttonuse;
+extern int eval_buttonchat;
+extern int eval_glow_size;
+extern int eval_glow_trail;
+extern int eval_glow_color;
+extern int eval_items2;
+extern int eval_scale;
+extern int eval_alpha;
+extern int eval_renderamt; // HalfLife support
+extern int eval_rendermode; // HalfLife support
+extern int eval_fullbright;
+extern int eval_ammo_shells1;
+extern int eval_ammo_nails1;
+extern int eval_ammo_lava_nails;
+extern int eval_ammo_rockets1;
+extern int eval_ammo_multi_rockets;
+extern int eval_ammo_cells1;
+extern int eval_ammo_plasma;
+extern int eval_idealpitch;
+extern int eval_pitch_speed;
+extern int eval_viewmodelforclient;
+extern int eval_nodrawtoclient;
+extern int eval_exteriormodeltoclient;
+extern int eval_drawonlytoclient;
+extern int eval_ping;
+extern int eval_movement;
+extern int eval_pmodel;
+extern int eval_punchvector;
+extern int eval_viewzoom;
+extern int eval_clientcolors;
+extern int eval_tag_entity;
+extern int eval_tag_index;
+extern int eval_light_lev;
+extern int eval_color;
+extern int eval_style;
+extern int eval_pflags;
+extern int eval_cursor_active;
+extern int eval_cursor_screen;
+extern int eval_cursor_trace_start;
+extern int eval_cursor_trace_endpos;
+extern int eval_cursor_trace_ent;
+extern int eval_colormod;
+extern int eval_playermodel;
+extern int eval_playerskin;
+extern int eval_SendEntity;
+extern int eval_Version;
+extern int eval_customizeentityforclient;
+
+extern mfunction_t *SV_PlayerPhysicsQC;
+extern mfunction_t *EndFrameQC;
+//KrimZon - SERVER COMMANDS IN QUAKEC
+extern mfunction_t *SV_ParseClientCommandQC;
+
+#endif
+
+
+
+
+
+
+//////////////////////////////////
+#if 0
 
 #include "pr_comp.h"                   // defs shared with qcc
 #include "progdefs.h"                  // generated by program cdefs
@@ -33,47 +157,58 @@ typedef union eval_s
        int                             ivector[3];
        int                             _int;
        int                             edict;
-} eval_t;
+} prvm_eval_t;
 
 typedef struct link_s
 {
-       void *entity;
+       int entitynumber;
        struct link_s   *prev, *next;
 } link_t;
 
 #define ENTITYGRIDAREAS 16
 
-// the entire server entity structure
-typedef struct edict_s
+typedef struct edict_engineprivate_s
 {
        // true if this edict is unused
        qboolean free;
+       // sv.time when the object was freed (to prevent early reuse which could
+       // mess up client interpolation or obscure severe QuakeC bugs)
+       float freetime;
+
+       // cached cluster links for quick stationary object visibility checking
+       vec3_t cullmins, cullmaxs;
+       int pvs_numclusters;
+       int pvs_clusterlist[MAX_ENTITYCLUSTERS];
+
        // physics grid areas this edict is linked into
        link_t areagrid[ENTITYGRIDAREAS];
        // since the areagrid can have multiple references to one entity,
        // we should avoid extensive checking on entities already encountered
        int areagridmarknumber;
 
-       // old entity protocol, not used
-#ifdef QUAKEENTITIES
+       // PROTOCOL_QUAKE, PROTOCOL_QUAKEDP, PROTOCOL_NEHAHRAMOVIE, PROTOCOL_QUAKEWORLD
        // baseline values
        entity_state_t baseline;
-       // LordHavoc: previous frame
-       entity_state_t deltabaseline;
-#endif
 
        // LordHavoc: gross hack to make floating items still work
        int suspendedinairflag;
-       // sv.time when the object was freed (to prevent early reuse which could
-       // mess up client interpolation or obscure severe QuakeC bugs)
-       float freetime;
        // used by PushMove to keep track of where objects were before they were
        // moved, in case they need to be moved back
        vec3_t moved_from;
        vec3_t moved_fromangles;
-       // edict fields (stored in another array)
+}
+edict_engineprivate_t;
+
+// the entire server entity structure
+// NOTE: keep this small!  priv and v are dynamic but this struct is not!
+typedef struct edict_s
+{
+       // engine-private fields (stored in dynamically resized array)
+       edict_engineprivate_t *e;
+       // QuakeC fields (stored in dynamically resized array)
        entvars_t *v;
-} edict_t;
+}
+prvm_edict_t;
 
 // LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue...  see pr_edict.c for the functions which use these.
 extern int eval_gravity;
@@ -83,6 +218,8 @@ extern int eval_button5;
 extern int eval_button6;
 extern int eval_button7;
 extern int eval_button8;
+extern int eval_buttonuse;
+extern int eval_buttonchat;
 extern int eval_glow_size;
 extern int eval_glow_trail;
 extern int eval_glow_color;
@@ -110,78 +247,114 @@ extern int eval_movement;
 extern int eval_pmodel;
 extern int eval_punchvector;
 extern int eval_viewzoom;
-
-#define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t *)((qbyte *)ed->v + fieldoffset) : NULL)
+extern int eval_clientcolors;
+extern int eval_tag_entity;
+extern int eval_tag_index;
+extern int eval_light_lev;
+extern int eval_color;
+extern int eval_style;
+extern int eval_pflags;
+extern int eval_cursor_active;
+extern int eval_cursor_screen;
+extern int eval_cursor_trace_start;
+extern int eval_cursor_trace_endpos;
+extern int eval_cursor_trace_ent;
+extern int eval_colormod;
+extern int eval_playermodel;
+extern int eval_playerskin;
+
+#define PRVM_GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (prvm_eval_t *)((unsigned char *)ed->v + fieldoffset) : NULL)
 
 
 extern mfunction_t *SV_PlayerPhysicsQC;
 extern mfunction_t *EndFrameQC;
+//KrimZon - SERVER COMMANDS IN QUAKEC
+extern mfunction_t *SV_ParseClientCommandQC;
 
 //============================================================================
 
 extern dprograms_t             *progs;
-extern mfunction_t             *pr_functions;
+extern mfunction_t             *prog->functions;
 extern char                    *pr_strings;
+extern int                             pr_stringssize;
 extern ddef_t                  *pr_globaldefs;
 extern ddef_t                  *pr_fielddefs;
 extern dstatement_t    *pr_statements;
 extern globalvars_t    *pr_global_struct;
 extern float                   *pr_globals;                    // same as pr_global_struct
 
-extern int                             pr_edict_size;  // in bytes
+extern int                             prog->edict_size;       // in bytes
 extern int                             pr_edictareasize; // LordHavoc: for bounds checking
 
+extern int                             pr_maxknownstrings;
+extern int                             pr_numknownstrings;
+extern const char              **pr_knownstrings;
+
 //============================================================================
 
 void PR_Init (void);
+void PR_Shutdown (void);
+
+void PRVM_ExecuteProgram (func_t fnum, const char *errormessage);
+void PR_LoadProgs (const char *progsname);
 
-void PR_ExecuteProgram (func_t fnum, const char *errormessage);
-void PR_LoadProgs (void);
+#define PR_Alloc(buffersize) _PR_Alloc(buffersize, __FILE__, __LINE__)
+#define PR_Free(buffer) _PR_Free(buffer, __FILE__, __LINE__)
+#define PR_FreeAll() _PR_FreeAll(__FILE__, __LINE__)
+void *_PR_Alloc (size_t buffersize, const char *filename, int fileline);
+void _PR_Free (void *buffer, const char *filename, int fileline);
+void _PR_FreeAll (const char *filename, int fileline);
 
 void PR_Profile_f (void);
 
+void PR_PrintState(void);
 void PR_Crash (void);
 
-edict_t *ED_Alloc (void);
-void ED_Free (edict_t *ed);
+void SV_IncreaseEdicts(void);
 
-char   *ED_NewString (const char *string);
-// returns a copy of the string allocated from the server's string heap
+prvm_edict_t *ED_Alloc (void);
+void ED_Free (prvm_edict_t *ed);
+void ED_ClearEdict (prvm_edict_t *e);
 
-void ED_Print (edict_t *ed);
-void ED_Write (qfile_t *f, edict_t *ed);
-const char *ED_ParseEdict (const char *data, edict_t *ent);
+void ED_Print(prvm_edict_t *ed);
+void ED_Write (qfile_t *f, prvm_edict_t *ed);
+const char *ED_ParseEdict (const char *data, prvm_edict_t *ent);
 
 void ED_WriteGlobals (qfile_t *f);
 void ED_ParseGlobals (const char *data);
 
 void ED_LoadFromFile (const char *data);
 
-edict_t *EDICT_NUM_ERROR(int n);
-#define EDICT_NUM(n) ((n >= 0 && n < sv.max_edicts) ? sv.edictstable[(n)] : EDICT_NUM_ERROR(n))
+prvm_edict_t *EDICT_NUM_ERROR(int n, char *filename, int fileline);
+#define PRVM_EDICT_NUM(n) (((n) >= 0 && (n) < prog->max_edicts) ? prog->edicts + (n) : EDICT_NUM_ERROR(n, __FILE__, __LINE__))
+#define EDICT_NUM_UNSIGNED(n) (((n) < prog->max_edicts) ? prog->edicts + (n) : EDICT_NUM_ERROR(n, __FILE__, __LINE__))
 
-int NUM_FOR_EDICT(edict_t *e);
+//int NUM_FOR_EDICT_ERROR(prvm_edict_t *e);
+#define PRVM_NUM_FOR_EDICT(e) ((int)((prvm_edict_t *)(e) - prog->edicts))
+//int PRVM_NUM_FOR_EDICT(prvm_edict_t *e);
 
-#define        NEXT_EDICT(e) ((e) + 1)
+#define        PRVM_NEXT_EDICT(e) ((e) + 1)
 
-int EDICT_TO_PROG(edict_t *e);
-edict_t *PROG_TO_EDICT(int n);
+#define PRVM_EDICT_TO_PROG(e) (PRVM_NUM_FOR_EDICT(e))
+//int PRVM_EDICT_TO_PROG(prvm_edict_t *e);
+#define PRVM_PROG_TO_EDICT(n) (PRVM_EDICT_NUM(n))
+//prvm_edict_t *PRVM_PROG_TO_EDICT(int n);
 
 //============================================================================
 
-#define        G_FLOAT(o) (pr_globals[o])
-#define        G_INT(o) (*(int *)&pr_globals[o])
-#define        G_EDICT(o) (PROG_TO_EDICT(*(int *)&pr_globals[o]))
-#define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o))
-#define        G_VECTOR(o) (&pr_globals[o])
-#define        G_STRING(o) (PR_GetString(*(string_t *)&pr_globals[o]))
+#define        PRVM_G_FLOAT(o) (pr_globals[o])
+#define        PRVM_G_INT(o) (*(int *)&pr_globals[o])
+#define        PRVM_G_EDICT(o) (PRVM_PROG_TO_EDICT(*(int *)&pr_globals[o]))
+#define PRVM_G_EDICTNUM(o) PRVM_NUM_FOR_EDICT(PRVM_G_EDICT(o))
+#define        PRVM_G_VECTOR(o) (&pr_globals[o])
+#define        PRVM_G_STRING(o) (PRVM_GetString(*(string_t *)&pr_globals[o]))
 //#define      G_FUNCTION(o) (*(func_t *)&pr_globals[o])
 
 // FIXME: make these go away?
 #define        E_FLOAT(e,o) (((float*)e->v)[o])
 //#define      E_INT(e,o) (((int*)e->v)[o])
 //#define      E_VECTOR(e,o) (&((float*)e->v)[o])
-#define        E_STRING(e,o) (PR_GetString(*(string_t *)&((float*)e->v)[o]))
+#define        E_STRING(e,o) (PRVM_GetString(*(string_t *)&((float*)e->v)[o]))
 
 extern int             type_size[8];
 
@@ -202,8 +375,11 @@ void PR_Execute_ProgsLoaded(void);
 void ED_PrintEdicts (void);
 void ED_PrintNum (int ent);
 
-#define PR_GetString(num) (pr_strings + num)
-#define PR_SetString(s) ((int) (s - pr_strings))
+const char *PRVM_GetString(int num);
+int PR_SetQCString(const char *s);
+int PRVM_SetEngineString(const char *s);
+char *PR_AllocString(int bufferlength);
+void PR_FreeString(char *s);
 
 #endif