]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - pr_cmds.c
PROTOCOL_DARKPLACES5
[xonotic/darkplaces.git] / pr_cmds.c
index 3f33113bca6fb0a579b8fea702dd94158a26fa9e..32fe4cf7b15177565993092ed1b698e7689617f4 100644 (file)
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -76,6 +76,7 @@ char *ENGINE_EXTENSIONS =
 "DP_EF_FLAME "
 "DP_EF_FULLBRIGHT "
 "DP_EF_NODRAW "
+"DP_EF_NOSHADOW "
 "DP_EF_RED "
 "DP_EF_STARDUST "
 "DP_ENT_ALPHA "
@@ -102,12 +103,15 @@ char *ENGINE_EXTENSIONS =
 "DP_QC_CVAR_STRING "
 "DP_QC_ETOS "
 "DP_QC_FINDCHAIN "
+"DP_QC_FINDCHAINFLAGS "
 "DP_QC_FINDCHAINFLOAT "
+"DP_QC_FINDFLAGS "
 "DP_QC_FINDFLOAT "
 "DP_QC_FS_SEARCH " // Black: same as in the menu qc
 "DP_QC_GETLIGHT "
 "DP_QC_GETSURFACE "
 "DP_QC_MINMAXBOUND "
+"DP_QC_MULTIPLETEMPSTRINGS "
 "DP_QC_RANDOMVEC "
 "DP_QC_SINCOSSQRTPOW "
 "DP_QC_TRACEBOX "
@@ -118,6 +122,9 @@ char *ENGINE_EXTENSIONS =
 "DP_QUAKE2_MODEL "
 "DP_QUAKE3_MODEL "
 "DP_REGISTERCVAR "
+"DP_SND_DIRECTIONLESSATTNNONE "
+"DP_SND_OGGVORBIS "
+"DP_SND_STEREOWAV "
 "DP_SOLIDCORPSE "
 "DP_SPRITE32 "
 "DP_SV_DRAWONLYTOCLIENT "
@@ -125,6 +132,7 @@ char *ENGINE_EXTENSIONS =
 "DP_SV_EXTERIORMODELTOCLIENT "
 "DP_SV_NODRAWTOCLIENT "
 "DP_SV_PLAYERPHYSICS "
+"DP_SV_ROTATINGBMODEL "
 "DP_SV_SETCOLOR "
 "DP_SV_SLOWMO "
 "DP_TE_BLOOD "
@@ -622,7 +630,7 @@ void PF_ambientsound (void)
        char            *samp;
        float           *pos;
        float           vol, attenuation;
-       int                     i, soundnum, large;
+       int                     soundnum, large;
 
        pos = G_VECTOR (OFS_PARM0);
        samp = G_STRING(OFS_PARM1);
@@ -651,8 +659,7 @@ void PF_ambientsound (void)
        else
                MSG_WriteByte (&sv.signon, svc_spawnstaticsound);
 
-       for (i=0 ; i<3 ; i++)
-               MSG_WriteDPCoord(&sv.signon, pos[i]);
+       MSG_WriteVector(&sv.signon, pos, sv.protocol);
 
        if (large)
                MSG_WriteShort (&sv.signon, soundnum);
@@ -1272,6 +1279,63 @@ void PF_findchainfloat (void)
        RETURN_EDICT(chain);
 }
 
