From 9e62ce771cc8586ed8b592f3bfe4725839cf8bf2 Mon Sep 17 00:00:00 2001 From: flowtron Date: Wed, 9 Mar 2022 09:48:34 +0100 Subject: [PATCH] flagdistance warning --- source/src/tools.cpp | 9 +++++++++ source/src/world.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/source/src/tools.cpp b/source/src/tools.cpp index 131780e3..75a5128d 100644 --- a/source/src/tools.cpp +++ b/source/src/tools.cpp @@ -261,6 +261,7 @@ int calcmapareastats(mapareastats_s &ms, servsqr *_servworld, int _ssize, const return 0; } +int lastflagdistancewarning = 0; void calcentitystats(entitystats_s &es, const persistent_entity *pents, int pentsize) { #ifndef STANDALONE @@ -310,6 +311,14 @@ void calcentitystats(entitystats_s &es, const persistent_entity *pents, int pent { vec fd(pents[es.flagents[0]].x - pents[es.flagents[1]].x, pents[es.flagents[0]].y - pents[es.flagents[1]].y, 0); es.flagentdistance = fd.magnitude(); + #ifndef STANDALONE + // the clientgame:server calls this too, so we need to check we didn't just warn already. + if(es.flagentdistance < MINFLAGDISTANCE && (lastflagdistancewarning==0 || (lastmillis - lastflagdistancewarning) > 1000)) + { + hudoutf("\f2flags \f3too close\f5! \f4[%d<%d]", es.flagentdistance, MINFLAGDISTANCE); + lastflagdistancewarning = lastmillis; + } + #endif // STANDALONE es.hasflags = es.flagentdistance >= MINFLAGDISTANCE; } int r = 0; diff --git a/source/src/world.h b/source/src/world.h index 13e5c666..df26acbd 100644 --- a/source/src/world.h +++ b/source/src/world.h @@ -148,7 +148,7 @@ struct vertex { float u, v, x, y, z; uchar r, g, b, a; }; // map statistics #define MINSPAWNS 5 // minimum number of spawns per team -#define MINFLAGDISTANCE 42 // minimum flag entity distance (2D) +#define MINFLAGDISTANCE 24 // w/o checking for walls between them // minimum flag entity distance (2D) struct entitystats_s {