mirror of https://github.com/OpenTTD/OpenTTD
Add: Industry accepted and waiting history graphs.
Records amount of cargo accepted, and a rolling average of the waiting amount. Average waiting samples the waiting amount once per day for each industry, spread out over an economy day.
parent
47018f8cf4
commit
b5d9e358cf
|
@ -1070,6 +1070,7 @@ static uint DeliverGoodsToIndustry(const Station *st, CargoType cargo_type, uint
|
||||||
|
|
||||||
uint amount = std::min(num_pieces, 0xFFFFu - it->waiting);
|
uint amount = std::min(num_pieces, 0xFFFFu - it->waiting);
|
||||||
it->waiting += amount;
|
it->waiting += amount;
|
||||||
|
it->history[THIS_MONTH].accepted += amount;
|
||||||
it->last_accepted = TimerGameEconomy::date;
|
it->last_accepted = TimerGameEconomy::date;
|
||||||
num_pieces -= amount;
|
num_pieces -= amount;
|
||||||
accepted += amount;
|
accepted += amount;
|
||||||
|
|
|
@ -1612,7 +1612,9 @@ CompanyID PerformanceRatingDetailWindow::company = CompanyID::Invalid();
|
||||||
struct IndustryProductionGraphWindow : BaseCargoGraphWindow {
|
struct IndustryProductionGraphWindow : BaseCargoGraphWindow {
|
||||||
static inline constexpr StringID RANGE_LABELS[] = {
|
static inline constexpr StringID RANGE_LABELS[] = {
|
||||||
STR_GRAPH_INDUSTRY_RANGE_PRODUCED,
|
STR_GRAPH_INDUSTRY_RANGE_PRODUCED,
|
||||||
STR_GRAPH_INDUSTRY_RANGE_TRANSPORTED
|
STR_GRAPH_INDUSTRY_RANGE_TRANSPORTED,
|
||||||
|
STR_GRAPH_INDUSTRY_RANGE_DELIVERED,
|
||||||
|
STR_GRAPH_INDUSTRY_RANGE_WAITING,
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline CargoTypes excluded_cargo_types{};
|
static inline CargoTypes excluded_cargo_types{};
|
||||||
|
@ -1627,6 +1629,10 @@ struct IndustryProductionGraphWindow : BaseCargoGraphWindow {
|
||||||
this->draw_dates = !TimerGameEconomy::UsingWallclockUnits();
|
this->draw_dates = !TimerGameEconomy::UsingWallclockUnits();
|
||||||
this->ranges = RANGE_LABELS;
|
this->ranges = RANGE_LABELS;
|
||||||
|
|
||||||
|
const Industry *i = Industry::Get(window_number);
|
||||||
|
if (!i->IsCargoProduced()) this->masked_range = (1U << 0) | (1U << 1);
|
||||||
|
if (!i->IsCargoAccepted()) this->masked_range = (1U << 2) | (1U << 3);
|
||||||
|
|
||||||
this->InitializeWindow(window_number, STR_GRAPH_LAST_24_MINUTES_TIME_LABEL);
|
this->InitializeWindow(window_number, STR_GRAPH_LAST_24_MINUTES_TIME_LABEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1634,6 +1640,9 @@ struct IndustryProductionGraphWindow : BaseCargoGraphWindow {
|
||||||
{
|
{
|
||||||
CargoTypes cargo_types{};
|
CargoTypes cargo_types{};
|
||||||
const Industry *i = Industry::Get(window_number);
|
const Industry *i = Industry::Get(window_number);
|
||||||
|
for (const auto &a : i->accepted) {
|
||||||
|
if (IsValidCargoType(a.cargo)) SetBit(cargo_types, a.cargo);
|
||||||
|
}
|
||||||
for (const auto &p : i->produced) {
|
for (const auto &p : i->produced) {
|
||||||
if (IsValidCargoType(p.cargo)) SetBit(cargo_types, p.cargo);
|
if (IsValidCargoType(p.cargo)) SetBit(cargo_types, p.cargo);
|
||||||
}
|
}
|
||||||
|
@ -1647,7 +1656,7 @@ struct IndustryProductionGraphWindow : BaseCargoGraphWindow {
|
||||||
|
|
||||||
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
|
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
|
||||||
{
|
{
|
||||||
if (widget == WID_GRAPH_CAPTION) return GetString(STR_GRAPH_INDUSTRY_PRODUCTION_CAPTION, this->window_number);
|
if (widget == WID_GRAPH_CAPTION) return GetString(STR_GRAPH_INDUSTRY_CAPTION, this->window_number);
|
||||||
|
|
||||||
return this->Window::GetWidgetString(widget, stringid);
|
return this->Window::GetWidgetString(widget, stringid);
|
||||||
}
|
}
|
||||||
|
@ -1693,6 +1702,27 @@ struct IndustryProductionGraphWindow : BaseCargoGraphWindow {
|
||||||
FillFromHistory<GRAPH_NUM_MONTHS>(p.history, Filler{produced, &Industry::ProducedHistory::production}, Filler{transported, &Industry::ProducedHistory::transported});
|
FillFromHistory<GRAPH_NUM_MONTHS>(p.history, Filler{produced, &Industry::ProducedHistory::production}, Filler{transported, &Industry::ProducedHistory::transported});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto &a : i->accepted) {
|
||||||
|
if (!IsValidCargoType(a.cargo)) continue;
|
||||||
|
const CargoSpec *cs = CargoSpec::Get(a.cargo);
|
||||||
|
|
||||||
|
this->data.reserve(this->data.size() + 2);
|
||||||
|
|
||||||
|
DataSet &accepted = this->data.emplace_back();
|
||||||
|
accepted.colour = cs->legend_colour;
|
||||||
|
accepted.exclude_bit = cs->Index();
|
||||||
|
accepted.range_bit = 2;
|
||||||
|
accepted.dash = 1;
|
||||||
|
|
||||||
|
DataSet &waiting = this->data.emplace_back();
|
||||||
|
waiting.colour = cs->legend_colour;
|
||||||
|
waiting.exclude_bit = cs->Index();
|
||||||
|
waiting.range_bit = 3;
|
||||||
|
waiting.dash = 4;
|
||||||
|
|
||||||
|
FillFromHistory<GRAPH_NUM_MONTHS>(a.history, Filler{accepted, &Industry::AcceptedHistory::accepted}, Filler{waiting, &Industry::AcceptedHistory::waiting});
|
||||||
|
}
|
||||||
|
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -77,10 +77,17 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
|
||||||
HistoryData<ProducedHistory> history{}; ///< History of cargo produced and transported for this month and 24 previous months
|
HistoryData<ProducedHistory> history{}; ///< History of cargo produced and transported for this month and 24 previous months
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct AcceptedHistory {
|
||||||
|
uint16_t accepted = 0; /// Total accepted.
|
||||||
|
uint16_t waiting = 0; /// Average waiting.
|
||||||
|
};
|
||||||
|
|
||||||
struct AcceptedCargo {
|
struct AcceptedCargo {
|
||||||
CargoType cargo = 0; ///< Cargo type
|
CargoType cargo = 0; ///< Cargo type
|
||||||
uint16_t waiting = 0; ///< Amount of cargo waiting to processed
|
uint16_t waiting = 0; ///< Amount of cargo waiting to processed
|
||||||
|
uint32_t accumulated_waiting = 0; ///< Accumulated waiting total over the last month, used to calculate average.
|
||||||
TimerGameEconomy::Date last_accepted{}; ///< Last day cargo was accepted by this industry
|
TimerGameEconomy::Date last_accepted{}; ///< Last day cargo was accepted by this industry
|
||||||
|
HistoryData<AcceptedHistory> history{}; ///< History of accepted and waiting cargo.
|
||||||
};
|
};
|
||||||
|
|
||||||
using ProducedCargoes = std::vector<ProducedCargo>;
|
using ProducedCargoes = std::vector<ProducedCargo>;
|
||||||
|
@ -150,7 +157,7 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
|
||||||
*/
|
*/
|
||||||
inline const AcceptedCargo &GetAccepted(size_t slot) const
|
inline const AcceptedCargo &GetAccepted(size_t slot) const
|
||||||
{
|
{
|
||||||
static const AcceptedCargo empty{INVALID_CARGO, 0, {}};
|
static const AcceptedCargo empty{INVALID_CARGO, 0, 0, {}, {}};
|
||||||
return slot < this->accepted.size() ? this->accepted[slot] : empty;
|
return slot < this->accepted.size() ? this->accepted[slot] : empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1245,6 +1245,10 @@ void OnTick_Industry()
|
||||||
|
|
||||||
for (Industry *i : Industry::Iterate()) {
|
for (Industry *i : Industry::Iterate()) {
|
||||||
ProduceIndustryGoods(i);
|
ProduceIndustryGoods(i);
|
||||||
|
|
||||||
|
if ((TimerGameTick::counter + i->index) % Ticks::DAY_TICKS == 0) {
|
||||||
|
for (auto &a : i->accepted) a.accumulated_waiting += a.waiting;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2502,6 +2506,12 @@ static void UpdateIndustryStatistics(Industry *i)
|
||||||
RotateHistory(p.history);
|
RotateHistory(p.history);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto &a : i->accepted) {
|
||||||
|
if (!IsValidCargoType(a.cargo)) continue;
|
||||||
|
a.history[THIS_MONTH].waiting = GetAndResetAccumulatedAverage<uint16_t>(a.accumulated_waiting);
|
||||||
|
RotateHistory(a.history);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -845,7 +845,7 @@ public:
|
||||||
nvp->InitializeViewport(this, Industry::Get(window_number)->location.GetCenterTile(), ScaleZoomGUI(ZoomLevel::Industry));
|
nvp->InitializeViewport(this, Industry::Get(window_number)->location.GetCenterTile(), ScaleZoomGUI(ZoomLevel::Industry));
|
||||||
|
|
||||||
const Industry *i = Industry::Get(window_number);
|
const Industry *i = Industry::Get(window_number);
|
||||||
if (!i->IsCargoProduced()) this->DisableWidget(WID_IV_GRAPH);
|
if (!i->IsCargoProduced() && !i->IsCargoAccepted()) this->DisableWidget(WID_IV_GRAPH);
|
||||||
|
|
||||||
this->InvalidateData();
|
this->InvalidateData();
|
||||||
}
|
}
|
||||||
|
@ -1242,7 +1242,7 @@ static constexpr NWidgetPart _nested_industry_view_widgets[] = {
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_CREAM, WID_IV_DISPLAY), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_INDUSTRY_DISPLAY_CHAIN, STR_INDUSTRY_DISPLAY_CHAIN_TOOLTIP),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_CREAM, WID_IV_DISPLAY), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_INDUSTRY_DISPLAY_CHAIN, STR_INDUSTRY_DISPLAY_CHAIN_TOOLTIP),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_CREAM, WID_IV_GRAPH), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_INDUSTRY_VIEW_PRODUCTION_GRAPH, STR_INDUSTRY_VIEW_PRODUCTION_GRAPH_TOOLTIP),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_CREAM, WID_IV_GRAPH), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_INDUSTRY_VIEW_CARGO_GRAPH, STR_INDUSTRY_VIEW_CARGO_GRAPH_TOOLTIP),
|
||||||
NWidget(WWT_RESIZEBOX, COLOUR_CREAM),
|
NWidget(WWT_RESIZEBOX, COLOUR_CREAM),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -633,9 +633,11 @@ STR_GRAPH_CARGO_TOOLTIP_DISABLE_ALL :{BLACK}Display
|
||||||
STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO :{BLACK}Toggle graph of this cargo type
|
STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO :{BLACK}Toggle graph of this cargo type
|
||||||
STR_GRAPH_CARGO_PAYMENT_CARGO :{TINY_FONT}{BLACK}{STRING}
|
STR_GRAPH_CARGO_PAYMENT_CARGO :{TINY_FONT}{BLACK}{STRING}
|
||||||
|
|
||||||
STR_GRAPH_INDUSTRY_PRODUCTION_CAPTION :{WHITE}{INDUSTRY} - Production History
|
STR_GRAPH_INDUSTRY_CAPTION :{WHITE}{INDUSTRY} - Cargo History
|
||||||
STR_GRAPH_INDUSTRY_RANGE_PRODUCED :Produced
|
STR_GRAPH_INDUSTRY_RANGE_PRODUCED :Produced
|
||||||
STR_GRAPH_INDUSTRY_RANGE_TRANSPORTED :Transported
|
STR_GRAPH_INDUSTRY_RANGE_TRANSPORTED :Transported
|
||||||
|
STR_GRAPH_INDUSTRY_RANGE_DELIVERED :Delivered
|
||||||
|
STR_GRAPH_INDUSTRY_RANGE_WAITING :Waiting
|
||||||
|
|
||||||
STR_GRAPH_PERFORMANCE_DETAIL_TOOLTIP :{BLACK}Show detailed performance ratings
|
STR_GRAPH_PERFORMANCE_DETAIL_TOOLTIP :{BLACK}Show detailed performance ratings
|
||||||
|
|
||||||
|
@ -4015,8 +4017,8 @@ STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE :{BLACK}Producti
|
||||||
STR_INDUSTRY_VIEW_PRODUCTION_LAST_MINUTE_TITLE :{BLACK}Production last minute:
|
STR_INDUSTRY_VIEW_PRODUCTION_LAST_MINUTE_TITLE :{BLACK}Production last minute:
|
||||||
STR_INDUSTRY_VIEW_TRANSPORTED :{YELLOW}{CARGO_LONG}{RAW_STRING}{BLACK} ({COMMA}% transported)
|
STR_INDUSTRY_VIEW_TRANSPORTED :{YELLOW}{CARGO_LONG}{RAW_STRING}{BLACK} ({COMMA}% transported)
|
||||||
STR_INDUSTRY_VIEW_LOCATION_TOOLTIP :{BLACK}Centre the main view on industry location. Ctrl+Click to open a new viewport on industry location
|
STR_INDUSTRY_VIEW_LOCATION_TOOLTIP :{BLACK}Centre the main view on industry location. Ctrl+Click to open a new viewport on industry location
|
||||||
STR_INDUSTRY_VIEW_PRODUCTION_GRAPH :{BLACK}Production Graph
|
STR_INDUSTRY_VIEW_CARGO_GRAPH :{BLACK}Cargo Graph
|
||||||
STR_INDUSTRY_VIEW_PRODUCTION_GRAPH_TOOLTIP :{BLACK}Shows the graph of industry production history
|
STR_INDUSTRY_VIEW_CARGO_GRAPH_TOOLTIP :{BLACK}Shows the graph of industry cargo history
|
||||||
STR_INDUSTRY_VIEW_PRODUCTION_LEVEL :{BLACK}Production level: {YELLOW}{COMMA}%
|
STR_INDUSTRY_VIEW_PRODUCTION_LEVEL :{BLACK}Production level: {YELLOW}{COMMA}%
|
||||||
STR_INDUSTRY_VIEW_INDUSTRY_ANNOUNCED_CLOSURE :{YELLOW}The industry has announced imminent closure!
|
STR_INDUSTRY_VIEW_INDUSTRY_ANNOUNCED_CLOSURE :{YELLOW}The industry has announced imminent closure!
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
#ifndef HISTORY_FUNC_HPP
|
#ifndef HISTORY_FUNC_HPP
|
||||||
#define HISTORY_FUNC_HPP
|
#define HISTORY_FUNC_HPP
|
||||||
|
|
||||||
|
#include "../core/math_func.hpp"
|
||||||
|
|
||||||
|
#include "../timer/timer_game_economy.h"
|
||||||
#include "history_type.hpp"
|
#include "history_type.hpp"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,6 +27,19 @@ void RotateHistory(HistoryData<T> &history)
|
||||||
history[THIS_MONTH] = {};
|
history[THIS_MONTH] = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an average value for the previous month, as reset for the next month.
|
||||||
|
* @param total Accrued total to average. Will be reset to zero.
|
||||||
|
* @return Average value for the month.
|
||||||
|
*/
|
||||||
|
template <typename T, typename Taccrued>
|
||||||
|
T GetAndResetAccumulatedAverage(Taccrued &total)
|
||||||
|
{
|
||||||
|
T result = ClampTo<T>(total / std::max(1U, TimerGameEconomy::days_since_last_month));
|
||||||
|
total = 0;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill some data with historical data.
|
* Fill some data with historical data.
|
||||||
* @param history Historical data to fill from.
|
* @param history Historical data to fill from.
|
||||||
|
|
|
@ -19,12 +19,48 @@
|
||||||
|
|
||||||
static OldPersistentStorage _old_ind_persistent_storage;
|
static OldPersistentStorage _old_ind_persistent_storage;
|
||||||
|
|
||||||
|
class SlIndustryAcceptedHistory : public DefaultSaveLoadHandler<SlIndustryAcceptedHistory, Industry::AcceptedCargo> {
|
||||||
|
public:
|
||||||
|
static inline const SaveLoad description[] = {
|
||||||
|
SLE_VAR(Industry::AcceptedHistory, accepted, SLE_UINT16),
|
||||||
|
SLE_VAR(Industry::AcceptedHistory, waiting, SLE_UINT16),
|
||||||
|
};
|
||||||
|
static inline const SaveLoadCompatTable compat_description = _industry_produced_history_sl_compat;
|
||||||
|
|
||||||
|
void Save(Industry::AcceptedCargo *a) const override
|
||||||
|
{
|
||||||
|
if (!IsValidCargoType(a->cargo)) {
|
||||||
|
/* Don't save any history if cargo slot isn't used. */
|
||||||
|
SlSetStructListLength(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SlSetStructListLength(a->history.size());
|
||||||
|
|
||||||
|
for (auto &h : a->history) {
|
||||||
|
SlObject(&h, this->GetDescription());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Load(Industry::AcceptedCargo *a) const override
|
||||||
|
{
|
||||||
|
size_t len = SlGetStructListLength(a->history.size());
|
||||||
|
|
||||||
|
for (auto &h : a->history) {
|
||||||
|
if (--len > a->history.size()) break; // unsigned so wraps after hitting zero.
|
||||||
|
SlObject(&h, this->GetDescription());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class SlIndustryAccepted : public VectorSaveLoadHandler<SlIndustryAccepted, Industry, Industry::AcceptedCargo, INDUSTRY_NUM_INPUTS> {
|
class SlIndustryAccepted : public VectorSaveLoadHandler<SlIndustryAccepted, Industry, Industry::AcceptedCargo, INDUSTRY_NUM_INPUTS> {
|
||||||
public:
|
public:
|
||||||
static inline const SaveLoad description[] = {
|
static inline const SaveLoad description[] = {
|
||||||
SLE_VAR(Industry::AcceptedCargo, cargo, SLE_UINT8),
|
SLE_VAR(Industry::AcceptedCargo, cargo, SLE_UINT8),
|
||||||
SLE_VAR(Industry::AcceptedCargo, waiting, SLE_UINT16),
|
SLE_VAR(Industry::AcceptedCargo, waiting, SLE_UINT16),
|
||||||
SLE_VAR(Industry::AcceptedCargo, last_accepted, SLE_INT32),
|
SLE_VAR(Industry::AcceptedCargo, last_accepted, SLE_INT32),
|
||||||
|
SLE_CONDVAR(Industry::AcceptedCargo, accumulated_waiting, SLE_UINT32, SLV_INDUSTRY_ACCEPTED_HISTORY, SL_MAX_VERSION),
|
||||||
|
SLEG_CONDSTRUCTLIST("history", SlIndustryAcceptedHistory, SLV_INDUSTRY_ACCEPTED_HISTORY, SL_MAX_VERSION),
|
||||||
};
|
};
|
||||||
static inline const SaveLoadCompatTable compat_description = _industry_accepts_sl_compat;
|
static inline const SaveLoadCompatTable compat_description = _industry_accepts_sl_compat;
|
||||||
|
|
||||||
|
|
|
@ -404,6 +404,7 @@ enum SaveLoadVersion : uint16_t {
|
||||||
SLV_ORDERS_OWNED_BY_ORDERLIST, ///< 354 PR#13948 Orders stored in OrderList, pool removed.
|
SLV_ORDERS_OWNED_BY_ORDERLIST, ///< 354 PR#13948 Orders stored in OrderList, pool removed.
|
||||||
|
|
||||||
SLV_FACE_STYLES, ///< 355 PR#14319 Addition of face styles, replacing gender and ethnicity.
|
SLV_FACE_STYLES, ///< 355 PR#14319 Addition of face styles, replacing gender and ethnicity.
|
||||||
|
SLV_INDUSTRY_ACCEPTED_HISTORY, ///< 356 PR#14321 Add per-industry history of cargo delivered and waiting.
|
||||||
|
|
||||||
SL_MAX_VERSION, ///< Highest possible saveload version
|
SL_MAX_VERSION, ///< Highest possible saveload version
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,6 +37,7 @@ TimerGameEconomy::Year TimerGameEconomy::year = {};
|
||||||
TimerGameEconomy::Month TimerGameEconomy::month = {};
|
TimerGameEconomy::Month TimerGameEconomy::month = {};
|
||||||
TimerGameEconomy::Date TimerGameEconomy::date = {};
|
TimerGameEconomy::Date TimerGameEconomy::date = {};
|
||||||
TimerGameEconomy::DateFract TimerGameEconomy::date_fract = {};
|
TimerGameEconomy::DateFract TimerGameEconomy::date_fract = {};
|
||||||
|
uint TimerGameEconomy::days_since_last_month = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a Date to a Year, Month & Day.
|
* Converts a Date to a Year, Month & Day.
|
||||||
|
@ -133,6 +134,7 @@ bool TimerManager<TimerGameEconomy>::Elapsed([[maybe_unused]] TimerGameEconomy::
|
||||||
|
|
||||||
/* increase day counter */
|
/* increase day counter */
|
||||||
TimerGameEconomy::date++;
|
TimerGameEconomy::date++;
|
||||||
|
++TimerGameEconomy::days_since_last_month;
|
||||||
|
|
||||||
TimerGameEconomy::YearMonthDay ymd = TimerGameEconomy::ConvertDateToYMD(TimerGameEconomy::date);
|
TimerGameEconomy::YearMonthDay ymd = TimerGameEconomy::ConvertDateToYMD(TimerGameEconomy::date);
|
||||||
|
|
||||||
|
@ -177,6 +179,8 @@ bool TimerManager<TimerGameEconomy>::Elapsed([[maybe_unused]] TimerGameEconomy::
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (new_month) TimerGameEconomy::days_since_last_month = 0;
|
||||||
|
|
||||||
/* check if we reached the maximum year, decrement dates by a year */
|
/* check if we reached the maximum year, decrement dates by a year */
|
||||||
if (TimerGameEconomy::year == EconomyTime::MAX_YEAR + 1) {
|
if (TimerGameEconomy::year == EconomyTime::MAX_YEAR + 1) {
|
||||||
TimerGameEconomy::year--;
|
TimerGameEconomy::year--;
|
||||||
|
|
|
@ -37,6 +37,8 @@ public:
|
||||||
static Date date; ///< Current date in days (day counter).
|
static Date date; ///< Current date in days (day counter).
|
||||||
static DateFract date_fract; ///< Fractional part of the day.
|
static DateFract date_fract; ///< Fractional part of the day.
|
||||||
|
|
||||||
|
static uint days_since_last_month; ///< Number of days that have elapsed since the last month.
|
||||||
|
|
||||||
static YearMonthDay ConvertDateToYMD(Date date);
|
static YearMonthDay ConvertDateToYMD(Date date);
|
||||||
static Date ConvertYMDToDate(Year year, Month month, Day day);
|
static Date ConvertYMDToDate(Year year, Month month, Day day);
|
||||||
static void SetDate(Date date, DateFract fract);
|
static void SetDate(Date date, DateFract fract);
|
||||||
|
|
Loading…
Reference in New Issue