From ce4899c60c4b9f5a1aac6d2b6b2ff7747b61c4ce Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Mon, 23 Oct 2017 14:47:12 +0200 Subject: [PATCH] Compile station.c as C++ --- OpenRCT2.xcodeproj/project.pbxproj | 20 +- src/openrct2/actions/RideCreateAction.hpp | 2 +- src/openrct2/cheats.c | 2 +- src/openrct2/peep/Peep.cpp | 4 +- src/openrct2/rct1/S4Importer.cpp | 2 +- src/openrct2/rct2/S6Importer.cpp | 2 +- src/openrct2/ride/{station.c => Station.cpp} | 220 ++++++++++--------- src/openrct2/ride/{station.h => Station.h} | 13 +- src/openrct2/ride/Track.cpp | 2 +- src/openrct2/ride/Vehicle.cpp | 2 +- src/openrct2/ride/ride.c | 2 +- src/openrct2/ride/ride_ratings.c | 2 +- src/openrct2/world/footpath.c | 2 +- 13 files changed, 145 insertions(+), 130 deletions(-) rename src/openrct2/ride/{station.c => Station.cpp} (65%) rename src/openrct2/ride/{station.h => Station.h} (75%) diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index a637f8c18b..1abd6beb3d 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -22,6 +22,7 @@ /* Begin PBXBuildFile section */ 4C4C1E981F58226500560300 /* TrackDesign.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C4C1E971F58226500560300 /* TrackDesign.cpp */; }; + 4C6AC20F1F9E1693004324AA /* Station.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C6AC20D1F9E1693004324AA /* Station.cpp */; }; 4C8667821EEFDCDF0024AAB8 /* RideGroupManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8667801EEFDCDF0024AAB8 /* RideGroupManager.cpp */; }; 4C8B42701EEB1ABD00F015CA /* X8DrawingEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8B426E1EEB1ABD00F015CA /* X8DrawingEngine.cpp */; }; 4C8B42721EEB1AE400F015CA /* HardwareDisplayDrawingEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8B42711EEB1AE400F015CA /* HardwareDisplayDrawingEngine.cpp */; }; @@ -176,6 +177,7 @@ C64FDAA71D6D9A2100F259B9 /* boat_ride.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F9031CDBC3B7009F9BFC /* boat_ride.c */; }; C64FDAA81D6D9A2100F259B9 /* dingy_slide.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F9041CDBC3B7009F9BFC /* dingy_slide.c */; }; C64FDAA91D6D9A2100F259B9 /* log_flume.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F9051CDBC3B7009F9BFC /* log_flume.c */; }; + C651A8D91F30204300443BCA /* Text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C651A8D71F30204300443BCA /* Text.cpp */; }; C654DF2D1F69C0430040F43D /* Banner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C654DF1C1F69C0430040F43D /* Banner.cpp */; }; C654DF2E1F69C0430040F43D /* DemolishRidePrompt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C654DF1D1F69C0430040F43D /* DemolishRidePrompt.cpp */; }; C654DF2F1F69C0430040F43D /* Error.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C654DF1E1F69C0430040F43D /* Error.cpp */; }; @@ -240,7 +242,6 @@ C685E51B1F8907850090598F /* Guest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C685E5161F8907840090598F /* Guest.cpp */; }; C685E51C1F8907850090598F /* Map.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C685E5171F8907840090598F /* Map.cpp */; }; C685E51D1F8907850090598F /* Research.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C685E5181F8907840090598F /* Research.cpp */; }; - C651A8D91F30204300443BCA /* Text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C651A8D71F30204300443BCA /* Text.cpp */; }; C6CB94F21EFFBF860065888F /* libfreetype.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D45A38B41CF3006400659A24 /* libfreetype.dylib */; }; C6E96E361E0408B40076A04F /* libzip.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C6E96E351E0408B40076A04F /* libzip.dylib */; }; C6E96E371E040E040076A04F /* libzip.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C6E96E351E0408B40076A04F /* libzip.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; @@ -403,7 +404,6 @@ F76C86FC1EC4E88400FA49E2 /* ride.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C84BA1EC4E7CC00FA49E2 /* ride.c */; }; F76C86FE1EC4E88400FA49E2 /* ride_data.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C84BC1EC4E7CC00FA49E2 /* ride_data.c */; }; F76C87001EC4E88400FA49E2 /* ride_ratings.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C84BE1EC4E7CC00FA49E2 /* ride_ratings.c */; }; - F76C87051EC4E88400FA49E2 /* station.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C84C41EC4E7CC00FA49E2 /* station.c */; }; F76C87141EC4E88400FA49E2 /* track_data.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C84D41EC4E7CC00FA49E2 /* track_data.c */; }; F76C87161EC4E88400FA49E2 /* track_data_old.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C84D61EC4E7CC00FA49E2 /* track_data_old.c */; }; F76C87191EC4E88400FA49E2 /* track_design_save.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C84D91EC4E7CD00FA49E2 /* track_design_save.c */; }; @@ -613,6 +613,8 @@ /* Begin PBXFileReference section */ 4C4C1E971F58226500560300 /* TrackDesign.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TrackDesign.cpp; sourceTree = ""; }; 4C4C1E991F5832AA00560300 /* TrackDesign.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TrackDesign.h; sourceTree = ""; }; + 4C6AC20D1F9E1693004324AA /* Station.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Station.cpp; sourceTree = ""; }; + 4C6AC20E1F9E1693004324AA /* Station.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Station.h; sourceTree = ""; }; 4C8667801EEFDCDF0024AAB8 /* RideGroupManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RideGroupManager.cpp; sourceTree = ""; }; 4C8667811EEFDCDF0024AAB8 /* RideGroupManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RideGroupManager.h; sourceTree = ""; }; 4C8B426E1EEB1ABD00F015CA /* X8DrawingEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = X8DrawingEngine.cpp; sourceTree = ""; }; @@ -782,6 +784,8 @@ C647C68F1E1D0CA000C7FB21 /* AudioMixer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioMixer.cpp; sourceTree = ""; }; C649B3D31DF04ED2008AC826 /* format_codes.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = format_codes.c; sourceTree = ""; }; C64FDA5D1D6D99F400F259B9 /* PaintTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = PaintTest; sourceTree = BUILT_PRODUCTS_DIR; }; + C651A8D71F30204300443BCA /* Text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Text.cpp; sourceTree = ""; }; + C651A8D81F30204300443BCA /* Text.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Text.h; sourceTree = ""; }; C654DF1C1F69C0430040F43D /* Banner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Banner.cpp; sourceTree = ""; }; C654DF1D1F69C0430040F43D /* DemolishRidePrompt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DemolishRidePrompt.cpp; sourceTree = ""; }; C654DF1E1F69C0430040F43D /* Error.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Error.cpp; sourceTree = ""; }; @@ -849,8 +853,6 @@ C685E5161F8907840090598F /* Guest.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Guest.cpp; sourceTree = ""; }; C685E5171F8907840090598F /* Map.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Map.cpp; sourceTree = ""; }; C685E5181F8907840090598F /* Research.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Research.cpp; sourceTree = ""; }; - C651A8D71F30204300443BCA /* Text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Text.cpp; sourceTree = ""; }; - C651A8D81F30204300443BCA /* Text.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Text.h; sourceTree = ""; }; C686F8E91CDBC3B7009F9BFC /* observation_tower.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = observation_tower.c; sourceTree = ""; }; C686F8EA1CDBC3B7009F9BFC /* space_rings.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = space_rings.c; sourceTree = ""; }; C686F8EB1CDBC3B7009F9BFC /* spiral_slide.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = spiral_slide.c; sourceTree = ""; }; @@ -1303,8 +1305,6 @@ F76C84BD1EC4E7CC00FA49E2 /* ride_data.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ride_data.h; sourceTree = ""; }; F76C84BE1EC4E7CC00FA49E2 /* ride_ratings.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = ride_ratings.c; sourceTree = ""; }; F76C84BF1EC4E7CC00FA49E2 /* ride_ratings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ride_ratings.h; sourceTree = ""; }; - F76C84C41EC4E7CC00FA49E2 /* station.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = station.c; sourceTree = ""; }; - F76C84C51EC4E7CC00FA49E2 /* station.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = station.h; sourceTree = ""; }; F76C84D41EC4E7CC00FA49E2 /* track_data.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = track_data.c; sourceTree = ""; }; F76C84D51EC4E7CC00FA49E2 /* track_data.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = track_data.h; sourceTree = ""; }; F76C84D61EC4E7CC00FA49E2 /* track_data_old.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = track_data_old.c; sourceTree = ""; }; @@ -2014,7 +2014,6 @@ F76C839D1EC4E7CC00FA49E2 /* drawing */ = { isa = PBXGroup; children = ( - F76C83A01EC4E7CC00FA49E2 /* drawing_fast.cpp */, F76C839E1EC4E7CC00FA49E2 /* drawing.c */, F76C839F1EC4E7CC00FA49E2 /* drawing.h */, F76C83A01EC4E7CC00FA49E2 /* DrawingFast.cpp */, @@ -2328,8 +2327,8 @@ 4C8667811EEFDCDF0024AAB8 /* RideGroupManager.h */, F76C84BE1EC4E7CC00FA49E2 /* ride_ratings.c */, F76C84BF1EC4E7CC00FA49E2 /* ride_ratings.h */, - F76C84C41EC4E7CC00FA49E2 /* station.c */, - F76C84C51EC4E7CC00FA49E2 /* station.h */, + 4C6AC20D1F9E1693004324AA /* Station.cpp */, + 4C6AC20E1F9E1693004324AA /* Station.h */, 4CFE4E8E1F9625B0005243C2 /* Track.cpp */, 4CFE4E8F1F9625B0005243C2 /* Track.h */, F76C84D41EC4E7CC00FA49E2 /* track_data.c */, @@ -3224,7 +3223,6 @@ 4C8667821EEFDCDF0024AAB8 /* RideGroupManager.cpp in Sources */, 4C93F18F1F8B747A00A9330D /* PirateShip.cpp in Sources */, C654DF381F69C0430040F43D /* StaffFirePrompt.cpp in Sources */, - F7CB86431EEDA0F50030C877 /* shortcut_key_change.c in Sources */, C651A8D91F30204300443BCA /* Text.cpp in Sources */, F76C88801EC5324E00FA49E2 /* DrawImageShader.cpp in Sources */, C685E51D1F8907850090598F /* Research.cpp in Sources */, @@ -3298,6 +3296,7 @@ 4C93F1911F8B747A00A9330D /* SwingingInverterShip.cpp in Sources */, 4C93F1461F8B744400A9330D /* LayDownRollerCoaster.cpp in Sources */, 4C93F1991F8B748200A9330D /* Chairlift.cpp in Sources */, + 4C6AC20F1F9E1693004324AA /* Station.cpp in Sources */, C64644FE1F3FA4120026AC2D /* Main.cpp in Sources */, 4C93F16B1F8B745700A9330D /* CircusShow.cpp in Sources */, 4C93F19B1F8B748200A9330D /* MiniatureRailway.cpp in Sources */, @@ -3479,7 +3478,6 @@ C666EE161F33E3800061AA04 /* EditorBottomToolbar.cpp in Sources */, C666EE4D1F33E3800061AA04 /* Tooltip.cpp in Sources */, C666EE291F33E3800061AA04 /* MapTooltip.cpp in Sources */, - F76C87051EC4E88400FA49E2 /* station.c in Sources */, F76C87141EC4E88400FA49E2 /* track_data.c in Sources */, F76C87161EC4E88400FA49E2 /* track_data_old.c in Sources */, F76C87191EC4E88400FA49E2 /* track_design_save.c in Sources */, diff --git a/src/openrct2/actions/RideCreateAction.hpp b/src/openrct2/actions/RideCreateAction.hpp index e07824a61f..f0a4e754be 100644 --- a/src/openrct2/actions/RideCreateAction.hpp +++ b/src/openrct2/actions/RideCreateAction.hpp @@ -28,7 +28,7 @@ #include "../rct1.h" #include "../ride/ride_data.h" #include "../ride/ride.h" -#include "../ride/station.h" +#include "../ride/Station.h" class RideCreateGameActionResult final : public GameActionResult { diff --git a/src/openrct2/cheats.c b/src/openrct2/cheats.c index 6f28c2d95d..e76487650e 100644 --- a/src/openrct2/cheats.c +++ b/src/openrct2/cheats.c @@ -22,7 +22,7 @@ #include "localisation/localisation.h" #include "management/Finance.h" #include "network/network.h" -#include "ride/station.h" +#include "ride/Station.h" #include "util/util.h" #include "world/Climate.h" #include "world/footpath.h" diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 29dc79b005..8012db8eae 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -32,7 +32,7 @@ #include "../network/network.h" #include "../ride/ride.h" #include "../ride/ride_data.h" -#include "../ride/station.h" +#include "../ride/Station.h" #include "../ride/Track.h" #include "../scenario/scenario.h" #include "../sprites.h" @@ -3422,7 +3422,7 @@ static void peep_update_ride_sub_state_7(rct_peep * peep) if (ride_station >= MAX_STATIONS) { // HACK #5658: Some parks have hacked rides which end up in this state - sint32 bestStationIndex = ride_get_first_valid_station_exit(ride); + sint8 bestStationIndex = ride_get_first_valid_station_exit(ride); if (bestStationIndex == -1) { bestStationIndex = 0; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index d6d556c158..657c186d1d 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -30,7 +30,7 @@ #include "../object/ObjectManager.h" #include "../object/ObjectRepository.h" #include "../ParkImporter.h" -#include "../ride/station.h" +#include "../ride/Station.h" #include "../scenario/ScenarioSources.h" #include "Tables.h" #include "../object_list.h" diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 5ef21f4f8f..e64559bb4f 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -28,7 +28,7 @@ #include "../ParkImporter.h" #include "../rct12/SawyerChunkReader.h" #include "../rct12/SawyerEncoding.h" -#include "../ride/station.h" +#include "../ride/Station.h" #include "../config/Config.h" #include "../game.h" diff --git a/src/openrct2/ride/station.c b/src/openrct2/ride/Station.cpp similarity index 65% rename from src/openrct2/ride/station.c rename to src/openrct2/ride/Station.cpp index 512dd5cafe..4050445861 100644 --- a/src/openrct2/ride/station.c +++ b/src/openrct2/ride/Station.cpp @@ -15,27 +15,26 @@ #pragma endregion #include "../game.h" -#include "../scenario/scenario.h" -#include "../world/sprite.h" -#include "station.h" +#include "Station.h" -static void ride_update_station_blocksection(Ride *ride, sint32 stationIndex); -static void ride_update_station_bumpercar(Ride *ride, sint32 stationIndex); -static void ride_update_station_normal(Ride *ride, sint32 stationIndex); -static void ride_update_station_race(Ride *ride, sint32 stationIndex); -static void ride_race_init_vehicle_speeds(Ride *ride); -static void ride_invalidate_station_start(Ride *ride, sint32 stationIndex, bool greenLight); +static void ride_update_station_blocksection(Ride * ride, sint32 stationIndex); +static void ride_update_station_bumpercar(Ride * ride, sint32 stationIndex); +static void ride_update_station_normal(Ride * ride, sint32 stationIndex); +static void ride_update_station_race(Ride * ride, sint32 stationIndex); +static void ride_race_init_vehicle_speeds(Ride * ride); +static void ride_invalidate_station_start(Ride * ride, sint32 stationIndex, bool greenLight); /** * * rct2: 0x006ABFFB */ -void ride_update_station(Ride *ride, sint32 stationIndex) +void ride_update_station(Ride * ride, sint32 stationIndex) { if (ride->station_starts[stationIndex].xy == RCT_XY8_UNDEFINED) return; - switch (ride->mode) { + switch (ride->mode) + { case RIDE_MODE_RACE: ride_update_station_race(ride, stationIndex); break; @@ -56,22 +55,26 @@ void ride_update_station(Ride *ride, sint32 stationIndex) * * rct2: 0x006AC0A1 */ -static void ride_update_station_blocksection(Ride *ride, sint32 stationIndex) +static void ride_update_station_blocksection(Ride * ride, sint32 stationIndex) { - rct_map_element *mapElement; + rct_map_element * mapElement = ride_get_station_start_track_element(ride, stationIndex); - mapElement = ride_get_station_start_track_element(ride, stationIndex); - - if ((ride->status == RIDE_STATUS_CLOSED && ride->num_riders == 0) || (mapElement != NULL && mapElement->flags & 0x20)) { + if ((ride->status == RIDE_STATUS_CLOSED && ride->num_riders == 0) || (mapElement != nullptr && mapElement->flags & 0x20)) + { ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; - if ((ride->station_depart[stationIndex] & STATION_DEPART_FLAG) || (mapElement != NULL && map_element_get_green_light(mapElement))) + if ((ride->station_depart[stationIndex] & STATION_DEPART_FLAG) || (mapElement != nullptr && map_element_get_green_light(mapElement))) ride_invalidate_station_start(ride, stationIndex, false); - } else { - if (!(ride->station_depart[stationIndex] & STATION_DEPART_FLAG)) { + } + else + { + if (!(ride->station_depart[stationIndex] & STATION_DEPART_FLAG)) + { ride->station_depart[stationIndex] |= STATION_DEPART_FLAG; ride_invalidate_station_start(ride, stationIndex, true); - } else if (mapElement != NULL && map_element_get_green_light(mapElement)) { + } + else if (mapElement != nullptr && map_element_get_green_light(mapElement)) + { ride_invalidate_station_start(ride, stationIndex, true); } } @@ -81,24 +84,25 @@ static void ride_update_station_blocksection(Ride *ride, sint32 stationIndex) * * rct2: 0x006AC12B */ -static void ride_update_station_bumpercar(Ride *ride, sint32 stationIndex) +static void ride_update_station_bumpercar(Ride * ride, sint32 stationIndex) { // Change of station depart flag should really call invalidate_station_start // but since dodgems do not have station lights there is no point. - if ( - ride->status == RIDE_STATUS_CLOSED || - (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) - ) { + if (ride->status == RIDE_STATUS_CLOSED || + (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED))) + { ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; return; } - if (ride->lifecycle_flags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING) { + if (ride->lifecycle_flags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING) + { sint32 dx = ride->time_limit * 32; sint32 dl = dx & 0xFF; sint32 dh = (dx >> 8) & 0xFF; - for (sint32 i = 0; i < ride->num_vehicles; i++) { - rct_vehicle *vehicle = &(get_sprite(ride->vehicles[i])->vehicle); + for (size_t i = 0; i < ride->num_vehicles; i++) + { + rct_vehicle * vehicle = &(get_sprite(ride->vehicles[i])->vehicle); if (vehicle->var_CE < dh || (vehicle->var_CE < dh && vehicle->sub_state > dl)) continue; @@ -110,11 +114,15 @@ static void ride_update_station_bumpercar(Ride *ride, sint32 stationIndex) // Continue match ride->station_depart[stationIndex] |= STATION_DEPART_FLAG; - } else { + } + else + { // Check if all vehicles are ready to go - for (sint32 i = 0; i < ride->num_vehicles; i++) { - rct_vehicle *vehicle = &(get_sprite(ride->vehicles[i])->vehicle); - if (vehicle->status != VEHICLE_STATUS_WAITING_TO_DEPART) { + for (size_t i = 0; i < ride->num_vehicles; i++) + { + rct_vehicle * vehicle = &(get_sprite(ride->vehicles[i])->vehicle); + if (vehicle->status != VEHICLE_STATUS_WAITING_TO_DEPART) + { ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; return; } @@ -131,25 +139,27 @@ static void ride_update_station_bumpercar(Ride *ride, sint32 stationIndex) * * rct2: 0x006AC02C */ -static void ride_update_station_normal(Ride *ride, sint32 stationIndex) +static void ride_update_station_normal(Ride * ride, sint32 stationIndex) { - sint32 time; - - time = ride->station_depart[stationIndex] & STATION_DEPART_MASK; - if ( - (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) || - (ride->status == RIDE_STATUS_CLOSED && ride->num_riders == 0) - ) { + sint32 time = ride->station_depart[stationIndex] & STATION_DEPART_MASK; + if ((ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) || + (ride->status == RIDE_STATUS_CLOSED && ride->num_riders == 0)) + { if (time != 0 && time != 127 && !(gCurrentTicks & 7)) time--; ride->station_depart[stationIndex] = time; ride_invalidate_station_start(ride, stationIndex, false); - } else { - if (time == 0) { + } + else + { + if (time == 0) + { ride->station_depart[stationIndex] |= STATION_DEPART_FLAG; ride_invalidate_station_start(ride, stationIndex, true); - } else { + } + else + { if (time != 127 && !(gCurrentTicks & 31)) time--; @@ -163,34 +173,39 @@ static void ride_update_station_normal(Ride *ride, sint32 stationIndex) * * rct2: 0x006AC1DF */ -static void ride_update_station_race(Ride *ride, sint32 stationIndex) +static void ride_update_station_race(Ride * ride, sint32 stationIndex) { - if ( - ride->status == RIDE_STATUS_CLOSED || - (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) - ) { - if (ride->station_depart[stationIndex] & STATION_DEPART_FLAG){ + if (ride->status == RIDE_STATUS_CLOSED || + (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED))) + { + if (ride->station_depart[stationIndex] & STATION_DEPART_FLAG) + { ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; ride_invalidate_station_start(ride, stationIndex, false); } return; } - if (ride->lifecycle_flags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING) { + if (ride->lifecycle_flags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING) + { sint32 numLaps = ride->num_laps; - for (sint32 i = 0; i < ride->num_vehicles; i++) { - rct_vehicle *vehicle = &(get_sprite(ride->vehicles[i])->vehicle); - if (vehicle->status != VEHICLE_STATUS_WAITING_TO_DEPART && vehicle->num_laps >= numLaps) { + for (size_t i = 0; i < ride->num_vehicles; i++) + { + rct_vehicle * vehicle = &(get_sprite(ride->vehicles[i])->vehicle); + if (vehicle->status != VEHICLE_STATUS_WAITING_TO_DEPART && vehicle->num_laps >= numLaps) + { // Found a winner - if (vehicle->num_peeps != 0) { - rct_peep *peep = &(get_sprite(vehicle->peep[0])->peep); + if (vehicle->num_peeps != 0) + { + rct_peep * peep = &(get_sprite(vehicle->peep[0])->peep); ride->race_winner = peep->sprite_index; ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST; } // Race is over ride->lifecycle_flags &= ~RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING; - if (ride->station_depart[stationIndex] & STATION_DEPART_FLAG){ + if (ride->station_depart[stationIndex] & STATION_DEPART_FLAG) + { ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; ride_invalidate_station_start(ride, stationIndex, false); } @@ -200,12 +215,17 @@ static void ride_update_station_race(Ride *ride, sint32 stationIndex) // Continue racing ride->station_depart[stationIndex] |= STATION_DEPART_FLAG; - } else { + } + else + { // Check if all vehicles are ready to go - for (sint32 i = 0; i < ride->num_vehicles; i++) { - rct_vehicle *vehicle = &(get_sprite(ride->vehicles[i])->vehicle); - if (vehicle->status != VEHICLE_STATUS_WAITING_TO_DEPART && vehicle->status != VEHICLE_STATUS_DEPARTING) { - if (ride->station_depart[stationIndex] & STATION_DEPART_FLAG){ + for (size_t i = 0; i < ride->num_vehicles; i++) + { + rct_vehicle * vehicle = &(get_sprite(ride->vehicles[i])->vehicle); + if (vehicle->status != VEHICLE_STATUS_WAITING_TO_DEPART && vehicle->status != VEHICLE_STATUS_DEPARTING) + { + if (ride->station_depart[stationIndex] & STATION_DEPART_FLAG) + { ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; ride_invalidate_station_start(ride, stationIndex, false); } @@ -216,7 +236,8 @@ static void ride_update_station_race(Ride *ride, sint32 stationIndex) // Begin the race ride_race_init_vehicle_speeds(ride); ride->lifecycle_flags |= RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING; - if (!(ride->station_depart[stationIndex] & STATION_DEPART_FLAG)){ + if (!(ride->station_depart[stationIndex] & STATION_DEPART_FLAG)) + { ride->station_depart[stationIndex] |= STATION_DEPART_FLAG; ride_invalidate_station_start(ride, stationIndex, true); } @@ -230,20 +251,23 @@ static void ride_update_station_race(Ride *ride, sint32 stationIndex) * set the speed of the go kart type vehicle at the start to a random value or alter if peep name is an easter egg * @param ride (esi) */ -static void ride_race_init_vehicle_speeds(Ride *ride) +static void ride_race_init_vehicle_speeds(Ride * ride) { - for (sint32 i = 0; i < ride->num_vehicles; i++) { - rct_vehicle *vehicle = &get_sprite(ride->vehicles[i])->vehicle; + for (size_t i = 0; i < ride->num_vehicles; i++) + { + rct_vehicle * vehicle = &get_sprite(ride->vehicles[i])->vehicle; vehicle->update_flags &= ~VEHICLE_UPDATE_FLAG_6; - rct_ride_entry *rideEntry = get_ride_entry(vehicle->ride_subtype); + rct_ride_entry * rideEntry = get_ride_entry(vehicle->ride_subtype); vehicle->speed = (scenario_rand() & 16) - 8 + rideEntry->vehicles[vehicle->vehicle_type].powered_max_speed; - if (vehicle->num_peeps != 0) { - rct_peep *peep = &get_sprite(vehicle->peep[0])->peep; + if (vehicle->num_peeps != 0) + { + rct_peep * peep = &get_sprite(vehicle->peep[0])->peep; - switch (peep_get_easteregg_name_id(peep)) { + switch (peep_get_easteregg_name_id(peep)) + { case EASTEREGG_PEEP_NAME_MICHAEL_SCHUMACHER: vehicle->speed += 35; break; @@ -268,17 +292,14 @@ static void ride_race_init_vehicle_speeds(Ride *ride) * * rct2: 0x006AC2C7 */ -static void ride_invalidate_station_start(Ride *ride, sint32 stationIndex, bool greenLight) +static void ride_invalidate_station_start(Ride * ride, sint32 stationIndex, bool greenLight) { - sint32 x, y; - rct_map_element *mapElement; - - x = ride->station_starts[stationIndex].x * 32; - y = ride->station_starts[stationIndex].y * 32; - mapElement = ride_get_station_start_track_element(ride, stationIndex); + sint32 x = ride->station_starts[stationIndex].x * 32; + sint32 y = ride->station_starts[stationIndex].y * 32; + rct_map_element * mapElement = ride_get_station_start_track_element(ride, stationIndex); // If no station track found return - if (mapElement == NULL) + if (mapElement == nullptr) return; map_element_set_green_light(mapElement, greenLight); @@ -287,41 +308,40 @@ static void ride_invalidate_station_start(Ride *ride, sint32 stationIndex, bool map_invalidate_tile_zoom1(x, y, mapElement->base_height * 8, mapElement->clearance_height * 8); } -rct_map_element *ride_get_station_start_track_element(Ride *ride, sint32 stationIndex) +rct_map_element * ride_get_station_start_track_element(Ride * ride, sint32 stationIndex) { - sint32 x, y, z; - rct_map_element *mapElement; - - x = ride->station_starts[stationIndex].x; - y = ride->station_starts[stationIndex].y; - z = ride->station_heights[stationIndex]; + sint32 x = ride->station_starts[stationIndex].x; + sint32 y = ride->station_starts[stationIndex].y; + sint32 z = ride->station_heights[stationIndex]; // Find the station track element - mapElement = map_get_first_element_at(x, y); - do { + rct_map_element * mapElement = map_get_first_element_at(x, y); + do + { if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_TRACK && z == mapElement->base_height) return mapElement; - } while (!map_element_is_last_for_tile(mapElement++)); + } + while (!map_element_is_last_for_tile(mapElement++)); - return NULL; + return nullptr; } -rct_map_element *ride_get_station_exit_element(Ride *ride, sint32 x, sint32 y, sint32 z) +rct_map_element * ride_get_station_exit_element(Ride * ride, sint32 x, sint32 y, sint32 z) { - rct_map_element *mapElement; - // Find the station track element - mapElement = map_get_first_element_at(x, y); - do { + rct_map_element * mapElement = map_get_first_element_at(x, y); + do + { if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_ENTRANCE && z == mapElement->base_height) return mapElement; - } while (!map_element_is_last_for_tile(mapElement++)); + } + while (!map_element_is_last_for_tile(mapElement++)); - return NULL; + return nullptr; } -sint32 ride_get_first_valid_station_exit(Ride * ride) +sint8 ride_get_first_valid_station_exit(Ride * ride) { for (sint32 i = 0; i < MAX_STATIONS; i++) { @@ -333,9 +353,9 @@ sint32 ride_get_first_valid_station_exit(Ride * ride) return -1; } -sint8 ride_get_first_valid_station_start(const Ride *ride) +sint8 ride_get_first_valid_station_start(const Ride * ride) { - for (sint32 i = 0; i < MAX_STATIONS; i++) + for (sint8 i = 0; i < MAX_STATIONS; i++) { if (ride->station_starts[i].xy != RCT_XY8_UNDEFINED) { @@ -345,9 +365,9 @@ sint8 ride_get_first_valid_station_start(const Ride *ride) return -1; } -sint8 ride_get_first_empty_station_start(const Ride *ride) +sint8 ride_get_first_empty_station_start(const Ride * ride) { - for (sint32 i = 0; i < MAX_STATIONS; i++) + for (sint8 i = 0; i < MAX_STATIONS; i++) { if (ride->station_starts[i].xy == RCT_XY8_UNDEFINED) { diff --git a/src/openrct2/ride/station.h b/src/openrct2/ride/Station.h similarity index 75% rename from src/openrct2/ride/station.h rename to src/openrct2/ride/Station.h index 1631c0cc2d..068fcfe3f3 100644 --- a/src/openrct2/ride/station.h +++ b/src/openrct2/ride/Station.h @@ -14,8 +14,7 @@ *****************************************************************************/ #pragma endregion -#ifndef _RIDE_STATION_H_ -#define _RIDE_STATION_H_ +#pragma once #include "../common.h" #include "../world/map.h" @@ -25,13 +24,11 @@ extern "C" { #endif -void ride_update_station(Ride *ride, sint32 stationIndex); -sint32 ride_get_first_valid_station_exit(Ride * ride); -sint8 ride_get_first_valid_station_start(const Ride *ride); -sint8 ride_get_first_empty_station_start(const Ride *ride); +void ride_update_station(Ride * ride, sint32 stationIndex); +sint8 ride_get_first_valid_station_exit(Ride * ride); +sint8 ride_get_first_valid_station_start(const Ride * ride); +sint8 ride_get_first_empty_station_start(const Ride * ride); #ifdef __cplusplus } #endif - -#endif diff --git a/src/openrct2/ride/Track.cpp b/src/openrct2/ride/Track.cpp index 7693d5b058..f6fd315e62 100644 --- a/src/openrct2/ride/Track.cpp +++ b/src/openrct2/ride/Track.cpp @@ -35,7 +35,7 @@ #include "ride_data.h" #include "ride_ratings.h" #include "RideGroupManager.h" -#include "station.h" +#include "Station.h" #include "Track.h" #include "track_data.h" diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 820cdfcb68..7e6941f7d0 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -38,7 +38,7 @@ #include "cable_lift.h" #include "ride.h" #include "ride_data.h" -#include "station.h" +#include "Station.h" #include "Track.h" #include "track_data.h" #include "vehicle_data.h" diff --git a/src/openrct2/ride/ride.c b/src/openrct2/ride/ride.c index 5f6045b344..8f3d5c15b2 100644 --- a/src/openrct2/ride/ride.c +++ b/src/openrct2/ride/ride.c @@ -49,7 +49,7 @@ #include "ride.h" #include "ride_data.h" #include "RideGroupManager.h" -#include "station.h" +#include "Station.h" #include "Track.h" #include "track_data.h" diff --git a/src/openrct2/ride/ride_ratings.c b/src/openrct2/ride/ride_ratings.c index 7537873148..c67cc9c3d8 100644 --- a/src/openrct2/ride/ride_ratings.c +++ b/src/openrct2/ride/ride_ratings.c @@ -22,7 +22,7 @@ #include "ride.h" #include "ride_data.h" #include "ride_ratings.h" -#include "station.h" +#include "Station.h" #include "Track.h" enum { diff --git a/src/openrct2/world/footpath.c b/src/openrct2/world/footpath.c index 10255db5c7..d38d25c4e6 100644 --- a/src/openrct2/world/footpath.c +++ b/src/openrct2/world/footpath.c @@ -20,7 +20,7 @@ #include "../network/network.h" #include "../object_list.h" #include "../OpenRCT2.h" -#include "../ride/station.h" +#include "../ride/Station.h" #include "../ride/Track.h" #include "../ride/track_data.h" #include "../util/util.h"