Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#2096 closed defect (fixed)

[PATCH] Allied units are not ejected upon player resignation.

Reported by: scythetwirler Owned by: sanderd17
Priority: Must Have Milestone: Alpha 15
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description (last modified by scythetwirler)

When a player resigns, allied units are not ejected. You will have a garrisoned Gaia structure.

Attachments (3)

resign.diff (2.1 KB ) - added by mimo 11 years ago.
resign.2.diff (5.0 KB ) - added by mimo 11 years ago.
garrisonCapacity.diff (1.1 KB ) - added by mimo 11 years ago.

Download all attachments as: .zip

Change History (21)

comment:1 by scythetwirler, 11 years ago

Description: modified (diff)

comment:2 by scythetwirler, 11 years ago

Keywords: simple added

comment:3 by historic_bruno, 11 years ago

Milestone: Alpha 14Alpha 15

comment:4 by leper, 11 years ago

Component: Core engineUI & Simulation

by mimo, 11 years ago

Attachment: resign.diff added

comment:5 by mimo, 11 years ago

Here is a fix to this bug. While testing it, I noticed that the rallyPoints were effective for allied units. As I don't think this is a wanted feature, I've also removed it in the patch. If you want to restore it, just remove the first lines of the patch (those about lines 278 to 289).

comment:6 by mimo, 11 years ago

Keywords: patch review added; simple removed
Summary: Allied units are not ejected upon player resignation.[PATCH] Allied units are not ejected upon player resignation.

comment:7 by sanderd17, 11 years ago

Your improvements work good, except for ships. But I see the existing also has problems with ships. When a ship changes ownership (or units in a ship change), they are forced to eject, and dropped to the bottom of the ocean. That would be a very nice way to cheat and attack ships with land units (imagine dropping rams to the ocean). It also happens in other parts (s.a. OnDiplomacyChanged).

Please see the OnHealthChanged about how it should be handled. It should be a forced eject for units in normal buildings, and just kill the units that are in entities (ships, planes ...) that kill their garrisoned entities when they die.

An alternative way would be ungarrisoning without being forced, and if that fails, kill the units. If you do it that way, also check the IsGarrisoningAllowed method, which is set by the plane when it's in the air. So although above valid ground, units should still be killed on ownership change.

It would be great if you can track down these issues.

Thanks for cleaning this up.

comment:8 by mimo, 11 years ago

Thanks for the checks. I indeed did not tested the ships behaviour. I've just updated the patch.

comment:9 by sanderd17, 11 years ago

Looks like a clean sollution with that extra throwAway function. I'll try it.

comment:10 by leper, 11 years ago

I'd rename ThrowAway to EjectOrKill (which tells you what it does and doesn't have you look at the comment).

by mimo, 11 years ago

Attachment: resign.2.diff added

comment:11 by sanderd17, 11 years ago

Owner: set to sanderd17
Resolution: fixed
Status: newclosed

In 13810:

fix ejection of garrisoned units on resign. Fix ejection or killing on ownership and deplomacy changes. Patch by mimo. Fixes #2096

comment:12 by sanderd17, 11 years ago

Keywords: review removed

I modified the OnHealthChanged to also use your new method (and avoid code duplication).

Thanks for working on the patch.

comment:13 by mimo, 11 years ago

Yes, I've hesitated to also do it, but haven't because the behaviour is a bit different : in this EjectOrKill, we do not go to the rallyPoint if there is any, while in the previous OnHealthChanged, we would go to it. I've no strong opinion about the preferred behaviour.

comment:14 by mimo, 11 years ago

There are still two small corrections needed in the latest GarrisonHolder code: UpdateGarrisonFlag is needed after line 542. After this change, the UpdateGarrisonFlag from line 490 could be moved to line 486.

comment:15 by sanderd17, 11 years ago

In 13815:

better garrison flag handling. Refs #2096.

comment:16 by mimo, 11 years ago

There is still a problem in GarrisonHolder because the test on the number of already garrisoned units is done using this.spaceOccupied, which is not always synchronised. We could add the missing synchronizations, but I think it would be simpler and safer to directly test on this.entities.length. I've added the corresponding patch.

by mimo, 11 years ago

Attachment: garrisonCapacity.diff added

comment:17 by sanderd17, 11 years ago

In 13857:

fix garrisoned units count for some special cases. Refs #2096. Patch by mimo

comment:18 by sanderd17, 11 years ago

You're right, clean patch, I added it.

Note: See TracTickets for help on using tickets.