]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - progs.h
sv.edicts (and related things) are now dynamically reallocated as more edicts are...
[xonotic/darkplaces.git] / progs.h
diff --git a/progs.h b/progs.h
index a8a5f3b7d0320ed07f1db3a391abae9bc9df7756..929bd27c0b1a636bd38ddd6b7e33e5fb96038d71 100644 (file)
--- a/progs.h
+++ b/progs.h
@@ -37,16 +37,22 @@ typedef union eval_s
 
 typedef struct link_s
 {
+       int entitynumber;
        struct link_s   *prev, *next;
 } link_t;
 
+#define ENTITYGRIDAREAS 16
+
 // the entire server entity structure
 typedef struct edict_s
 {
        // true if this edict is unused
        qboolean free;
-       // physics area this edict is linked into
-       link_t area;
+       // 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
@@ -108,13 +114,13 @@ extern int eval_viewzoom;
 #define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t *)((qbyte *)ed->v + fieldoffset) : NULL)
 
 
-extern dfunction_t *SV_PlayerPhysicsQC;
-extern dfunction_t *EndFrameQC;
+extern mfunction_t *SV_PlayerPhysicsQC;
+extern mfunction_t *EndFrameQC;
 
 //============================================================================
 
 extern dprograms_t             *progs;
-extern dfunction_t             *pr_functions;
+extern mfunction_t             *pr_functions;
 extern char                    *pr_strings;
 extern ddef_t                  *pr_globaldefs;
 extern ddef_t                  *pr_fielddefs;
@@ -143,23 +149,27 @@ char      *ED_NewString (const char *string);
 // returns a copy of the string allocated from the server's string heap
 
 void ED_Print (edict_t *ed);
-void ED_Write (QFile *f, edict_t *ed);
+void ED_Write (qfile_t *f, edict_t *ed);
 const char *ED_ParseEdict (const char *data, edict_t *ent);
 
-void ED_WriteGlobals (QFile *f);
+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))
+edict_t *EDICT_NUM_ERROR(int n, char *filename, int fileline);
+#define EDICT_NUM(n) (((n) >= 0 && (n) < sv.max_edicts) ? sv.edictstable[(n)] : EDICT_NUM_ERROR(n, __FILE__, __LINE__))
 
-int NUM_FOR_EDICT(edict_t *e);
+//int NUM_FOR_EDICT_ERROR(edict_t *e);
+#define NUM_FOR_EDICT(e) ((edict_t *)(e) - sv.edicts)
+//int NUM_FOR_EDICT(edict_t *e);
 
 #define        NEXT_EDICT(e) ((e) + 1)
 
-int EDICT_TO_PROG(edict_t *e);
-edict_t *PROG_TO_EDICT(int n);
+#define EDICT_TO_PROG(e) (NUM_FOR_EDICT(e))
+//int EDICT_TO_PROG(edict_t *e);
+#define PROG_TO_EDICT(n) (EDICT_NUM(n))
+//edict_t *PROG_TO_EDICT(int n);
 
 //============================================================================
 
@@ -186,7 +196,7 @@ extern int pr_numbuiltins;
 extern int             pr_argc;
 
 extern int                     pr_trace;
-extern dfunction_t     *pr_xfunction;
+extern mfunction_t     *pr_xfunction;
 extern int                     pr_xstatement;
 
 extern unsigned short          pr_crc;