+// LordHavoc: search for flags in float fields
+void PF_findflags (void)
+{
+       int             e;
+       int             f;
+       int             s;
+       edict_t *ed;
+
+       e = G_EDICTNUM(OFS_PARM0);
+       f = G_INT(OFS_PARM1);
+       s = (int)G_FLOAT(OFS_PARM2);
+
+       for (e++ ; e < sv.num_edicts ; e++)
+       {
+               pr_xfunction->builtinsprofile++;
+               ed = EDICT_NUM(e);
+               if (ed->e->free)
+                       continue;
+               if ((int)E_FLOAT(ed,f) & s)
+               {
+                       RETURN_EDICT(ed);
+                       return;
+               }
+       }
+
+       RETURN_EDICT(sv.edicts);
+}
+
+// LordHavoc: chained search for flags in float fields
+void PF_findchainflags (void)
+{
+       int             i;
+       int             f;
+       int             s;
+       edict_t *ent, *chain;
+
+       chain = (edict_t *)sv.edicts;
+
+       f = G_INT(OFS_PARM0);
+       s = (int)G_FLOAT(OFS_PARM1);
+
+       ent = NEXT_EDICT(sv.edicts);
+       for (i = 1;i < sv.num_edicts;i++, ent = NEXT_EDICT(ent))
+       {
+               pr_xfunction->builtinsprofile++;
+               if (ent->e->free)
+                       continue;
+               if (!((int)E_FLOAT(ent,f) & s))
+                       continue;
+
+               ent->v->chain = EDICT_TO_PROG(chain);
+               chain = ent;
+       }
+
+       RETURN_EDICT(chain);
+}
+
 void PR_CheckEmptyString (char *s)
 {
        if (s[0] <= ' ')
@@ -1287,6 +1351,7 @@ void PF_precache_sound (void)
 {
        char    *s;
        int             i;
+       int             limit = (sv.protocol == PROTOCOL_QUAKE ? 256 : MAX_SOUNDS);
 
        if (sv.state != ss_loading)
                PF_ERROR("PF_Precache_*: Precache can only be done in spawn functions");
@@ -1295,7 +1360,7 @@ void PF_precache_sound (void)
        G_INT(OFS_RETURN) = G_INT(OFS_PARM0);
        PR_CheckEmptyString (s);
 
-       for (i=0 ; i<MAX_SOUNDS ; i++)
+       for (i=0 ; i<limit ; i++)
        {
                if (!sv.sound_precache[i])
                {
@@ -1312,6 +1377,7 @@ void PF_precache_model (void)
 {
        char    *s;
        int             i;
+       int             limit = (sv.protocol == PROTOCOL_QUAKE ? 256 : MAX_MODELS);
 
        if (sv.state != ss_loading)
                PF_ERROR("PF_Precache_*: Precache can only be done in spawn functions");
@@ -1322,7 +1388,7 @@ void PF_precache_model (void)
        G_INT(OFS_RETURN) = G_INT(OFS_PARM0);
        PR_CheckEmptyString (s);
 
-       for (i=0 ; i<MAX_MODELS ; i++)
+       for (i = 0;i < limit;i++)
        {
                if (!sv.model_precache[i])
                {
@@ -1811,12 +1877,15 @@ void PF_WriteLong (void)
 
 void PF_WriteAngle (void)
 {
-       MSG_WriteAngle (WriteDest(), G_FLOAT(OFS_PARM1));
+       if (sv.protocol == PROTOCOL_DARKPLACES5)
+               MSG_WriteAngle16i (WriteDest(), G_FLOAT(OFS_PARM1));
+       else
+               MSG_WriteAngle8i (WriteDest(), G_FLOAT(OFS_PARM1));
 }
 
 void PF_WriteCoord (void)
 {
-       MSG_WriteDPCoord (WriteDest(), G_FLOAT(OFS_PARM1));
+       MSG_WriteCoord (WriteDest(), G_FLOAT(OFS_PARM1), sv.protocol);
 }
 
 void PF_WriteString (void)
@@ -1864,8 +1933,8 @@ void PF_makestatic (void)
        MSG_WriteByte (&sv.signon, ent->v->skin);
        for (i=0 ; i<3 ; i++)
        {
-               MSG_WriteDPCoord(&sv.signon, ent->v->origin[i]);
-               MSG_WriteAngle(&sv.signon, ent->v->angles[i]);
+               MSG_WriteCoord(&sv.signon, ent->v->origin[i], sv.protocol);
+               MSG_WriteAngle8i(&sv.signon, ent->v->angles[i]);
        }
 
 // throw the entity away now
@@ -2174,12 +2243,16 @@ effect(origin, modelname, startframe, framecount, framerate)
 */
 void PF_effect (void)
 {
+       int i;
        char *s;
        s = G_STRING(OFS_PARM1);
        if (!s || !s[0])
                PF_WARNING("effect: no model specified\n");
 
-       SV_StartEffect(G_VECTOR(OFS_PARM0), SV_ModelIndex(s), G_FLOAT(OFS_PARM2), G_FLOAT(OFS_PARM3), G_FLOAT(OFS_PARM4));
+       i = SV_ModelIndex(s);
+       if (i < 0)
+               PF_WARNING("effect: model not precached\n");
+       SV_StartEffect(G_VECTOR(OFS_PARM0), i, G_FLOAT(OFS_PARM2), G_FLOAT(OFS_PARM3), G_FLOAT(OFS_PARM4));
 }
 
 void PF_te_blood (void)
@@ -2189,9 +2262,9 @@ void PF_te_blood (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_BLOOD);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
        // velocity
        MSG_WriteByte(&sv.datagram, bound(-128, (int) G_VECTOR(OFS_PARM1)[0], 127));
        MSG_WriteByte(&sv.datagram, bound(-128, (int) G_VECTOR(OFS_PARM1)[1], 127));
@@ -2207,15 +2280,15 @@ void PF_te_bloodshower (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_BLOODSHOWER);
        // min
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
        // max
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[2], sv.protocol);
        // speed
-       MSG_WriteDPCoord(&sv.datagram, G_FLOAT(OFS_PARM2));
+       MSG_WriteCoord(&sv.datagram, G_FLOAT(OFS_PARM2), sv.protocol);
        // count
        MSG_WriteShort(&sv.datagram, bound(0, G_FLOAT(OFS_PARM3), 65535));
 }
@@ -2225,9 +2298,9 @@ void PF_te_explosionrgb (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_EXPLOSIONRGB);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
        // color
        MSG_WriteByte(&sv.datagram, bound(0, (int) (G_VECTOR(OFS_PARM1)[0] * 255), 255));
        MSG_WriteByte(&sv.datagram, bound(0, (int) (G_VECTOR(OFS_PARM1)[1] * 255), 255));
@@ -2241,17 +2314,17 @@ void PF_te_particlecube (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_PARTICLECUBE);
        // min
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
        // max
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[2], sv.protocol);
        // velocity
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[2], sv.protocol);
        // count
        MSG_WriteShort(&sv.datagram, bound(0, G_FLOAT(OFS_PARM3), 65535));
        // color
@@ -2259,7 +2332,7 @@ void PF_te_particlecube (void)
        // gravity true/false
        MSG_WriteByte(&sv.datagram, ((int) G_FLOAT(OFS_PARM5)) != 0);
        // randomvel
-       MSG_WriteDPCoord(&sv.datagram, G_FLOAT(OFS_PARM6));
+       MSG_WriteCoord(&sv.datagram, G_FLOAT(OFS_PARM6), sv.protocol);
 }
 
 void PF_te_particlerain (void)
@@ -2269,17 +2342,17 @@ void PF_te_particlerain (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_PARTICLERAIN);
        // min
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
        // max
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[2], sv.protocol);
        // velocity
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[2], sv.protocol);
        // count
        MSG_WriteShort(&sv.datagram, bound(0, G_FLOAT(OFS_PARM3), 65535));
        // color
