]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make accumulated functions explicit, fix a few missed cases of pow being used directly
authorMario <mario.mario@y7mail.com>
Sat, 2 Jul 2022 16:27:03 +0000 (02:27 +1000)
committerMario <mario.mario@y7mail.com>
Sat, 2 Jul 2022 16:27:03 +0000 (02:27 +1000)
qcsrc/common/mutators/base.qh
qcsrc/lib/cvar.qh
qcsrc/lib/oo.qh
qcsrc/lib/registry.qh
qcsrc/lib/static.qh
qcsrc/lib/stats.qh
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/cheats.qc
qcsrc/server/damage.qc

index 7af5a12ce4abfb009842c3bd4159eac566577056..a0dd2fc83f498a2d89895f6a1c63d1a59412090a 100644 (file)
@@ -120,8 +120,8 @@ ENDCLASS(CallbackChain)
 #define _MUTATOR_HANDLE_POPTMP(type, id) id = tmp_##id;
 #define _MUTATOR_HANDLE_POPOUT(type, id) id = out_##id;
 
-void RegisterHooks() {};
-void RegisterCallbacks() {};
+ACCUMULATE void RegisterHooks() {};
+ACCUMULATE void RegisterCallbacks() {};
 
 #define MUTATOR_HOOKABLE(id, params) _MUTATOR_HOOKABLE(id, params)
 #define _MUTATOR_HOOKABLE(id, params) \
@@ -261,8 +261,8 @@ void Mutator_Remove(Mutator mut)
 }
 
 #define REGISTER_MUTATOR(id, dependence) \
-    bool MUTATORFUNC_##id##_hooks(int mode) { return = false; } \
-    bool MUTATORFUNC_##id(int mode) { \
+    ACCUMULATE bool MUTATORFUNC_##id##_hooks(int mode) { return = false; } \
+    ACCUMULATE bool MUTATORFUNC_##id(int mode) { \
         return = false; \
         bool ret = MUTATORFUNC_##id##_hooks(mode); if (ret) return ret; \
     } \
@@ -304,7 +304,7 @@ MACRO_END
 
 #define _MUTATOR_CALLBACK(name, func) \
     Callback CB_##name; \
-    bool func(); \
+    ACCUMULATE bool func(); \
     ACCUMULATE void RegisterCallbacks() { CB_##name = NEW(Callback, func); }
 
 #define MUTATOR_HOOKFUNCTION(...) \
index d5b47ce43ee70bfdda9f758b3d2d36969bdd9ccb..3c47551bac8518dfb15a087b0c750d420eec60cd 100644 (file)
@@ -5,6 +5,7 @@
 #include "static.qh"
 
 ERASEABLE
+ACCUMULATE
 void RegisterCvars(void(string name, string def, string desc, bool archive, string file) f) {}
 
 ERASEABLE
index a2cef664bad3b72f9936ab371b12087c1e362027..fd3d65a1a1f565ff3d4065ae0f54c4076e670649 100644 (file)
@@ -199,7 +199,7 @@ void clearentity(entity e)
        ACCUMULATE cname spawn##cname##_1(cname this)
 
 #define CONSTRUCTOR(cname, ...)                                                                    \
-       cname OVERLOAD(spawn##cname, cname this, __VA_ARGS__)                                          \
+       ACCUMULATE cname OVERLOAD(spawn##cname, cname this, __VA_ARGS__)                                          \
        {                                                                                              \
                return = this;                                                                             \
        }                                                                                              \
@@ -277,7 +277,7 @@ void clearentity(entity e)
 .string vtblname;
 .entity vtblbase;
 
-void RegisterClasses() {}
+ACCUMULATE void RegisterClasses() {}
 STATIC_INIT(RegisterClasses)
 {
        RegisterClasses();
index fdcc730a068527b73b4a1e2291fc910616e9b53f..3b5b9d906a4589c5189387160003d08775fe37f3 100644 (file)
@@ -28,7 +28,7 @@
        ACCUMULATE void REGISTRY_DEPENDS_(id) {} \
        REGISTRY_BEGIN(id) {} \
        REGISTRY_END(id) {} \
-       void _Register##id() {} \
+       ACCUMULATE void _Register##id() {} \
        int id##_state = 0; \
        void Register##id() { if (id##_state) return; id##_state = 1; REGISTRY_DEPENDS_(id); REGISTRY_BEGIN_(id); _Register##id(); id##_state = 2; REGISTRY_END_(id); } \
        const int id##_MAX = max; \
index e1879890e8521dfe9c5173c209aee501c89da628..6087c404180d75f5dbbb8302db26ff30fe2fbb2c 100644 (file)
@@ -26,26 +26,26 @@ void profile(string s)
 /** before worldspawn */
 #define STATIC_INIT_EARLY(func) _STATIC_INIT(func##_0,    __static_init_0)
 #define static_init_early()     CALL_ACCUMULATED_FUNCTION(__static_init_0)
-void __static_init_0() {}
+ACCUMULATE void __static_init_0() {}
 
 /** during worldspawn */
 #define STATIC_INIT(func)       _STATIC_INIT(func##_1,    __static_init_1)
 #define static_init()           CALL_ACCUMULATED_FUNCTION(__static_init_1)
-void __static_init_1() {}
+ACCUMULATE void __static_init_1() {}
 
 /** directly after STATIC_INIT */
 #define STATIC_INIT_LATE(func)  _STATIC_INIT(func##_2,    __static_init_2)
 #define static_init_late()      CALL_ACCUMULATED_FUNCTION(__static_init_2)
-void __static_init_2() {}
+ACCUMULATE void __static_init_2() {}
 
 /** directly after STATIC_INIT_LATE */
 #define PRECACHE(func)          _STATIC_INIT(func##_3,    __static_init_3)
 #define static_init_precache()  CALL_ACCUMULATED_FUNCTION(__static_init_3)
-void __static_init_3() {}
+ACCUMULATE void __static_init_3() {}
 
 /* other map entities spawn now */
 
 /** before shutdown */
 #define SHUTDOWN(func)          _STATIC_INIT(func##_shutdown, __shutdown)
 #define shutdownhooks()         CALL_ACCUMULATED_FUNCTION(    __shutdown)
-void __shutdown() {}
+ACCUMULATE void __shutdown() {}
index f0ea92d6345e347c12d40116ed63fac1c8390c68..4eebad5ef9cc7841fd5c400ff84d227ebe338ffb 100644 (file)
@@ -65,7 +65,7 @@ int g_magic_stats_hole = 0;
 #define EVAL_REGISTER_STAT(...) __VA_ARGS__
 #if defined(CSQC)
        /** Get all stats and store them as globals, access with `STAT(ID)` */
-       void stats_get() {}
+       ACCUMULATE void stats_get() {}
        #define STAT(...) EVAL_STAT(OVERLOAD(STAT, __VA_ARGS__))
        #define EVAL_STAT(...) __VA_ARGS__
     #define STAT_1(id) (RVALUE, _STAT(id))
@@ -99,7 +99,7 @@ int g_magic_stats_hole = 0;
     /** Internal use only */
     entity STATS;
        /** Add all registered stats, access with `STAT(ID, player)` or `.type stat = _STAT(ID); player.stat` */
-       void stats_add() {}
+       ACCUMULATE void stats_add() {}
        #define STAT(...) EVAL_STAT(OVERLOAD_(STAT, __VA_ARGS__))
     #define EVAL_STAT(...) __VA_ARGS__
     #define STAT_1(id) (RVALUE, STAT_2(id, STATS))
@@ -151,8 +151,8 @@ int g_magic_stats_hole = 0;
                        .T fld = _STAT(id); \
                        addstat_##T(STAT_##id.m_id, fld); \
                }
-       void GlobalStats_update(entity this) {}
-       void GlobalStats_updateglobal() {}
+       ACCUMULATE void GlobalStats_update(entity this) {}
+       ACCUMULATE void GlobalStats_updateglobal() {}
     /** TODO: do we want the global copy to update? */
     #define REGISTER_STAT_3(id, T, expr) \
        REGISTER_STAT_2(id, T); \
index 788e6e5c894a6dd105f0b4940e02c9e55b51e324..1e6ec980e3cf88abc25daca8169725d8230ea7fd 100644 (file)
@@ -990,7 +990,7 @@ void havocbot_movetogoal(entity this)
                                float dist = vlen(vec2(this.origin + offset - destorg));
                                // if current and next goal are close to each other make sure
                                // actual_destorg isn't set beyond next_goal_org
-                               if (dist ** 2 > vlen2(vec2(next_goal_org - destorg)))
+                               if (pow(dist, 2) > vlen2(vec2(next_goal_org - destorg)))
                                        actual_destorg = next_goal_org;
                                else
                                        actual_destorg = vec2(destorg) + dist * next_dir;
index 9ec7cc69a637466cfc9759ac3fe398cc5a02558c..bf2d1d6342c35e19ceb29f44f539e3f6a83f92c6 100644 (file)
@@ -854,7 +854,7 @@ void Drag_Begin(entity dragger, entity draggee, vector touchpoint)
        dragger.dragdistance = vlen(touchpoint - dragger.origin - dragger.view_ofs);
        dragger.draglocalangle = draggee.angles.y - dragger.v_angle.y;
        touchpoint = touchpoint - gettaginfo(draggee, 0);
-       tagscale = (vlen(v_forward) ** -2);
+       tagscale = pow(vlen(v_forward), -2);
        dragger.draglocalvector_x = touchpoint * v_forward * tagscale;
        dragger.draglocalvector_y = touchpoint * v_right * tagscale;
        dragger.draglocalvector_z = touchpoint * v_up * tagscale;
@@ -929,7 +929,7 @@ void Drag_MoveForward(entity dragger)
 
 void Drag_SetSpeed(entity dragger, float s)
 {
-       dragger.dragspeed = (2 ** s);
+       dragger.dragspeed = pow(2, s);
 }
 
 void Drag_MoveBackward(entity dragger)
index 3cbc07c57d3dddb989bd6b954ad58df86e6186f0..5b2afc85faeeb35d0ac9125914178caa8839083a 100644 (file)
@@ -980,7 +980,7 @@ float RadiusDamageForSource (entity inflictor, vector inflictororigin, vector in
                                                        LOG_INFOF("THROUGHFLOOR: D=%f F=%f max(dD)=1/%f max(dF)=1/%f", finaldmg, vlen(force), mininv_d, mininv_f);
 
 
-                                               total = 0.25 * (max(mininv_f, mininv_d) ** 2);
+                                               total = 0.25 * pow(max(mininv_f, mininv_d), 2);
 
                                                if(autocvar_g_throughfloor_debug)
                                                        LOG_INFOF(" steps=%f", total);