]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Get rid of all vector / float in server code. 1442/head
authorRudolf Polzer <divVerent@gmail.com>
Thu, 23 Jan 2025 16:32:34 +0000 (11:32 -0500)
committerRudolf Polzer <divVerent@gmail.com>
Thu, 23 Jan 2025 16:32:34 +0000 (11:32 -0500)
It's a bit less accurate than it should be in GMQCC:

https://github.com/graphitemaster/gmqcc/issues/210

To get better equality between compilers, change the code so both
compilers emit the same.

12 files changed:
qcsrc/common/debug.qh
qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc
qcsrc/common/mapobjects/func/ladder.qc
qcsrc/common/mapobjects/trigger/jumppads.qc
qcsrc/common/mutators/mutator/nades/net.qc
qcsrc/common/mutators/mutator/nades/sv_nades.qc
qcsrc/common/util.qc
qcsrc/common/weapons/weapon/arc.qc
qcsrc/server/bot/default/aim.qc
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/waypoints.qc
qcsrc/server/hook.qc

index 16f6d632a3853ce776bca5b84821c5591fe5bf4e..a4c3f388b45f4d85fe60a7786b7f2da2892ea454 100644 (file)
@@ -48,7 +48,7 @@ REGISTER_NET_TEMP(net_debug)
                WriteByte(channel, is_pure(this));
                vector o = this.origin;
                if (o == '0 0 0') // brushes
-                       o = (this.absmin + this.absmax) / 2;
+                       o = (this.absmin + this.absmax) * 0.5;
                if (this.tag_entity)
                        o += this.tag_entity.origin;
                WriteVector(channel, o);
index 48657df2e2d5411f62eeb8daf3c78bfde1f66828..de5c07482796942e275e75a2970e3f692a581708 100644 (file)
@@ -1482,7 +1482,8 @@ void havocbot_ctf_calculate_middlepoint()
        if(!n)
                return;
 
-       havocbot_middlepoint = s / n;
+       // TODO: Consider changing this back to `s / n` after https://github.com/graphitemaster/gmqcc/issues/210.
+       havocbot_middlepoint = s * (1 / n);
        havocbot_middlepoint_radius = vlen(fo - havocbot_middlepoint);
 
        havocbot_symmetry_axis_m = 0;
index a1b374b868dfe2878481f2ca36ad2246b055f2c5..0698b4ca2cb0f6261d038f919971c0dd68cdca88 100644 (file)
@@ -67,7 +67,7 @@ void func_ladder_init(entity this)
        setsize(tracetest_ent, PL_MIN_CONST, PL_MAX_CONST);
        tracetest_ent.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
 
-       vector top_min = (this.absmin + this.absmax) / 2;
+       vector top_min = (this.absmin + this.absmax) * 0.5;
        top_min.z = this.absmax.z;
        vector top_max = top_min;
        top_max.z += PL_MAX_CONST.z - PL_MIN_CONST.z;
