From d87ca57e72d3399609b571ef4767dc34de6ab6db Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 7 Feb 2019 22:02:49 +0100 Subject: [PATCH] Replace game command references with new game action. --- src/openrct2-ui/windows/Ride.cpp | 15 ++-- src/openrct2/Game.cpp | 2 +- src/openrct2/Game.h | 2 +- src/openrct2/ride/Ride.cpp | 132 ------------------------------- src/openrct2/ride/Ride.h | 2 - 5 files changed, 9 insertions(+), 144 deletions(-) diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 1b23193faa..977d774d9c 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -47,7 +48,6 @@ #include #include #include - using namespace OpenRCT2; enum @@ -6179,7 +6179,6 @@ static void window_ride_income_toggle_primary_price(rct_window* w) Ride* ride; rct_ride_entry* rideEntry; uint32_t shop_item; - money16 price; ride = get_ride(w->number); rideEntry = get_ride_entry(ride->subtype); @@ -6197,8 +6196,8 @@ static void window_ride_income_toggle_primary_price(rct_window* w) update_same_price_throughout_flags(shop_item); - price = ride->price; - game_do_command(0, 1, 0, w->number, GAME_COMMAND_SET_RIDE_PRICE, price, 0); + auto rideSetPriceAction = RideSetPriceAction(w->number, ride->price, true); + GameActions::Execute(&rideSetPriceAction); } /** @@ -6210,7 +6209,6 @@ static void window_ride_income_toggle_secondary_price(rct_window* w) Ride* ride; rct_ride_entry* rideEntry; uint32_t shop_item; - money16 price; ride = get_ride(w->number); rideEntry = get_ride_entry(ride->subtype); @@ -6221,13 +6219,14 @@ static void window_ride_income_toggle_secondary_price(rct_window* w) update_same_price_throughout_flags(shop_item); - price = ride->price_secondary; - game_do_command(0, 1, 0, (1 << 8) | w->number, GAME_COMMAND_SET_RIDE_PRICE, price, 0); + auto rideSetPriceAction = RideSetPriceAction(w->number, ride->price_secondary, false); + GameActions::Execute(&rideSetPriceAction); } static void window_ride_income_set_primary_price(rct_window* w, money16 price) { - game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, w->number, GAME_COMMAND_SET_RIDE_PRICE, price, 0); + auto rideSetPriceAction = RideSetPriceAction(w->number, price, true); + GameActions::Execute(&rideSetPriceAction); } /** diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 68f848b192..a65150bd1d 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -1475,7 +1475,7 @@ GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT] = { game_command_place_footpath_from_track, nullptr, game_command_change_surface_style, - game_command_set_ride_price, + nullptr, game_command_set_guest_name, game_command_set_staff_name, game_command_raise_land, diff --git a/src/openrct2/Game.h b/src/openrct2/Game.h index 9fa682e467..fff8defaa9 100644 --- a/src/openrct2/Game.h +++ b/src/openrct2/Game.h @@ -39,7 +39,7 @@ enum GAME_COMMAND GAME_COMMAND_PLACE_PATH_FROM_TRACK, GAME_COMMAND_REMOVE_PATH, GAME_COMMAND_CHANGE_SURFACE_STYLE, - GAME_COMMAND_SET_RIDE_PRICE, + GAME_COMMAND_SET_RIDE_PRICE, // GA GAME_COMMAND_SET_GUEST_NAME, // GA GAME_COMMAND_SET_STAFF_NAME, // GA GAME_COMMAND_RAISE_LAND, diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 5dcfc4e84c..98cafd109a 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -6389,138 +6389,6 @@ void game_command_callback_ride_remove_track_piece( window_ride_construction_mouseup_demolish_next_piece(x, y, z, direction, type); } -/** - * - * rct2: 0x006B53E9 - */ -void game_command_set_ride_price( - [[maybe_unused]] int32_t* eax, int32_t* ebx, [[maybe_unused]] int32_t* ecx, int32_t* edx, [[maybe_unused]] int32_t* esi, - int32_t* edi, [[maybe_unused]] int32_t* ebp) -{ - uint32_t flags = *ebx; - uint8_t ride_number = (*edx & 0xFF); - if (ride_number >= MAX_RIDES) - { - log_warning("Invalid game command for ride %u", ride_number); - *ebx = MONEY32_UNDEFINED; - return; - } - Ride* ride = get_ride(ride_number); - if (ride->type == RIDE_TYPE_NULL) - { - log_warning("Invalid game command for ride %u", ride_number); - *ebx = MONEY32_UNDEFINED; - return; - } - rct_ride_entry* rideEntry = get_ride_entry(ride->subtype); - money16 price = *edi; - bool secondary_price = (*edx >> 8); - - if (rideEntry == nullptr) - { - log_warning("Invalid game command for ride %u", ride_number); - *ebx = MONEY32_UNDEFINED; - return; - } - - // eax - // ebx flags - // ecx ecx - // edx ride_number - // ebp rideEntry - - *ebx = 0; // for cost check - changing ride price does not cost anything - - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_PARK_RIDE_TICKETS; - if (flags & GAME_COMMAND_FLAG_APPLY) - { - uint32_t shop_item; - - if (ride->overall_view.xy != RCT_XY8_UNDEFINED) - { - LocationXYZ16 coord; - coord.x = ride->overall_view.x * 32 + 16; - coord.y = ride->overall_view.y * 32 + 16; - coord.z = tile_element_height(coord.x, coord.y); - network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); - } - - if (!secondary_price) - { - shop_item = SHOP_ITEM_ADMISSION; - if (ride->type != RIDE_TYPE_TOILETS) - { - shop_item = rideEntry->shop_item; - if (shop_item == SHOP_ITEM_NONE) - { - ride->price = price; - window_invalidate_by_class(WC_RIDE); - return; - } - } - // Check same price in park flags - if (!shop_item_has_common_price(shop_item)) - { - ride->price = price; - window_invalidate_by_class(WC_RIDE); - return; - } - } - else - { - shop_item = rideEntry->shop_item_secondary; - if (shop_item == SHOP_ITEM_NONE) - { - shop_item = RidePhotoItems[ride->type]; - if ((ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) == 0) - { - ride->price_secondary = price; - window_invalidate_by_class(WC_RIDE); - return; - } - } - // Check same price in park flags - if (!shop_item_has_common_price(shop_item)) - { - ride->price_secondary = price; - window_invalidate_by_class(WC_RIDE); - return; - } - } - ride = get_ride(0); - - for (uint8_t rideId = 0; rideId < MAX_RIDES; rideId++, ride++) - { - // Unplaced rides have a type of NULL - if (ride->type == RIDE_TYPE_NULL) - continue; - - rideEntry = get_ride_entry(ride->subtype); - - if (ride->type != RIDE_TYPE_TOILETS || shop_item != SHOP_ITEM_ADMISSION) - { - if (rideEntry->shop_item == shop_item) - { - ride->price = price; - window_invalidate_by_number(WC_RIDE, rideId); - } - } - else - { - ride->price = price; - window_invalidate_by_number(WC_RIDE, rideId); - } - // If the shop item is the same or an on-ride photo - if (rideEntry->shop_item_secondary == shop_item - || (rideEntry->shop_item_secondary == SHOP_ITEM_NONE && shop_item_is_photo(shop_item))) - { - ride->price_secondary = price; - window_invalidate_by_number(WC_RIDE, rideId); - } - } - } -} - bool ride_type_has_flag(int32_t rideType, int32_t flag) { return (RideProperties[rideType].flags & flag) != 0; diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 5a967a1aba..0a70829873 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -1077,8 +1077,6 @@ void game_command_callback_ride_remove_track_piece( int32_t eax, int32_t ebx, int32_t ecx, int32_t edx, int32_t esi, int32_t edi, int32_t ebp); void game_command_demolish_ride( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); -void game_command_set_ride_price( - int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); money32 ride_create_command(int32_t type, int32_t subType, int32_t flags, ride_id_t* outRideIndex, uint8_t* outRideColour); void ride_set_name_to_default(Ride* ride, rct_ride_entry* rideEntry);