From 06dcd352db11013db8f791ba049fc48ad3a8871b Mon Sep 17 00:00:00 2001 From: LegendaryGuard Date: Thu, 25 May 2023 10:04:18 +0000 Subject: [PATCH] Add SPAWNFUNC_CHECK_FIELDS macro to enable/disable map entity whitelist checks --- qcsrc/lib/spawnfunc.qh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qcsrc/lib/spawnfunc.qh b/qcsrc/lib/spawnfunc.qh index 2d9392dad..b63deac97 100644 --- a/qcsrc/lib/spawnfunc.qh +++ b/qcsrc/lib/spawnfunc.qh @@ -87,6 +87,11 @@ noref string __fullspawndata; e.__spawnfunc_constructor(e); } +// enables/disables warnings if a map entity has a field that doesn't exist +// useful for debugging and compatibility testing +#define SPAWNFUNC_CHECK_FIELDS 1 +#if SPAWNFUNC_CHECK_FIELDS + #define FIELD_SCALAR(fld, n) \ fld(n) #define FIELD_VEC(fld, n) \ @@ -244,10 +249,12 @@ noref string __fullspawndata; FIELD_VEC(fld, modelscale_vec) \ FIELD_VEC(fld, velocity) \ /**/ +#endif ERASEABLE void _checkWhitelisted(entity this, string id) { +#if SPAWNFUNC_CHECK_FIELDS for (int i = 0, n = numentityfields(); i < n; ++i) { string value = getentityfieldstring(i, this); @@ -259,6 +266,7 @@ void _checkWhitelisted(entity this, string id) FIELDS_UNION(_spawnfunc_check) LOG_WARNF(_("Entity field %s.%s (%s) is not whitelisted. If you believe this is an error, please file an issue."), id, s, value); } +#endif } // this function simply avoids expanding IL_NEW during compilation -- 2.39.2