Fix crash when asking for defenders of harbor with waiting attackers#1913
Merged
Conversation
The idea is to potentially use those for defense. However e.g. harbors might contain soldiers that belong to another building and are about to leave. Don't consider those as this complicates the logic too much. Currently it crashed because adding "active" soldiers is assumed to be either the defender or a soldier on a mission from this building. Other soldiers will get lost in the accounting of their home building. Fixes Return-To-The-Roots#1912
It combines handling of armor and boat carriers.
Flow86
reviewed
Apr 20, 2026
Replaced by `GetHome` & `GetGoal`
Flow86
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What happened:
This was indeed introduced by #1910
Prior to that such a soldier would be ignored here.
The result is:
The idea is to potentially use those for defense.
However e.g. harbors might contain soldiers that belong to another
building and are about to leave.
Don't consider those as this complicates the logic too much and just revert to this behavior.
It fixes the crash which is prior to that caught by an assertion: The soldier is not in
troop_on_mission.Fixes #1912
Also fix an assertion failure that detected a mismatch in expected armors: There could be more armored soldiers than soldiers (logic is we have n of m soldiers with armor)
This is detected by continuing the provided savegame.
To avoid similar issues I deduplicated code handling the warehouse inventory: Boat-carrier, soldier and others have to be handled consistently