Phobos icon indicating copy to clipboard operation
Phobos copied to clipboard

DetonateOnAllMapObjects doesn't affect all objects in some situations

Open MortonPL opened this issue 2 years ago • 2 comments

Description

Warheads with DetonateOnAllMapObjects don't affect all target objects in some situations that modify the number of existing technos during detonation (i.e. Ares advanced rubble).

Phobos Version

latest develop

Conditions to reproduce

Ares 3.0

INI code

No response

Steps to reproduce

  1. Play on a map with buildings that can turn into advanced rubble.
  2. Detonate a map-wide warhead with absurd damage through any means.
  3. Watch as not all targets die / become rubble.

Expected behaviour

Warhead detonates on all targeted objects existing at the time of detonation.

Actual behaviour

Warhead detonated only on some targeted objects existing at the time of detonation, or causes a fatal error due to invalid techno pointer.

Additional context

Example video - warhead should convert all oil derricks into rubble and kill all other structures, but only some are destroyed or converted into rubble: https://cdn.discordapp.com/attachments/366962006093463552/1150862354171568138/gamemd_2023-09-11_20-34-37.mp4

Checklist

  • [X] The issue happens on the latest official version of Phobos and wasn't fixed yet.
  • [X] I agree to elaborate the details if requested and provide thorough testing if the bugfix is implemented.
  • [X] I added a very descriptive title to this issue.
  • [X] I used the GitHub search and read the issue list to find a similar issue and didn't find it.
  • [X] I have attached as much information as possible (screenshots, gifs, videos, debug and exception logs, etc).

MortonPL avatar Sep 11 '23 21:09 MortonPL

The proposed solution is to make a shallow copy of the array before iteration and iterate on it instead.

Metadorius avatar Sep 11 '23 21:09 Metadorius

Should be fixed in ed3b785ed594a10f659437733dc80a1fd064ba23. It now iterates on a copy of the array instead of the original.

This is not normally an issue because things like objects dying as result of damage and being logically deleted from the game etc. happen 1 frame after they're hit by the fatal damage, by which point this code is done iterating through them anyways. Advanced rubble (and probably rubble in general) is however created immediately after the building has been taken fatal damage which causes the arrays to change mid-iteration here. Another case I think that is probably the same are passengers of Explodes=true transport. It might be possible that there are other edge-cases that could cause potentially eligible targets to expire before they are iterated over, even if it is a copy of array but difficult to say for sure.

Starkku avatar Oct 19 '23 15:10 Starkku