mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-20 05:23:04 +01:00
Add built_date to ScRide and add GetAge()
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2019 OpenRCT2 developers
|
||||
* Copyright (c) 2014-2020 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
@@ -6980,7 +6980,7 @@ static void window_ride_customer_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
{
|
||||
int32_t x, y;
|
||||
uint8_t shopItem;
|
||||
int16_t popularity, satisfaction, queueTime, age;
|
||||
int16_t popularity, satisfaction, queueTime;
|
||||
int32_t customersPerHour;
|
||||
rct_string_id stringId;
|
||||
|
||||
@@ -7080,7 +7080,7 @@ static void window_ride_customer_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
|
||||
// Age
|
||||
// If the ride has a build date that is in the future, show it as built this year.
|
||||
age = std::max((gDateMonthsElapsed - ride->build_date) / 8, 0);
|
||||
int16_t age = std::max(date_get_year(ride->GetAge()), 0);
|
||||
stringId = age == 0 ? STR_BUILT_THIS_YEAR : age == 1 ? STR_BUILT_LAST_YEAR : STR_BUILT_YEARS_AGO;
|
||||
gfx_draw_string_left(dpi, stringId, &age, COLOUR_BLACK, x, y);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2019 OpenRCT2 developers
|
||||
* Copyright (c) 2014-2020 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
@@ -665,7 +665,7 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
|
||||
break;
|
||||
case INFORMATION_TYPE_AGE:
|
||||
{
|
||||
int16_t age = date_get_year(gDateMonthsElapsed - ride->build_date);
|
||||
int16_t age = date_get_year(ride->GetAge());
|
||||
switch (age)
|
||||
{
|
||||
case 0:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2019 OpenRCT2 developers
|
||||
* Copyright (c) 2014-2020 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
@@ -176,7 +176,7 @@ struct rct1_ride
|
||||
uint8_t pad_11F[0x7]; // 0x11F
|
||||
uint8_t spiral_slide_progress; // 0x126
|
||||
uint8_t pad_127[0x9]; // 0x127
|
||||
int16_t build_date; // 0x130
|
||||
uint16_t build_date; // 0x130
|
||||
money16 upkeep_cost; // 0x131
|
||||
uint16_t race_winner; // 0x132
|
||||
uint8_t unk_134[2]; // 0x134
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2019 OpenRCT2 developers
|
||||
* Copyright (c) 2014-2020 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
@@ -251,7 +251,7 @@ struct rct2_ride
|
||||
uint8_t pad_16F[0x7]; // 0x16F
|
||||
uint8_t spiral_slide_progress; // 0x176
|
||||
uint8_t pad_177[0x9]; // 0x177
|
||||
int16_t build_date; // 0x180
|
||||
uint16_t build_date; // 0x180
|
||||
money16 upkeep_cost; // 0x182
|
||||
uint16_t race_winner; // 0x184
|
||||
uint8_t pad_186[0x02]; // 0x186
|
||||
|
||||
@@ -248,6 +248,11 @@ int32_t ride_get_count()
|
||||
return static_cast<int32_t>(GetRideManager().size());
|
||||
}
|
||||
|
||||
int32_t Ride::GetAge() const
|
||||
{
|
||||
return static_cast<int32_t>(gDateMonthsElapsed) - build_date;
|
||||
}
|
||||
|
||||
int32_t Ride::GetTotalQueueLength() const
|
||||
{
|
||||
int32_t i, queueLength = 0;
|
||||
@@ -891,7 +896,9 @@ void ride_init_all()
|
||||
void reset_all_ride_build_dates()
|
||||
{
|
||||
for (auto& ride : GetRideManager())
|
||||
ride.build_date -= gDateMonthsElapsed;
|
||||
{
|
||||
ride.build_date = gDateMonthsElapsed;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
@@ -2214,8 +2221,7 @@ static void ride_inspection_update(Ride* ride)
|
||||
|
||||
static int32_t get_age_penalty(Ride* ride)
|
||||
{
|
||||
int32_t years;
|
||||
years = date_get_year(gDateMonthsElapsed - ride->build_date);
|
||||
auto years = date_get_year(ride->GetAge());
|
||||
switch (years)
|
||||
{
|
||||
case 0:
|
||||
@@ -2308,7 +2314,7 @@ static void ride_breakdown_update(Ride* ride)
|
||||
*/
|
||||
static int32_t ride_get_new_breakdown_problem(Ride* ride)
|
||||
{
|
||||
int32_t availableBreakdownProblems, monthsOld, totalProbability, randomProbability, problemBits, breakdownProblem;
|
||||
int32_t availableBreakdownProblems, totalProbability, randomProbability, problemBits, breakdownProblem;
|
||||
|
||||
// Brake failure is more likely when it's raining
|
||||
_breakdownProblemProbabilities[BREAKDOWN_BRAKES_FAILURE] = climate_is_raining() ? 20 : 3;
|
||||
@@ -2356,7 +2362,7 @@ static int32_t ride_get_new_breakdown_problem(Ride* ride)
|
||||
if (gCheatsDisableBrakesFailure)
|
||||
return -1;
|
||||
|
||||
monthsOld = gDateMonthsElapsed - ride->build_date;
|
||||
auto monthsOld = ride->GetAge();
|
||||
if (monthsOld < 16 || ride->reliability_percentage > 50)
|
||||
return -1;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2019 OpenRCT2 developers
|
||||
* Copyright (c) 2014-2020 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
@@ -306,7 +306,7 @@ struct Ride
|
||||
};
|
||||
uint8_t slide_peep_t_shirt_colour;
|
||||
uint8_t spiral_slide_progress;
|
||||
int16_t build_date;
|
||||
uint16_t build_date;
|
||||
money16 upkeep_cost;
|
||||
uint16_t race_winner;
|
||||
uint32_t music_position;
|
||||
@@ -411,6 +411,7 @@ public:
|
||||
|
||||
rct_ride_entry* GetRideEntry() const;
|
||||
|
||||
int32_t GetAge() const;
|
||||
int32_t GetTotalQueueLength() const;
|
||||
int32_t GetMaxQueueTime() const;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2019 OpenRCT2 developers
|
||||
* Copyright (c) 2014-2020 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
@@ -846,7 +846,7 @@ static void ride_ratings_calculate_value(Ride* ride)
|
||||
int32_t monthsOld = 0;
|
||||
if (!gCheatsDisableRideValueAging)
|
||||
{
|
||||
monthsOld = gDateMonthsElapsed - ride->build_date;
|
||||
monthsOld = ride->GetAge();
|
||||
}
|
||||
|
||||
const row* ageTable = ageTableNew;
|
||||
|
||||
@@ -549,6 +549,21 @@ namespace OpenRCT2::Scripting
|
||||
}
|
||||
}
|
||||
|
||||
int16_t buildDate_get() const
|
||||
{
|
||||
auto ride = GetRide();
|
||||
return ride != nullptr ? ride->build_date : 0;
|
||||
}
|
||||
void buildDate_set(int16_t value)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
auto ride = GetRide();
|
||||
if (ride != nullptr)
|
||||
{
|
||||
ride->build_date = value;
|
||||
}
|
||||
}
|
||||
|
||||
Ride* GetRide() const
|
||||
{
|
||||
return get_ride(_rideId);
|
||||
@@ -581,6 +596,7 @@ namespace OpenRCT2::Scripting
|
||||
dukglue_register_property(ctx, &ScRide::intensity_get, &ScRide::intensity_set, "intensity");
|
||||
dukglue_register_property(ctx, &ScRide::nausea_get, &ScRide::nausea_set, "nausea");
|
||||
dukglue_register_property(ctx, &ScRide::totalCustomers_get, &ScRide::totalCustomers_set, "totalCustomers");
|
||||
dukglue_register_property(ctx, &ScRide::buildDate_get, &ScRide::buildDate_set, "buildDate");
|
||||
}
|
||||
};
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
Reference in New Issue
Block a user