From d57867e72225dc40bee3c065101f15eede3e60f4 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 23 Jul 2017 16:10:09 +0100 Subject: [PATCH] Use the Date class in GameState. --- src/openrct2/GameState.cpp | 7 ++++++- src/openrct2/GameState.h | 3 +++ src/openrct2/scenario/Scenario.cpp | 1 - src/openrct2/world/Park.cpp | 5 +++-- src/openrct2/world/Park.h | 4 +++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/openrct2/GameState.cpp b/src/openrct2/GameState.cpp index fd66caa1da..62bd6d5aba 100644 --- a/src/openrct2/GameState.cpp +++ b/src/openrct2/GameState.cpp @@ -20,6 +20,7 @@ #include "Editor.h" #include "Input.h" #include "interface/Screenshot.h" +#include "localisation/Date.h" #include "management/NewsItem.h" #include "network/network.h" #include "OpenRCT2.h" @@ -184,6 +185,10 @@ void GameState::UpdateLogic() } sub_68B089(); + + date_update(); + _date = Date(gDateMonthTicks, gDateMonthTicks); + scenario_update(); climate_update(); map_update_tiles(); @@ -198,7 +203,7 @@ void GameState::UpdateLogic() if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) { - _park->Update(); + _park->Update(_date); } research_update(); diff --git a/src/openrct2/GameState.h b/src/openrct2/GameState.h index 00bca7fb70..7ac8d2773d 100644 --- a/src/openrct2/GameState.h +++ b/src/openrct2/GameState.h @@ -17,6 +17,7 @@ #pragma once #include +#include "Date.h" namespace OpenRCT2 { @@ -29,10 +30,12 @@ namespace OpenRCT2 { private: std::unique_ptr _park; + Date _date; public: GameState(); + Date * GetDate() { return &_date; } Park * GetPark() { return _park.get(); } void Update(); diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index e6552d24e9..5521ac58b7 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -397,7 +397,6 @@ void scenario_update() { if (gScreenFlags == SCREEN_FLAGS_PLAYING) { - date_update(); if (date_is_day_start(gDateMonthTicks)) { scenario_day_update(); diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index ae87856b89..e3b101c028 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -20,6 +20,7 @@ #include "../core/Math.hpp" #include "../core/Memory.hpp" #include "../core/Util.hpp" +#include "../Date.h" #include "../Game.h" #include "../interface/Colour.h" #include "../interface/Window.h" @@ -577,7 +578,7 @@ void Park::Initialise() format_string(gS6Info.details, 256, STR_NO_DETAILS_YET, nullptr); } -void Park::Update() +void Park::Update(const Date &date) { // Every 5 seconds approximately if (gCurrentTicks % 512 == 0) @@ -595,7 +596,7 @@ void Park::Update() } // Every week - if (date_is_week_start(gDateMonthTicks)) + if (date.IsWeekStart()) { UpdateHistories(); gParkSize = CalculateParkSize(); diff --git a/src/openrct2/world/Park.h b/src/openrct2/world/Park.h index 31a1462cd1..0c15e87c01 100644 --- a/src/openrct2/world/Park.h +++ b/src/openrct2/world/Park.h @@ -55,6 +55,8 @@ struct rct_ride; namespace OpenRCT2 { + class Date; + class Park final { public: @@ -65,7 +67,7 @@ namespace OpenRCT2 money32 GetCompanyValue() const; void Initialise(); - void Update(); + void Update(const Date &date); sint32 CalculateParkSize() const; sint32 CalculateParkRating() const;