CleverRaven/Cataclysm-DDA — pull request #9820 by BevapDin (2014-11-03 16:20:59+00:00)
Title: Fix rotten items in containers not vanishing and containers preserve their content

I just started in a new world with Initial season "winter" and teleported into a grocery store. There was fresh food *in containers*, but waiting for a turn made all the fresh food into rotten food as it should be.

What happened is this: `map::loadn` does some magic when the submap has been loaded, one of this is to remove items that have rotten away. This works just fine, the rot is calculated, the item is considered rotten away and removed. Some items have a high spoilage value (eggs, bologna) and may appear (depending on the weather) as "rotten" or only "old" and are not rotten away. But the code only looks at items outside of containers. Items in containers are not considered at all, their `calc_rot` function is not called.

But after the first turn, all active items (food) are processed as usual. This invokes the rot calculation of the items and the items show up as rotten.

----

This fixes the issue above: items in containers are properly removed when they have been rotten away. The code that is run after the submap has been loaded is now in a separate functions and even further separated into the proper functions. This also avoids repeated looping over the submap.

Sadly this also removed the broth from inside tin cans, so I added a flag "PRESERVES" to tin cans, aluminum cans, glass jars and 3l glass jars. It prevents the contents from spoiling (by setting `item::last_rot_check` to the current turn, effectively preventing `item::calc_rot` from doing anything). This fixes #3566.

During testing (item spawn factor 10 helps), I started in winter again and found empty gallon jugs (probably contained milk), empty plastic cups (yogurt), empty plastic bags, plastic bags with rotten bologna, but also fresh meat soup and fresh broth and others in tin cans.

However, some might not like that (especially when they have the trait to eat rotten food) and it is up to discussion whether items in containers should rot away completely. Containers like the gallon jug should prevent anything from getting out, so rotten milk would still be inside it, but others (paper wrappers, ...) would not prevent that.

----

This fixes the bug where containers with differently charged contents would stack (e.g. jug with water (2) and jug with water (10) would stack). My apologies, all.

----

A question for the weather team: the function `get_weather` etc. take a point as parameter, this seems to be a point in the reality bubble and it is shifted when the player moves. For example in `game::update_weather`, it uses `u.pos()` as input. That point will *always* be somewhere in the range (60,60)...(71,71) - otherwise the map would be shifted and the player is again in the middle of the map. That seems wrong, shouldn't it be an global absolute coordinate?