diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index ce2d6133d5..13ff135cf6 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -467,6 +467,7 @@ D46F2A9E1D39A25A00A36AB7 /* peep_data.c in Sources */ = {isa = PBXBuildFile; fileRef = D46F2A9D1D39A25A00A36AB7 /* peep_data.c */; }; D47304D51C4FF8250015C0EA /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D47304D41C4FF8250015C0EA /* libz.tbd */; }; D48A8D831D00272F00649DA7 /* TcpSocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D48A8D811D00272F00649DA7 /* TcpSocket.cpp */; }; + D48ABABA1E71EBD500A3E39C /* entrance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D48ABAB91E71EBD500A3E39C /* entrance.cpp */; }; D49464781E4DB27B00DC690E /* sprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D49464771E4DB27B00DC690E /* sprite.cpp */; }; D49766831D03B9FE002222CD /* SoftwareDrawingEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D49766811D03B9FE002222CD /* SoftwareDrawingEngine.cpp */; }; D49766861D03BAA5002222CD /* NewDrawing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D49766841D03BAA5002222CD /* NewDrawing.cpp */; }; @@ -1222,6 +1223,7 @@ D4895D321C23EFDD000CD788 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = distribution/macos/Info.plist; sourceTree = SOURCE_ROOT; }; D48A8D811D00272F00649DA7 /* TcpSocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TcpSocket.cpp; sourceTree = ""; usesTabs = 0; }; D48A8D821D00272F00649DA7 /* TcpSocket.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = TcpSocket.h; sourceTree = ""; usesTabs = 0; }; + D48ABAB91E71EBD500A3E39C /* entrance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = entrance.cpp; sourceTree = ""; }; D49464771E4DB27B00DC690E /* sprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sprite.cpp; sourceTree = ""; }; D49766811D03B9FE002222CD /* SoftwareDrawingEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SoftwareDrawingEngine.cpp; sourceTree = ""; }; D49766841D03BAA5002222CD /* NewDrawing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewDrawing.cpp; sourceTree = ""; usesTabs = 0; }; @@ -2044,6 +2046,7 @@ D44271DA1CC81B3200D84D28 /* banner.c */, D44271DB1CC81B3200D84D28 /* banner.h */, D44271DE1CC81B3200D84D28 /* duck.c */, + D48ABAB91E71EBD500A3E39C /* entrance.cpp */, D44271DF1CC81B3200D84D28 /* entrance.h */, D44271E01CC81B3200D84D28 /* footpath.c */, D44271E11CC81B3200D84D28 /* footpath.h */, @@ -3020,6 +3023,7 @@ C686F9361CDBC3B7009F9BFC /* mini_helicopters.c in Sources */, C686F93F1CDBC3B7009F9BFC /* enterprise.c in Sources */, C686F91B1CDBC3B7009F9BFC /* mini_roller_coaster.c in Sources */, + D48ABABA1E71EBD500A3E39C /* entrance.cpp in Sources */, D464FEE51D31A6AA00CBABAC /* BannerObject.cpp in Sources */, D44272391CC81B3200D84D28 /* peep.c in Sources */, D44272681CC81B3200D84D28 /* land_rights.c in Sources */, diff --git a/src/openrct2/editor.c b/src/openrct2/editor.c index 5ebbcfd5ee..12b15013e2 100644 --- a/src/openrct2/editor.c +++ b/src/openrct2/editor.c @@ -37,6 +37,7 @@ #include "world/banner.h" #include "world/Climate.h" #include "world/footpath.h" +#include "world/entrance.h" #include "world/map.h" #include "world/park.h" #include "world/scenery.h" diff --git a/src/openrct2/game.c b/src/openrct2/game.c index 1479b4e0ae..f70e54a23d 100644 --- a/src/openrct2/game.c +++ b/src/openrct2/game.c @@ -48,6 +48,7 @@ #include "windows/error.h" #include "windows/tooltip.h" #include "world/Climate.h" +#include "world/entrance.h" #include "world/footpath.h" #include "world/map_animation.h" #include "world/park.h" @@ -1156,7 +1157,7 @@ void game_init_all(sint32 mapSize) map_init(mapSize); park_init(); finance_init(); - reset_park_entrances(); + reset_park_entry(); banner_init(); ride_init_all(); reset_sprite_list(); diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 831ee165e6..40212868c5 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -337,6 +337,7 @@ + diff --git a/src/openrct2/peep/peep.c b/src/openrct2/peep/peep.c index f1d7d4c257..1ab24a89b9 100644 --- a/src/openrct2/peep/peep.c +++ b/src/openrct2/peep/peep.c @@ -35,6 +35,7 @@ #include "../sprites.h" #include "../util/util.h" #include "../world/Climate.h" +#include "../world/entrance.h" #include "../world/footpath.h" #include "../world/map.h" #include "../world/scenery.h" diff --git a/src/openrct2/peep/staff.c b/src/openrct2/peep/staff.c index fffb4c932e..00f8f851fe 100644 --- a/src/openrct2/peep/staff.c +++ b/src/openrct2/peep/staff.c @@ -24,6 +24,7 @@ #include "../network/network.h" #include "../scenario/scenario.h" #include "../util/util.h" +#include "../world/entrance.h" #include "../world/footpath.h" #include "../world/scenery.h" #include "../world/sprite.h" diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 55efb34d99..dc07af379a 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -55,6 +55,7 @@ extern "C" #include "../world/footpath.h" #include "../world/map_animation.h" #include "../world/park.h" + #include "../world/entrance.h" #include "../world/scenery.h" } diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index bf6f439aec..fce4348d95 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -46,6 +46,7 @@ extern "C" #include "../scenario/scenario.h" #include "../util/sawyercoding.h" #include "../world/Climate.h" + #include "../world/entrance.h" #include "../world/map_animation.h" #include "../world/park.h" } diff --git a/src/openrct2/ride/ride.c b/src/openrct2/ride/ride.c index d386239f7d..d74eb61f28 100644 --- a/src/openrct2/ride/ride.c +++ b/src/openrct2/ride/ride.c @@ -185,8 +185,8 @@ uint8 _currentBrakeSpeed2; uint8 _currentSeatRotationAngle; rct_xyz16 _unkF44188; -rct_xyzd16 _unkF440BF; -uint8 _unkF440C4; + + rct_xyzd16 _unkF440C5; uint8 gRideEntranceExitPlaceType; @@ -214,9 +214,7 @@ static void ride_spiral_slide_update(rct_ride *ride); static void ride_update(sint32 rideIndex); static void ride_update_vehicle_colours(sint32 rideIndex); static void ride_set_vehicle_colours_to_random_preset(rct_ride *ride, uint8 preset_index); -static void maze_entrance_hedge_removal(sint32 x, sint32 y, rct_map_element *mapElement); void loc_6DDF9C(rct_ride *ride, rct_map_element *mapElement); -static void maze_entrance_hedge_replacement(sint32 x, sint32 y, rct_map_element *mapElement); bool sub_6CA2DF(sint32 *trackType, sint32 *trackDirection, sint32 *rideIndex, sint32 *edxRS16, sint32 *x, sint32 *y, sint32 *z, sint32 *properties); money32 sub_6CA162(sint32 rideIndex, sint32 trackType, sint32 trackDirection, sint32 edxRS16, sint32 x, sint32 y, sint32 z); @@ -1099,7 +1097,7 @@ void ride_clear_for_construction(sint32 rideIndex) * * rct2: 0x006664DF */ -static void ride_remove_peeps(sint32 rideIndex) +void ride_remove_peeps(sint32 rideIndex) { rct_ride *ride = get_ride(rideIndex); @@ -1330,36 +1328,6 @@ sint32 sub_6C683D(sint32* x, sint32* y, sint32* z, sint32 direction, sint32 type return 0; } -void ride_restore_provisional_entrance_or_exit() -{ - if (_currentTrackSelectionFlags & TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT) { - game_do_command( - _unkF440BF.x, - (GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_GHOST) | (_unkF440BF.direction << 8), - _unkF440BF.y, - _currentRideIndex | (gRideEntranceExitPlaceType << 8), - GAME_COMMAND_PLACE_RIDE_ENTRANCE_OR_EXIT, - _unkF440C4, - 0 - ); - } -} - -void ride_remove_provisional_entrance_or_exit() -{ - if (_currentTrackSelectionFlags & TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT) { - game_do_command( - _unkF440BF.x, - (GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_APPLY), - _unkF440BF.y, - _currentRideIndex, - GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, - _unkF440C4, - 0 - ); - } -} - void ride_restore_provisional_track_piece() { if (_currentTrackSelectionFlags & TRACK_SELECTION_FLAG_TRACK) { @@ -1423,7 +1391,7 @@ void sub_6C96C0() { if (_currentTrackSelectionFlags & TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT) { - ride_remove_provisional_entrance_or_exit(); + ride_entrance_exit_remove_ghost(); _currentTrackSelectionFlags &= ~TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT; } if (_currentTrackSelectionFlags & TRACK_SELECTION_FLAG_TRACK) { @@ -7044,32 +7012,6 @@ void set_vehicle_type_image_max_sizes(rct_ride_entry_vehicle* vehicle_type, sint vehicle_type->sprite_height_positive = bh; } -/** - * - * rct2: 0x006CA28C - */ -money32 ride_get_entrance_or_exit_price(sint32 rideIndex, sint32 x, sint32 y, sint32 direction, sint32 dh, sint32 di) -{ - sub_6C96C0(); - money32 result = game_do_command( - x, - (GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_GHOST) | (direction << 8), - y, - rideIndex | (dh << 8), - GAME_COMMAND_PLACE_RIDE_ENTRANCE_OR_EXIT, - di, - 0 - ); - if (result != MONEY32_UNDEFINED) { - _currentTrackSelectionFlags |= TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT; - _unkF440BF.x = x; - _unkF440BF.y = y; - _unkF440BF.direction = direction; - _unkF440C4 = di & 0xFF; - } - return result; -} - static sint32 loc_6CD18E(sint16 mapX, sint16 mapY, sint16 entranceMinX, sint16 entranceMinY, sint16 entranceMaxX, sint16 entranceMaxY) { sint32 direction = 0; @@ -8082,379 +8024,6 @@ void sub_6CB945(sint32 rideIndex) } } -/** - * Removes the hedge walls for an entrance placement. - * rct2: 0x00666CBE - */ -static void maze_entrance_hedge_removal(sint32 x, sint32 y, rct_map_element *mapElement) -{ - sint32 direction = mapElement->type & MAP_ELEMENT_DIRECTION_MASK; - x += TileDirectionDelta[direction].x; - y += TileDirectionDelta[direction].y; - sint32 z = mapElement->base_height; - sint32 rideIndex = mapElement->properties.track.ride_index; - - mapElement = map_get_first_element_at(x >> 5, y >> 5); - do { - if (mapElement->type != MAP_ELEMENT_TYPE_TRACK) continue; - if (mapElement->properties.track.ride_index != rideIndex) continue; - if (mapElement->base_height != z) continue; - if (mapElement->properties.track.type != TRACK_ELEM_INVERTED_90_DEG_UP_TO_FLAT_QUARTER_LOOP) continue; - - // Each maze element is split into 4 sections with 4 different walls - uint8 mazeSection = direction * 4; - // Remove the top outer wall - mapElement->properties.track.maze_entry &= ~(1 << ((mazeSection + 9) & 0x0F)); - // Remove the bottom outer wall - mapElement->properties.track.maze_entry &= ~(1 << ((mazeSection + 12) & 0x0F)); - // Remove the intersecting wall - mapElement->properties.track.maze_entry &= ~(1 << ((mazeSection + 10) & 0x0F)); - // Remove the top hedge section - mapElement->properties.track.maze_entry &= ~(1 << ((mazeSection + 11) & 0x0F)); - // Remove the bottom hedge section - mapElement->properties.track.maze_entry &= ~(1 << ((mazeSection + 15) & 0x0F)); - - map_invalidate_tile(x, y, mapElement->base_height * 8, mapElement->clearance_height * 8); - return; - } while (!map_element_is_last_for_tile(mapElement++)); -} - -/** - * Replaces the outer hedge walls for an entrance placement removal. - * rct2: 0x00666D6F - */ -static void maze_entrance_hedge_replacement(sint32 x, sint32 y, rct_map_element *mapElement) -{ - sint32 direction = mapElement->type & MAP_ELEMENT_DIRECTION_MASK; - x += TileDirectionDelta[direction].x; - y += TileDirectionDelta[direction].y; - sint32 z = mapElement->base_height; - sint32 rideIndex = mapElement->properties.track.ride_index; - - mapElement = map_get_first_element_at(x >> 5, y >> 5); - do { - if (mapElement->type != MAP_ELEMENT_TYPE_TRACK) continue; - if (mapElement->properties.track.ride_index != rideIndex) continue; - if (mapElement->base_height != z) continue; - if (mapElement->properties.track.type != TRACK_ELEM_INVERTED_90_DEG_UP_TO_FLAT_QUARTER_LOOP) continue; - - // Each maze element is split into 4 sections with 4 different walls - uint8 mazeSection = direction * 4; - // Add the top outer wall - mapElement->properties.track.maze_entry |= (1 << ((mazeSection + 9) & 0x0F)); - // Add the bottom outer wall - mapElement->properties.track.maze_entry |= (1 << ((mazeSection + 12) & 0x0F)); - - map_invalidate_tile(x, y, mapElement->base_height * 8, mapElement->clearance_height * 8); - return; - } while (!map_element_is_last_for_tile(mapElement++)); -} - -static money32 place_ride_entrance_or_exit(sint16 x, sint16 y, sint16 z, uint8 direction, uint8 flags, uint8 rideIndex, uint8 station_num, uint8 is_exit) -{ - // Remember when in Unknown station num mode rideIndex is unknown and z is set - // When in known station num mode rideIndex is known and z is unknown - - money32 cost = 0; - gCommandPosition.x = x; - gCommandPosition.y = y; - - if (!map_check_free_elements_and_reorganise(1)) { - return MONEY32_UNDEFINED; - } - - if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && game_is_paused() && !gCheatsBuildInPauseMode){ - gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; - return MONEY32_UNDEFINED; - } - - if (station_num == 0xFF) { - z *= 16; - if (flags & GAME_COMMAND_FLAG_APPLY) - return MONEY32_UNDEFINED; - - if (!gCheatsSandboxMode && !map_is_location_owned(x, y, z)) { - return MONEY32_UNDEFINED; - } - - sint16 clear_z = z / 8 + (is_exit ? 5 : 7); - - if (!gCheatsDisableClearanceChecks && !map_can_construct_with_clear_at(x, y, z / 8, clear_z, &map_place_non_scenery_clear_func, 0xF, flags, &cost)) { - return MONEY32_UNDEFINED; - } - - if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) { - gGameCommandErrorText = STR_RIDE_CANT_BUILD_THIS_UNDERWATER; - return MONEY32_UNDEFINED; - } - - if (z > 1952) { - gGameCommandErrorText = STR_TOO_HIGH; - return MONEY32_UNDEFINED; - } - } else { - if (rideIndex >= MAX_RIDES) - { - log_warning("Invalid game command for ride %u", rideIndex); - return MONEY32_UNDEFINED; - } - rct_ride* ride = get_ride(rideIndex); - if (ride->type == RIDE_TYPE_NULL) - { - log_warning("Invalid game command for ride %u", rideIndex); - return MONEY32_UNDEFINED; - } - if (ride->status != RIDE_STATUS_CLOSED) { - gGameCommandErrorText = STR_MUST_BE_CLOSED_FIRST; - return MONEY32_UNDEFINED; - } - - if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) { - gGameCommandErrorText = STR_NOT_ALLOWED_TO_MODIFY_STATION; - return MONEY32_UNDEFINED; - } - - ride_clear_for_construction(rideIndex); - ride_remove_peeps(rideIndex); - - uint8 requires_remove = 0; - sint16 remove_x = 0; - sint16 remove_y = 0; - - if (is_exit) { - if (ride->exits[station_num] != 0xFFFF) { - if (flags & GAME_COMMAND_FLAG_GHOST) { - gGameCommandErrorText = 0; - return MONEY32_UNDEFINED; - } - - remove_x = (ride->exits[station_num] & 0xFF) * 32; - remove_y = ((ride->exits[station_num] >> 8) & 0xFF) * 32; - requires_remove = 1; - } - } else if (ride->entrances[station_num] != 0xFFFF) { - if (flags & GAME_COMMAND_FLAG_GHOST) { - gGameCommandErrorText = 0; - return MONEY32_UNDEFINED; - } - - remove_x = (ride->entrances[station_num] & 0xFF) * 32; - remove_y = ((ride->entrances[station_num] >> 8) & 0xFF) * 32; - requires_remove = 1; - } - - if (requires_remove) { - money32 success = game_do_command( - remove_x, - flags, - remove_y, - rideIndex, - GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, - station_num, - 0 - ); - - if (success == MONEY32_UNDEFINED) { - return MONEY32_UNDEFINED; - } - } - - z = ride->station_heights[station_num] * 8; - gCommandPosition.z = z; - - if ( - (flags & GAME_COMMAND_FLAG_APPLY) && - !(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && - !(flags & GAME_COMMAND_FLAG_GHOST) - ) { - footpath_remove_litter(x, y, z); - wall_remove_at_z(x, y, z); - } - - if (!gCheatsSandboxMode && !map_is_location_owned(x, y, z)) { - return MONEY32_UNDEFINED; - } - - sint8 clear_z = (z / 8) + (is_exit ? 5 : 7); - - if (!gCheatsDisableClearanceChecks && !map_can_construct_with_clear_at(x, y, z / 8, clear_z, &map_place_non_scenery_clear_func, 0xF, flags, &cost)) { - return MONEY32_UNDEFINED; - } - - if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) { - gGameCommandErrorText = STR_RIDE_CANT_BUILD_THIS_UNDERWATER; - return MONEY32_UNDEFINED; - } - - if (z / 8 > 244){ - gGameCommandErrorText = STR_TOO_HIGH; - return MONEY32_UNDEFINED; - } - - if (flags & GAME_COMMAND_FLAG_APPLY) { - rct_xyz16 coord; - coord.x = x + 16; - coord.y = y + 16; - coord.z = map_element_height(coord.x, coord.y); - network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); - - rct_map_element* mapElement = map_element_insert(x / 32, y / 32, z / 8, 0xF); - assert(mapElement != NULL); - mapElement->clearance_height = clear_z; - mapElement->properties.entrance.type = is_exit; - mapElement->properties.entrance.index = station_num << 4; - mapElement->properties.entrance.ride_index = rideIndex; - mapElement->type = MAP_ELEMENT_TYPE_ENTRANCE | direction; - - if (flags & GAME_COMMAND_FLAG_GHOST) { - mapElement->flags |= MAP_ELEMENT_FLAG_GHOST; - } - - if (is_exit) { - ride->exits[station_num] = (x / 32) | (y / 32 << 8); - } else { - ride->entrances[station_num] = (x / 32) | (y / 32 << 8); - ride->last_peep_in_queue[station_num] = SPRITE_INDEX_NULL; - ride->queue_length[station_num] = 0; - - map_animation_create(MAP_ANIMATION_TYPE_RIDE_ENTRANCE, x, y, z / 8); - } - - footpath_queue_chain_reset(); - if (!(flags & GAME_COMMAND_FLAG_GHOST)) { - maze_entrance_hedge_removal(x, y, mapElement); - } - footpath_connect_edges(x, y, mapElement, flags); - sub_6A759F(); - - map_invalidate_tile_full(x, y); - } - } - - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION; - return cost; -} - -/** - * - * rct2: 0x006660A8 - */ -void game_command_place_ride_entrance_or_exit(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp){ - *ebx = place_ride_entrance_or_exit( - *eax & 0xFFFF, - *ecx & 0xFFFF, - *edx & 0xFF, - (*ebx >> 8) & 0xFF, - *ebx & 0xFF, - *edx & 0xFF, - *edi & 0xFF, - (*edx >> 8) & 0xFF - ); -} - -static money32 remove_ride_entrance_or_exit(sint16 x, sint16 y, uint8 rideIndex, uint8 station_num, uint8 flags){ - if (rideIndex >= MAX_RIDES) - { - log_warning("Invalid game command for ride %u", rideIndex); - return MONEY32_UNDEFINED; - } - rct_ride* ride = get_ride(rideIndex); - if (ride->type == RIDE_TYPE_NULL) - { - log_warning("Invalide ride id %u for entrance/exit removal", rideIndex); - return MONEY32_UNDEFINED; - } - - if (!(flags & GAME_COMMAND_FLAG_GHOST)){ - if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && game_is_paused() && !gCheatsBuildInPauseMode){ - gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; - return MONEY32_UNDEFINED; - } - } - - if (ride->status != RIDE_STATUS_CLOSED){ - gGameCommandErrorText = STR_MUST_BE_CLOSED_FIRST; - return MONEY32_UNDEFINED; - } - - if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) { - gGameCommandErrorText = STR_NOT_ALLOWED_TO_MODIFY_STATION; - return MONEY32_UNDEFINED; - } - - if (flags & GAME_COMMAND_FLAG_APPLY){ - ride_clear_for_construction(rideIndex); - ride_remove_peeps(rideIndex); - invalidate_test_results(rideIndex); - - uint8 found = 0; - rct_map_element* mapElement = map_get_first_element_at(x / 32, y / 32); - if (mapElement == NULL) - { - log_warning("Invalid coordinates for entrance/exit removal x = %d, y = %d", x, y); - return MONEY32_UNDEFINED; - } - do{ - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_ENTRANCE) - continue; - - if (mapElement->base_height != ride->station_heights[station_num]) - continue; - - if (flags & (1 << 5) && !(mapElement->flags & MAP_ELEMENT_FLAG_GHOST)) - continue; - - found = 1; - break; - } while (!map_element_is_last_for_tile(mapElement++)); - - if (!found){ - return MONEY32_UNDEFINED; - } - - rct_xyz16 coord; - coord.x = x + 16; - coord.y = y + 16; - coord.z = map_element_height(coord.x, coord.y); - network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); - - footpath_queue_chain_reset(); - maze_entrance_hedge_replacement(x, y, mapElement); - footpath_remove_edges_at(x, y, mapElement); - - uint8 is_exit = mapElement->properties.entrance.type; - - map_element_remove(mapElement); - - if (is_exit){ - ride->exits[station_num] = 0xFFFF; - } - else{ - ride->entrances[station_num] = 0xFFFF; - } - - sub_6A759F(); - - map_invalidate_tile_full(x, y); - } - - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION; - return 0; -} - -/** - * - * rct2: 0x0066640B - */ -void game_command_remove_ride_entrance_or_exit(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp){ - *ebx = remove_ride_entrance_or_exit( - *eax & 0xFFFF, - *ecx & 0xFFFF, - *edx & 0xFF, - *edi & 0xFF, - *ebx & 0xFF - ); -} void ride_set_to_default_inspection_interval(sint32 rideIndex) { diff --git a/src/openrct2/ride/ride.h b/src/openrct2/ride/ride.h index 5a62f13800..34ce051c0d 100644 --- a/src/openrct2/ride/ride.h +++ b/src/openrct2/ride/ride.h @@ -978,8 +978,7 @@ extern uint8 _currentBrakeSpeed2; extern uint8 _currentSeatRotationAngle; extern rct_xyz16 _unkF44188; -extern rct_xyzd16 _unkF440BF; -extern uint8 _unkF440C4; + extern rct_xyzd16 _unkF440C5; extern uint8 gRideEntranceExitPlaceType; @@ -1016,6 +1015,7 @@ sint32 ride_find_track_gap(rct_xy_element *input, rct_xy_element *output); void ride_construct_new(ride_list_item listItem); void ride_construct(sint32 rideIndex); sint32 ride_modify(rct_xy_element *input); +void ride_remove_peeps(sint32 rideIndex); void ride_get_status(sint32 rideIndex, rct_string_id *formatSecondary, sint32 *argument); rct_peep *ride_get_assigned_mechanic(rct_ride *ride); sint32 ride_get_total_length(rct_ride *ride); @@ -1059,8 +1059,8 @@ void game_command_set_ride_price(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 * money32 ride_create_command(sint32 type, sint32 subType, sint32 flags, uint8 *outRideIndex, uint8 *outRideColour); void ride_clear_for_construction(sint32 rideIndex); -void ride_restore_provisional_entrance_or_exit(); -void ride_remove_provisional_entrance_or_exit(); +void ride_entrance_exit_place_provisional_ghost(); +void ride_entrance_exit_remove_ghost(); void ride_restore_provisional_track_piece(); void ride_remove_provisional_track_piece(); void set_vehicle_type_image_max_sizes(rct_ride_entry_vehicle* vehicle_type, sint32 num_images); @@ -1102,7 +1102,7 @@ bool track_block_get_previous_from_zero(sint16 x, sint16 y, sint16 z, uint8 ride void sub_6C84CE(); void sub_6C96C0(); -money32 ride_get_entrance_or_exit_price(sint32 rideIndex, sint32 x, sint32 y, sint32 direction, sint32 dh, sint32 di); +money32 ride_entrance_exit_place_ghost(sint32 rideIndex, sint32 x, sint32 y, sint32 direction, sint32 placeType, sint32 stationNum); void ride_get_entrance_or_exit_position_from_screen_position(sint32 x, sint32 y, sint32 *outX, sint32 *outY, sint32 *outDirection); bool ride_select_backwards_from_front(); diff --git a/src/openrct2/windows/map.c b/src/openrct2/windows/map.c index dfe28f3e09..607f991443 100644 --- a/src/openrct2/windows/map.c +++ b/src/openrct2/windows/map.c @@ -25,6 +25,7 @@ #include "../localisation/localisation.h" #include "../rct2.h" #include "../sprites.h" +#include "../world/entrance.h" #include "../world/footpath.h" #include "../world/scenery.h" #include "error.h" @@ -526,7 +527,7 @@ static void window_map_toolabort(rct_window *w, sint32 widgetIndex) hide_construction_rights(); break; case WIDX_BUILD_PARK_ENTRANCE: - park_remove_ghost_entrance(); + park_entrance_remove_ghost(); window_invalidate(w); hide_gridlines(); hide_land_rights(); @@ -1243,7 +1244,7 @@ static void window_map_place_park_entrance_tool_update(sint32 x, sint32 y) gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; sub_666EEF(x, y, &mapX, &mapY, &mapZ, &direction); if (mapX == (sint16)-1) { - park_remove_ghost_entrance(); + park_entrance_remove_ghost(); return; } @@ -1268,8 +1269,8 @@ static void window_map_place_park_entrance_tool_update(sint32 x, sint32 y) return; } - park_remove_ghost_entrance(); - gParkEntranceGhostPrice = park_place_ghost_entrance(mapX, mapY, mapZ, direction); + park_entrance_remove_ghost(); + gParkEntranceGhostPrice = park_entrance_place_ghost(mapX, mapY, mapZ, direction); } /** @@ -1316,7 +1317,7 @@ static void window_map_set_peep_spawn_tool_update(sint32 x, sint32 y) */ static void window_map_place_park_entrance_tool_down(sint32 x, sint32 y) { - park_remove_ghost_entrance(); + park_entrance_remove_ghost(); sint16 mapX, mapY, mapZ; sint32 direction; diff --git a/src/openrct2/windows/park.c b/src/openrct2/windows/park.c index 49ba87104a..52d0da3a58 100644 --- a/src/openrct2/windows/park.c +++ b/src/openrct2/windows/park.c @@ -30,6 +30,7 @@ #include "../scenario/scenario.h" #include "../sprites.h" #include "../util/util.h" +#include "../world/entrance.h" #include "../world/park.h" #include "../world/sprite.h" #include "../management/finance.h" diff --git a/src/openrct2/windows/ride_construction.c b/src/openrct2/windows/ride_construction.c index 81bbb6609d..e8563a0151 100644 --- a/src/openrct2/windows/ride_construction.c +++ b/src/openrct2/windows/ride_construction.c @@ -33,6 +33,7 @@ #include "dropdown.h" #include "../sprites.h" #include "../world/map.h" +#include "../world/entrance.h" /* move to ride.c */ static void sub_6B2FA9(rct_windownumber number) @@ -3737,7 +3738,7 @@ void ride_construction_toolupdate_construct(sint32 screenX, sint32 screenY) void ride_construction_toolupdate_entrance_exit(sint32 screenX, sint32 screenY) { sint32 x, y, direction; - uint8 unk; + uint8 stationNum; map_invalidate_selection_rect(); map_invalidate_map_selection_tiles(); @@ -3763,16 +3764,16 @@ void ride_construction_toolupdate_entrance_exit(sint32 screenX, sint32 screenY) map_invalidate_selection_rect(); direction = gRideEntranceExitPlaceDirection ^ 2; - unk = gRideEntranceExitPlaceStationIndex; + stationNum = gRideEntranceExitPlaceStationIndex; if ( !(_currentTrackSelectionFlags & TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT) || - x != _unkF440BF.x || - y != _unkF440BF.y || - direction != _unkF440BF.direction || - unk != _unkF440C4 + x != gRideEntranceExitGhostPosition.x || + y != gRideEntranceExitGhostPosition.y || + direction != gRideEntranceExitGhostPosition.direction || + stationNum != gRideEntranceExitGhostStationIndex ) { - _currentTrackPrice = ride_get_entrance_or_exit_price( - _currentRideIndex, x, y, direction, gRideEntranceExitPlaceType, unk + _currentTrackPrice = ride_entrance_exit_place_ghost( + _currentRideIndex, x, y, direction, gRideEntranceExitPlaceType, stationNum ); sub_6C84CE(); } diff --git a/src/openrct2/windows/tile_inspector.c b/src/openrct2/windows/tile_inspector.c index fcbf1c34d0..a8abde0367 100644 --- a/src/openrct2/windows/tile_inspector.c +++ b/src/openrct2/windows/tile_inspector.c @@ -1793,7 +1793,7 @@ static void window_tile_inspector_paint(rct_window *w, rct_drawpixelinfo *dpi) sint32 middleX = windowTileInspectorTileX << 5; sint32 middleY = windowTileInspectorTileY << 5; // TODO: Make this work with Left/Right park entrance parts - sint16 parkEntranceIndex = park_get_entrance_index(middleX, middleY, mapElement->base_height * 8); + sint16 parkEntranceIndex = park_entrance_get_index(middleX, middleY, mapElement->base_height * 8); gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_ENTRANCE_ENTRANCE_ID, &parkEntranceIndex, COLOUR_DARK_GREEN, x, y + 11); } else { diff --git a/src/openrct2/world/entrance.cpp b/src/openrct2/world/entrance.cpp new file mode 100644 index 0000000000..fbfdd079b7 --- /dev/null +++ b/src/openrct2/world/entrance.cpp @@ -0,0 +1,868 @@ +#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers +/***************************************************************************** + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * OpenRCT2 is the work of many authors, a full list can be found in contributors.md + * For more information, visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * A full copy of the GNU General Public License can be found in licence.txt + *****************************************************************************/ +#pragma endregion + +#include "../rct2.h" +#include "../network/network.h" + +extern "C" +{ + #include "entrance.h" + #include "footpath.h" + #include "map.h" + #include "park.h" + #include "../cheats.h" + #include "../game.h" + #include "../localisation/string_ids.h" + #include "../management/finance.h" + #include "../ride/track.h" +} + +bool gParkEntranceGhostExists; +rct_xyz16 gParkEntranceGhostPosition; +uint8 gParkEntranceGhostDirection; +money32 gParkEntranceGhostPrice; +rct_xyzd16 gParkEntrances[MAX_PARK_ENTRANCES]; + +rct_xyzd16 gRideEntranceExitGhostPosition; +uint8 gRideEntranceExitGhostStationIndex; + +static money32 ParkEntrancePlace(sint32 flags, sint16 x, sint16 y, uint8 z, uint8 direction) +{ + if (!(gScreenFlags & SCREEN_FLAGS_EDITOR) && !gCheatsSandboxMode) + { + return MONEY32_UNDEFINED; + } + + gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LAND_PURCHASE; + + gCommandPosition.x = x; + gCommandPosition.y = y; + gCommandPosition.z = z * 16; + + if (!map_check_free_elements_and_reorganise(3)) + { + return MONEY32_UNDEFINED; + } + + if (x <= 32 || y <= 32 || x >= (gMapSizeUnits - 32) || y >= (gMapSizeUnits - 32)) + { + gGameCommandErrorText = STR_TOO_CLOSE_TO_EDGE_OF_MAP; + return MONEY32_UNDEFINED; + } + + sint8 entranceNum = -1; + for (uint8 i = 0; i < MAX_PARK_ENTRANCES; ++i) + { + if (gParkEntrances[i].x == MAP_LOCATION_NULL) + { + entranceNum = i; + break; + } + } + + if (entranceNum == -1) + { + gGameCommandErrorText = STR_ERR_TOO_MANY_PARK_ENTRANCES; + return MONEY32_UNDEFINED; + } + + if (flags & GAME_COMMAND_FLAG_APPLY) + { + gParkEntrances[entranceNum].x = x; + gParkEntrances[entranceNum].y = y; + gParkEntrances[entranceNum].z = z * 16; + gParkEntrances[entranceNum].direction = direction; + } + + sint8 zLow = z * 2; + sint8 zHigh = zLow + 12; + + for (uint8 index = 0; index < 3; index++) + { + if (index == 1) + { + x += TileDirectionDelta[(direction - 1) & 0x3].x; + y += TileDirectionDelta[(direction - 1) & 0x3].y; + } + else if (index == 2) + { + x += TileDirectionDelta[(direction + 1) & 0x3].x * 2; + y += TileDirectionDelta[(direction + 1) & 0x3].y * 2; + } + + if (!gCheatsDisableClearanceChecks) + { + if (!map_can_construct_at(x, y, zLow, zHigh, 0xF)) + { + return MONEY32_UNDEFINED; + } + } + + // Check that entrance element does not already exist at this location + rct_map_element* entranceElement = map_get_park_entrance_element_at(x, y, zLow, false); + if (entranceElement != NULL) + { + return MONEY32_UNDEFINED; + } + + if (!(flags & GAME_COMMAND_FLAG_APPLY)) + { + continue; + } + + if (!(flags & GAME_COMMAND_FLAG_GHOST)) + { + rct_map_element* surfaceElement = map_get_surface_element_at(x / 32, y / 32); + surfaceElement->properties.surface.ownership = 0; + } + + rct_map_element* newElement = map_element_insert(x / 32, y / 32, zLow, 0xF); + assert(newElement != NULL); + newElement->clearance_height = zHigh; + + if (flags & GAME_COMMAND_FLAG_GHOST) + { + newElement->flags |= MAP_ELEMENT_FLAG_GHOST; + } + + newElement->type = MAP_ELEMENT_TYPE_ENTRANCE; + newElement->type |= direction; + newElement->properties.entrance.index = index; + newElement->properties.entrance.type = ENTRANCE_TYPE_PARK_ENTRANCE; + newElement->properties.entrance.path_type = gFootpathSelectedId; + + if (!(flags & GAME_COMMAND_FLAG_GHOST)) + { + footpath_connect_edges(x, y, newElement, 1); + } + + update_park_fences(x, y); + update_park_fences(x - 32, y); + update_park_fences(x + 32, y); + update_park_fences(x, y - 32); + update_park_fences(x, y + 32); + + map_invalidate_tile(x, y, newElement->base_height * 8, newElement->clearance_height * 8); + + if (index == 0) + { + map_animation_create(MAP_ANIMATION_TYPE_PARK_ENTRANCE, x, y, zLow); + } + } + return 0; +} + +static void ParkEntranceRemoveSegment(sint32 x, sint32 y, sint32 z) +{ + rct_map_element *mapElement; + + mapElement = map_get_park_entrance_element_at(x, y, z, true); + if (mapElement == NULL) + { + return; + } + + map_invalidate_tile(x, y, mapElement->base_height * 8, mapElement->clearance_height * 8); + map_element_remove(mapElement); + update_park_fences(x, y); +} + +static money32 ParkEntranceRemove(sint16 x, sint16 y, uint8 z, uint8 flags) +{ + sint32 entranceIndex, direction; + + if (!(gScreenFlags & SCREEN_FLAGS_EDITOR) && !gCheatsSandboxMode) + { + return MONEY32_UNDEFINED; + } + + gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LAND_PURCHASE; + gCommandPosition.x = x; + gCommandPosition.y = y; + gCommandPosition.z = z * 16; + + if (!(flags & GAME_COMMAND_FLAG_APPLY)) + { + return 0; + } + + entranceIndex = park_entrance_get_index(x, y, z * 16); + if (entranceIndex == -1) + { + return 0; + } + + gParkEntrances[entranceIndex].x = MAP_LOCATION_NULL; + direction = (gParkEntrances[entranceIndex].direction - 1) & 3; + + // Centre (sign) + ParkEntranceRemoveSegment(x, y, z * 2); + + // Left post + ParkEntranceRemoveSegment( + x + TileDirectionDelta[direction].x, + y + TileDirectionDelta[direction].y, + z * 2 + ); + + // Right post + ParkEntranceRemoveSegment( + x - TileDirectionDelta[direction].x, + y - TileDirectionDelta[direction].y, + z * 2 + ); + + return 0; +} + +static money32 RideEntranceExitPlace(sint16 x, + sint16 y, + sint16 z, + uint8 direction, + uint8 flags, + uint8 rideIndex, + uint8 stationNum, + bool isExit) +{ + // Remember when in Unknown station num mode rideIndex is unknown and z is set + // When in known station num mode rideIndex is known and z is unknown + + money32 cost = 0; + gCommandPosition.x = x; + gCommandPosition.y = y; + + if (!map_check_free_elements_and_reorganise(1)) + { + return MONEY32_UNDEFINED; + } + + if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && game_is_paused() && !gCheatsBuildInPauseMode) + { + gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; + return MONEY32_UNDEFINED; + } + + if (stationNum == 0xFF) + { + z *= 16; + if (flags & GAME_COMMAND_FLAG_APPLY) + { + return MONEY32_UNDEFINED; + } + + if (!gCheatsSandboxMode && !map_is_location_owned(x, y, z)) + { + return MONEY32_UNDEFINED; + } + + sint16 clear_z = z / 8 + (isExit ? 5 : 7); + + if (!gCheatsDisableClearanceChecks && + !map_can_construct_with_clear_at(x, y, z / 8, clear_z, &map_place_non_scenery_clear_func, 0xF, flags, &cost)) + { + return MONEY32_UNDEFINED; + } + + if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) + { + gGameCommandErrorText = STR_RIDE_CANT_BUILD_THIS_UNDERWATER; + return MONEY32_UNDEFINED; + } + + if (z / 8 > 244) + { + gGameCommandErrorText = STR_TOO_HIGH; + return MONEY32_UNDEFINED; + } + } + else + { + if (rideIndex >= MAX_RIDES) + { + log_warning("Invalid game command for ride %u", rideIndex); + return MONEY32_UNDEFINED; + } + + rct_ride* ride = get_ride(rideIndex); + if (ride->type == RIDE_TYPE_NULL) + { + log_warning("Invalid game command for ride %u", rideIndex); + return MONEY32_UNDEFINED; + } + + if (ride->status != RIDE_STATUS_CLOSED) + { + gGameCommandErrorText = STR_MUST_BE_CLOSED_FIRST; + return MONEY32_UNDEFINED; + } + + if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) + { + gGameCommandErrorText = STR_NOT_ALLOWED_TO_MODIFY_STATION; + return MONEY32_UNDEFINED; + } + + ride_clear_for_construction(rideIndex); + ride_remove_peeps(rideIndex); + + bool requiresRemove = false; + rct_xy16 removeCoord = { 0, 0 }; + + if (isExit) + { + if (ride->exits[stationNum] != 0xFFFF) + { + if (flags & GAME_COMMAND_FLAG_GHOST) + { + gGameCommandErrorText = 0; + return MONEY32_UNDEFINED; + } + + removeCoord.x = (ride->exits[stationNum] & 0xFF) * 32; + removeCoord.y = ((ride->exits[stationNum] >> 8) & 0xFF) * 32; + requiresRemove = true; + } + } + else if (ride->entrances[stationNum] != 0xFFFF) + { + if (flags & GAME_COMMAND_FLAG_GHOST) + { + gGameCommandErrorText = 0; + return MONEY32_UNDEFINED; + } + + removeCoord.x = (ride->entrances[stationNum] & 0xFF) * 32; + removeCoord.y = ((ride->entrances[stationNum] >> 8) & 0xFF) * 32; + requiresRemove = true; + } + + if (requiresRemove) + { + money32 success = game_do_command( + removeCoord.x, + flags, + removeCoord.y, + rideIndex, + GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, + stationNum, + 0 + ); + + if (success == MONEY32_UNDEFINED) + { + return MONEY32_UNDEFINED; + } + } + + z = ride->station_heights[stationNum] * 8; + gCommandPosition.z = z; + + if ((flags & GAME_COMMAND_FLAG_APPLY) && + !(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && + !(flags & GAME_COMMAND_FLAG_GHOST)) + { + footpath_remove_litter(x, y, z); + wall_remove_at_z(x, y, z); + } + + if (!gCheatsSandboxMode && !map_is_location_owned(x, y, z)) + { + return MONEY32_UNDEFINED; + } + + sint8 clear_z = (z / 8) + (isExit ? 5 : 7); + + if (!gCheatsDisableClearanceChecks && + !map_can_construct_with_clear_at(x, y, z / 8, clear_z, &map_place_non_scenery_clear_func, 0xF, flags, &cost)) + { + return MONEY32_UNDEFINED; + } + + if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) + { + gGameCommandErrorText = STR_RIDE_CANT_BUILD_THIS_UNDERWATER; + return MONEY32_UNDEFINED; + } + + if (z / 8 > 244) + { + gGameCommandErrorText = STR_TOO_HIGH; + return MONEY32_UNDEFINED; + } + + if (flags & GAME_COMMAND_FLAG_APPLY) + { + rct_xyz16 coord; + coord.x = x + 16; + coord.y = y + 16; + coord.z = map_element_height(coord.x, coord.y); + network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); + + rct_map_element* mapElement = map_element_insert(x / 32, y / 32, z / 8, 0xF); + assert(mapElement != NULL); + mapElement->clearance_height = clear_z; + mapElement->properties.entrance.type = isExit; + mapElement->properties.entrance.index = stationNum << 4; + mapElement->properties.entrance.ride_index = rideIndex; + mapElement->type = MAP_ELEMENT_TYPE_ENTRANCE | direction; + + if (flags & GAME_COMMAND_FLAG_GHOST) + { + mapElement->flags |= MAP_ELEMENT_FLAG_GHOST; + } + + if (isExit) + { + ride->exits[stationNum] = (x / 32) | (y / 32 << 8); + } + else + { + ride->entrances[stationNum] = (x / 32) | (y / 32 << 8); + ride->last_peep_in_queue[stationNum] = SPRITE_INDEX_NULL; + ride->queue_length[stationNum] = 0; + + map_animation_create(MAP_ANIMATION_TYPE_RIDE_ENTRANCE, x, y, z / 8); + } + + footpath_queue_chain_reset(); + + if (!(flags & GAME_COMMAND_FLAG_GHOST)) + { + maze_entrance_hedge_removal(x, y, mapElement); + } + + footpath_connect_edges(x, y, mapElement, flags); + sub_6A759F(); + + map_invalidate_tile_full(x, y); + } + } + + gCommandExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION; + return cost; +} + +static money32 RideEntranceExitRemove(sint16 x, sint16 y, uint8 rideIndex, uint8 stationNum, uint8 flags) +{ + if (rideIndex >= MAX_RIDES) + { + log_warning("Invalid game command for ride %u", rideIndex); + return MONEY32_UNDEFINED; + } + + rct_ride* ride = get_ride(rideIndex); + if (ride->type == RIDE_TYPE_NULL) + { + log_warning("Invalide ride id %u for entrance/exit removal", rideIndex); + return MONEY32_UNDEFINED; + } + + if (!(flags & GAME_COMMAND_FLAG_GHOST)) + { + if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && + game_is_paused() && + !gCheatsBuildInPauseMode) + { + gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; + return MONEY32_UNDEFINED; + } + } + + if (ride->status != RIDE_STATUS_CLOSED) + { + gGameCommandErrorText = STR_MUST_BE_CLOSED_FIRST; + return MONEY32_UNDEFINED; + } + + if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) + { + gGameCommandErrorText = STR_NOT_ALLOWED_TO_MODIFY_STATION; + return MONEY32_UNDEFINED; + } + + if (flags & GAME_COMMAND_FLAG_APPLY) + { + ride_clear_for_construction(rideIndex); + ride_remove_peeps(rideIndex); + invalidate_test_results(rideIndex); + + bool found = false; + rct_map_element* mapElement = map_get_first_element_at(x / 32, y / 32); + if (mapElement == NULL) + { + log_warning("Invalid coordinates for entrance/exit removal x = %d, y = %d", x, y); + return MONEY32_UNDEFINED; + } + + do + { + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_ENTRANCE) + continue; + + if (mapElement->base_height != ride->station_heights[stationNum]) + continue; + + if (flags & GAME_COMMAND_FLAG_5 && !(mapElement->flags & MAP_ELEMENT_FLAG_GHOST)) + continue; + + found = true; + break; + } + while (!map_element_is_last_for_tile(mapElement++)); + + if (!found) + { + return MONEY32_UNDEFINED; + } + + rct_xyz16 coord; + coord.x = x + 16; + coord.y = y + 16; + coord.z = map_element_height(coord.x, coord.y); + network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); + + footpath_queue_chain_reset(); + maze_entrance_hedge_replacement(x, y, mapElement); + footpath_remove_edges_at(x, y, mapElement); + + bool isExit = mapElement->properties.entrance.type == ENTRANCE_TYPE_RIDE_EXIT; + + map_element_remove(mapElement); + + if (isExit) + { + ride->exits[stationNum] = 0xFFFF; + } + else + { + ride->entrances[stationNum] = 0xFFFF; + } + + sub_6A759F(); + + map_invalidate_tile_full(x, y); + } + + gCommandExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION; + return 0; +} + +static money32 RideEntranceExitPlaceGhost(uint8 rideIndex, sint16 x, sint16 y, uint8 direction, uint8 placeType, uint8 stationNum) +{ + return game_do_command( + x, + (GAME_COMMAND_FLAG_APPLY | + GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | + GAME_COMMAND_FLAG_5 | + GAME_COMMAND_FLAG_GHOST) | + (direction << 8), + y, + rideIndex | (placeType << 8), + GAME_COMMAND_PLACE_RIDE_ENTRANCE_OR_EXIT, + stationNum, + 0 + ); +} + +extern "C" +{ + /** + * + * rct2: 0x006666E7 + */ + void game_command_place_park_entrance(sint32* eax, + sint32* ebx, + sint32* ecx, + sint32* edx, + sint32* esi, + sint32* edi, + sint32* ebp) + { + *ebx = ParkEntrancePlace( + *ebx & 0xFF, + *eax & 0xFFFF, + *ecx & 0xFFFF, + *edx & 0xFF, + (*ebx >> 8) & 0xFF); + } + + /** + * + * rct2: 0x00666A63 + */ + void game_command_remove_park_entrance(sint32 *eax, + sint32 *ebx, + sint32 *ecx, + sint32 *edx, + sint32 *esi, + sint32 *edi, + sint32 *ebp) + { + *ebx = ParkEntranceRemove( + *eax & 0xFFFF, + *ecx & 0xFFFF, + *edx & 0xFF, + *ebx & 0xFF); + } + + /** + * + * rct2: 0x00666F9E + */ + void park_entrance_remove_ghost() + { + if (gParkEntranceGhostExists) + { + gParkEntranceGhostExists = false; + game_do_command( + gParkEntranceGhostPosition.x, + GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_APPLY, + gParkEntranceGhostPosition.y, + gParkEntranceGhostPosition.z, + GAME_COMMAND_REMOVE_PARK_ENTRANCE, + 0, + 0 + ); + } + } + + /** + * + * rct2: 0x00666F4E + */ + money32 park_entrance_place_ghost(sint32 x, sint32 y, sint32 z, sint32 direction) + { + money32 result; + + park_entrance_remove_ghost(); + result = game_do_command( + x, + GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | + GAME_COMMAND_FLAG_5 | + GAME_COMMAND_FLAG_GHOST | + GAME_COMMAND_FLAG_APPLY | + (direction << 8), + y, + z, + GAME_COMMAND_PLACE_PARK_ENTRANCE, + 0, + 0 + ); + + if (result != MONEY32_UNDEFINED) + { + gParkEntranceGhostPosition.x = x; + gParkEntranceGhostPosition.y = y; + gParkEntranceGhostPosition.z = z; + gParkEntranceGhostDirection = direction; + gParkEntranceGhostExists = true; + } + return result; + } + + + sint32 park_entrance_get_index(sint32 x, sint32 y, sint32 z) + { + sint32 i; + + for (i = 0; i < MAX_PARK_ENTRANCES; i++) + { + if (x == gParkEntrances[i].x && + y == gParkEntrances[i].y && + z == gParkEntrances[i].z) + { + return i; + } + } + + return -1; + } + + void reset_park_entrance() + { + for (sint32 i = 0; i < MAX_PARK_ENTRANCES; i++) + { + gParkEntrances[i].x = MAP_LOCATION_NULL; + } + } + + + void ride_entrance_exit_place_provisional_ghost() + { + if (_currentTrackSelectionFlags & TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT) { + RideEntranceExitPlaceGhost(_currentRideIndex, + gRideEntranceExitGhostPosition.x, + gRideEntranceExitGhostPosition.y, + gRideEntranceExitGhostPosition.direction, + gRideEntranceExitPlaceType, + gRideEntranceExitGhostStationIndex); + } + } + + void ride_entrance_exit_remove_ghost() + { + if (_currentTrackSelectionFlags & TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT) { + game_do_command( + gRideEntranceExitGhostPosition.x, + (GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_APPLY), + gRideEntranceExitGhostPosition.y, + _currentRideIndex, + GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, + gRideEntranceExitGhostStationIndex, + 0 + ); + } + } + + + /** + * + * rct2: 0x006CA28C + */ + money32 ride_entrance_exit_place_ghost(sint32 rideIndex, + sint32 x, + sint32 y, + sint32 direction, + sint32 placeType, + sint32 stationNum) + { + sub_6C96C0(); + money32 result = RideEntranceExitPlaceGhost(rideIndex, x, y, direction, placeType, stationNum); + + if (result != MONEY32_UNDEFINED) + { + _currentTrackSelectionFlags |= TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT; + gRideEntranceExitGhostPosition.x = x; + gRideEntranceExitGhostPosition.y = y; + gRideEntranceExitGhostPosition.direction = direction; + gRideEntranceExitGhostStationIndex = stationNum & 0xFF; + } + return result; + } + + /** + * + * rct2: 0x006660A8 + */ + void game_command_place_ride_entrance_or_exit(sint32 *eax, + sint32 *ebx, + sint32 *ecx, + sint32 *edx, + sint32 *esi, + sint32 *edi, + sint32 *ebp) + { + *ebx = RideEntranceExitPlace( + *eax & 0xFFFF, + *ecx & 0xFFFF, + *edx & 0xFF, + (*ebx >> 8) & 0xFF, + *ebx & 0xFF, + *edx & 0xFF, + *edi & 0xFF, + ((*edx >> 8) & 0xFF) != 0 + ); + } + + /** + * + * rct2: 0x0066640B + */ + void game_command_remove_ride_entrance_or_exit(sint32 *eax, + sint32 *ebx, + sint32 *ecx, + sint32 *edx, + sint32 *esi, + sint32 *edi, + sint32 *ebp) + { + *ebx = RideEntranceExitRemove( + *eax & 0xFFFF, + *ecx & 0xFFFF, + *edx & 0xFF, + *edi & 0xFF, + *ebx & 0xFF + ); + } + + /** + * Replaces the outer hedge walls for an entrance placement removal. + * rct2: 0x00666D6F + */ + void maze_entrance_hedge_replacement(sint32 x, sint32 y, rct_map_element *mapElement) + { + sint32 direction = mapElement->type & MAP_ELEMENT_DIRECTION_MASK; + x += TileDirectionDelta[direction].x; + y += TileDirectionDelta[direction].y; + sint32 z = mapElement->base_height; + sint32 rideIndex = mapElement->properties.track.ride_index; + + mapElement = map_get_first_element_at(x >> 5, y >> 5); + do { + if (mapElement->type != MAP_ELEMENT_TYPE_TRACK) continue; + if (mapElement->properties.track.ride_index != rideIndex) continue; + if (mapElement->base_height != z) continue; + if (mapElement->properties.track.type != TRACK_ELEM_MAZE) continue; + + // Each maze element is split into 4 sections with 4 different walls + uint8 mazeSection = direction * 4; + // Add the top outer wall + mapElement->properties.track.maze_entry |= (1 << ((mazeSection + 9) & 0x0F)); + // Add the bottom outer wall + mapElement->properties.track.maze_entry |= (1 << ((mazeSection + 12) & 0x0F)); + + map_invalidate_tile(x, y, mapElement->base_height * 8, mapElement->clearance_height * 8); + return; + } while (!map_element_is_last_for_tile(mapElement++)); + } + + /** + * Removes the hedge walls for an entrance placement. + * rct2: 0x00666CBE + */ + void maze_entrance_hedge_removal(sint32 x, sint32 y, rct_map_element *mapElement) + { + sint32 direction = mapElement->type & MAP_ELEMENT_DIRECTION_MASK; + x += TileDirectionDelta[direction].x; + y += TileDirectionDelta[direction].y; + sint32 z = mapElement->base_height; + sint32 rideIndex = mapElement->properties.track.ride_index; + + mapElement = map_get_first_element_at(x >> 5, y >> 5); + do { + if (mapElement->type != MAP_ELEMENT_TYPE_TRACK) continue; + if (mapElement->properties.track.ride_index != rideIndex) continue; + if (mapElement->base_height != z) continue; + if (mapElement->properties.track.type != TRACK_ELEM_MAZE) continue; + + // Each maze element is split into 4 sections with 4 different walls + uint8 mazeSection = direction * 4; + // Remove the top outer wall + mapElement->properties.track.maze_entry &= ~(1 << ((mazeSection + 9) & 0x0F)); + // Remove the bottom outer wall + mapElement->properties.track.maze_entry &= ~(1 << ((mazeSection + 12) & 0x0F)); + // Remove the intersecting wall + mapElement->properties.track.maze_entry &= ~(1 << ((mazeSection + 10) & 0x0F)); + // Remove the top hedge section + mapElement->properties.track.maze_entry &= ~(1 << ((mazeSection + 11) & 0x0F)); + // Remove the bottom hedge section + mapElement->properties.track.maze_entry &= ~(1 << ((mazeSection + 15) & 0x0F)); + + map_invalidate_tile(x, y, mapElement->base_height * 8, mapElement->clearance_height * 8); + return; + } while (!map_element_is_last_for_tile(mapElement++)); + } +} \ No newline at end of file diff --git a/src/openrct2/world/entrance.h b/src/openrct2/world/entrance.h index 781fa6d1a0..5b6029ff06 100644 --- a/src/openrct2/world/entrance.h +++ b/src/openrct2/world/entrance.h @@ -29,4 +29,28 @@ typedef struct rct_entrance_type { assert_struct_size(rct_entrance_type, 8); #pragma pack(pop) +void game_command_remove_park_entrance(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp); + +typedef struct rct_xyz16 rct_xyz16; +typedef struct rct_xyzd16 rct_xyzd16; +typedef struct rct_map_element rct_map_element; + +extern bool gParkEntranceGhostExists; +extern rct_xyz16 gParkEntranceGhostPosition; +extern uint8 gParkEntranceGhostDirection; +extern money32 gParkEntranceGhostPrice; + +#define MAX_PARK_ENTRANCES 4 + +extern rct_xyzd16 gParkEntrances[MAX_PARK_ENTRANCES]; + +extern rct_xyzd16 gRideEntranceExitGhostPosition; +extern uint8 gRideEntranceExitGhostStationIndex; + +void park_entrance_remove_ghost(); +money32 park_entrance_place_ghost(sint32 x, sint32 y, sint32 z, sint32 direction); +void reset_park_entrance(); +void maze_entrance_hedge_replacement(sint32 x, sint32 y, rct_map_element *mapElement); +void maze_entrance_hedge_removal(sint32 x, sint32 y, rct_map_element *mapElement); + #endif diff --git a/src/openrct2/world/map.c b/src/openrct2/world/map.c index 8606bd6840..f9f4c7c006 100644 --- a/src/openrct2/world/map.c +++ b/src/openrct2/world/map.c @@ -3971,10 +3971,10 @@ void map_remove_provisional_elements() footpath_provisional_remove(); gFootpathProvisionalFlags |= PROVISIONAL_PATH_FLAG_1; } - if (window_find_by_class(WC_CONSTRUCT_RIDE) != NULL) + if (window_find_by_class(WC_RIDE_CONSTRUCTION ) != NULL) { ride_remove_provisional_track_piece(); - ride_remove_provisional_entrance_or_exit(); + ride_entrance_exit_remove_ghost(); } } @@ -3989,10 +3989,10 @@ void map_restore_provisional_elements() gFootpathProvisionalPosition.z, gFootpathProvisionalSlope); } - if (window_find_by_class(WC_CONSTRUCT_RIDE) != NULL) + if (window_find_by_class(WC_RIDE_CONSTRUCTION) != NULL) { ride_restore_provisional_track_piece(); - ride_restore_provisional_entrance_or_exit(); + ride_entrance_exit_place_provisional_ghost(); } } @@ -4580,125 +4580,6 @@ void map_clear_all_elements() } } -static money32 place_park_entrance(sint32 flags, sint16 x, sint16 y, sint16 z, uint8 direction) { - if (!(gScreenFlags & SCREEN_FLAGS_EDITOR) && !gCheatsSandboxMode) { - return MONEY32_UNDEFINED; - } - - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LAND_PURCHASE; - - gCommandPosition.x = x; - gCommandPosition.y = y; - // ?? - gCommandPosition.z = (z & 0xFF) << 4; - - if (!map_check_free_elements_and_reorganise(3)) { - return MONEY32_UNDEFINED; - } - - if (x <= 32 || y <= 32 || x >= (gMapSizeUnits - 32) || y >= (gMapSizeUnits - 32)) { - gGameCommandErrorText = STR_TOO_CLOSE_TO_EDGE_OF_MAP; - return MONEY32_UNDEFINED; - } - - sint8 entranceNum = -1; - for (uint8 i = 0; i < MAX_PARK_ENTRANCES; ++i) { - if (gParkEntrances[i].x == MAP_LOCATION_NULL) { - entranceNum = i; - break; - } - } - - if (entranceNum == -1) { - gGameCommandErrorText = STR_ERR_TOO_MANY_PARK_ENTRANCES; - return MONEY32_UNDEFINED; - } - - if (flags & GAME_COMMAND_FLAG_APPLY) { - gParkEntrances[entranceNum].x = x; - gParkEntrances[entranceNum].y = y; - gParkEntrances[entranceNum].z = (z & 0xFF) << 4; - gParkEntrances[entranceNum].direction = direction; - } - - sint8 zLow = (z & 0xFF) * 2; - sint8 zHigh = zLow + 12; - - for (uint8 index = 0; index < 3; index++) { - if (index == 1) { - x += TileDirectionDelta[(direction - 1) & 0x3].x; - y += TileDirectionDelta[(direction - 1) & 0x3].y; - } - else if (index == 2) { - x += TileDirectionDelta[(direction + 1) & 0x3].x * 2; - y += TileDirectionDelta[(direction + 1) & 0x3].y * 2; - } - - if (!gCheatsDisableClearanceChecks) { - if (!map_can_construct_at(x, y, zLow, zHigh, 0xF)) { - return MONEY32_UNDEFINED; - } - } - - // Check that entrance element does not already exist at this location - rct_map_element* entranceElement = map_get_park_entrance_element_at(x, y, zLow, false); - if (entranceElement != NULL) - return MONEY32_UNDEFINED; - - if (!(flags & GAME_COMMAND_FLAG_APPLY)) - continue; - - if (!(flags & GAME_COMMAND_FLAG_GHOST)) { - rct_map_element* surfaceElement = map_get_surface_element_at(x / 32, y / 32); - surfaceElement->properties.surface.ownership = 0; - } - - rct_map_element* newElement = map_element_insert(x / 32, y / 32, zLow, 0xF); - assert(newElement != NULL); - newElement->clearance_height = zHigh; - - if (flags & GAME_COMMAND_FLAG_GHOST) { - newElement->flags |= MAP_ELEMENT_FLAG_GHOST; - } - - newElement->type = MAP_ELEMENT_TYPE_ENTRANCE; - newElement->type |= direction; - newElement->properties.entrance.index = index; - newElement->properties.entrance.type = ENTRANCE_TYPE_PARK_ENTRANCE; - newElement->properties.entrance.path_type = gFootpathSelectedId & 0xFF; - - if (!(flags & GAME_COMMAND_FLAG_GHOST)) { - footpath_connect_edges(x, y, newElement, 1); - } - - update_park_fences(x, y); - update_park_fences(x - 32, y); - update_park_fences(x + 32, y); - update_park_fences(x, y - 32); - update_park_fences(x, y + 32); - - map_invalidate_tile(x, y, newElement->base_height * 8, newElement->clearance_height * 8); - - if (index == 0) { - map_animation_create(MAP_ANIMATION_TYPE_PARK_ENTRANCE, x, y, zLow); - } - } - return 0; -} - -/** - * - * rct2: 0x006666E7 - */ -void game_command_place_park_entrance(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) { - *ebx = place_park_entrance( - *ebx & 0xFF, - *eax & 0xFFFF, - *ecx & 0xFFFF, - *edx & 0xFFFF, - (*ebx >> 8) & 0xFF); -} - void game_command_set_banner_name(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp) { static char newName[128]; diff --git a/src/openrct2/world/park.c b/src/openrct2/world/park.c index ef90c2dc25..323cba9b16 100644 --- a/src/openrct2/world/park.c +++ b/src/openrct2/world/park.c @@ -32,6 +32,7 @@ #include "../ride/ride_data.h" #include "../scenario/scenario.h" #include "../world/map.h" +#include "entrance.h" #include "park.h" #include "sprite.h" @@ -70,13 +71,6 @@ sint32 _suggestedGuestMaximum; */ sint32 _guestGenerationProbability; -rct_xyzd16 gParkEntrances[MAX_PARK_ENTRANCES]; - -bool gParkEntranceGhostExists; -rct_xyz16 gParkEntranceGhostPosition; -uint8 gParkEntranceGhostDirection; -money32 gParkEntranceGhostPrice; - sint32 park_is_open() { return (gParkFlags & PARK_FLAGS_PARK_OPEN) != 0; @@ -354,12 +348,10 @@ money32 calculate_company_value() * * rct2: 0x00667104 */ -void reset_park_entrances() +void reset_park_entry() { gParkName = 0; - for (sint32 i = 0; i < MAX_PARK_ENTRANCES; i++) { - gParkEntrances[i].x = MAP_LOCATION_NULL; - } + reset_park_entrance(); for (sint32 i = 0; i < MAX_PEEP_SPAWNS; i++) { gPeepSpawns[i].x = PEEP_SPAWN_UNDEFINED; } @@ -713,23 +705,6 @@ void game_command_set_park_open(sint32* eax, sint32* ebx, sint32* ecx, sint32* e *ebx = 0; } -sint32 park_get_entrance_index(sint32 x, sint32 y, sint32 z) -{ - sint32 i; - - for (i = 0; i < MAX_PARK_ENTRANCES; i++) { - if ( - x == gParkEntrances[i].x && - y == gParkEntrances[i].y && - z == gParkEntrances[i].z - ) { - return i; - } - } - - return -1; -} - /** * * rct2: 0x00664D05 @@ -801,76 +776,6 @@ void update_park_fences(sint32 x, sint32 y) } } -static void park_remove_entrance_segment(sint32 x, sint32 y, sint32 z) -{ - rct_map_element *mapElement; - - mapElement = map_get_park_entrance_element_at(x, y, z, true); - if (mapElement == NULL) - return; - - map_invalidate_tile(x, y, mapElement->base_height * 8, mapElement->clearance_height * 8); - map_element_remove(mapElement); - update_park_fences(x, y); -} - -/** - * - * rct2: 0x00666A63 - */ -void game_command_remove_park_entrance(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp) -{ - sint32 x, y, z, entranceIndex, direction; - - x = *eax & 0xFFFF; - y = *ecx & 0xFFFF; - z = *edx * 16; - - if (!(gScreenFlags & SCREEN_FLAGS_EDITOR) && !gCheatsSandboxMode) { - *ebx = MONEY32_UNDEFINED; - return; - } - - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LAND_PURCHASE; - gCommandPosition.x = x; - gCommandPosition.y = y; - gCommandPosition.z = z; - - if (!(*ebx & GAME_COMMAND_FLAG_APPLY)) { - *ebx = 0; - return; - } - - entranceIndex = park_get_entrance_index(x, y, z); - if (entranceIndex == -1) { - *ebx = 0; - return; - } - - gParkEntrances[entranceIndex].x = MAP_LOCATION_NULL; - direction = (gParkEntrances[entranceIndex].direction - 1) & 3; - z = (*edx & 0xFF) * 2; - - // Centre (sign) - park_remove_entrance_segment(x, y, z); - - // Left post - park_remove_entrance_segment( - x + TileDirectionDelta[direction].x, - y + TileDirectionDelta[direction].y, - z - ); - - // Right post - park_remove_entrance_segment( - x - TileDirectionDelta[direction].x, - y - TileDirectionDelta[direction].y, - z - ); - - *ebx = 0; -} - void park_set_name(const char *name) { gGameCommandErrorTitle = STR_CANT_RENAME_PARK; @@ -1138,54 +1043,6 @@ sint32 get_forced_park_rating(){ return gForcedParkRating; } -/** - * - * rct2: 0x00666F9E - */ -void park_remove_ghost_entrance() -{ - if (gParkEntranceGhostExists) { - gParkEntranceGhostExists = false; - game_do_command( - gParkEntranceGhostPosition.x, - 40 | GAME_COMMAND_FLAG_APPLY, - gParkEntranceGhostPosition.y, - gParkEntranceGhostPosition.z, - GAME_COMMAND_REMOVE_PARK_ENTRANCE, - 0, - 0 - ); - } -} - -/** - * - * rct2: 0x00666F4E - */ -money32 park_place_ghost_entrance(sint32 x, sint32 y, sint32 z, sint32 direction) -{ - money32 result; - - park_remove_ghost_entrance(); - result = game_do_command( - x, - 104 | GAME_COMMAND_FLAG_APPLY | (direction << 8), - y, - z, - GAME_COMMAND_PLACE_PARK_ENTRANCE, - 0, - 0 - ); - if (result != MONEY32_UNDEFINED) { - gParkEntranceGhostPosition.x = x; - gParkEntranceGhostPosition.y = y; - gParkEntranceGhostPosition.z = z; - gParkEntranceGhostDirection = direction; - gParkEntranceGhostExists = true; - } - return result; -} - money16 park_get_entrance_fee() { if (gParkFlags & PARK_FLAGS_NO_MONEY) return 0; diff --git a/src/openrct2/world/park.h b/src/openrct2/world/park.h index eaae2125bd..b56efd49f1 100644 --- a/src/openrct2/world/park.h +++ b/src/openrct2/world/park.h @@ -23,7 +23,6 @@ #define DECRYPT_MONEY(money) ((money32)rol32((money) ^ 0xF4EC9621, 13)) #define ENCRYPT_MONEY(money) ((money32)(ror32((money), 13) ^ 0xF4EC9621)) -#define MAX_PARK_ENTRANCES 4 enum { PARK_FLAGS_PARK_OPEN = (1 << 0), @@ -67,13 +66,6 @@ extern uint8 gGuestsInParkHistory[32]; extern sint32 _guestGenerationProbability; extern sint32 _suggestedGuestMaximum; -extern rct_xyzd16 gParkEntrances[MAX_PARK_ENTRANCES]; - -extern bool gParkEntranceGhostExists; -extern rct_xyz16 gParkEntranceGhostPosition; -extern uint8 gParkEntranceGhostDirection; -extern money32 gParkEntranceGhostPrice; - void set_forced_park_rating(sint32 rating); sint32 get_forced_park_rating(); @@ -85,7 +77,7 @@ sint32 park_calculate_size(); sint32 calculate_park_rating(); money32 calculate_park_value(); money32 calculate_company_value(); -void reset_park_entrances(); +void reset_park_entry(); rct_peep * park_generate_new_guest(); void park_update(); @@ -95,7 +87,7 @@ void update_park_fences(sint32 x, sint32 y); uint8 calculate_guest_initial_happiness(uint8 percentage); void park_set_open(sint32 open); -sint32 park_get_entrance_index(sint32 x, sint32 y, sint32 z); +sint32 park_entrance_get_index(sint32 x, sint32 y, sint32 z); void park_set_name(const char *name); void park_set_entrance_fee(money32 value); @@ -103,13 +95,9 @@ sint32 map_buy_land_rights(sint32 x0, sint32 y0, sint32 x1, sint32 y1, sint32 se void game_command_set_park_entrance_fee(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp); void game_command_set_park_open(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp); -void game_command_remove_park_entrance(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp); void game_command_set_park_name(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp); void game_command_buy_land_rights(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp); -void park_remove_ghost_entrance(); -money32 park_place_ghost_entrance(sint32 x, sint32 y, sint32 z, sint32 direction); - money16 park_get_entrance_fee(); #endif