Fields are not spreading north-west when they shouldn't anymore #34226
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.
Summary
SUMMARY: Bugfixes "Fields are not spreading north-west when they shouldn't anymore"
Purpose of change
Fixes #33275.
Describe the solution
When
spread
vector was empty,one_in( spread.size() )
would still betrue
asone_in( 0 )
returnstrue
on any value less than or equal to1
, thus fields would still try spreading.Spread direction should've been randomly selected using
random_entry( spread )
, but when collection is empty,random_entry
just returns a default value for a given collection member type (0
forsize_t
).That cause spreading to always choose
neighs[ 0 ]
, which is a tile north-west of field initial tile.I've added check for
spread
emptiness before trying to spread horizontally. Field would try to spread vertically if horizontal spread is impossible.