From: Mario Date: Sat, 2 Jul 2022 16:27:03 +0000 (+1000) Subject: Make accumulated functions explicit, fix a few missed cases of pow being used directly X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5de81e3e4e6429bf83e66867612750187642c096;p=xonotic%2Fxonotic-data.pk3dir.git Make accumulated functions explicit, fix a few missed cases of pow being used directly --- diff --git a/qcsrc/common/mutators/base.qh b/qcsrc/common/mutators/base.qh index 7af5a12ce..a0dd2fc83 100644 --- a/qcsrc/common/mutators/base.qh +++ b/qcsrc/common/mutators/base.qh @@ -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(...) \ diff --git a/qcsrc/lib/cvar.qh b/qcsrc/lib/cvar.qh index d5b47ce43..3c47551ba 100644 --- a/qcsrc/lib/cvar.qh +++ b/qcsrc/lib/cvar.qh @@ -5,6 +5,7 @@ #include "static.qh" ERASEABLE +ACCUMULATE void RegisterCvars(void(string name, string def, string desc, bool archive, string file) f) {} ERASEABLE diff --git a/qcsrc/lib/oo.qh b/qcsrc/lib/oo.qh index a2cef664b..fd3d65a1a 100644 --- a/qcsrc/lib/oo.qh +++ b/qcsrc/lib/oo.qh @@ -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(); diff --git a/qcsrc/lib/registry.qh b/qcsrc/lib/registry.qh index fdcc730a0..3b5b9d906 100644 --- a/qcsrc/lib/registry.qh +++ b/qcsrc/lib/registry.qh @@ -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; \ diff --git a/qcsrc/lib/static.qh b/qcsrc/lib/static.qh index e1879890e..6087c4041 100644 --- a/qcsrc/lib/static.qh +++ b/qcsrc/lib/static.qh @@ -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() {} diff --git a/qcsrc/lib/stats.qh b/qcsrc/lib/stats.qh index f0ea92d63..4eebad5ef 100644 --- a/qcsrc/lib/stats.qh +++ b/qcsrc/lib/stats.qh @@ -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); \ diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 788e6e5c8..1e6ec980e 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -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; diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 9ec7cc69a..bf2d1d634 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -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) diff --git a/qcsrc/server/damage.qc b/qcsrc/server/damage.qc index 3cbc07c57..5b2afc85f 100644 --- a/qcsrc/server/damage.qc +++ b/qcsrc/server/damage.qc @@ -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);