Merge pull request #12771 from tupaschoal/fix-12764

Fix #12764: Rides don't start aged anymore
This commit is contained in:
Tulio Leao 2020-08-25 21:51:57 -03:00 committed by GitHub
commit 02d1c5afca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 26 additions and 25 deletions

View File

@ -4,6 +4,7 @@
- Fix: [#12694] Crash when switching ride types with construction window open. - Fix: [#12694] Crash when switching ride types with construction window open.
- Fix: [#12701] Silent NSIS setup flag /S isn't silent, upgrade pop-up appears anyway. - Fix: [#12701] Silent NSIS setup flag /S isn't silent, upgrade pop-up appears anyway.
- Fix: [#12737] Space Rings draw the same vehicle 4 times. - Fix: [#12737] Space Rings draw the same vehicle 4 times.
- Fix: [#12764] Rides don't start aged anymore.
- Fix: Incomplete loop collision box allowed overlapping track (original bug). - Fix: Incomplete loop collision box allowed overlapping track (original bug).
0.3.0 (2020-08-15) 0.3.0 (2020-08-15)

View File

@ -742,7 +742,7 @@ static void window_finances_summary_scrollpaint(rct_window* w, rct_drawpixelinfo
} }
// Expenditure / Income values for each month // Expenditure / Income values for each month
int16_t currentMonthYear = gDateMonthsElapsed; int16_t currentMonthYear = static_cast<int16_t>(gDateMonthsElapsed);
for (int32_t i = summary_max_available_month(); i >= 0; i--) for (int32_t i = summary_max_available_month(); i >= 0; i--)
{ {
screenCoords.y = 0; screenCoords.y = 0;

View File

@ -276,7 +276,7 @@ void GameState::UpdateLogic()
#endif #endif
date_update(); date_update();
_date = Date(gDateMonthsElapsed, gDateMonthTicks); _date = Date(static_cast<uint32_t>(gDateMonthsElapsed), gDateMonthTicks);
scenario_update(); scenario_update();
climate_update(); climate_update();

View File

@ -48,7 +48,7 @@ extern const rct_string_id DateFormatStringIds[];
extern const rct_string_id DateFormatStringFormatIds[]; extern const rct_string_id DateFormatStringFormatIds[];
extern uint16_t gDateMonthTicks; extern uint16_t gDateMonthTicks;
extern uint16_t gDateMonthsElapsed; extern int32_t gDateMonthsElapsed;
extern openrct2_timeofday gRealTimeOfDay; extern openrct2_timeofday gRealTimeOfDay;

View File

@ -15,7 +15,7 @@
#include <time.h> #include <time.h>
uint16_t gDateMonthTicks; uint16_t gDateMonthTicks;
uint16_t gDateMonthsElapsed; int32_t gDateMonthsElapsed;
// rct2: 0x00993988 // rct2: 0x00993988
const int16_t days_in_month[MONTH_COUNT] = { 31, 30, 31, 30, 31, 31, 30, 31 }; const int16_t days_in_month[MONTH_COUNT] = { 31, 30, 31, 30, 31, 31, 30, 31 };

View File

@ -318,7 +318,7 @@ News::Item* News::AddItemToQueue(News::ItemType type, const utf8* text, uint32_t
newsItem->Flags = 0; newsItem->Flags = 0;
newsItem->Assoc = assoc; newsItem->Assoc = assoc;
newsItem->Ticks = 0; newsItem->Ticks = 0;
newsItem->MonthYear = gDateMonthsElapsed; newsItem->MonthYear = static_cast<uint16_t>(gDateMonthsElapsed);
newsItem->Day = ((days_in_month[date_get_month(newsItem->MonthYear)] * gDateMonthTicks) >> 16) + 1; newsItem->Day = ((days_in_month[date_get_month(newsItem->MonthYear)] * gDateMonthTicks) >> 16) + 1;
safe_strcpy(newsItem->Text, text, sizeof(newsItem->Text)); safe_strcpy(newsItem->Text, text, sizeof(newsItem->Text));

View File

@ -33,7 +33,7 @@
// This string specifies which version of network stream current build uses. // This string specifies which version of network stream current build uses.
// It is used for making sure only compatible builds get connected, even within // It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version. // single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "1" #define NETWORK_STREAM_VERSION "2"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static Peep* _pickup_peep = nullptr; static Peep* _pickup_peep = nullptr;

View File

@ -176,7 +176,7 @@ struct rct1_ride
uint8_t pad_11F[0x7]; // 0x11F uint8_t pad_11F[0x7]; // 0x11F
uint8_t spiral_slide_progress; // 0x126 uint8_t spiral_slide_progress; // 0x126
uint8_t pad_127[0x9]; // 0x127 uint8_t pad_127[0x9]; // 0x127
uint16_t build_date; // 0x130 int16_t build_date; // 0x130
money16 upkeep_cost; // 0x131 money16 upkeep_cost; // 0x131
uint16_t race_winner; // 0x132 uint16_t race_winner; // 0x132
uint8_t unk_134[2]; // 0x134 uint8_t unk_134[2]; // 0x134

View File

@ -875,7 +875,7 @@ private:
SetRideColourScheme(dst, src); SetRideColourScheme(dst, src);
// Maintenance // Maintenance
dst->build_date = src->build_date; dst->build_date = static_cast<int32_t>(src->build_date);
dst->inspection_interval = src->inspection_interval; dst->inspection_interval = src->inspection_interval;
dst->last_inspection = src->last_inspection; dst->last_inspection = src->last_inspection;
dst->reliability = src->reliability; dst->reliability = src->reliability;
@ -2523,7 +2523,7 @@ private:
// Date and srand // Date and srand
gScenarioTicks = _s4.ticks; gScenarioTicks = _s4.ticks;
scenario_rand_seed(_s4.random_a, _s4.random_b); scenario_rand_seed(_s4.random_a, _s4.random_b);
gDateMonthsElapsed = _s4.month; gDateMonthsElapsed = static_cast<int32_t>(_s4.month);
gDateMonthTicks = _s4.day; gDateMonthTicks = _s4.day;
// Park rating // Park rating

View File

@ -256,7 +256,7 @@ struct rct2_ride
uint8_t pad_16F[0x7]; // 0x16F uint8_t pad_16F[0x7]; // 0x16F
uint8_t spiral_slide_progress; // 0x176 uint8_t spiral_slide_progress; // 0x176
uint8_t pad_177[0x9]; // 0x177 uint8_t pad_177[0x9]; // 0x177
uint16_t build_date; // 0x180 int16_t build_date; // 0x180
money16 upkeep_cost; // 0x182 money16 upkeep_cost; // 0x182
uint16_t race_winner; // 0x184 uint16_t race_winner; // 0x184
uint8_t pad_186[0x02]; // 0x186 uint8_t pad_186[0x02]; // 0x186

View File

@ -186,7 +186,7 @@ void S6Exporter::Export()
} }
} }
_s6.elapsed_months = gDateMonthsElapsed; _s6.elapsed_months = static_cast<uint16_t>(gDateMonthsElapsed);
_s6.current_day = gDateMonthTicks; _s6.current_day = gDateMonthTicks;
_s6.scenario_ticks = gScenarioTicks; _s6.scenario_ticks = gScenarioTicks;
@ -703,7 +703,7 @@ void S6Exporter::ExportRide(rct2_ride* dst, const Ride* src)
// pad_16F[0x7]; // pad_16F[0x7];
dst->spiral_slide_progress = src->spiral_slide_progress; dst->spiral_slide_progress = src->spiral_slide_progress;
// pad_177[0x9]; // pad_177[0x9];
dst->build_date = src->build_date; dst->build_date = static_cast<int16_t>(src->build_date);
dst->upkeep_cost = src->upkeep_cost; dst->upkeep_cost = src->upkeep_cost;
dst->race_winner = src->race_winner; dst->race_winner = src->race_winner;
// pad_186[0x02]; // pad_186[0x02];

View File

@ -216,7 +216,7 @@ public:
safe_strcpy(gS6Info.details, _s6.info.details, sizeof(gS6Info.details)); safe_strcpy(gS6Info.details, _s6.info.details, sizeof(gS6Info.details));
} }
gDateMonthsElapsed = _s6.elapsed_months; gDateMonthsElapsed = static_cast<int32_t>(_s6.elapsed_months);
gDateMonthTicks = _s6.current_day; gDateMonthTicks = _s6.current_day;
gScenarioTicks = _s6.scenario_ticks; gScenarioTicks = _s6.scenario_ticks;
@ -718,7 +718,7 @@ public:
// pad_16F[0x7]; // pad_16F[0x7];
dst->spiral_slide_progress = src->spiral_slide_progress; dst->spiral_slide_progress = src->spiral_slide_progress;
// pad_177[0x9]; // pad_177[0x9];
dst->build_date = src->build_date; dst->build_date = static_cast<int32_t>(src->build_date);
dst->upkeep_cost = src->upkeep_cost; dst->upkeep_cost = src->upkeep_cost;
dst->race_winner = src->race_winner; dst->race_winner = src->race_winner;
// pad_186[0x02]; // pad_186[0x02];

