HDIAndrew / EFS

12 stars 0 forks source link

Game crashes when in an "infinite loop in combat" scenario on a structure #96

Closed floralpond closed 1 year ago

floralpond commented 1 year ago

#### Description: When an "infinite loop in combat" scenario occurs on a structure such as Ruin, Farm, or (I assume) whatever, the game crashes. From what I've seen in my testing, this generally occurs when a unit type in the attacker stack can't be attacked by the defender stack, but the defender stack has a unit whose agility is too high to be hit by the attacker stack. For example:

Attacker stack has a bunch of green Gryphons (3/20 close attack) Defender stack is symbiots, has a noble with a unit that can't attack air but has high agility/camo - in my examples, a Doppleganger (10 camo and 7 agility, which is bumped up by the noble bonus, and the symbiot sect bonus to agility, and the fact that it was camo, giving another agility bonus).

The attacker stack will take out the noble, but can't hit the Doppleganger. When the defender stack is on an empty tile such as desert, we get the "infinite loop in combat" message and combat is resolved quickly. But when the defender stack is on a structure such as Ruin, Alien Ruin, or Farm, then the game will crash instead of combat resolving.

Expected behavior: Game should exit combat when an infinite loop in combat occurs after other combat resolutions are completed.

Actual behavior: Game crashes.

#### Game version: 1.5 vanilla A scenario (see attached below) was artificially created in 1.5 vanilla using the map editor, but was originally seen in EW3.0.

#### Steps to reproduce: In the attached zip file, there is a modified galaxy (based on the historical vanilla galaxy), where purple has a bunch of Gryphons in the factory and church, and there are a bunch of symbiot structures just north of them that have Noble/Officer/Doppleganger/Assassin combinations. Some of them resolve just fine (like the ones not on a structure, or the ones without a Noble or Officer present), but most of them cause a crash. There is also a save file with the gryphons next to the the symbiot structures ready to attack.

Open the attached save file, and attack one of the structures that have a noble in it. The noble will be killed, then the game will crash.

INFINITELOOPCRASH.zip

#### Additional information:

I'm not exactly sure where the cutoff is (how high does defender agility above attacker accuracy need to be to cause an infinite loop scenario), but I believe that this scenario would not be very common in 1.5 Vanilla, but actually would be more common in heavily modded games such as EW3.0, where units have a much wider variation of accuracy and agility, and targeting might be different. I think in natural gameplay in either vanilla or modded gameplay, this is most likely to occur on ruins or alien ruins, because they frequently have nobles or officers in them with a random of high level units such as dopplegangers who can't attack air units, but could happen on any structure (I've tested farm specifically and it also crashes there). There may also be other scenarios (like something else not involving air units that causes an infinite loop). But I think just generally speaking, if you get an infinite loop in combat message while attacking a structure, then the game will crash.

Matt-Caspermeyer commented 1 year ago

I'm not certain why it would be crashing here since this behavior was not changed from V1.4; however, we hope to look into it in the near future...

Matt-Caspermeyer commented 1 year ago

I have an update on this issue.

I was not seeing a crash here, but rather what appeared to be an endless loop. In reality, it was taking a long time to playout the damage to the structure, but it wasn't showing the structure damage properly.

What I've done for now is to add a timer that had a default of 75 and changed it to 25 (it is called timer_show_structure_damage in EFS.INI and the user can drop it lower) so that now when playing out the structure damage, instead of taking about 1 minute to play out it is less than 20 seconds (and it now shows the damage to the structure correctly) and the player can speed that up more with the above EFS.INI setting.

This PR is currently undergoing our approval and merge process and we hope to have it in the next V1.51 beta build.

floralpond commented 1 year ago

ok, yep that's what I saw. When it was in the loop, if I tried clicking windows would pop up saying that it was unresponsive, so I didn't try waiting and I interpreted it as a crash, when really it's more like a very long loop. 👍