Skip to content

Fix IndexOutOfBoundsException starting a game on a one-coast map#166

Open
KevinGriffin-new wants to merge 1 commit into
FreeCol:sf-auto-mergefrom
KevinGriffin-new:fix-one-coast-start-crash
Open

Fix IndexOutOfBoundsException starting a game on a one-coast map#166
KevinGriffin-new wants to merge 1 commit into
FreeCol:sf-auto-mergefrom
KevinGriffin-new:fix-one-coast-start-crash

Conversation

@KevinGriffin-new

Copy link
Copy Markdown

Made a Pacific-coast map (sea only on the west edge). Every nation except Russia has starts-on-east-coast=true, and EuropeanStartingPositionsGenerator does remove(0) on the east list, which is empty:

java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
    at java.util.ArrayList.remove(ArrayList.java:551)
    at net.sf.freecol.server.generator.EuropeanStartingPositionsGenerator.determineStartingTilesWithoutUsingPredeterminedPositions(EuropeanStartingPositionsGenerator.java:316)

Patch falls back to the other coast when the preferred one has no tiles.

On maps with sea on only one edge (e.g. a Pacific-coast map),
determineStartingTilesWithoutUsingPredeterminedPositions crashed with
IndexOutOfBoundsException for any nation with starts-on-east-coast=true
— every European nation except Russia — because classic-mode selection
did remove(0) on the empty preferred-coast list.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant