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

Fix distributing food with empties containers #41232

Merged
merged 6 commits into from
Jun 13, 2020

Conversation

BevapDin
Copy link
Contributor

SUMMARY: None

Fixes #37149. It rewrites the whole food distributing block, and thereby also fixes #40712.

I also removed the littering feature. It would teleport empty contains on a specific area (using magic values as coordinates) with no regard for the surround (e.g. into fire, or into an enclosed area).

BevapDin added 4 commits June 11, 2020 15:51
Note that `omt_pos` is a global coordinate.
Multiple things in one commit because this is basically a complete rewrite of the existing code.

The existing code doesn't handle food in containers correctly. It gets a list of pointers to the items within a container, and clears the content of that container. Now those pointers are all dangling, but they are used nonetheless. That'll cause UB.

Empty containers were dropped on a special tile, with **global** coordinates (omt_pos is global). This has been fixed, but it will still teleport items randomly without any sense.

Code was restructured by using lambdas to create separate parts.
…mp food

Instead just keep the container where it is.
@Fris0uman
Copy link
Contributor

I also removed the littering feature

Does that make the containers disapear?

@mlangsdorf mlangsdorf added Items: Containers Things that hold other things Player Faction Base / Camp All about the player faction base/camp/site labels Jun 13, 2020
@mlangsdorf mlangsdorf self-requested a review June 13, 2020 00:35
Copy link
Contributor

@mlangsdorf mlangsdorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I support KorGgenT's mission to get rid of auto when we know a function's return, but other than that minor quibble, this looks great. Thanks for fixing this!

If I'm reading this correctly, the containers will be left in place, because the contents are removed in consume(). Seems like a sensible solution.

Co-authored-by: Mark Langsdorf <[email protected]>
@kevingranade kevingranade merged commit a9385fc into CleverRaven:master Jun 13, 2020
fengjixuchui added a commit to fengjixuchui/Cataclysm-DDA that referenced this pull request Jun 13, 2020
Fix distributing food with empties containers (CleverRaven#41232)
@BevapDin BevapDin deleted the cem branch June 18, 2020 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Items: Containers Things that hold other things Player Faction Base / Camp All about the player faction base/camp/site
Projects
None yet
4 participants