]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - pr_edict.c
corrected a few LittleLongs to LittleFloat in md3 loading (EEP those were bad)
[xonotic/darkplaces.git] / pr_edict.c
index b7d347304a8c2c3c22245668fe001cd97129b7bc..9f22b1e4dae18769f48bf0d44039fbab0d7a176f 100644 (file)
@@ -119,6 +119,9 @@ int eval_movement;
 int eval_pmodel;
 int eval_punchvector;
 int eval_viewzoom;
+int eval_clientcolors;
+int eval_tag_entity;
+int eval_tag_index;
 
 mfunction_t *SV_PlayerPhysicsQC;
 mfunction_t *EndFrameQC;
@@ -170,6 +173,9 @@ void FindEdictFieldOffsets(void)
        eval_pmodel = FindFieldOffset("pmodel");
        eval_punchvector = FindFieldOffset("punchvector");
        eval_viewzoom = FindFieldOffset("viewzoom");
+       eval_clientcolors = FindFieldOffset("clientcolors");
+       eval_tag_entity = FindFieldOffset("tag_entity");
+       eval_tag_index = FindFieldOffset("tag_index");
 
        // LordHavoc: allowing QuakeC to override the player movement code
        SV_PlayerPhysicsQC = ED_FindFunction ("SV_PlayerPhysics");
@@ -188,8 +194,17 @@ Sets everything to NULL
 */
 void ED_ClearEdict (edict_t *e)
 {
+       int num;
        memset (e->v, 0, progs->entityfields * 4);
        e->e->free = false;
+       // LordHavoc: for consistency set these here
+       num = NUM_FOR_EDICT(e) - 1;
+       if (num >= 0 && num < svs.maxclients)
+       {
+               e->v->colormap = num + 1;
+               e->v->team = (svs.clients[num].colors & 15) + 1;
+               e->v->netname = PR_SetString(svs.clients[num].name);
+       }
 }
 
 /*
@@ -203,7 +218,6 @@ instead of being removed and recreated, which can cause interpolated
 angles and bad trails.
 =================
 */
-extern void SV_IncreaseEdicts(void);
 edict_t *ED_Alloc (void)
 {
        int                     i;
@@ -800,7 +814,7 @@ void ED_ParseGlobals (const char *data)
        while (1)
        {
                // parse key
-               if (!COM_ParseToken (&data))
+               if (!COM_ParseToken(&data, false))
                        Host_Error ("ED_ParseEntity: EOF without closing brace");
                if (com_token[0] == '}')
                        break;
@@ -808,7 +822,7 @@ void ED_ParseGlobals (const char *data)
                strcpy (keyname, com_token);
 
                // parse value
-               if (!COM_ParseToken (&data))
+               if (!COM_ParseToken(&data, false))
                        Host_Error ("ED_ParseEntity: EOF without closing brace");
 
                if (com_token[0] == '}')
@@ -905,7 +919,12 @@ qboolean   ED_ParseEpair (void *base, ddef_t *key, const char *s)
                break;
 
        case ev_entity:
-               *(int *)d = EDICT_TO_PROG(EDICT_NUM(atoi (s)));
+               i = atoi (s);
+               if (i < 0 || i >= MAX_EDICTS)
+                       Con_DPrintf("ED_ParseEpair: ev_entity reference too large (edict %i >= MAX_EDICTS %i)\n", i, MAX_EDICTS);
+               while (i >= sv.max_edicts)
+                       SV_IncreaseEdicts();
+               *(int *)d = EDICT_TO_PROG(EDICT_NUM(i));
                break;
 
        case ev_field:
@@ -963,7 +982,7 @@ const char *ED_ParseEdict (const char *data, edict_t *ent)
        while (1)
        {
        // parse key
-               if (!COM_ParseToken (&data))
+               if (!COM_ParseToken(&data, false))
                        Host_Error ("ED_ParseEntity: EOF without closing brace");
                if (com_token[0] == '}')
                        break;
@@ -993,7 +1012,7 @@ const char *ED_ParseEdict (const char *data, edict_t *ent)
                }
 
        // parse value
-               if (!COM_ParseToken (&data))
+               if (!COM_ParseToken(&data, false))
                        Host_Error ("ED_ParseEntity: EOF without closing brace");
 
                if (com_token[0] == '}')
@@ -1063,7 +1082,7 @@ void ED_LoadFromFile (const char *data)
        while (1)
        {
 // parse the opening brace
-               if (!COM_ParseToken (&data))
+               if (!COM_ParseToken(&data, false))
                        break;
                if (com_token[0] != '{')
                        Host_Error ("ED_LoadFromFile: found %s when expecting {",com_token);
@@ -1173,7 +1192,10 @@ dpfield_t dpfields[] =
        {ev_float, "ping"},
        {ev_vector, "movement"},
        {ev_float, "pmodel"},
-       {ev_vector, "punchvector"}
+       {ev_vector, "punchvector"},
+       {ev_float, "clientcolors"},
+       {ev_entity, "tag_entity"},
+       {ev_float, "tag_index"}
 };
 
 /*
@@ -1574,7 +1596,7 @@ void PR_Init (void)
 // LordHavoc: turned EDICT_NUM into a #define for speed reasons
 edict_t *EDICT_NUM_ERROR(int n, char *filename, int fileline)
 {
-       Host_Error ("EDICT_NUM: bad number %i (called at %f:%i)", n, filename, fileline);
+       Host_Error ("EDICT_NUM: bad number %i (called at %s:%i)", n, filename, fileline);
        return NULL;
 }