Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fields are not spreading north-west when they shouldn't anymore #34226

Merged

Conversation

ZhilkinSerg
Copy link
Contributor

@ZhilkinSerg ZhilkinSerg commented Sep 25, 2019

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 be true as one_in( 0 ) returns true on any value less than or equal to 1, 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 for size_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.

@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. labels Sep 25, 2019
@kevingranade kevingranade merged commit a8afea2 into CleverRaven:master Sep 26, 2019
@ZhilkinSerg ZhilkinSerg deleted the fix-fields-spreading-north-west branch September 26, 2019 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Fields / Furniture / Terrain / Traps Objects that are part of the map or its features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hot air propagates North-West indefinitely through solid rock and walls underground
2 participants