index 38d0d0ca6f06f387603ae4a96833aa3d43fb535e..2edbc6236aa0635a3a5ca4331a8fe8bdabdda9f1 100644 (file)
@@ -495,7 +495,7 @@ bool trigger_push_testorigin(entity tracetest_ent, entity targ, entity jp, vecto
                tracetoss(tracetest_ent, tracetest_ent);
                if (trace_startsolid && ofs.z)
                {
-                       setorigin(tracetest_ent, targ.origin + ofs / 2);
+                       setorigin(tracetest_ent, targ.origin + ofs * 0.5);
                        tracetoss(tracetest_ent, tracetest_ent);
                        if (trace_startsolid && ofs.z)
                        {
index 296e7d11582db1e1bdfa04e8736e321fa4607f8a..67e91ffff6c5bd36ba00da49f289b0b98f2e8e5b 100644 (file)
@@ -42,7 +42,7 @@ void orb_setup(entity e)
        setorigin(e, e.origin);
 
        float model_radius = e.maxs.x;
-       vector size = '1 1 1' * e.orb_radius / 2;
+       vector size = '.5 .5 .5' * e.orb_radius;
        setsize(e,-size,size);
        e.orb_radius = e.orb_radius/model_radius*0.6;
 
index 618f502d77b07d976d157ee5dad124d080d1f79b..48359f8887c1ecea3fdb5276027febcbcbe09a2b 100644 (file)
@@ -91,7 +91,7 @@ entity nades_spawn_orb(entity own, entity realown, vector org, float orb_ltime,
        setmodel(orb, MDL_NADE_ORB);
        orb.skin = 1;
        orb.orb_radius = orb_rad; // required for fading
-       vector size = '1 1 1' * orb.orb_radius / 2;
+       vector size = '.5 .5 .5' * orb.orb_radius;
        setsize(orb, -size, size);
 
        Net_LinkEntity(orb, true, 0, orb_send);
index 4ad93f9142685d212400df6aae3783b3725b375c..2e4b7e447e03a6fd5d02f2bca658b7ce309cc4b7 100644 (file)
@@ -1242,7 +1242,7 @@ vector decompressShotOrigin(int f)
        if (v.y & BIT(7)) { v.y &= ~BIT(7); v.x *= -1; }
        if (v.y & BIT(6)) { v.y &= ~BIT(6); v.y *= -1; }
        if (v.z & BIT(6)) { v.z &= ~BIT(6); v.z *= -1; }
-       return v / 2;
+       return v * 0.5;
 }
 
 #ifdef GAMEQC
index 489a1f43f17dcde7b4e6af5e360af5a452f37559..bfce9660b7e2d930530296fc7b99c20fb658e4ed 100644 (file)
@@ -339,7 +339,7 @@ void W_Arc_Beam_Think(entity this)
                float max_allowed_segments = ARC_MAX_SEGMENTS;
                if(WEP_CVAR(WEP_ARC, beam_distancepersegment))
                {
-                       max_allowed_segments = 1 + (vlen(w_shotdir / WEP_CVAR(WEP_ARC, beam_distancepersegment)));
+                       max_allowed_segments = 1 + vlen(w_shotdir) / WEP_CVAR(WEP_ARC, beam_distancepersegment);
                        max_allowed_segments = bound(1, max_allowed_segments, ARC_MAX_SEGMENTS);
                }
 
index 40a61fb4082395972e146ebf77540c3ae02fdec6..0a02e50d1d9df85705a39d58ecd2a52b726f3d83 100644 (file)
@@ -52,7 +52,8 @@ float findtrajectorywithleading(vector org, vector m1, vector m2, entity targ, f
        setorigin(tracetossfaketarget, v);
 
        c = 0;
-       dir = (end - org) / shotdistance; // same as dir = normalize(end - org); but cheaper
+       // TODO: Consider changing this back to `/ shotdistance` after https://github.com/graphitemaster/gmqcc/issues/210.
+       dir = (end - org) * (1 / shotdistance); // same as dir = normalize(end - org); but cheaper
        vector test_dir = dir;
        vector test_dir_normalized = dir;
        while (c < 10) // 10 traces
index d597272b7f1d707798aacaab30a1be6018f51ae2..5a9ef8f6286ff01afafbb8073fdc56f98dfd6785 100644 (file)
@@ -281,7 +281,8 @@ void havocbot_keyboard_movement(entity this, vector destorg)
                                + 0.05 / max(1, sk + this.havocbot_keyboardskill)
                                + random() * 0.025 / max(0.00025, skill + this.havocbot_keyboardskill)
                , time);
-       vector keyboard = CS(this).movement / autocvar_sv_maxspeed;
+       // TODO: Consider changing this back to `/ autocvar_sv_maxspeed` after https://github.com/graphitemaster/gmqcc/issues/210.
+       vector keyboard = CS(this).movement * (1 / autocvar_sv_maxspeed);
 
        float trigger = autocvar_bot_ai_keyboard_threshold;
 
@@ -1086,7 +1087,7 @@ void havocbot_movetogoal(entity this)
                                                }
                                                else
                                                {
-                                                       jump_height = stepheightvec + jumpheight_vec / 2;
+                                                       jump_height = stepheightvec + jumpheight_vec * 0.5;
                                                        tracebox(this.origin + jump_height, this.mins, this.maxs, actual_destorg + jump_height, false, this);
                                                        if (trace_fraction > s)
                                                        {
index 2c60fd4324fa630adc01a4365cc9a5a556b342a7..22a825528afb4378ed8240ab1d3988c1b0d7f338 100644 (file)
@@ -138,7 +138,7 @@ void waypoint_getSymmetricalAxis_cmd(entity caller, bool save, int arg_idx)
 {
        vector v1 = stov(argv(arg_idx++));
        vector v2 = stov(argv(arg_idx++));
-       vector mid = (v1 + v2) / 2;
+       vector mid = (v1 + v2) * 0.5;
 
        float diffy = (v2.y - v1.y);
        float diffx = (v2.x - v1.x);
@@ -190,14 +190,16 @@ void waypoint_getSymmetricalOrigin_cmd(entity caller, bool save, int arg_idx)
        else
        {
                vector v1, v2, v3, v4, v5, v6;
+               // TODO: Consider inlining this away after https://github.com/graphitemaster/gmqcc/issues/210.
+               float r_ctf_flags = 1 / ctf_flags;
                for (int i = 1; i <= ctf_flags; ++i)
                {
-                       if (i == 1) { v1 = stov(argv(arg_idx++)); org = v1 ctf_flags; }
-                       else if (i == 2) { v2 = stov(argv(arg_idx++)); org += v2 ctf_flags; }
-                       else if (i == 3) { v3 = stov(argv(arg_idx++)); org += v3 ctf_flags; }
-                       else if (i == 4) { v4 = stov(argv(arg_idx++)); org += v4 ctf_flags; }
-                       else if (i == 5) { v5 = stov(argv(arg_idx++)); org += v5 ctf_flags; }
-                       else if (i == 6) { v6 = stov(argv(arg_idx++)); org += v6 ctf_flags; }
+                       if (i == 1) { v1 = stov(argv(arg_idx++)); org = v1 * r_ctf_flags; }
+                       else if (i == 2) { v2 = stov(argv(arg_idx++)); org += v2 * r_ctf_flags; }
+                       else if (i == 3) { v3 = stov(argv(arg_idx++)); org += v3 * r_ctf_flags; }
+                       else if (i == 4) { v4 = stov(argv(arg_idx++)); org += v4 * r_ctf_flags; }
+                       else if (i == 5) { v5 = stov(argv(arg_idx++)); org += v5 * r_ctf_flags; }
+                       else if (i == 6) { v6 = stov(argv(arg_idx++)); org += v6 * r_ctf_flags; }
                }
        }
 
index 3d93a169502d44c1fd2e5360d2243a753f300a47..26753d95ec61c98ac26c8e0187120e333989354b 100644 (file)
@@ -170,7 +170,9 @@ void GrapplingHookThink(entity this)
 
                vector dir = this.origin - myorg;
                dist = vlen(dir);
-               dir = (dist ? dir / dist : '0 0 0'); // same as dir = normalize(dir); but cheaper
+
+               // TODO: Consider changing this back to `dir / dist` after https://github.com/graphitemaster/gmqcc/issues/210.
+               dir = (dist ? dir * (1 / dist) : '0 0 0'); // same as dir = normalize(dir); but cheaper
 
                if(tarzan)
                {