MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / UpdateIndustryStatistics

Function UpdateIndustryStatistics

src/industry_cmd.cpp:2566–2586  ·  view source on GitHub ↗

* Monthly update of industry statistics. * @param i Industry to update. */

Source from the content-addressed store, hash-verified

2564 * @param i Industry to update.
2565 */
2566static void UpdateIndustryStatistics(Industry *i)
2567{
2568 auto month = TimerGameEconomy::month;
2569 UpdateValidHistory(i->valid_history, HISTORY_YEAR, month);
2570
2571 for (auto &p : i->produced) {
2572 if (IsValidCargoType(p.cargo)) {
2573 if (p.history[THIS_MONTH].production != 0) i->last_prod_year = TimerGameEconomy::year;
2574
2575 RotateHistory(p.history, i->valid_history, HISTORY_YEAR, month);
2576 }
2577 }
2578
2579 for (auto &a : i->accepted) {
2580 if (!IsValidCargoType(a.cargo)) continue;
2581 if (a.history == nullptr) continue;
2582
2583 (*a.history)[THIS_MONTH].waiting = GetAndResetAccumulatedAverage<uint16_t>(a.accumulated_waiting);
2584 RotateHistory(*a.history, i->valid_history, HISTORY_YEAR, month);
2585 }
2586}
2587
2588/**
2589 * Recompute #production_rate for current #prod_level.

Callers 1

industry_cmd.cppFile · 0.85

Calls 3

UpdateValidHistoryFunction · 0.85
IsValidCargoTypeFunction · 0.85
RotateHistoryFunction · 0.85

Tested by

no test coverage detected