]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add SPAWNFUNC_CHECK_FIELDS macro to enable/disable map entity whitelist checks
authorLegendaryGuard <rootuser999@gmail.com>
Thu, 25 May 2023 10:04:18 +0000 (10:04 +0000)
committerLegendaryGuard <rootuser999@gmail.com>
Thu, 25 May 2023 10:04:18 +0000 (10:04 +0000)
qcsrc/lib/spawnfunc.qh

index 2d9392dada941f7f921fe839bcb67891a8c14148..b63deac97a0a039e056b46a0cb052d434f7664af 100644 (file)
@@ -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