]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Small optimization to the damage code
authorterencehill <piuntn@gmail.com>
Sun, 13 Aug 2023 09:02:53 +0000 (11:02 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 13 Aug 2023 09:02:53 +0000 (11:02 +0200)
Hash changed due to extremely small difference in the final amount of damage dealt in the bot match (max difference < 0.0012)

.gitlab-ci.yml
qcsrc/server/damage.qc

index 02ed88f0ef425e06de7da9292fa64a812086e42a..7aca67b20d3d3676d58c2305d77487a727eed974 100644 (file)
@@ -75,7 +75,7 @@ test_sv_game:
     - wget -nv -O data/maps/stormkeep.waypoints https://gitlab.com/xonotic/xonotic-maps.pk3dir/raw/master/maps/stormkeep.waypoints
     - wget -nv -O data/maps/stormkeep.waypoints.cache https://gitlab.com/xonotic/xonotic-maps.pk3dir/raw/master/maps/stormkeep.waypoints.cache
 
-    - EXPECT=81e076663013c894f58976efa6af99c1
+    - EXPECT=b2a88982cfc61339f82bbc9a956dbc30
     - HASH=$(${ENGINE} +exec serverbench.cfg
       | tee /dev/stderr
       | grep '^:'
index eb70572c02322674308a557c1d484c6a14045b85..99c99153aaa54e3e74a591d998b6640fd6bfb3d1 100644 (file)
@@ -919,9 +919,14 @@ float RadiusDamageForSource (entity inflictor, vector inflictororigin, vector in
                if (((cantbe != targ) && !mustbe) || (mustbe == targ))
                if (targ.takedamage)
                {
-                       // measure distance from nearest point on target (not origin)
-                       // to nearest point on inflictor (not origin)
+                       // calculate distance from nearest point on target to nearest point on inflictor
+                       // instead of origin to ensure full damage on impacts
+
                        vector nearest = targ.WarpZone_findradius_nearest;
+
+                       // optimize code by getting inflictororigin_wz from WarpZone_FindRadius calculations instead of
+                       //vector inflictororigin_wz = WarpZone_TransformOrigin(targ, inflictororigin);
+
                        vector inflictororigin_wz = targ.WarpZone_findradius_nearest + targ.WarpZone_findradius_dist;
                        vector inflictornearest = NearestPointOnBoundingBox(
                                inflictororigin_wz + inflictor.mins, inflictororigin_wz + inflictor.maxs, nearest);
@@ -940,15 +945,12 @@ float RadiusDamageForSource (entity inflictor, vector inflictororigin, vector in
                                        float a;
                                        float c;
                                        vector hitloc;
-                                       vector myblastorigin;
                                        vector center;
 
-                                       myblastorigin = WarpZone_TransformOrigin(targ, inflictororigin);
-
                                        // if it's a player, use the view origin as reference
                                        center = CENTER_OR_VIEWOFS(targ);
 
-                                       force = normalize(center - myblastorigin);
+                                       force = normalize(center - inflictororigin_wz);
                                        force = force * (finaldmg / max(coredamage, edgedamage)) * forceintensity;
                                        hitloc = nearest;