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

Function UpdateValidHistory

src/misc/history.cpp:25–38  ·  view source on GitHub ↗

* Update mask of valid records for a historical data. * @note Call only for the largest history range sub-division. * @param[in,out] valid_history Valid history records. * @param hr History range to update mask for. * @param cur_month Current economy month. */

Source from the content-addressed store, hash-verified

23 * @param cur_month Current economy month.
24 */
25void UpdateValidHistory(ValidHistoryMask &valid_history, const HistoryRange &hr, uint cur_month)
26{
27 /* Update for subdivisions first. */
28 if (hr.hr != nullptr) UpdateValidHistory(valid_history, *hr.hr, cur_month);
29
30 /* No need to update if our last entry is marked valid. */
31 if (HasBit(valid_history, hr.last - 1)) return;
32 /* Is it the right time for this history range? */
33 if (cur_month % hr.total_division != 0) return;
34 /* Is the previous history range valid yet? */
35 if (hr.division != 1 && !HasBit(valid_history, hr.first - hr.division)) return;
36
37 SB(valid_history, hr.first, hr.records, GB(valid_history, hr.first, hr.records) << 1ULL | 1ULL);
38}
39
40/**
41 * Test if history data is valid, without extracting data.

Callers 4

DoCreateNewIndustryFunction · 0.85
UpdateIndustryStatisticsFunction · 0.85
town_cmd.cppFile · 0.85
history_func.cppFile · 0.85

Calls 3

HasBitFunction · 0.85
SBFunction · 0.85
GBFunction · 0.85

Tested by

no test coverage detected