X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=pr_cmds.c;h=32fe4cf7b15177565993092ed1b698e7689617f4;hp=fae2c4629117f9b9cc9feafa95013db0f7e6bab3;hb=435b52972823fa8e8ceb9b67797ca3f886f6208a;hpb=fc3a13a5dc1496107696a01398448c2a0cad3772 diff --git a/pr_cmds.c b/pr_cmds.c index fae2c462..32fe4cf7 100644 --- a/pr_cmds.c +++ b/pr_cmds.c @@ -103,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 " @@ -119,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 " @@ -624,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); @@ -653,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); @@ -1274,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] <= ' ') @@ -1289,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"); @@ -1297,7 +1360,7 @@ void PF_precache_sound (void) G_INT(OFS_RETURN) = G_INT(OFS_PARM0); PR_CheckEmptyString (s); - for (i=0 ; iv->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 @@ -2176,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) @@ -2191,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)); @@ -2209,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)); } @@ -2227,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)); @@ -2243,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 @@ -2261,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) @@ -2271,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 @@ -2295,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 @@ -2319,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)); @@ -2335,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) @@ -2345,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) @@ -2355,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) @@ -2365,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) @@ -2375,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) @@ -2387,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 @@ -2405,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) @@ -2415,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) @@ -2425,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) @@ -2435,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) @@ -2445,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) @@ -2455,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) @@ -2465,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) @@ -2475,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) @@ -2485,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) @@ -2495,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) @@ -2509,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) @@ -2525,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) @@ -2541,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) @@ -2557,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) @@ -2765,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) @@ -2794,15 +2866,20 @@ 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); @@ -2864,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; @@ -3046,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)) @@ -3381,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) @@ -3403,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; @@ -3412,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(); }