diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a8d3eaba0..12ed42f22d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,9 +50,9 @@ set(OBJECTS_VERSION "1.0.21") set(OBJECTS_URL "https://github.com/OpenRCT2/objects/releases/download/v${OBJECTS_VERSION}/objects.zip") set(OBJECTS_SHA1 "c38af45d51a6e440386180feacf76c64720b6ac5") -set(REPLAYS_VERSION "0.0.52") +set(REPLAYS_VERSION "0.0.53") set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v${REPLAYS_VERSION}/replays.zip") -set(REPLAYS_SHA1 "3A1A6B5B25ACA3B8AADC618A9D2BE44F8A23A7BB") +set(REPLAYS_SHA1 "8DDA5F2CC0B101D477396A3B016FF5F3EDFD074F") option(FORCE32 "Force 32-bit build. It will add `-m32` to compiler flags.") option(WITH_TESTS "Build tests") diff --git a/openrct2.proj b/openrct2.proj index b0641bfc8c..8e90ba9d3b 100644 --- a/openrct2.proj +++ b/openrct2.proj @@ -48,8 +48,8 @@ 304d13a126c15bf2c86ff13b81a2f2cc1856ac8d https://github.com/OpenRCT2/objects/releases/download/v1.0.21/objects.zip c38af45d51a6e440386180feacf76c64720b6ac5 - https://github.com/OpenRCT2/replays/releases/download/v0.0.52/replays.zip - 3A1A6B5B25ACA3B8AADC618A9D2BE44F8A23A7BB + https://github.com/OpenRCT2/replays/releases/download/v0.0.53/replays.zip + 8DDA5F2CC0B101D477396A3B016FF5F3EDFD074F diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index db53bce639..c7063690af 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -1411,7 +1411,7 @@ void window_guest_stats_paint(rct_window* w, rct_drawpixelinfo* dpi) int32_t guestEntryTime = peep->GetParkEntryTime(); if (guestEntryTime != -1) { - int32_t timeInPark = (gScenarioTicks - guestEntryTime) >> 11; + int32_t timeInPark = (gCurrentTicks - guestEntryTime) >> 11; auto ft = Formatter(); ft.Add(timeInPark & 0xFFFF); DrawTextBasic(dpi, screenCoords, STR_GUEST_STAT_TIME_IN_PARK, ft); @@ -1481,7 +1481,7 @@ void window_guest_rides_update(rct_window* w) } // Every 2048 ticks do a full window_invalidate - int32_t number_of_ticks = gScenarioTicks - guest->GetParkEntryTime(); + int32_t number_of_ticks = gCurrentTicks - guest->GetParkEntryTime(); if (!(number_of_ticks & 0x7FF)) w->Invalidate(); diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index cc3b1254c9..a276b5fad3 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -807,7 +807,7 @@ private: bool IsRefreshOfGroupsRequired() { - uint32_t tick256 = floor2(gScenarioTicks, 256); + uint32_t tick256 = floor2(gCurrentTicks, 256); if (_selectedView == _lastFindGroupsSelectedView) { if (_lastFindGroupsWait != 0 || _lastFindGroupsTick == tick256) @@ -834,7 +834,7 @@ private: void RefreshGroups() { - _lastFindGroupsTick = floor2(gScenarioTicks, 256); + _lastFindGroupsTick = floor2(gCurrentTicks, 256); _lastFindGroupsSelectedView = _selectedView; _lastFindGroupsWait = 320; _groups.clear(); diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index b0db04d1f8..6f8cbfb6df 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -495,7 +495,7 @@ namespace OpenRCT2 #endif } - gScenarioTicks = 0; + gCurrentTicks = 0; input_reset_place_obj_modifier(); viewport_init_all(); diff --git a/src/openrct2/GameState.cpp b/src/openrct2/GameState.cpp index def2b810aa..043f46dd1e 100644 --- a/src/openrct2/GameState.cpp +++ b/src/openrct2/GameState.cpp @@ -56,6 +56,7 @@ GameState::GameState() void GameState::InitAll(int32_t mapSize) { gInMapInitCode = true; + gCurrentTicks = 0; map_init(mapSize); _park->Initialise(); @@ -367,7 +368,6 @@ void GameState::UpdateLogic(LogicTimings* timings) report_time(LogicTimePart::NetworkFlush); gCurrentTicks++; - gScenarioTicks++; gSavedAge++; #ifdef ENABLE_SCRIPTING diff --git a/src/openrct2/drawing/Weather.cpp b/src/openrct2/drawing/Weather.cpp index 35eb7e0cff..c8fdb13670 100644 --- a/src/openrct2/drawing/Weather.cpp +++ b/src/openrct2/drawing/Weather.cpp @@ -9,6 +9,7 @@ #include "Weather.h" +#include "../Game.h" #include "../config/Config.h" #include "../interface/Viewport.h" #include "../ride/TrackDesign.h" @@ -77,15 +78,15 @@ void DrawWeather(rct_drawpixelinfo* dpi, IWeatherDrawer* weatherDrawer) */ static void DrawLightRain(IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height) { - int32_t x_start = -static_cast(gScenarioTicks) + 8; - int32_t y_start = (gScenarioTicks * 3) + 7; + int32_t x_start = -static_cast(gCurrentTicks) + 8; + int32_t y_start = (gCurrentTicks * 3) + 7; y_start = -y_start; x_start += left; y_start += top; weatherDrawer->Draw(left, top, width, height, x_start, y_start, RainPattern); - x_start = -static_cast(gScenarioTicks) + 0x18; - y_start = (gScenarioTicks * 4) + 0x0D; + x_start = -static_cast(gCurrentTicks) + 0x18; + y_start = (gCurrentTicks * 4) + 0x0D; y_start = -y_start; x_start += left; y_start += top; @@ -98,29 +99,29 @@ static void DrawLightRain(IWeatherDrawer* weatherDrawer, int32_t left, int32_t t */ static void DrawHeavyRain(IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height) { - int32_t x_start = -static_cast(gScenarioTicks); - int32_t y_start = gScenarioTicks * 5; + int32_t x_start = -static_cast(gCurrentTicks); + int32_t y_start = gCurrentTicks * 5; y_start = -y_start; x_start += left; y_start += top; weatherDrawer->Draw(left, top, width, height, x_start, y_start, RainPattern); - x_start = -static_cast(gScenarioTicks) + 0x10; - y_start = (gScenarioTicks * 6) + 5; + x_start = -static_cast(gCurrentTicks) + 0x10; + y_start = (gCurrentTicks * 6) + 5; y_start = -y_start; x_start += left; y_start += top; weatherDrawer->Draw(left, top, width, height, x_start, y_start, RainPattern); - x_start = -static_cast(gScenarioTicks) + 8; - y_start = (gScenarioTicks * 3) + 7; + x_start = -static_cast(gCurrentTicks) + 8; + y_start = (gCurrentTicks * 3) + 7; y_start = -y_start; x_start += left; y_start += top; weatherDrawer->Draw(left, top, width, height, x_start, y_start, RainPattern); - x_start = -static_cast(gScenarioTicks) + 0x18; - y_start = (gScenarioTicks * 4) + 0x0D; + x_start = -static_cast(gCurrentTicks) + 0x18; + y_start = (gCurrentTicks * 4) + 0x0D; y_start = -y_start; x_start += left; y_start += top; @@ -129,9 +130,9 @@ static void DrawHeavyRain(IWeatherDrawer* weatherDrawer, int32_t left, int32_t t static void DrawLightSnow(IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height) { - const uint32_t t = gScenarioTicks / 2; + const uint32_t t = gCurrentTicks / 2; const int32_t negT = -static_cast(t); - const double cosTick = static_cast(gScenarioTicks) * 0.05; + const double cosTick = static_cast(gCurrentTicks) * 0.05; int32_t x_start = negT + 1 + (cos(1.0 + cosTick) * 6); int32_t y_start = t + 1; @@ -150,29 +151,29 @@ static void DrawLightSnow(IWeatherDrawer* weatherDrawer, int32_t left, int32_t t static void DrawHeavySnow(IWeatherDrawer* weatherDrawer, int32_t left, int32_t top, int32_t width, int32_t height) { - int32_t x_start = -static_cast(gScenarioTicks * 3) + 1; - int32_t y_start = gScenarioTicks + 23; + int32_t x_start = -static_cast(gCurrentTicks * 3) + 1; + int32_t y_start = gCurrentTicks + 23; y_start = -y_start; x_start += left; y_start += top; weatherDrawer->Draw(left, top, width, height, x_start, y_start, SnowPattern); - x_start = -static_cast(gScenarioTicks * 4) + 6; - y_start = gScenarioTicks + 5; + x_start = -static_cast(gCurrentTicks * 4) + 6; + y_start = gCurrentTicks + 5; y_start = -y_start; x_start += left; y_start += top; weatherDrawer->Draw(left, top, width, height, x_start, y_start, SnowPattern); - x_start = -static_cast(gScenarioTicks * 2) + 11; - y_start = gScenarioTicks + 18; + x_start = -static_cast(gCurrentTicks * 2) + 11; + y_start = gCurrentTicks + 18; y_start = -y_start; x_start += left; y_start += top; weatherDrawer->Draw(left, top, width, height, x_start, y_start, SnowPattern); - x_start = -static_cast(gScenarioTicks * 3) + 17; - y_start = gScenarioTicks + 11; + x_start = -static_cast(gCurrentTicks * 3) + 17; + y_start = gCurrentTicks + 11; y_start = -y_start; x_start += left; y_start += top; diff --git a/src/openrct2/localisation/Localisation.Date.cpp b/src/openrct2/localisation/Localisation.Date.cpp index 7d7dd6f7ec..ce4330600b 100644 --- a/src/openrct2/localisation/Localisation.Date.cpp +++ b/src/openrct2/localisation/Localisation.Date.cpp @@ -61,7 +61,6 @@ void date_reset() { gDateMonthsElapsed = 0; gDateMonthTicks = 0; - gCurrentTicks = 0; gCurrentRealTimeTicks = 0; } diff --git a/src/openrct2/management/Research.cpp b/src/openrct2/management/Research.cpp index 45e60590c8..456667b110 100644 --- a/src/openrct2/management/Research.cpp +++ b/src/openrct2/management/Research.cpp @@ -315,7 +315,7 @@ void research_update() return; } - if (gScenarioTicks % 32 != 0) + if (gCurrentTicks % 32 != 0) { return; } diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index e88238c4cd..137ef0c030 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -38,7 +38,7 @@ // This string specifies which version of network stream current build uses. // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. -#define NETWORK_STREAM_VERSION "9" +#define NETWORK_STREAM_VERSION "10" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static Peep* _pickup_peep = nullptr; diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 170734532d..9895036e18 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -989,7 +989,7 @@ void Guest::Tick128UpdateGuest(int32_t index) if (State == PeepState::Walking && !OutsideOfPark && !(PeepFlags & PEEP_FLAGS_LEAVING_PARK) && GuestNumRides == 0 && GuestHeadingToRideId == RIDE_ID_NULL) { - uint32_t time_duration = gScenarioTicks - ParkEntryTime; + uint32_t time_duration = gCurrentTicks - ParkEntryTime; time_duration /= 2048; if (time_duration >= 5) @@ -5583,7 +5583,7 @@ void Guest::UpdateEnteringPark() SetState(PeepState::Falling); OutsideOfPark = false; - ParkEntryTime = gScenarioTicks; + ParkEntryTime = gCurrentTicks; increment_guests_in_park(); decrement_guests_heading_for_park(); auto intent = Intent(INTENT_ACTION_UPDATE_GUEST_COUNT); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 2f14a337cc..8affdcb863 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2091,7 +2091,7 @@ namespace RCT1 void ImportParkFlags() { // Date and srand - gScenarioTicks = _s4.ticks; + gCurrentTicks = _s4.ticks; scenario_rand_seed(_s4.random_a, _s4.random_b); gDateMonthsElapsed = static_cast(_s4.month); gDateMonthTicks = _s4.day; diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 29871290be..7ef6c5f03e 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -316,7 +316,7 @@ void S6Exporter::Export() _s6.elapsed_months = static_cast(gDateMonthsElapsed); _s6.current_day = gDateMonthTicks; - _s6.scenario_ticks = gScenarioTicks; + _s6.scenario_ticks = gCurrentTicks; auto state = scenario_rand_state(); _s6.scenario_srand_0 = state.s0; diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 5c7c7145a4..60f0f0b8c5 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -225,7 +225,7 @@ public: gDateMonthsElapsed = static_cast(_s6.elapsed_months); gDateMonthTicks = _s6.current_day; - gScenarioTicks = _s6.scenario_ticks; + gCurrentTicks = _s6.game_ticks_1; scenario_rand_seed(_s6.scenario_srand_0, _s6.scenario_srand_1); @@ -401,7 +401,6 @@ public: String::Set(gScenarioFileName, sizeof(gScenarioFileName), _s6.scenario_filename); } std::memcpy(gScenarioExpansionPacks, _s6.saved_expansion_pack_names, sizeof(_s6.saved_expansion_pack_names)); - gCurrentTicks = _s6.game_ticks_1; gCurrentRealTimeTicks = 0; ImportRides(); @@ -480,6 +479,7 @@ public: research_determine_first_of_type(); } + void FixLandOwnership() const { if (String::Equals(_s6.scenario_filename, "Europe - European Cultural Festival.SC6")) @@ -1724,6 +1724,15 @@ template<> void S6Importer::ImportEntity(const RCT12SpriteBase& baseSrc dst->IsCrashedVehicle = src->flags & RCT12_SPRITE_FLAGS_IS_CRASHED_VEHICLE_SPRITE; } +static uint32_t AdjustScenarioToCurrentTicks(const rct_s6_data& s6, uint32_t tick) +{ + // Previously gScenarioTicks was used as a time point, now it's gCurrentTicks. + // gCurrentTicks and gScenarioTicks are now exported as the same, older saves that have a different + // scenario tick must account for the difference between the two. + uint32_t ticksElapsed = s6.scenario_ticks - tick; + return s6.game_ticks_1 - ticksElapsed; +} + template<> void S6Importer::ImportEntity(const RCT12SpriteBase& baseSrc) { auto dst = CreateEntityAt(baseSrc.sprite_index); @@ -1756,7 +1765,7 @@ template<> void S6Importer::ImportEntity(const RCT12SpriteBase& baseSrc) dst->TimeInQueue = src->time_in_queue; dst->CashInPocket = src->cash_in_pocket; dst->CashSpent = src->cash_spent; - dst->ParkEntryTime = src->park_entry_time; + dst->ParkEntryTime = AdjustScenarioToCurrentTicks(_s6, src->park_entry_time); dst->RejoinQueueTimeout = src->rejoin_queue_timeout; dst->PreviousRide = RCT12RideIdToOpenRCT2RideId(src->previous_ride); dst->PreviousRideTimeOut = src->previous_ride_time_out; @@ -1806,6 +1815,7 @@ template<> void S6Importer::ImportEntity(const RCT12SpriteBase& baseSrc) dst->AssignedStaffType = StaffType(src->staff_type); dst->MechanicTimeSinceCall = src->mechanic_time_since_call; + dst->HireDate = src->park_entry_time; dst->StaffId = src->staff_id; dst->StaffOrders = src->staff_orders; @@ -1924,7 +1934,7 @@ template<> void S6Importer::ImportEntity(const RCT12SpriteBase& baseSrc) auto src = static_cast(&baseSrc); ImportEntityCommonProperties(dst, src); dst->SubType = Litter::Type(src->type); - dst->creationTick = src->creationTick; + dst->creationTick = AdjustScenarioToCurrentTicks(_s6, src->creationTick); } void S6Importer::ImportEntity(const RCT12SpriteBase& src) diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 444763ffb3..8075bca203 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -1885,7 +1885,7 @@ static void ride_measurement_update(Ride& ride, RideMeasurement& measurement) gForces.VerticalG = std::clamp(gForces.VerticalG / 8, -127, 127); gForces.LateralG = std::clamp(gForces.LateralG / 8, -127, 127); - if (gScenarioTicks & 1) + if (gCurrentTicks & 1) { gForces.VerticalG = (gForces.VerticalG + measurement.vertical[measurement.current_item]) / 2; gForces.LateralG = (gForces.LateralG + measurement.lateral[measurement.current_item]) / 2; @@ -1898,7 +1898,7 @@ static void ride_measurement_update(Ride& ride, RideMeasurement& measurement) auto velocity = std::min(std::abs((vehicle->velocity * 5) >> 16), 255); auto altitude = std::min(vehicle->z / 8, 255); - if (gScenarioTicks & 1) + if (gCurrentTicks & 1) { velocity = (velocity + measurement.velocity[measurement.current_item]) / 2; altitude = (altitude + measurement.altitude[measurement.current_item]) / 2; @@ -1907,7 +1907,7 @@ static void ride_measurement_update(Ride& ride, RideMeasurement& measurement) measurement.velocity[measurement.current_item] = velocity & 0xFF; measurement.altitude[measurement.current_item] = altitude & 0xFF; - if (gScenarioTicks & 1) + if (gCurrentTicks & 1) { measurement.current_item++; measurement.num_items = std::max(measurement.num_items, measurement.current_item); @@ -2010,7 +2010,7 @@ std::pair Ride::GetMeasurement() assert(measurement != nullptr); } - measurement->last_use_tick = gScenarioTicks; + measurement->last_use_tick = gCurrentTicks; if (measurement->flags & 1) { return { measurement.get(), { STR_EMPTY, {} } }; diff --git a/src/openrct2/ride/TrackPaint.cpp b/src/openrct2/ride/TrackPaint.cpp index b2529b4da2..39645719be 100644 --- a/src/openrct2/ride/TrackPaint.cpp +++ b/src/openrct2/ride/TrackPaint.cpp @@ -9,6 +9,7 @@ #include "TrackPaint.h" +#include "../Game.h" #include "../config/Config.h" #include "../drawing/Drawing.h" #include "../drawing/LightFX.h" @@ -2048,7 +2049,7 @@ void track_paint_util_left_quarter_turn_1_tile_tunnel( void track_paint_util_spinning_tunnel_paint(paint_session* session, int8_t thickness, int16_t height, Direction direction) { - int32_t frame = gScenarioTicks >> 2 & 3; + int32_t frame = gCurrentTicks >> 2 & 3; uint32_t colourFlags = session->TrackColours[SCHEME_SUPPORTS]; uint32_t colourFlags2 = session->TrackColours[SCHEME_TRACK]; diff --git a/src/openrct2/ride/water/RiverRapids.cpp b/src/openrct2/ride/water/RiverRapids.cpp index 5564e9ba5c..7ca899d9e9 100644 --- a/src/openrct2/ride/water/RiverRapids.cpp +++ b/src/openrct2/ride/water/RiverRapids.cpp @@ -676,7 +676,7 @@ static void paint_river_rapids_track_waterfall( { uint32_t imageId; - uint16_t frameNum = (gScenarioTicks / 2) & 7; + uint16_t frameNum = (gCurrentTicks / 2) & 7; if (direction & 1) { @@ -739,7 +739,7 @@ static void paint_river_rapids_track_rapids( { uint32_t imageId; - uint16_t frameNum = (gScenarioTicks / 2) & 7; + uint16_t frameNum = (gCurrentTicks / 2) & 7; if (direction & 1) { @@ -790,7 +790,7 @@ static void paint_river_rapids_track_whirlpool( { uint32_t imageId; - uint8_t frameNum = (gScenarioTicks / 4) % 16; + uint8_t frameNum = (gCurrentTicks / 4) % 16; if (direction & 1) { diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index 9586f1fd2c..4228cae01a 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -68,7 +68,6 @@ bool gFirstTimeSaving = true; uint16_t gSavedAge; uint32_t gLastAutoSaveUpdate = 0; -uint32_t gScenarioTicks; random_engine_t gScenarioRand; Objective gScenarioObjective; diff --git a/src/openrct2/scenario/Scenario.h b/src/openrct2/scenario/Scenario.h index 3d63931f9b..50f3b43af2 100644 --- a/src/openrct2/scenario/Scenario.h +++ b/src/openrct2/scenario/Scenario.h @@ -149,7 +149,6 @@ static constexpr money64 COMPANY_VALUE_ON_FAILED_OBJECTIVE = 0x8000000000000001; extern const rct_string_id ScenarioCategoryStringIds[SCENARIO_CATEGORY_COUNT]; -extern uint32_t gScenarioTicks; extern random_engine_t gScenarioRand; extern Objective gScenarioObjective; diff --git a/src/openrct2/world/Litter.cpp b/src/openrct2/world/Litter.cpp index 91f721e620..c3348056a0 100644 --- a/src/openrct2/world/Litter.cpp +++ b/src/openrct2/world/Litter.cpp @@ -1,6 +1,7 @@ #include "Litter.h" #include "../Cheats.h" +#include "../Game.h" #include "../localisation/StringIds.h" #include "../scenario/Scenario.h" #include "EntityList.h" @@ -77,7 +78,7 @@ void Litter::Create(const CoordsXYZD& litterPos, Type type) litter->sprite_height_positive = 3; litter->SubType = type; litter->MoveTo(offsetLitterPos); - litter->creationTick = gScenarioTicks; + litter->creationTick = gCurrentTicks; } /** diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index d9314bfe0a..22e1301ad3 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -468,7 +468,7 @@ int32_t Park::CalculateParkRating() const for (auto litter : EntityList()) { // Ignore recently dropped litter - if (litter->creationTick - gScenarioTicks >= 7680) + if (litter->creationTick - gCurrentTicks >= 7680) { litterCount++; }