Page MenuHomeWildfire Games

Don't early return in MissileHit when the main target has no position anymore.
AbandonedPublic

Authored by fatherbushido on Jun 2 2017, 10:32 PM.

Details

Reviewers
None
Trac Tickets
#4595
Summary

If a projectile miss its main target there is a query to check if the projectile doesn't actually hit another entity.
To not hardcoded a number, currently the radius of the query is twice the distance between the projectile position and the main target position.
That radius as no real meaning, we just know that it will not be too big. The wrong thing is that if the main target is dead or has not anymore position (garrisoned for example), we will just fall in an early return and the actually hit target won't be damaged.
We could use an hardcoded number, 20 would handle all the case (even if we hit the corner of the case) but could be also too big (so we will check too much collision).
We could use also another not hardcoded distance.

refs D590 #4595

Test Plan

-

Event Timeline

fatherbushido created this revision.Jun 2 2017, 10:32 PM
fatherbushido retitled this revision from e current main target position to Don't early return in MissileHit when the main target has no position anymore..
Vulcan added a subscriber: Vulcan.Jun 2 2017, 11:54 PM
Executing section Default...
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'cmpAttackerOwnership'.
|----|    | /mnt/data/jenkins-phabricator/workspace/phabricator_lint/binaries/data/mods/public/simulation/components/Damage.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/phabricator_lint/binaries/data/mods/public/simulation/components/Damage.js
| 259| 259| Damage.prototype.TargetKilled = function(attacker, target, attackerOwner)
| 260| 260| {
| 261| 261| 	let cmpAttackerOwnership = Engine.QueryInterface(attacker, IID_Ownership);
| 262|    |-	let atkOwner =  cmpAttackerOwnership && cmpAttackerOwnership.GetOwner() != -1 ? cmpAttackerOwnership.GetOwner() : attackerOwner;
|    | 262|+	let atkOwner = cmpAttackerOwnership && cmpAttackerOwnership.GetOwner() != -1 ? cmpAttackerOwnership.GetOwner() : attackerOwner;
| 263| 263| 
| 264| 264| 	// Add to killer statistics.
| 265| 265| 	let cmpKillerPlayerStatisticsTracker = QueryPlayerIDInterface(atkOwner, IID_StatisticsTracker);
Executing section XML GUI...
Executing section Python...
Executing section Perl...

http://jw:8080/job/phabricator_lint/112/ for more details.

elexis added a subscriber: elexis.Jun 3 2017, 3:24 AM
elexis added inline comments.
binaries/data/mods/public/simulation/components/Damage.js
128

20 seems like an unfortunate hardcoding. If the world unit is changed or if mods add huge templates, this might fail. Maybe it already fails for things like the wonder where a catapult hits before this change but now not anymore?

Perhaps the spread of the attacker (or twice that) should be used? (Sounds like work though)

129

The return was added with rP11886 and moved here by rP18625.
It looks just as wrong in that old code as it does in the current.
If the unit died, it should still attempt to damage other units.

Vulcan added a comment.Jun 3 2017, 4:04 AM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jw:8080/job/phabricator/1454/ for more details.

fatherbushido added inline comments.Jun 3 2017, 4:44 PM
binaries/data/mods/public/simulation/components/Damage.js
128

Sure (see summary). If such a number was used, it would need at least a comment.
Indeed currently we have some case where we miss our main target and the projectile collides a corner of a big structure and that one is not damaged.
The only good value to use here would be to use the max footprint radius of all the templates.
I have some wonders also about performances as the bigger the range is, the most collision we have to test.

I don't see obvious link with the spread.

fatherbushido added inline comments.Jun 4 2017, 10:21 AM
binaries/data/mods/public/simulation/components/Damage.js
128

Expecting the center vs footprint boundary thing, we will basically just check the first one of the array (and having a big range query is really bad if nothing else is hurt imo). The current thing was a rough approximation. We could add method (in range query or here) or something like that to get the first encoutered entity, but then we would need a threshold, wich is in fact exactly what we have here.
So if there wasn't the center vs footprint boundary issue (which is mainly only relevant for structure), we could just check the first ent of the query.
(and even with the current code we are missing big structure)

fatherbushido added inline comments.Jun 4 2017, 11:40 AM
binaries/data/mods/public/simulation/components/Damage.js
128

I have an idea (but there is not enough room in this margin).

fatherbushido planned changes to this revision.Jun 5 2017, 8:10 AM
fatherbushido removed a reviewer: Restricted Owners Package.Aug 20 2017, 11:40 PM
fatherbushido abandoned this revision.Aug 30 2017, 11:26 PM

one should find a way to do the right query

fatherbushido reclaimed this revision.Oct 1 2017, 8:43 AM
fatherbushido planned changes to this revision.

Anectdote:
in source/simulation/Collision.h?rev=4437

// maximum radius at which we check for entities (if some entity is much bigger than this, that's bad)
#define COLLISION_RANGE 20
fatherbushido abandoned this revision.Nov 12 2017, 5:33 PM