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

move has_rotten_away from map to item #38022

Merged
merged 1 commit into from
Apr 2, 2020

Conversation

KorGgenT
Copy link
Member

Summary

SUMMARY: Infrastructure "move has_rotten_away() from map to item"

Purpose of change

This function really shouldn't have been in map. there was literally no reason for it. when i moved it to item, it didn't use any functions or variables from map at all! The main reason i'm moving it is because of the item contents refactor i'm working on. map really shouldn't be accessing item contents directly.

Describe the solution

move the function to the item scope. this changes the parameter to just const tripoint &pos moved to item.cpp. it was only used in one place so there wasn't any extra cleanup.

Testing

compiled.

@KorGgenT KorGgenT added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style 0.E Feature Freeze labels Feb 14, 2020
src/item.h Outdated Show resolved Hide resolved
src/item.h Outdated Show resolved Hide resolved
src/item.h Outdated Show resolved Hide resolved
@Hirmuolio
Copy link
Contributor

Hirmuolio commented Feb 15, 2020

has_rotten_away() and has_rotten_away() being separate things that work together to kind of do the same thing is pretty confusing too.

Also now that I look at this. The reason why items in freezer sometimes rot away may be due to the has_rotten_away(). This thing only uses item and item location and does not include the temperature_flag which marks the container temperature. So if has_rotten_away() is called on an item that is in freezer/fridge/etc it will process the item temperature and rot as if it was on ground.
It probably is also called on items taht are being milled/smokend and those items should not get processed at all.

@Hirmuolio
Copy link
Contributor

Acutally I now think that map::has_rotten_away( item &itm, const tripoint &pnt ) doesn't need to exist at all.

Just check has_rotten_away() at the end of item::process_temperature_rot. Remove items that have rotten away and spawn carrion spawns as needed.

The original idea was probably to process food items once when they are loaded and after that limit how often they are processed with processing_speed.
But that limit doesn't seem to work and food items are processed on every turn. This doesn't cause problems because there is another time gate in process_temperature_rot that bails out early if the item doesn't need processing yet.

@KorGgenT
Copy link
Member Author

Acutally I now think that map::has_rotten_away( item &itm, const tripoint &pnt ) doesn't need to exist at all.

right, that's why i removed it from map and moved it to item... i'm having a hard time following what you're saying though. maybe you could follow up this pr to do what you said?

@Hirmuolio
Copy link
Contributor

Currently this seems to happen:

  • Item is loaded to reality bubble.
  • map::remove_rotten_items is called.
  • It calls map::has_rotten_awayon all items on ground (so this can't be the reason for freezer problem).
  • it calls item::process_temperature_rot.
  • Return back to map::remove_rotten_items and and call map::rotten_item_spawn if item rotted away.

Then on the next turn the item is procesed normally and item::process_temperature_rot is done normally making the whole ordeal kind of pointless.

So we could just remove that part and do:

  • Item is loaded to reality bubble.
  • Do no special temperature/rot processing on it.
  • On next turn it is processed.
  • At the end of process_temperature_rot check wether it has rotten away and remove the item if it has rotten away and call map::rotten_item_spawn.

@KorGgenT KorGgenT force-pushed the move-has-rotten-away branch from a8964cf to 50ea6e9 Compare April 2, 2020 17:56
@kevingranade kevingranade merged commit fc990f7 into CleverRaven:master Apr 2, 2020
@KorGgenT KorGgenT deleted the move-has-rotten-away branch August 13, 2020 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants