From: terencehill Date: Sun, 13 Aug 2023 09:02:53 +0000 (+0200) Subject: Small optimization to the damage code X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c1cf79059637354691256bac382910382d910339;p=xonotic%2Fxonotic-data.pk3dir.git Small optimization to the damage code Hash changed due to extremely small difference in the final amount of damage dealt in the bot match (max difference < 0.0012) --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 02ed88f0e..7aca67b20 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 '^:' diff --git a/qcsrc/server/damage.qc b/qcsrc/server/damage.qc index eb70572c0..99c99153a 100644 --- a/qcsrc/server/damage.qc +++ b/qcsrc/server/damage.qc @@ -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;