From 5b05414d7f3968865176e29e131aa077efca3b7c Mon Sep 17 00:00:00 2001 From: Shpoike Date: Mon, 6 Sep 2021 11:59:09 +0100 Subject: [PATCH] Require mods to actually query DP_SV_PRECACHEANYTIME if they want to avoid warnings from making use of it. This should avoid unintentional compat issues for QS in mods. --- Quake/pr_cmds.c | 35 ++++++++++++++++++++++++----------- Quake/pr_ext.c | 6 ++++++ Quake/progs.h | 1 + 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/Quake/pr_cmds.c b/Quake/pr_cmds.c index 3ec47824..1c38aa84 100644 --- a/Quake/pr_cmds.c +++ b/Quake/pr_cmds.c @@ -1079,7 +1079,16 @@ static void PF_vtos (void) char *s; s = PR_GetTempString(); - sprintf (s, "'%5.1f %5.1f %5.1f'", G_VECTOR(OFS_PARM0)[0], G_VECTOR(OFS_PARM0)[1], G_VECTOR(OFS_PARM0)[2]); + if (!pr_checkextension.value) + sprintf (s, "'%5.1f %5.1f %5.1f'", G_VECTOR(OFS_PARM0)[0], G_VECTOR(OFS_PARM0)[1], G_VECTOR(OFS_PARM0)[2]); + else + { + char x[64], y[64], z[64]; + Q_ftoa(x, G_VECTOR(OFS_PARM0)[0]); + Q_ftoa(y, G_VECTOR(OFS_PARM0)[1]); + Q_ftoa(z, G_VECTOR(OFS_PARM0)[2]); + sprintf (s, "'%s %s %s'", x, y, z); + } G_INT(OFS_RETURN) = PR_SetEngineString(s); } @@ -1148,13 +1157,19 @@ int SV_Precache_Sound(const char *s) { //must be a persistent string. int i; + if (sv.state != ss_loading && !qcvm->precacheanytime) + { + Con_Warning("PF_precache_sound(\"%s\"): 'DP_SV_PRECACHEANYTIME' not checked, so precaches should only be done in spawn functions\n", s); + if (!developer.value) + qcvm->precacheanytime = true; //don't spam too much + } + for (i = 0; i < MAX_SOUNDS; i++) { if (!sv.sound_precache[i]) { if (sv.state != ss_loading) //spike -- moved this so that there's no actual error any more. { - Con_Warning("PF_precache_sound(\"%s\"): Precache should only be done in spawn functions\n", s); //let existing clients know about it MSG_WriteByte(&sv.reliable_datagram, svcdp_precache); MSG_WriteShort(&sv.reliable_datagram, i|0x8000); @@ -1164,11 +1179,7 @@ int SV_Precache_Sound(const char *s) return i; } if (!strcmp(sv.sound_precache[i], s)) - { - if (sv.state != ss_loading && !pr_checkextension.value) - Con_Warning("PF_precache_sound(\"%s\"): Precache should only be done in spawn functions\n", s); return i; - } } return 0; } @@ -1219,13 +1230,19 @@ static void PF_sv_precache_model (void) G_INT(OFS_RETURN) = G_INT(OFS_PARM0); PR_CheckEmptyString (s); + if (sv.state != ss_loading && !qcvm->precacheanytime) + { + Con_Warning ("PF_precache_model(\"%s\"): 'DP_SV_PRECACHEANYTIME' not checked, so precaches should only be done in spawn functions\n", s); + if (!developer.value) + qcvm->precacheanytime = true; //don't spam too much + } + for (i = 0; i < MAX_MODELS; i++) { if (!sv.model_precache[i]) { if (sv.state != ss_loading) { - Con_Warning ("PF_precache_model(\"%s\"): Precache should only be done in spawn functions\n", s); //let existing clients know about it MSG_WriteByte(&sv.reliable_datagram, svcdp_precache); MSG_WriteShort(&sv.reliable_datagram, i|0x8000); @@ -1237,11 +1254,7 @@ static void PF_sv_precache_model (void) return; } if (!strcmp(sv.model_precache[i], s)) - { - if (sv.state != ss_loading && !pr_checkextension.value) - Con_Warning ("PF_precache_model(\"%s\"): Precache should only be done in spawn functions\n", s); return; - } } PR_RunError ("PF_precache_model: overflow"); } diff --git a/Quake/pr_ext.c b/Quake/pr_ext.c index 4b84ac87..aa59e5f4 100644 --- a/Quake/pr_ext.c +++ b/Quake/pr_ext.c @@ -7473,6 +7473,11 @@ qboolean PR_Can_Ent_Scale(unsigned int prot, unsigned int pext1, unsigned int pe else return false; //sorry. don't report it as supported. } +qboolean PR_CanPrecacheAnyTime(unsigned int prot, unsigned int pext1, unsigned int pext2) +{ + qcvm->precacheanytime = true; + return true; +} static struct { const char *name; @@ -7536,6 +7541,7 @@ static struct {"DP_SV_DROPCLIENT"}, // {"DP_SV_POINTPARTICLES", PR_Can_Particles}, //can't enable this, because certain mods then assume that we're DP and all the particles break. {"DP_SV_POINTSOUND"}, + {"DP_SV_PRECACHEANYTIME", PR_CanPrecacheAnyTime}, {"DP_SV_PRINT"}, {"DP_SV_SETCOLOR"}, {"DP_SV_SPAWNFUNC_PREFIX"}, diff --git a/Quake/progs.h b/Quake/progs.h index 331b51ee..91eef189 100644 --- a/Quake/progs.h +++ b/Quake/progs.h @@ -375,6 +375,7 @@ struct qcvm_s void *cursorhandle; //video code. qboolean nogameaccess; //simplecsqc isn't allowed to poke properties of the actual game (to prevent cheats when there's no restrictions on what it can access) qboolean brokenbouncemissile; //2021 rerelease redefined it, breaking any mod that depends on it. + qboolean precacheanytime; //mod queried for support. this is used to spam warnings to anyone that doesn't bother checking for it first. this annoyance is to reduce compat issues. //was static inside pr_edict char *strings;