diff --git a/src/addresses.h b/src/addresses.h index 1877a9ba31..36f408a053 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -371,8 +371,10 @@ #define RCT2_ADDRESS_SAVED_VIEW_ZOOM 0x0138869E #define RCT2_ADDRESS_SAVED_VIEW_ROTATION 0x0138869F #define RCT2_ADDRESS_SCENARIO_COMPLETED_BY 0x013587D8 +#define RCT2_ADDRESS_NUM_MAP_ANIMATIONS 0x0138B580 #define RCT2_ADDRESS_RIDE_MEASUREMENTS 0x0138B60C +#define RCT2_ADDRESS_NEXT_GUEST_NUMBER 0x013B0E6C #define RCT2_ADDRESS_GRASS_SCENERY_TILEPOS 0x013B0E70 #define RCT2_ADDRESS_STAFF_PATROL_AREAS 0x013B0E72 diff --git a/src/interface/window.c b/src/interface/window.c index af4bd13f60..536fe8dd99 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -1824,7 +1824,7 @@ void tool_cancel() */ void window_guest_list_init_vars_a() { - RCT2_GLOBAL(0x013B0E6C, uint32) = 1; + gNextGuestNumber = 1; RCT2_GLOBAL(0x00F1AF1C, uint32) = 0xFFFFFFFF; RCT2_GLOBAL(0x00F1EE02, uint32) = 0xFFFFFFFF; RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_FILTER, uint8) = 0xFF; diff --git a/src/peep/peep.c b/src/peep/peep.c index 0d32f0026b..933906024c 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -6138,7 +6138,7 @@ rct_peep *peep_generate(int x, int y, int z) peep->no_of_rides = 0; memset(&peep->ride_types_been_on, 0, 16); - peep->id = RCT2_GLOBAL(0x013B0E6C, uint32)++; + peep->id = gNextGuestNumber++; peep->name_string_idx = 767; money32 cash = (scenario_rand() & 0x3) * 100 - 100 + gGuestInitialCash; diff --git a/src/peep/peep.h b/src/peep/peep.h index 11920001c3..a13cbde84f 100644 --- a/src/peep/peep.h +++ b/src/peep/peep.h @@ -605,6 +605,8 @@ enum { #define gGuestInitialHunger RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_HUNGER, uint8) #define gGuestInitialThirst RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_THIRST, uint8) +#define gNextGuestNumber RCT2_GLOBAL(RCT2_ADDRESS_NEXT_GUEST_NUMBER, uint32) + int peep_get_staff_count(); int peep_can_be_picked_up(rct_peep* peep); void peep_update_all(); diff --git a/src/rct1/S4Importer.cpp b/src/rct1/S4Importer.cpp index 5f589ee354..4710260fe2 100644 --- a/src/rct1/S4Importer.cpp +++ b/src/rct1/S4Importer.cpp @@ -669,7 +669,7 @@ void S4Importer::ImportMapAnimations() gAnimatedObjects[i] = s4Animations[i]; gAnimatedObjects[i].baseZ /= 2; } - RCT2_GLOBAL(0x0138B580, uint16) = _s4.num_map_animations; + gNumMapAnimations = _s4.num_map_animations; } void S4Importer::ImportFinance() diff --git a/src/rct2/S6Exporter.cpp b/src/rct2/S6Exporter.cpp index c0ac66638d..122d42ad61 100644 --- a/src/rct2/S6Exporter.cpp +++ b/src/rct2/S6Exporter.cpp @@ -391,7 +391,7 @@ void S6Exporter::Export() _s6.saved_view_rotation = gSavedViewRotation; memcpy(_s6.map_animations, gAnimatedObjects, sizeof(_s6.map_animations)); // rct1_map_animations - _s6.num_map_animations = RCT2_GLOBAL(0x0138B580, uint16); + _s6.num_map_animations = gNumMapAnimations; // pad_0138B582 _s6.ride_ratings_proximity_x = _rideRatingsProximityX; @@ -408,9 +408,9 @@ void S6Exporter::Export() memcpy(_s6.ride_ratings_proximity_scores, _proximityScores, sizeof(_s6.ride_ratings_proximity_scores)); _s6.ride_ratings_num_brakes = _rideRatingsNumBrakes; _s6.ride_ratings_num_reversers = _rideRatingsNumReversers; - _s6.word_0138B5CE = RCT2_GLOBAL(0x00138B5CE, uint16); - memcpy(_s6.ride_measurements, RCT2_ADDRESS(RCT2_ADDRESS_RIDE_MEASUREMENTS, rct_ride_measurement), sizeof(_s6.ride_measurements)); - _s6.next_guest_index = RCT2_GLOBAL(0x013B0E6C, uint32); + _s6.ride_ratings_station_flags = _rideRatingsStationFlags; + memcpy(_s6.ride_measurements, gRideMeasurements, sizeof(_s6.ride_measurements)); + _s6.next_guest_index = gNextGuestNumber; _s6.grass_and_scenery_tilepos = gGrassSceneryTileLoopPosition; memcpy(_s6.patrol_areas, gStaffPatrolAreas, sizeof(_s6.patrol_areas)); memcpy(_s6.staff_modes, gStaffModes, sizeof(_s6.staff_modes)); diff --git a/src/rct2/S6Importer.cpp b/src/rct2/S6Importer.cpp index 13c42af859..fa86d2c641 100644 --- a/src/rct2/S6Importer.cpp +++ b/src/rct2/S6Importer.cpp @@ -323,7 +323,7 @@ void S6Importer::Import() gSavedViewRotation = _s6.saved_view_rotation; memcpy(gAnimatedObjects, _s6.map_animations, sizeof(_s6.map_animations)); // rct1_map_animations - RCT2_GLOBAL(0x0138B580, uint16) = _s6.num_map_animations; + gNumMapAnimations = _s6.num_map_animations; // pad_0138B582 _rideRatingsProximityX = _s6.ride_ratings_proximity_x; @@ -340,9 +340,9 @@ void S6Importer::Import() memcpy(_proximityScores, _s6.ride_ratings_proximity_scores, sizeof(_s6.ride_ratings_proximity_scores)); _rideRatingsNumBrakes = _s6.ride_ratings_num_brakes; _rideRatingsNumReversers = _s6.ride_ratings_num_reversers; - RCT2_GLOBAL(0x00138B5CE, uint16) = _s6.word_0138B5CE; - memcpy(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_MEASUREMENTS, rct_ride_measurement), _s6.ride_measurements, sizeof(_s6.ride_measurements)); - RCT2_GLOBAL(0x013B0E6C, uint32) = _s6.next_guest_index; + _rideRatingsStationFlags = _s6.ride_ratings_station_flags; + memcpy(gRideMeasurements, _s6.ride_measurements, sizeof(_s6.ride_measurements)); + gNextGuestNumber = _s6.next_guest_index; gGrassSceneryTileLoopPosition = _s6.grass_and_scenery_tilepos; memcpy(gStaffPatrolAreas, _s6.patrol_areas, sizeof(_s6.patrol_areas)); memcpy(gStaffModes, _s6.staff_modes, sizeof(_s6.staff_modes)); diff --git a/src/ride/ride.c b/src/ride/ride.c index c40db6fdd8..ff52777b08 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -127,6 +127,7 @@ static const int RideInspectionInterval[] = { rct_ride_entry **gRideTypeList = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_ENTRIES, rct_ride_entry*); rct_ride* gRideList = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride); +rct_ride_measurement *gRideMeasurements = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_MEASUREMENTS, rct_ride_measurement); bool gGotoStartPlacementMode = false; int gRideRemoveTrackPieceCallbackX; int gRideRemoveTrackPieceCallbackY; @@ -222,7 +223,7 @@ void get_ride_entry_name(char *name, int index) rct_ride_measurement *get_ride_measurement(int index) { - return &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_MEASUREMENTS, rct_ride_measurement)[index]); + return &gRideMeasurements[index]; } rct_ride_entry *get_ride_entry_by_ride(rct_ride *ride) diff --git a/src/ride/ride.h b/src/ride/ride.h index cc5141a909..8b96ab7eba 100644 --- a/src/ride/ride.h +++ b/src/ride/ride.h @@ -891,6 +891,7 @@ rct_ride_measurement *get_ride_measurement(int index); extern const uint8 gRideClassifications[255]; extern rct_ride *gRideList; +extern rct_ride_measurement *gRideMeasurements; extern money32 _currentTrackPrice; diff --git a/src/ride/ride_ratings.c b/src/ride/ride_ratings.c index e8261a268a..cf80804c2f 100644 --- a/src/ride/ride_ratings.c +++ b/src/ride/ride_ratings.c @@ -140,7 +140,7 @@ static void ride_ratings_update_state_1() RCT2_GLOBAL(0x0138B5CA, uint16) = 0; RCT2_GLOBAL(0x0138B5CC, uint16) = 0; _rideRatingsState = RIDE_RATINGS_STATE_2; - RCT2_GLOBAL(0x0138B5CE, uint16) = 0; + _rideRatingsStationFlags = 0; ride_ratings_begin_proximity_loop(); } @@ -175,10 +175,11 @@ static void ride_ratings_update_state_2() if (trackType == 255 || ((mapElement->properties.track.sequence & 0x0F) == 0 && trackType == mapElement->properties.track.type)) { if (trackType == TRACK_ELEM_END_STATION) { - entranceIndex = (mapElement->properties.track.sequence >> 4) & 7; - RCT2_GLOBAL(0x0138B5CE, uint16) &= ~1; - if (ride->entrances[entranceIndex] == 0xFFFF) - RCT2_GLOBAL(0x0138B5CE, uint16) |= 1; + entranceIndex = map_get_station(mapElement); + _rideRatingsStationFlags &= ~RIDE_RATING_STATION_FLAG_NO_ENTRANCE; + if (ride->entrances[entranceIndex] == 0xFFFF) { + _rideRatingsStationFlags |= RIDE_RATING_STATION_FLAG_NO_ENTRANCE; + } } ride_ratings_score_close_proximity(mapElement); @@ -320,9 +321,10 @@ static void ride_ratings_begin_proximity_loop() for (i = 0; i < 4; i++) { if (ride->station_starts[i] != 0xFFFF) { - RCT2_GLOBAL(0x0138B5CE, uint16) &= ~1; - if (ride->entrances[i] == 0xFFFF) - RCT2_GLOBAL(0x0138B5CE, uint16) |= 1; + _rideRatingsStationFlags &= ~RIDE_RATING_STATION_FLAG_NO_ENTRANCE; + if (ride->entrances[i] == 0xFFFF) { + _rideRatingsStationFlags |= RIDE_RATING_STATION_FLAG_NO_ENTRANCE; + } x = (ride->station_starts[i] & 0xFF) * 32; y = (ride->station_starts[i] >> 8) * 32; @@ -462,8 +464,9 @@ static void ride_ratings_score_close_proximity(rct_map_element *inputMapElement) int x, y, z, direction, waterHeight, trackType, sequence; bool isStation; - if (RCT2_GLOBAL(0x0138B5CE, uint16) & 1) + if (_rideRatingsStationFlags & RIDE_RATING_STATION_FLAG_NO_ENTRANCE) { return; + } _rideRatingsProximityTotal++; x = _rideRatingsProximityX; diff --git a/src/ride/ride_ratings.h b/src/ride/ride_ratings.h index 7c8e3579ff..6d9d506eb2 100644 --- a/src/ride/ride_ratings.h +++ b/src/ride/ride_ratings.h @@ -20,6 +20,10 @@ #include "../common.h" #include "ride.h" +enum { + RIDE_RATING_STATION_FLAG_NO_ENTRANCE = 1 << 0 +}; + #define _rideRatingsProximityX RCT2_GLOBAL(0x0138B584, uint16) #define _rideRatingsProximityY RCT2_GLOBAL(0x0138B586, uint16) #define _rideRatingsProximityZ RCT2_GLOBAL(0x0138B588, uint16) @@ -34,6 +38,7 @@ #define _rideRatingsNumBrakes RCT2_GLOBAL(0x0138B5CA, uint16) #define _rideRatingsNumReversers RCT2_GLOBAL(0x0138B5CC, uint16) +#define _rideRatingsStationFlags RCT2_GLOBAL(0x0138B5CE, uint16) extern uint16 *_proximityScores; diff --git a/src/scenario.h b/src/scenario.h index d50d37e8ca..fba0317e71 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -303,7 +303,7 @@ typedef struct { uint16 ride_ratings_proximity_scores[26]; uint16 ride_ratings_num_brakes; uint16 ride_ratings_num_reversers; - uint16 word_0138B5CE; + uint16 ride_ratings_station_flags; uint8 pad_0138B5D0[60]; rct_ride_measurement ride_measurements[8]; uint32 next_guest_index; diff --git a/src/world/map.c b/src/world/map.c index 2f7da4a574..73d2fe59f0 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -314,7 +314,7 @@ void map_init(int size) rct_map_element *map_element; date_reset(); - RCT2_GLOBAL(0x0138B580, sint16) = 0; + gNumMapAnimations = 0; RCT2_GLOBAL(0x010E63B8, sint32) = 0; for (i = 0; i < MAX_TILE_MAP_ELEMENT_POINTERS; i++) { diff --git a/src/world/map_animation.c b/src/world/map_animation.c index 630b06a395..711309f2bf 100644 --- a/src/world/map_animation.c +++ b/src/world/map_animation.c @@ -45,7 +45,7 @@ rct_map_animation *gAnimatedObjects = (rct_map_animation*)0x013886A0; void map_animation_create(int type, int x, int y, int z) { rct_map_animation *aobj = &gAnimatedObjects[0]; - int numAnimatedObjects = RCT2_GLOBAL(0x0138B580, uint16); + int numAnimatedObjects = gNumMapAnimations; if (numAnimatedObjects >= 2000) { log_error("Exceeded the maximum number of animations"); return; @@ -64,7 +64,7 @@ void map_animation_create(int type, int x, int y, int z) } // Create new animation - RCT2_GLOBAL(0x0138B580, uint16)++; + gNumMapAnimations++; aobj->type = type; aobj->x = x; aobj->y = y; @@ -78,11 +78,11 @@ void map_animation_create(int type, int x, int y, int z) void map_animation_invalidate_all() { rct_map_animation *aobj = &gAnimatedObjects[0]; - int numAnimatedObjects = RCT2_GLOBAL(0x0138B580, uint16); + int numAnimatedObjects = gNumMapAnimations; while (numAnimatedObjects > 0) { if (map_animation_invalidate(aobj)) { // Remove animated object - RCT2_GLOBAL(0x0138B580, uint16)--; + gNumMapAnimations--; numAnimatedObjects--; if (numAnimatedObjects > 0) memmove(aobj, aobj + 1, numAnimatedObjects * sizeof(rct_map_animation)); diff --git a/src/world/map_animation.h b/src/world/map_animation.h index 000ceba7f6..e52241be83 100644 --- a/src/world/map_animation.h +++ b/src/world/map_animation.h @@ -48,6 +48,8 @@ enum { MAP_ANIMATION_TYPE_COUNT }; +#define gNumMapAnimations RCT2_GLOBAL(RCT2_ADDRESS_NUM_MAP_ANIMATIONS, uint16) + extern rct_map_animation *gAnimatedObjects; void map_animation_create(int type, int x, int y, int z);