|
OpenTTD Source 20251104-master-g3befbdd52f
|
Functions for storing historical data. More...
#include "../core/bitmath_func.hpp"#include "../core/math_func.hpp"#include "../timer/timer_game_economy.h"#include "history_type.hpp"Go to the source code of this file.
Functions | |
| void | UpdateValidHistory (ValidHistoryMask &valid_history, const HistoryRange &hr, uint cur_month) |
| Update mask of valid records for a historical data. | |
| bool | IsValidHistory (ValidHistoryMask valid_history, const HistoryRange &hr, uint age) |
| Test if history data is valid, without extracting data. | |
| template<typename T > | |
| T | SumHistory (typename std::span< const T > history) |
| Sum history data elements. | |
| template<typename T > | |
| void | RotateHistory (HistoryData< T > &history, ValidHistoryMask valid_history, const HistoryRange &hr, uint cur_month) |
| Rotate historical data. | |
| template<typename T , typename Taccrued > | |
| T | GetAndResetAccumulatedAverage (Taccrued &total) |
| Get an average value for the previous month, as reset for the next month. | |
| template<typename T > | |
| bool | GetHistory (const HistoryData< T > &history, ValidHistoryMask valid_history, const HistoryRange &hr, uint age, T &result) |
| Get historical data. | |
| template<uint N, typename T , typename... Tfillers> | |
| void | FillFromHistory (const HistoryData< T > &history, ValidHistoryMask valid_history, const HistoryRange &hr, Tfillers &&... fillers) |
| Fill some data with historical data. | |
| template<uint N, typename T , typename... Tfillers> | |
| void | FillFromHistory (const HistoryData< T > *history, ValidHistoryMask valid_history, const HistoryRange &hr, Tfillers &&... fillers) |
| Fill some data with optional historical data. | |
Functions for storing historical data.
Definition in file history_func.hpp.
| void FillFromHistory | ( | const HistoryData< T > & | history, |
| ValidHistoryMask | valid_history, | ||
| const HistoryRange & | hr, | ||
| Tfillers &&... | fillers | ||
| ) |
Fill some data with historical data.
| history | Historical data to fill from. |
| valid_history | Mask of valid history records. |
| hr | History range to fill with. |
| fillers | Fillers to fill with history data. |
Definition at line 119 of file history_func.hpp.
References GetHistory().
| void FillFromHistory | ( | const HistoryData< T > * | history, |
| ValidHistoryMask | valid_history, | ||
| const HistoryRange & | hr, | ||
| Tfillers &&... | fillers | ||
| ) |
Fill some data with optional historical data.
| history | Historical data to fill from, or nullptr if not present. |
| valid_history | Mask of valid history records. |
| hr | History range to fill with. |
| fillers | Fillers to fill with history data. |
Definition at line 139 of file history_func.hpp.
References IsValidHistory().
| T GetAndResetAccumulatedAverage | ( | Taccrued & | total | ) |
Get an average value for the previous month, as reset for the next month.
| total | Accrued total to average. Will be reset to zero. |
Definition at line 64 of file history_func.hpp.
References TimerGameEconomy::days_since_last_month.
| bool GetHistory | ( | const HistoryData< T > & | history, |
| ValidHistoryMask | valid_history, | ||
| const HistoryRange & | hr, | ||
| uint | age, | ||
| T & | result | ||
| ) |
Get historical data.
| T | type of history data element. |
| history | History data to extract from. | |
| valid_history | Mask of valid history records. | |
| hr | History range to get. | |
| age | Age of data to get. | |
| cur_month | Current economy month. | |
| [out] | result | Extracted historical data. |
Definition at line 83 of file history_func.hpp.
References HistoryRange::division, HistoryRange::first, GetHistory(), HasBit(), TimerGameEconomy::month, and HistoryRange::periods.
Referenced by FillFromHistory(), and GetHistory().
| bool IsValidHistory | ( | ValidHistoryMask | valid_history, |
| const HistoryRange & | hr, | ||
| uint | age | ||
| ) |
Test if history data is valid, without extracting data.
| valid_history | Mask of valid history records. |
| hr | History range to test. |
| age | Age of data to test. |
Definition at line 47 of file history.cpp.
References HistoryRange::division, HistoryRange::first, HasBit(), IsValidHistory(), TimerGameEconomy::month, and HistoryRange::periods.
Referenced by FillFromHistory(), and IsValidHistory().
| void RotateHistory | ( | HistoryData< T > & | history, |
| ValidHistoryMask | valid_history, | ||
| const HistoryRange & | hr, | ||
| uint | cur_month | ||
| ) |
Rotate historical data.
| T | type of history data element. |
| history | Historical data to rotate. |
| valid_history | Mask of valid history records. |
| hr | History range to rotate.. |
| cur_month | Current economy month. |
Definition at line 41 of file history_func.hpp.
References HistoryRange::division, HistoryRange::first, HasBit(), HistoryRange::last, RotateHistory(), and HistoryRange::total_division.
Referenced by RotateHistory(), and UpdateIndustryStatistics().
| T SumHistory | ( | typename std::span< const T > | history | ) |
Sum history data elements.
| T | type of history data element. |
| history | History elements to sum. |
| void UpdateValidHistory | ( | ValidHistoryMask & | valid_history, |
| const HistoryRange & | hr, | ||
| uint | cur_month | ||
| ) |
Update mask of valid records for a historical data.
| [in,out] | valid_history | Valid history records. |
| hr | History range to update mask for. | |
| cur_month | Current economy month. |
Definition at line 25 of file history.cpp.
References HistoryRange::division, HistoryRange::first, GB(), HasBit(), HistoryRange::last, HistoryRange::records, SB(), HistoryRange::total_division, and UpdateValidHistory().
Referenced by DoCreateNewIndustry(), UpdateIndustryStatistics(), and UpdateValidHistory().