View File

@ -280,7 +280,7 @@ size_t Ride::GetNumPrices() const
int32_t Ride::GetAge() const int32_t Ride::GetAge() const
{ {
return static_cast<int32_t>(gDateMonthsElapsed) - build_date; return gDateMonthsElapsed - build_date;
} }
int32_t Ride::GetTotalQueueLength() const int32_t Ride::GetTotalQueueLength() const
@ -932,7 +932,7 @@ void reset_all_ride_build_dates()
{ {
for (auto& ride : GetRideManager()) for (auto& ride : GetRideManager())
{ {
ride.build_date = gDateMonthsElapsed; ride.build_date -= gDateMonthsElapsed;
} }
} }

View File

@ -306,7 +306,7 @@ struct Ride
}; };
uint8_t slide_peep_t_shirt_colour; uint8_t slide_peep_t_shirt_colour;
uint8_t spiral_slide_progress; uint8_t spiral_slide_progress;
uint16_t build_date; int32_t build_date;
money16 upkeep_cost; money16 upkeep_cost;
uint16_t race_winner; uint16_t race_winner;
uint32_t music_position; uint32_t music_position;

View File

@ -715,7 +715,7 @@ static void scenario_objective_check_guests_by()
{ {
uint8_t objectiveYear = gScenarioObjectiveYear; uint8_t objectiveYear = gScenarioObjectiveYear;
int16_t parkRating = gParkRating; int16_t parkRating = gParkRating;
int16_t currentMonthYear = gDateMonthsElapsed; int32_t currentMonthYear = gDateMonthsElapsed;
if (currentMonthYear == MONTH_COUNT * objectiveYear || gConfigGeneral.allow_early_completion) if (currentMonthYear == MONTH_COUNT * objectiveYear || gConfigGeneral.allow_early_completion)
{ {
@ -733,7 +733,7 @@ static void scenario_objective_check_guests_by()
static void scenario_objective_check_park_value_by() static void scenario_objective_check_park_value_by()
{ {
uint8_t objectiveYear = gScenarioObjectiveYear; uint8_t objectiveYear = gScenarioObjectiveYear;
int16_t currentMonthYear = gDateMonthsElapsed; int32_t currentMonthYear = gDateMonthsElapsed;
money32 objectiveParkValue = gScenarioObjectiveCurrency; money32 objectiveParkValue = gScenarioObjectiveCurrency;
money32 parkValue = gParkValue; money32 parkValue = gParkValue;

View File

@ -37,16 +37,16 @@ namespace OpenRCT2::Scripting
} }
private: private:
uint32_t monthsElapsed_get() const int32_t monthsElapsed_get() const
{ {
const auto& date = GetDate(); const auto& date = GetDate();
return date.GetMonthsElapsed(); return date.GetMonthsElapsed();
} }
void monthsElapsed_set(uint32_t value) void monthsElapsed_set(int32_t value)
{ {
ThrowIfGameStateNotMutable(); ThrowIfGameStateNotMutable();
gDateMonthsElapsed = value; gDateMonthsElapsed = static_cast<int32_t>(value);
} }
uint32_t monthProgress_get() const uint32_t monthProgress_get() const

View File

@ -546,12 +546,12 @@ namespace OpenRCT2::Scripting
} }
} }
int16_t buildDate_get() const int32_t buildDate_get() const
{ {
auto ride = GetRide(); auto ride = GetRide();
return ride != nullptr ? ride->build_date : 0; return ride != nullptr ? ride->build_date : 0;
} }
void buildDate_set(int16_t value) void buildDate_set(int32_t value)
{ {
ThrowIfGameStateNotMutable(); ThrowIfGameStateNotMutable();
auto ride = GetRide(); auto ride = GetRide();

View File

@ -258,7 +258,7 @@ static int8_t climate_step_weather_level(int8_t currentWeatherLevel, int8_t next
*/ */
static void climate_determine_future_weather(int32_t randomDistribution) static void climate_determine_future_weather(int32_t randomDistribution)
{ {
int8_t month = date_get_month(gDateMonthsElapsed); int32_t month = date_get_month(gDateMonthsElapsed);
// Generate a random variable with values 0 up to DistributionSize-1 and chose weather from the distribution table // Generate a random variable with values 0 up to DistributionSize-1 and chose weather from the distribution table
// accordingly // accordingly