CleverRaven/Cataclysm-DDA — pull request #3868 by atomicdryad (2013-10-25 22:46:22+00:00)
Title: [READY] Fill far-away funnels retroactivey on map::load, based on weather history. (RFI on a real refactor)

This utilizes the trap-cache and item-rot-expire loops in map::loadn to find any funnels with a valid container, fills them based on logged weather data from the item's bday to current turn. Sets bday to turn afterwards. This also adjusts fill_funnel, by carving off logic and moving them into functions accessible to map (also, sets the bday). New functions:

void item::add_rain_to_container(bool acid, int charges = 1); // see below
bool item::is_watertight_container() const;
int item::is_funnel_container(int bigger_than) const; // see below
double trap::funnel_charges_per_turn( double rain_depth_mm_per_hour ) const;
void retroactively_fill_from_funnel( game * g, item *it, const trap_id t, const int endturn );
std::pair rain_or_acid_level( const int wt ); // omg see below

**I had to resist the urge to refactor many things to keep this simple**
in-map funnel filling works the same as before, however:

* we have -3- integer values for 2 variations of precipitation. Ideally I'd like to get rid of rain_or_acid_level and add int rainlevel (4 & 8), int acidlevel (4 & 8) to weather_data[]. The morality levels (30 and 60) and fire-extinguish levells (15 and 45) can be determined from consistent values in weather_data[].
* should funnels even be traps? traps have no data, and there is no safe way to reference a map item, so they must iterate every turn. Perhaps funnels could be active items?
* add_rain_to_container(bool acid, int charges = 1) should probably be (int rainamount, int acidamount);..and alot of the functions in weather.cpp involving funnels are just wonky. In particular;
* fill_funnels; it takes a good amount of turns to add 1 charge, and since charge is int (see below), fill_funnels uses RNG. In theory, this would be somewhat consistent...however after debugging I've found it's most definitely not. This can be corrected by adding an item variable ( partial_fill or such ), however a better idea is fixing the fact that ** item::volume, weights, and charges are completely inconsistent and insane **

That's for another PR though. This PR fixes the OOM funnel fill issue with minimal impact.