From 4ec6ab47defc60460617f64ad2e023fb98626102 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 2 Jul 2022 23:54:02 +1000 Subject: [PATCH] Enforce use of the pow macro, allow switching between FTEQCC and GMQCC pow implementations --- qcsrc/Makefile | 2 ++ qcsrc/client/announcer.qc | 4 ++-- qcsrc/client/hud/panel/physics.qc | 2 +- qcsrc/client/hud/panel/score.qc | 2 +- qcsrc/client/mapvoting.qc | 2 +- qcsrc/client/view.qc | 4 ++-- qcsrc/common/command/rpn.qc | 2 +- .../gamemode/freezetag/sv_freezetag.qc | 2 +- .../gamemodes/gamemode/keyhunt/sv_keyhunt.qc | 4 ++-- .../common/mapobjects/func/pointparticles.qc | 2 +- qcsrc/common/mapobjects/trigger/impulse.qc | 4 ++-- qcsrc/common/mapobjects/trigger/jumppads.qc | 2 +- .../mutators/mutator/bugrigs/bugrigs.qc | 4 ++-- .../mutators/mutator/dodging/sv_dodging.qc | 2 +- .../dynamic_handicap/sv_dynamic_handicap.qc | 2 +- qcsrc/common/mutators/mutator/nades/nades.qc | 2 +- .../mutator/waypoints/waypointsprites.qc | 6 +++--- qcsrc/common/physics/player.qc | 4 ++-- qcsrc/common/turrets/cl_turrets.qc | 6 +++--- qcsrc/common/util.qc | 4 ++-- qcsrc/common/vehicles/cl_vehicles.qc | 2 +- qcsrc/common/weapons/weapon/crylink.qc | 4 ++-- qcsrc/common/weapons/weapon/hook.qc | 2 +- qcsrc/common/weapons/weapon/tuba.qc | 8 ++++---- qcsrc/lib/_all.inc | 2 +- qcsrc/lib/compiler.qh | 20 +++++++++++++------ qcsrc/lib/math.qh | 14 ++++++------- qcsrc/lib/noise.qh | 8 ++++---- qcsrc/lib/vector.qh | 2 +- qcsrc/menu/xonotic/serverlist.qc | 2 +- qcsrc/menu/xonotic/slider_picmip.qc | 4 ++-- qcsrc/server/bot/default/aim.qc | 4 ++-- qcsrc/server/bot/default/bot.qc | 4 ++-- qcsrc/server/bot/default/havocbot/havocbot.qc | 10 +++++----- qcsrc/server/bot/default/havocbot/roles.qc | 4 ++-- qcsrc/server/bot/default/scripting.qc | 2 +- qcsrc/server/intermission.qc | 2 +- qcsrc/server/spawnpoints.qc | 2 +- qcsrc/tools/qcc.sh | 2 +- 39 files changed, 85 insertions(+), 75 deletions(-) diff --git a/qcsrc/Makefile b/qcsrc/Makefile index ee9e7e64a..c4650c26f 100644 --- a/qcsrc/Makefile +++ b/qcsrc/Makefile @@ -1,5 +1,6 @@ CPP := cc -xc -E QCC ?= ../../../../gmqcc/gmqcc +QCCIDENT ?= -DGMQCC PROGS_OUT ?= .. WORKDIR ?= ../.tmp @@ -128,6 +129,7 @@ export CPP export QCC export QCCDEFS export QCCFLAGS +export QCCIDENT $(PROGS_OUT)/csprogs.dat: client/progs.inc $(QCCVERSIONFILE) | $(WORKDIR) @ echo make[1]: Entering directory \`$(CURDIR)/client\' diff --git a/qcsrc/client/announcer.qc b/qcsrc/client/announcer.qc index d46595e87..2199f9b45 100644 --- a/qcsrc/client/announcer.qc +++ b/qcsrc/client/announcer.qc @@ -32,8 +32,8 @@ void Announcer_Duel() entity pl1 = players.sort_next; entity pl2 = pl1.sort_next; - string pl1_name = (pl1 && pl1.team != NUM_SPECTATOR ? entcs_GetName(pl1.sv_entnum) : "???"); - string pl2_name = (pl2 && pl2.team != NUM_SPECTATOR ? entcs_GetName(pl2.sv_entnum) : "???"); + string pl1_name = ((pl1 && pl1.team != NUM_SPECTATOR) ? entcs_GetName(pl1.sv_entnum) : "???"); + string pl2_name = ((pl2 && pl2.team != NUM_SPECTATOR) ? entcs_GetName(pl2.sv_entnum) : "???"); if(pl1_name == prev_pl1_name && pl2_name == prev_pl2_name) return; // Players haven't changed, stop here diff --git a/qcsrc/client/hud/panel/physics.qc b/qcsrc/client/hud/panel/physics.qc index 53d778a4b..34afc2907 100644 --- a/qcsrc/client/hud/panel/physics.qc +++ b/qcsrc/client/hud/panel/physics.qc @@ -105,7 +105,7 @@ void HUD_Physics() { discrete_acceleration = acceleration; // workaround for ftos_decimals returning a negative 0 - if(discrete_acceleration > -1 / (10 ** acc_decimals) && discrete_acceleration < 0) + if(discrete_acceleration > -1 / pow(10, acc_decimals) && discrete_acceleration < 0) discrete_acceleration = 0; discrete_speed = speed; physics_update_time += autocvar_hud_panel_physics_update_interval; diff --git a/qcsrc/client/hud/panel/score.qc b/qcsrc/client/hud/panel/score.qc index c33fce08b..a8cd5cf08 100644 --- a/qcsrc/client/hud/panel/score.qc +++ b/qcsrc/client/hud/panel/score.qc @@ -186,7 +186,7 @@ void HUD_Score() // distribution display distribution = me.(scores(ps_primary)) - pl.(scores(ps_primary)); - distrtimer = ftos_decimals(fabs(distribution/(10 ** TIME_DECIMALS)), TIME_DECIMALS); + distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS); if (distribution <= 0) { distribution_color = '0 1 0'; diff --git a/qcsrc/client/mapvoting.qc b/qcsrc/client/mapvoting.qc index 29640128c..f69c069e8 100644 --- a/qcsrc/client/mapvoting.qc +++ b/qcsrc/client/mapvoting.qc @@ -473,7 +473,7 @@ void MapVote_Draw() mv_selection = MapVote_Selection(pos, dist, rows, mv_columns); if (mv_top2_time) - mv_top2_alpha = max(0.2, 1 - (time - mv_top2_time) ** 2); + mv_top2_alpha = max(0.2, pow(1 - (time - mv_top2_time), 2)); void (vector, float, float, string, string, float, float) DrawItem; diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 530324656..b731d0881 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -500,7 +500,7 @@ vector GetCurrentFov(float fov) current_zoomfraction = (current_viewzoom - 1) / (1/zoomfactor - 1); if(zoomsensitivity < 1) - setsensitivityscale(current_viewzoom ** (1 - zoomsensitivity)); + setsensitivityscale(pow(current_viewzoom, (1 - zoomsensitivity))); else setsensitivityscale(1); @@ -1331,7 +1331,7 @@ void View_BlurTest() { float t = (time - blurtest_time0) / (blurtest_time1 - blurtest_time0); float r = t * blurtest_radius; - float f = 1 / (t ** blurtest_power) - 1; + float f = 1 / pow(t, blurtest_power) - 1; cvar_set("r_glsl_postprocess", "1"); cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(r), " ", ftos(f), " 0 0")); diff --git a/qcsrc/common/command/rpn.qc b/qcsrc/common/command/rpn.qc index 99f96ff76..2bc494962 100644 --- a/qcsrc/common/command/rpn.qc +++ b/qcsrc/common/command/rpn.qc @@ -171,7 +171,7 @@ void GenericCommand_rpn(int request, int argc, string command) rpn_setf(f2 - f * floor(f2 / f)); } else if(rpncmd == "pow" || rpncmd == "**") { f = rpn_popf(); - rpn_setf(rpn_getf() ** f); + rpn_setf(pow(rpn_getf(), f)); } else if(rpncmd == "bitand" || rpncmd == "&") { f = rpn_popf(); rpn_setf(rpn_getf() & f); diff --git a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc index 4c50abb46..c1f6a081b 100644 --- a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc +++ b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc @@ -223,7 +223,7 @@ void havocbot_goalrating_ft_freeplayers(entity this, float ratingscale, vector o // If teamate is not frozen still seek them out as fight better // in a group. best_dist2 = vlen2(it.origin - org); - if (best_dist2 < 700 ** 2) + if (best_dist2 < pow(700, 2)) { best_pl = NULL; best_dist2 = 0; // already close to a teammate diff --git a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc index 5f90c390f..31cd84172 100644 --- a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc +++ b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc @@ -128,7 +128,7 @@ void kh_update_state() f = key.team; else f = 30; - s |= (32 ** key.count) * f; + s |= pow(32, key.count) * f; } FOREACH_CLIENT(true, { STAT(OBJECTIVE_STATUS, it) = s; }); @@ -136,7 +136,7 @@ void kh_update_state() FOR_EACH_KH_KEY(key) { if(key.owner) - STAT(OBJECTIVE_STATUS, key.owner) |= (32 ** key.count) * 31; + STAT(OBJECTIVE_STATUS, key.owner) |= pow(32, key.count) * 31; } //print(ftos((nextent(NULL)).kh_state), "\n"); } diff --git a/qcsrc/common/mapobjects/func/pointparticles.qc b/qcsrc/common/mapobjects/func/pointparticles.qc index 7aa34ce47..51e4bd0b3 100644 --- a/qcsrc/common/mapobjects/func/pointparticles.qc +++ b/qcsrc/common/mapobjects/func/pointparticles.qc @@ -324,7 +324,7 @@ NET_HANDLE(ENT_CLIENT_POINTPARTICLES, bool isnew) if(!this.absolute) { v = this.maxs - this.mins; - this.impulse *= -v.x * v.y * v.z / (64**3); // relative: particles per 64^3 cube + this.impulse *= -v.x * v.y * v.z / pow(64, 3); // relative: particles per 64^3 cube } } diff --git a/qcsrc/common/mapobjects/trigger/impulse.qc b/qcsrc/common/mapobjects/trigger/impulse.qc index 4306e2ff7..296c6436e 100644 --- a/qcsrc/common/mapobjects/trigger/impulse.qc +++ b/qcsrc/common/mapobjects/trigger/impulse.qc @@ -80,7 +80,7 @@ void trigger_impulse_touch_accel(entity this, entity toucher) } // div0: ticrate independent, 1 = identity (not 20) - toucher.velocity = toucher.velocity * (this.strength ** pushdeltatime); + toucher.velocity = toucher.velocity * pow(this.strength, pushdeltatime); #ifdef SVQC UpdateCSQCProjectile(toucher); @@ -203,7 +203,7 @@ spawnfunc(trigger_impulse) { this.strength = IMPULSE_DEFAULT_ACCEL_STRENGTH; } - this.strength = (this.strength ** autocvar_g_triggerimpulse_accel_power) * autocvar_g_triggerimpulse_accel_multiplier; + this.strength = pow(this.strength, autocvar_g_triggerimpulse_accel_power) * autocvar_g_triggerimpulse_accel_multiplier; settouch(this, trigger_impulse_touch_accel); } } diff --git a/qcsrc/common/mapobjects/trigger/jumppads.qc b/qcsrc/common/mapobjects/trigger/jumppads.qc index 59fd0c553..a4cc2a971 100644 --- a/qcsrc/common/mapobjects/trigger/jumppads.qc +++ b/qcsrc/common/mapobjects/trigger/jumppads.qc @@ -371,7 +371,7 @@ float trigger_push_get_push_time(entity this, vector endpos) vector v = this.movedir; float t = v.z / grav; - float jump_height = 1/2 * grav * (t ** 2); + float jump_height = 1/2 * grav * pow(t, 2); float remaining_height = org.z + jump_height - endpos.z; float v2_z = sqrt(2 * grav * remaining_height); diff --git a/qcsrc/common/mutators/mutator/bugrigs/bugrigs.qc b/qcsrc/common/mutators/mutator/bugrigs/bugrigs.qc index 1ee60e1d4..a9c9c76a0 100644 --- a/qcsrc/common/mutators/mutator/bugrigs/bugrigs.qc +++ b/qcsrc/common/mutators/mutator/bugrigs/bugrigs.qc @@ -135,7 +135,7 @@ void RaceCarPhysics(entity this, float dt) float upspeed = this.velocity * v_up; // responsiveness factor for steering and acceleration - float f = 1 / (1 + ((max(-myspeed, myspeed) / PHYS_BUGRIGS_SPEED_REF(this)) ** PHYS_BUGRIGS_SPEED_POW(this))); + float f = 1 / (1 + pow((max(-myspeed, myspeed) / PHYS_BUGRIGS_SPEED_REF(this)), PHYS_BUGRIGS_SPEED_POW(this))); //MAXIMA: f(v) := 1 / (1 + (v / PHYS_BUGRIGS_SPEED_REF(this)) ^ PHYS_BUGRIGS_SPEED_POW(this)); float steerfactor; @@ -192,7 +192,7 @@ void RaceCarPhysics(entity this, float dt) float myspeed = vlen(this.velocity); // responsiveness factor for steering and acceleration - float f = 1 / (1 + (max(0, myspeed / PHYS_BUGRIGS_SPEED_REF(this)) ** PHYS_BUGRIGS_SPEED_POW(this))); + float f = 1 / (1 + pow(max(0, myspeed / PHYS_BUGRIGS_SPEED_REF(this)), PHYS_BUGRIGS_SPEED_POW(this))); float steerfactor = -myspeed * f; this.angles_y += steer * dt * steerfactor; // apply steering diff --git a/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc b/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc index 8af509222..e01a89561 100644 --- a/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc +++ b/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc @@ -206,7 +206,7 @@ bool PM_dodging_checkpressedkeys(entity this) this.dodging_direction.y = tap_direction_y; // normalize the dodging_direction vector.. (unlike UT99) XD - float length = sqrt(this.dodging_direction.x ** 2 + this.dodging_direction.y ** 2); + float length = sqrt(pow(this.dodging_direction.x, 2) + pow(this.dodging_direction.y, 2)); this.dodging_direction.x = this.dodging_direction.x / length; this.dodging_direction.y = this.dodging_direction.y / length; diff --git a/qcsrc/common/mutators/mutator/dynamic_handicap/sv_dynamic_handicap.qc b/qcsrc/common/mutators/mutator/dynamic_handicap/sv_dynamic_handicap.qc index 237d14a6e..e34ab2f1c 100644 --- a/qcsrc/common/mutators/mutator/dynamic_handicap/sv_dynamic_handicap.qc +++ b/qcsrc/common/mutators/mutator/dynamic_handicap/sv_dynamic_handicap.qc @@ -44,7 +44,7 @@ void DynamicHandicap_UpdateHandicap() float score = PlayerScore_Get(it, SP_SCORE); float handicap = fabs((score - mean_score) * autocvar_g_dynamic_handicap_scale); - handicap = handicap ** autocvar_g_dynamic_handicap_exponent; + handicap = pow(handicap, autocvar_g_dynamic_handicap_exponent); if (score < mean_score) { handicap = -handicap; diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index f64e5d329..3b423e0da 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -594,7 +594,7 @@ void nade_entrap_touch(entity this, entity toucher) if(!pushdeltatime) return; // div0: ticrate independent, 1 = identity (not 20) - toucher.velocity = toucher.velocity * (autocvar_g_nades_entrap_strength ** pushdeltatime); + toucher.velocity = toucher.velocity * pow(autocvar_g_nades_entrap_strength, pushdeltatime); #ifdef SVQC UpdateCSQCProjectile(toucher); diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc index 88c508229..5062c9f20 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc @@ -470,7 +470,7 @@ vector fixrgbexcess(vector rgb) void Draw_WaypointSprite(entity this) { if (this.lifetime > 0) - this.alpha = (bound(0, (this.fadetime - time) / this.lifetime, 1) ** waypointsprite_timealphaexponent); + this.alpha = pow(bound(0, (this.fadetime - time) / this.lifetime, 1), waypointsprite_timealphaexponent); else this.alpha = 1; @@ -535,7 +535,7 @@ void Draw_WaypointSprite(entity this) { // restrict maximum normal distance to the waypoint's maximum distance to prevent exploiting cvars float maxnormdistance = bound(0, waypointsprite_normdistance, this.maxdistance - 1); - a *= (bound(0, (this.maxdistance - dist) / (this.maxdistance - maxnormdistance), 1) ** waypointsprite_distancealphaexponent); + a *= pow(bound(0, (this.maxdistance - dist) / (this.maxdistance - maxnormdistance), 1), waypointsprite_distancealphaexponent); } vector rgb = spritelookupcolor(this, spriteimage, this.teamradar_color); @@ -626,7 +626,7 @@ void Draw_WaypointSprite(entity this) (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right)) - o.x, (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)) - o.y); - float crosshairdistance = sqrt( ((o.x - vid_conwidth/2) ** 2) + ((o.y - vid_conheight/2) ** 2) ); + float crosshairdistance = sqrt( pow((o.x - vid_conwidth/2), 2) + pow((o.y - vid_conheight/2), 2) ); t = waypointsprite_scale; a *= waypointsprite_alpha; diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index 75ebfd2ce..e6d90b091 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -116,7 +116,7 @@ float GeomLerp(float a, float _lerp, float b) { return a == 0 ? (_lerp < 1 ? 0 : b) : b == 0 ? (_lerp > 0 ? 0 : a) - : a * (fabs(b / a) ** _lerp); + : a * pow(fabs(b / a), _lerp); } void PM_ClientMovement_UpdateStatus(entity this) @@ -200,7 +200,7 @@ void CPM_PM_Aircontrol(entity this, float dt, vector wishdir, float wishspeed) if (dot > 0) // we can't change direction while slowing down { - k *= (dot ** PHYS_AIRCONTROL_POWER(this)) * dt; + k *= pow(dot, PHYS_AIRCONTROL_POWER(this)) * dt; xyspeed = max(0, xyspeed - PHYS_AIRCONTROL_PENALTY(this) * sqrt(max(0, 1 - dot*dot)) * k/32); k *= PHYS_AIRCONTROL(this); this.velocity = normalize(this.velocity * xyspeed + wishdir * k); diff --git a/qcsrc/common/turrets/cl_turrets.qc b/qcsrc/common/turrets/cl_turrets.qc index aff0f764c..8201ddb8a 100644 --- a/qcsrc/common/turrets/cl_turrets.qc +++ b/qcsrc/common/turrets/cl_turrets.qc @@ -106,9 +106,9 @@ void turret_draw2d(entity this) if(this.maxdistance > waypointsprite_normdistance) - a *= (bound(0, (this.maxdistance - dist) / (this.maxdistance - waypointsprite_normdistance), 1) ** waypointsprite_distancealphaexponent); + a *= pow(bound(0, (this.maxdistance - dist) / (this.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent); else if(this.maxdistance > 0) - a *= (bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1) ** waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha; + a *= pow(bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha; if(rgb == '0 0 0') { @@ -158,7 +158,7 @@ void turret_draw2d(entity this) (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right)) - o_x, (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)) - o_y); - float crosshairdistance = sqrt( ((o.x - vid_conwidth/2) ** 2) + ((o.y - vid_conheight/2) ** 2) ); + float crosshairdistance = sqrt( pow((o.x - vid_conwidth/2), 2) + pow((o.y - vid_conheight/2), 2) ); t = waypointsprite_scale; a *= waypointsprite_alpha; diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index 8ef6b2019..3db18ebc0 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -502,7 +502,7 @@ float compressShortVector(vector vec) STATIC_INIT(compressShortVector) { float l = 1; - float f = (2 ** (1/8)); + float f = pow(2, (1/8)); int i; for(i = 0; i < 128; ++i) { @@ -1891,7 +1891,7 @@ void attach_sameorigin(entity e, entity to, string tag) float tagscale; org = e.origin - gettaginfo(to, gettagindex(to, tag)); - tagscale = (vlen(v_forward) ** -2); // undo a scale on the tag + tagscale = pow(vlen(v_forward), -2); // undo a scale on the tag t_forward = v_forward * tagscale; t_left = v_right * -tagscale; t_up = v_up * tagscale; diff --git a/qcsrc/common/vehicles/cl_vehicles.qc b/qcsrc/common/vehicles/cl_vehicles.qc index a9f44a2c2..d9cac4768 100644 --- a/qcsrc/common/vehicles/cl_vehicles.qc +++ b/qcsrc/common/vehicles/cl_vehicles.qc @@ -167,7 +167,7 @@ void Vehicles_drawHUD( float tmpblinkValue = 0.55 + sin(time * 3) * 0.45; tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (96/256) - tmpSize.x; tmpPos.y = vehicleHud_Pos.y; - tmpSize = '1 1 1' * hud_fontsize; + tmpSize = hud_fontsize; drawstring(tmpPos, sprintf(_("Press %s"), getcommandkey(_("drop weapon"), "dropweapon")), tmpSize, '1 0 0' + '0 1 1' * tmpblinkValue, hudAlpha, DRAWFLAG_NORMAL); } diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 5458a2496..70483c3b9 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -115,9 +115,9 @@ vector W_Crylink_LinkJoin(entity e, float jspeed) return avg_origin; // nothing to do // yes, mathematically we can do this in ONE step, but beware of 32bit floats... - avg_dist = (vlen(e.origin - avg_origin) ** 2); + avg_dist = pow(vlen(e.origin - avg_origin), 2); for(p = e; (p = p.queuenext) != e; ) - avg_dist += (vlen(WarpZone_RefSys_TransformOrigin(p, e, p.origin) - avg_origin) ** 2); + avg_dist += pow(vlen(WarpZone_RefSys_TransformOrigin(p, e, p.origin) - avg_origin), 2); avg_dist *= (1.0 / n); avg_dist = sqrt(avg_dist); diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index d9e11dc01..f6dffa047 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -7,7 +7,7 @@ void W_Hook_ExplodeThink(entity this) float dt, dmg_remaining_next, f; dt = time - this.teleport_time; - dmg_remaining_next = (bound(0, 1 - dt / this.dmg_duration, 1) ** this.dmg_power); + dmg_remaining_next = pow(bound(0, 1 - dt / this.dmg_duration, 1), this.dmg_power); f = this.dmg_last - dmg_remaining_next; this.dmg_last = dmg_remaining_next; diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index bb1c015dd..0e0858d62 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -454,23 +454,23 @@ void tubasound(entity e, bool restart) if (restart) { snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m + Tuba_PitchStep); } - speed1 = (2.0 ** ((m - Tuba_PitchStep) / 12.0)); + speed1 = pow(2.0, ((m - Tuba_PitchStep) / 12.0)); } else if (e.note - m + Tuba_PitchStep > TUBA_MAX) { if (restart) { snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m); } - speed1 = (2.0 ** (m / 12.0)); + speed1 = pow(2.0, (m / 12.0)); } else { if (restart) { snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m); } vol1 = cos(M_PI_2 * m / Tuba_PitchStep); - speed1 = (2.0 ** (m / 12.0)); + speed1 = pow(2.0, (m / 12.0)); if (restart) { snd2 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m + Tuba_PitchStep); } vol2 = sin(M_PI_2 * m / Tuba_PitchStep); - speed2 = (2.0 ** ((m - Tuba_PitchStep) / 12.0)); + speed2 = pow(2.0, ((m - Tuba_PitchStep) / 12.0)); } } else if (restart) { snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note); diff --git a/qcsrc/lib/_all.inc b/qcsrc/lib/_all.inc index 0bef0b6e0..7e9fd3cc8 100644 --- a/qcsrc/lib/_all.inc +++ b/qcsrc/lib/_all.inc @@ -64,7 +64,7 @@ #ifndef QCC_SUPPORT_POW #define pow(a, b) pow(a, b) #else - #define pow(a, b) ((a) ** (b)) + #define pow(a, b) POW(a, b) #endif #include "self.qh" diff --git a/qcsrc/lib/compiler.qh b/qcsrc/lib/compiler.qh index 5ca0ed565..b633782dc 100644 --- a/qcsrc/lib/compiler.qh +++ b/qcsrc/lib/compiler.qh @@ -1,37 +1,45 @@ #pragma once #ifndef QCC_SUPPORT_ACCUMULATE - #ifdef GMQCC + #if defined(GMQCC) || defined(FTEQCC) #define QCC_SUPPORT_ACCUMULATE #endif #endif #ifndef QCC_SUPPORT_NIL - #ifdef GMQCC + #if defined(GMQCC) || defined(FTEQCC) #define QCC_SUPPORT_NIL #endif #endif #ifndef QCC_SUPPORT_ERASEABLE - #ifdef GMQCC + #if defined(GMQCC) || defined(FTEQCC) #define QCC_SUPPORT_ERASEABLE #endif #endif #ifndef QCC_SUPPORT_ALIAS - #ifdef GMQCC + #if defined(GMQCC) || defined(FTEQCC) #define QCC_SUPPORT_ALIAS #endif #endif #ifndef QCC_SUPPORT_POW - #ifdef GMQCC + #if defined(GMQCC) || defined(FTEQCC) #define QCC_SUPPORT_POW #endif #endif -#ifdef GMQCC +#if defined(GMQCC) || defined(FTEQCC) #define LABEL(id) :id #else #define LABEL(id) id: #endif + +#ifdef QCC_SUPPORT_POW + #ifdef FTEQCC + #define POW(a, b) ((a) *^ (b)) + #else + #define POW(a, b) ((a) ** (b)) + #endif +#endif diff --git a/qcsrc/lib/math.qh b/qcsrc/lib/math.qh index ac2332500..46b5554e3 100644 --- a/qcsrc/lib/math.qh +++ b/qcsrc/lib/math.qh @@ -6,8 +6,8 @@ ERASEABLE void mean_accumulate(entity e, .float a, .float c, float mean, float value, float weight) { if (weight == 0) return; - if (mean == 0) e.(a) *= (value ** weight); - else e.(a) += (value ** mean) * weight; + if (mean == 0) e.(a) *= pow(value, weight); + else e.(a) += pow(value, mean) * weight; e.(c) += weight; } @@ -15,8 +15,8 @@ ERASEABLE float mean_evaluate(entity e, .float a, .float c, float mean) { if (e.(c) == 0) return 0; - if (mean == 0) return (e.(a) ** (1.0 / e.(c))); - else return ((e.(a) / e.(c)) ** (1.0 / mean)); + if (mean == 0) return pow(e.(a), (1.0 / e.(c))); + else return pow((e.(a) / e.(c)), (1.0 / mean)); } #define MEAN_ACCUMULATE(s, prefix, v, w) mean_accumulate(s, prefix##_accumulator, prefix##_count, prefix##_mean, v, w) @@ -243,12 +243,12 @@ float almost_in_bounds(float a, float b, float c) ERASEABLE float ExponentialFalloff(float mindist, float maxdist, float halflifedist, float d) { - if (halflifedist > 0) return (0.5 ** ((bound(mindist, d, maxdist) - mindist) / halflifedist)); - else if (halflifedist < 0) return (0.5 ** ((bound(mindist, d, maxdist) - maxdist) / halflifedist)); + if (halflifedist > 0) return pow(0.5, ((bound(mindist, d, maxdist) - mindist) / halflifedist)); + else if (halflifedist < 0) return pow(0.5, ((bound(mindist, d, maxdist) - maxdist) / halflifedist)); else return 1; } -#define power2of(e) (2 ** e) +#define power2of(e) pow(2, e) ERASEABLE float log2of(float e) diff --git a/qcsrc/lib/noise.qh b/qcsrc/lib/noise.qh index 5ef9cf8b6..8e5308baa 100644 --- a/qcsrc/lib/noise.qh +++ b/qcsrc/lib/noise.qh @@ -20,9 +20,9 @@ float Noise_Pink(entity e, float dt) float f; f = dt * 60; // http://home.earthlink.net/~ltrammell/tech/pinkalg.htm - if (random() > (0.3190 ** f)) e.noise_paccum = 0.34848 * (2 * random() - 1); - if (random() > (0.7756 ** f)) e.noise_paccum2 = 0.28768 * (2 * random() - 1); - if (random() > (0.9613 ** f)) e.noise_paccum3 = 0.43488 * (2 * random() - 1); + if (random() > pow(0.3190, f)) e.noise_paccum = 0.34848 * (2 * random() - 1); + if (random() > pow(0.7756, f)) e.noise_paccum2 = 0.28768 * (2 * random() - 1); + if (random() > pow(0.9613, f)) e.noise_paccum3 = 0.43488 * (2 * random() - 1); return e.noise_paccum + e.noise_paccum2 + e.noise_paccum3; } ERASEABLE @@ -34,6 +34,6 @@ float Noise_White(entity e, float dt) ERASEABLE float Noise_Burst(entity e, float dt, float p) { - if (random() > (p ** dt)) e.noise_bstate = !e.noise_bstate; + if (random() > pow(p, dt)) e.noise_bstate = !e.noise_bstate; return 2 * e.noise_bstate - 1; } diff --git a/qcsrc/lib/vector.qh b/qcsrc/lib/vector.qh index 23bfdf055..e048fad81 100644 --- a/qcsrc/lib/vector.qh +++ b/qcsrc/lib/vector.qh @@ -5,7 +5,7 @@ noref vector _vlen2; #if 1 /** Vector distance comparison, avoids sqrt() */ -#define vdist(v, cmp, f) (vlen2(v) cmp ((f) ** 2)) +#define vdist(v, cmp, f) (vlen2(v) cmp pow((f), 2)) #else #define vdist(v, cmp, f) (vlen(v) cmp (f)) #endif diff --git a/qcsrc/menu/xonotic/serverlist.qc b/qcsrc/menu/xonotic/serverlist.qc index e07081e54..1455cc9c8 100644 --- a/qcsrc/menu/xonotic/serverlist.qc +++ b/qcsrc/menu/xonotic/serverlist.qc @@ -239,7 +239,7 @@ METHOD(XonoticServerList, toggleFavorite, void(XonoticServerList this, string sr adding = false; string before = (i > 0) ? substring(s, 0, argv_end_index(i - 1)) : ""; string after = (i < n - 1) ? substring(s, argv_start_index(i + 1), -1) : ""; - s = strcat(before, (before != "" && after != "" ? " " : ""), after); + s = strcat(before, ((before != "" && after != "") ? " " : ""), after); ret = s; // keep searching // TODO: why not break here? diff --git a/qcsrc/menu/xonotic/slider_picmip.qc b/qcsrc/menu/xonotic/slider_picmip.qc index c0b03af57..ba4bf0782 100644 --- a/qcsrc/menu/xonotic/slider_picmip.qc +++ b/qcsrc/menu/xonotic/slider_picmip.qc @@ -18,8 +18,8 @@ float texmemsize(float s3tc) { return ( - 2500 * (0.25 ** max(0, cvar("gl_picmip") + cvar("gl_picmip_other"))) - + 1500 * (0.25 ** max(0, cvar("gl_picmip") + cvar("gl_picmip_world"))) + 2500 * pow(0.25, max(0, cvar("gl_picmip") + cvar("gl_picmip_other"))) + + 1500 * pow(0.25, max(0, cvar("gl_picmip") + cvar("gl_picmip_world"))) ) * ((s3tc && (cvar("r_texture_dds_load") || cvar("gl_texturecompression"))) ? 0.2 : 1.0); // TC: normalmaps 50%, other 25%, few incompressible, guessing 40% as conservative average } void XonoticPicmipSlider_autofix(entity me) diff --git a/qcsrc/server/bot/default/aim.qc b/qcsrc/server/bot/default/aim.qc index 6b1488bac..9b4d5ee20 100644 --- a/qcsrc/server/bot/default/aim.qc +++ b/qcsrc/server/bot/default/aim.qc @@ -254,7 +254,7 @@ void bot_aimdir(entity this, vector v, float maxfiredeviation) this.bot_5th_order_aimfilter= this.bot_5th_order_aimfilter + (this.bot_4th_order_aimfilter - this.bot_5th_order_aimfilter) * bound(0, autocvar_bot_ai_aimskill_order_filter_5th,1); - //blend = (bound(0,skill,10)*0.1)*((1-bound(0,skill,10)*0.05) ** 2.5)*5.656854249; //Plot formule before changing ! + //blend = (bound(0,skill,10)*0.1)*pow((1-bound(0,skill,10)*0.05), 2.5)*5.656854249; //Plot formule before changing ! blend = bound(0,skill+this.bot_aimskill,10)*0.1; desiredang = desiredang + blend * ( @@ -307,7 +307,7 @@ void bot_aimdir(entity this, vector v, float maxfiredeviation) blendrate = autocvar_bot_ai_aimskill_blendrate; r = max(fixedrate, blendrate); //this.v_angle = this.v_angle + diffang * bound(frametime, r * frametime * (2+skill*skill*0.05-random()*0.05*(10-skill)), 1); - r = bound(delta_t, r * delta_t * (2 + ((skill + this.bot_mouseskill) ** 3) * 0.005 - random()), 1); + r = bound(delta_t, r * delta_t * (2 + pow((skill + this.bot_mouseskill), 3) * 0.005 - random()), 1); this.v_angle += diffang * (r + (1 - r) * bound(0, 1 - autocvar_bot_ai_aimskill_mouse, 1)); this.v_angle_z = 0; diff --git a/qcsrc/server/bot/default/bot.qc b/qcsrc/server/bot/default/bot.qc index 79b3a9692..bdd148082 100644 --- a/qcsrc/server/bot/default/bot.qc +++ b/qcsrc/server/bot/default/bot.qc @@ -64,7 +64,7 @@ void bot_think(entity this) if(autocvar_bot_god) this.flags |= FL_GODMODE; - this.bot_nextthink = max(time, this.bot_nextthink) + max(0.01, autocvar_bot_ai_thinkinterval * (0.5 ** this.bot_aiskill) * min(14 / (skill + 14), 1)); + this.bot_nextthink = max(time, this.bot_nextthink) + max(0.01, autocvar_bot_ai_thinkinterval * pow(0.5, this.bot_aiskill) * min(14 / (skill + 14), 1)); if (!IS_PLAYER(this) || (autocvar_g_campaign && !campaign_bots_may_start)) { @@ -587,7 +587,7 @@ void autoskill(float factor) void bot_calculate_stepheightvec() { stepheightvec = autocvar_sv_stepheight * '0 0 1'; - jumpheight_vec = (autocvar_sv_jumpvelocity ** 2) / (2 * autocvar_sv_gravity) * '0 0 1'; + jumpheight_vec = pow(autocvar_sv_jumpvelocity, 2) / (2 * autocvar_sv_gravity) * '0 0 1'; jumpstepheightvec = stepheightvec + jumpheight_vec * 0.85; // reduce it a bit to make the jumps easy jumpheight_time = autocvar_sv_jumpvelocity / autocvar_sv_gravity; } diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 689f0c179..788e6e5c8 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -376,7 +376,7 @@ entity havocbot_select_an_item_of_group(entity this, int gr) IL_EACH(g_items, it.item_group == gr && it.solid, { float dist2 = vlen2(this.origin - it.origin); - if (dist2 < 600 ** 2 && dist2 > selected_dist2) + if (dist2 < pow(600, 2) && dist2 > selected_dist2) { selected = it; selected_dist2 = vlen2(this.origin - selected.origin); @@ -447,7 +447,7 @@ void havocbot_movetogoal(entity this) if(d < db || d < 500) { // Brake - if (vel2 > (maxspeed * 0.3) ** 2) + if (vel2 > pow((maxspeed * 0.3), 2)) { CS(this).movement_x = dir * v_forward * -maxspeed; return; @@ -1333,7 +1333,7 @@ void havocbot_chooseenemy(entity this) this.havocbot_chooseenemy_finished = time + autocvar_bot_ai_enemydetectioninterval; vector eye = this.origin + this.view_ofs; entity best = NULL; - float bestrating = autocvar_bot_ai_enemydetectionradius ** 2; + float bestrating = pow(autocvar_bot_ai_enemydetectionradius, 2); // Backup hit flags int hf = this.dphitcontentsmask; @@ -1379,7 +1379,7 @@ LABEL(scan_targets) { scan_secondary_targets = true; // restart the loop - bestrating = autocvar_bot_ai_enemydetectionradius ** 2; + bestrating = pow(autocvar_bot_ai_enemydetectionradius, 2); goto scan_targets; } @@ -1479,7 +1479,7 @@ void havocbot_chooseweapon(entity this, .entity weaponentity) this.lastcombotime = time; } - distance *= (2 ** this.bot_rangepreference); + distance *= pow(2, this.bot_rangepreference); // Custom weapon list based on distance to the enemy if(bot_custom_weapon){ diff --git a/qcsrc/server/bot/default/havocbot/roles.qc b/qcsrc/server/bot/default/havocbot/roles.qc index 52aff186a..e7d752523 100644 --- a/qcsrc/server/bot/default/havocbot/roles.qc +++ b/qcsrc/server/bot/default/havocbot/roles.qc @@ -97,8 +97,8 @@ bool havocbot_goalrating_item_pickable_check_players(entity this, vector org, en // Rate the item only if no one needs it, or if an enemy is closer to it dist2 = vlen2(item_org - org); if ((enemy_dist2 < friend_dist2 && dist2 < enemy_dist2) - || (friend_dist2 > autocvar_bot_ai_friends_aware_pickup_radius ** 2) - || (dist2 < friend_dist2 && dist2 < 200 ** 2)) + || (friend_dist2 > pow(autocvar_bot_ai_friends_aware_pickup_radius, 2)) + || (dist2 < friend_dist2 && dist2 < pow(200, 2))) return true; return false; }; diff --git a/qcsrc/server/bot/default/scripting.qc b/qcsrc/server/bot/default/scripting.qc index 5a1333065..e072a8372 100644 --- a/qcsrc/server/bot/default/scripting.qc +++ b/qcsrc/server/bot/default/scripting.qc @@ -892,7 +892,7 @@ float bot_cmd_keypress_handler(entity this, string key, float enabled) { case "all": if(enabled) - this.bot_cmd_keys = (2 ** 20) - 1; // >:) + this.bot_cmd_keys = pow(2, 20) - 1; // >:) else this.bot_cmd_keys = BOT_CMD_KEY_NONE; case "forward": diff --git a/qcsrc/server/intermission.qc b/qcsrc/server/intermission.qc index 98d2ef25b..0e2f7d55f 100644 --- a/qcsrc/server/intermission.qc +++ b/qcsrc/server/intermission.qc @@ -225,7 +225,7 @@ float MaplistMethod_Shuffle(float exponent) // more clever shuffling string newlist; // now reinsert this at another position - insertpos = (random() ** (1 / exponent)); // ]0, 1] + insertpos = pow(random(), (1 / exponent)); // ]0, 1] insertpos = insertpos * (Map_Count - 1); // ]0, Map_Count - 1] insertpos = ceil(insertpos) + 1; // {2, 3, 4, ..., Map_Count} LOG_TRACE("SHUFFLE: insert pos = ", ftos(insertpos)); diff --git a/qcsrc/server/spawnpoints.qc b/qcsrc/server/spawnpoints.qc index dbe15ee19..8fc73e844 100644 --- a/qcsrc/server/spawnpoints.qc +++ b/qcsrc/server/spawnpoints.qc @@ -312,7 +312,7 @@ entity Spawn_WeightedPoint(entity firstspot, float lower, float upper, float exp RandomSelection_Init(); for(spot = firstspot; spot; spot = spot.chain) - RandomSelection_AddEnt(spot, (bound(lower, spot.spawnpoint_score.y, upper) ** exponent) * spot.cnt, (spot.spawnpoint_score.y >= lower) * 0.5 + spot.spawnpoint_score.x); + RandomSelection_AddEnt(spot, pow(bound(lower, spot.spawnpoint_score.y, upper), exponent) * spot.cnt, (spot.spawnpoint_score.y >= lower) * 0.5 + spot.spawnpoint_score.x); return RandomSelection_chosen_ent; } diff --git a/qcsrc/tools/qcc.sh b/qcsrc/tools/qcc.sh index dfc375bb5..bf6c26eec 100755 --- a/qcsrc/tools/qcc.sh +++ b/qcsrc/tools/qcc.sh @@ -5,7 +5,7 @@ IFS=$' \n\t' WORKDIR=${WORKDIR} CPP=${CPP} QCC=${QCC} -QCCIDENT="-DGMQCC" +QCCIDENT=${QCCIDENT} QCCDEFS=${QCCDEFS} QCCFLAGS=${QCCFLAGS} -- 2.39.2