@@ -2293,17 +2366,17 @@ void PF_te_particlesnow (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_PARTICLESNOW);
        // min
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
        // max
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[2], sv.protocol);
        // velocity
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[2], sv.protocol);
        // count
        MSG_WriteShort(&sv.datagram, bound(0, G_FLOAT(OFS_PARM3), 65535));
        // color
@@ -2317,9 +2390,9 @@ void PF_te_spark (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_SPARK);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
        // velocity
        MSG_WriteByte(&sv.datagram, bound(-128, (int) G_VECTOR(OFS_PARM1)[0], 127));
        MSG_WriteByte(&sv.datagram, bound(-128, (int) G_VECTOR(OFS_PARM1)[1], 127));
@@ -2333,9 +2406,9 @@ void PF_te_gunshotquad (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_GUNSHOTQUAD);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
 }
 
 void PF_te_spikequad (void)
@@ -2343,9 +2416,9 @@ void PF_te_spikequad (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_SPIKEQUAD);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
 }
 
 void PF_te_superspikequad (void)
@@ -2353,9 +2426,9 @@ void PF_te_superspikequad (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_SUPERSPIKEQUAD);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
 }
 
 void PF_te_explosionquad (void)
@@ -2363,9 +2436,9 @@ void PF_te_explosionquad (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_EXPLOSIONQUAD);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
 }
 
 void PF_te_smallflash (void)
@@ -2373,9 +2446,9 @@ void PF_te_smallflash (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_SMALLFLASH);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
 }
 
 void PF_te_customflash (void)
@@ -2385,9 +2458,9 @@ void PF_te_customflash (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_CUSTOMFLASH);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
        // radius
        MSG_WriteByte(&sv.datagram, bound(0, G_FLOAT(OFS_PARM1) / 8 - 1, 255));
        // lifetime
@@ -2403,9 +2476,9 @@ void PF_te_gunshot (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_GUNSHOT);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
 }
 
 void PF_te_spike (void)
@@ -2413,9 +2486,9 @@ void PF_te_spike (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_SPIKE);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
 }
 
 void PF_te_superspike (void)
@@ -2423,9 +2496,9 @@ void PF_te_superspike (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_SUPERSPIKE);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
 }
 
 void PF_te_explosion (void)
@@ -2433,9 +2506,9 @@ void PF_te_explosion (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_EXPLOSION);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
 }
 
 void PF_te_tarexplosion (void)
@@ -2443,9 +2516,9 @@ void PF_te_tarexplosion (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_TAREXPLOSION);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
 }
 
 void PF_te_wizspike (void)
@@ -2453,9 +2526,9 @@ void PF_te_wizspike (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_WIZSPIKE);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
 }
 
 void PF_te_knightspike (void)
@@ -2463,9 +2536,9 @@ void PF_te_knightspike (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_KNIGHTSPIKE);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
 }
 
 void PF_te_lavasplash (void)
@@ -2473,9 +2546,9 @@ void PF_te_lavasplash (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_LAVASPLASH);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
 }
 
 void PF_te_teleport (void)
@@ -2483,9 +2556,9 @@ void PF_te_teleport (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_TELEPORT);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
 }
 
 void PF_te_explosion2 (void)
@@ -2493,11 +2566,12 @@ void PF_te_explosion2 (void)
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_EXPLOSION2);
        // origin
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
        // color
        MSG_WriteByte(&sv.datagram, G_FLOAT(OFS_PARM1));
+       MSG_WriteByte(&sv.datagram, G_FLOAT(OFS_PARM2));
 }
 
 void PF_te_lightning1 (void)
@@ -2507,13 +2581,13 @@ void PF_te_lightning1 (void)
        // owner entity
        MSG_WriteShort(&sv.datagram, G_EDICTNUM(OFS_PARM0));
        // start
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[2], sv.protocol);
        // end
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[2], sv.protocol);
 }
 
 void PF_te_lightning2 (void)
@@ -2523,13 +2597,13 @@ void PF_te_lightning2 (void)
        // owner entity
        MSG_WriteShort(&sv.datagram, G_EDICTNUM(OFS_PARM0));
        // start
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[2], sv.protocol);
        // end
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[2], sv.protocol);
 }
 
 void PF_te_lightning3 (void)
@@ -2539,13 +2613,13 @@ void PF_te_lightning3 (void)
        // owner entity
        MSG_WriteShort(&sv.datagram, G_EDICTNUM(OFS_PARM0));
        // start
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[2], sv.protocol);
        // end
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[2], sv.protocol);
 }
 
 void PF_te_beam (void)
@@ -2555,22 +2629,22 @@ void PF_te_beam (void)
        // owner entity
        MSG_WriteShort(&sv.datagram, G_EDICTNUM(OFS_PARM0));
        // start
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM1)[2], sv.protocol);
        // end
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM2)[2], sv.protocol);
 }
 
 void PF_te_plasmaburn (void)
 {
        MSG_WriteByte(&sv.datagram, svc_temp_entity);
        MSG_WriteByte(&sv.datagram, TE_PLASMABURN);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1]);
-       MSG_WriteDPCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2]);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[0], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[1], sv.protocol);
+       MSG_WriteCoord(&sv.datagram, G_VECTOR(OFS_PARM0)[2], sv.protocol);
 }
 
 static void clippointtosurface(msurface_t *surf, vec3_t p, vec3_t out)
@@ -2608,9 +2682,9 @@ static msurface_t *getsurface(edict_t *ed, int surfnum)
        if (modelindex < 1 || modelindex >= MAX_MODELS)
                return NULL;
        model = sv.models[modelindex];
-       if (surfnum < 0 || surfnum >= model->brushq1.nummodelsurfaces)
+       if (surfnum < 0 || surfnum >= model->nummodelsurfaces)
                return NULL;
-       return model->brushq1.surfaces + surfnum + model->brushq1.firstmodelsurface;
+       return model->brushq1.surfaces + surfnum + model->firstmodelsurface;
 }
 
 
@@ -2694,9 +2768,9 @@ void PF_getsurfacenearpoint(void)
        VectorSubtract(point, ed->v->origin, p);
        best = -1;
        bestdist = 1000000000;
-       for (surfnum = 0;surfnum < model->brushq1.nummodelsurfaces;surfnum++)
+       for (surfnum = 0;surfnum < model->nummodelsurfaces;surfnum++)
        {
-               surf = model->brushq1.surfaces + surfnum + model->brushq1.firstmodelsurface;
+               surf = model->brushq1.surfaces + surfnum + model->firstmodelsurface;
                dist = PlaneDiff(p, surf->plane);
                dist = dist * dist;
                if (dist < bestdist)
@@ -2763,7 +2837,7 @@ void PF_stof(void)
 //float(string filename, float mode) fopen = #110; // opens a file inside quake/gamedir/data/ (mode is FILE_READ, FILE_APPEND, or FILE_WRITE), returns fhandle >= 0 if successful, or fhandle < 0 if unable to open file for any reason
 void PF_fopen(void)
 {
-       int filenum, mode;
+       int filenum, mode, i;
        char *modestring, *filename;
        for (filenum = 0;filenum < MAX_PRFILES;filenum++)
                if (pr_files[filenum] == NULL)
@@ -2792,17 +2866,26 @@ void PF_fopen(void)
                return;
        }
        filename = G_STRING(OFS_PARM0);
-       // .. is parent directory on many platforms
-       // / is parent directory on Amiga
+       // control characters do not cause issues with any platforms I know of, but they are usually annoying to deal with
+       // ../ is parent directory on many platforms
+       // // is parent directory on Amiga
+       // / at the beginning of a path is root on unix, and parent directory on Amiga
        // : is root of drive on Amiga (also used as a directory separator on Mac, but / works there too, so that's a bad idea)
        // \ is a windows-ism (so it's naughty to use it, / works on all platforms)
-       if ((filename[0] == '.' && filename[1] == '.') || filename[0] == '/' || strrchr(filename, ':') || strrchr(filename, '\\'))
+       for (i = 0;filename[i];i++)
        {
-               Con_Printf("PF_fopen: dangerous or non-portable filename \"%s\" not allowed. (contains : or \\ or begins with .. or /)\n", filename);
-               G_FLOAT(OFS_RETURN) = -4;
-               return;
+               if (filename[i] < ' ' || (filename[i] == '/' && filename[i+1] == '/') || (filename[i] == '.' && filename[i+1] == '.') || filename[i] == ':' || filename[i] == '\\' || filename[0] == '/')
+               {
+                       Con_Printf("PF_fopen: dangerous/confusing/annoying/non-portable filename \"%s\" not allowed. (contains control characters or // or .. or : or \\ or begins with /)\n", filename);
+                       G_FLOAT(OFS_RETURN) = -4;
+                       return;
+               }
        }
        pr_files[filenum] = FS_Open(va("data/%s", filename), modestring, false);
+
+       if (pr_files[filenum] == NULL && modestring == "rb")
+               pr_files[filenum] = FS_Open(filename, modestring, false);
+
        if (pr_files[filenum] == NULL)
                G_FLOAT(OFS_RETURN) = -1;
        else
@@ -2858,7 +2941,7 @@ void PF_fgets(void)
                c = FS_Getc(pr_files[filenum]);
        if (developer.integer)
                Con_Printf("fgets: %s\n", string);
-       if (c >= 0)
+       if (c >= 0 || end)
                G_INT(OFS_RETURN) = PR_SetString(string);
        else
                G_INT(OFS_RETURN) = 0;
@@ -3040,6 +3123,7 @@ void PF_setattachment (void)
                                for (i = 0;i < model->data_overridetagnamesforskin[(unsigned int)tagentity->v->skin].num_overridetagnames;i++)
                                        if (!strcmp(tagname, model->data_overridetagnamesforskin[(unsigned int)tagentity->v->skin].data_overridetagnames[i].name))
                                                v->_float = i + 1;
+                       // FIXME: use a model function to get tag info (need to handle skeletal)
                        if (v->_float == 0 && model->alias.aliasnum_tags)
                                for (i = 0;i < model->alias.aliasnum_tags;i++)
                                        if (!strcmp(tagname, model->alias.aliasdata_tags[i].name))
@@ -3375,7 +3459,7 @@ PF_te_wizspike,                           // #423 void(vector org) te_wizspike (DP_TE_STANDARDEFFECTBUI
 PF_te_knightspike,                     // #424 void(vector org) te_knightspike (DP_TE_STANDARDEFFECTBUILTINS)
 PF_te_lavasplash,                      // #425 void(vector org) te_lavasplash (DP_TE_STANDARDEFFECTBUILTINS)
 PF_te_teleport,                                // #426 void(vector org) te_teleport (DP_TE_STANDARDEFFECTBUILTINS)
-PF_te_explosion2,                      // #427 void(vector org, float color) te_explosion2 (DP_TE_STANDARDEFFECTBUILTINS)
+PF_te_explosion2,                      // #427 void(vector org, float colorstart, float colorlength) te_explosion2 (DP_TE_STANDARDEFFECTBUILTINS)
 PF_te_lightning1,                      // #428 void(entity own, vector start, vector end) te_lightning1 (DP_TE_STANDARDEFFECTBUILTINS)
 PF_te_lightning2,                      // #429 void(entity own, vector start, vector end) te_lightning2 (DP_TE_STANDARDEFFECTBUILTINS)
 PF_te_lightning3,                      // #430 void(entity own, vector start, vector end) te_lightning3 (DP_TE_STANDARDEFFECTBUILTINS)
@@ -3397,8 +3481,18 @@ PF_search_end,                           // #445
 PF_search_getsize,                     // #446
 PF_search_getfilename,         // #447
 PF_cvar_string,                                // #448 string(string s) cvar_string (DP_QC_CVAR_STRING)
-NULL,                                          // #449
-a a a a a                                      // #450-499 (LordHavoc)
+PF_findflags,                          // #449 entity(entity start, .float fld, float match) findflags (DP_QC_FINDFLAGS)
+PF_findchainflags,                     // #450 entity(.float fld, float match) findchainflags (DP_QC_FINDCHAINFLAGS)
+NULL,                                          // #451
+NULL,                                          // #452
+NULL,                                          // #453
+NULL,                                          // #454
+NULL,                                          // #455
+NULL,                                          // #456
+NULL,                                          // #457
+NULL,                                          // #458
+NULL,                                          // #459
+a a a a                                                // #460-499 (LordHavoc)
 };
 
 builtin_t *pr_builtins = pr_builtin;
@@ -3406,7 +3500,7 @@ int pr_numbuiltins = sizeof(pr_builtin)/sizeof(pr_builtin[0]);
 
 void PR_Cmd_Init(void)
 {
-       pr_strings_mempool = Mem_AllocPool("pr_stringszone");
+       pr_strings_mempool = Mem_AllocPool("pr_stringszone", 0, NULL);
        PR_Files_Init();
        PR_Search_Init();
 }