1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 05:23:04 +01:00

Replace game command references with new game action.

This commit is contained in:
Matt
2019-02-07 22:02:49 +01:00
parent a5e48e759d
commit d87ca57e72
5 changed files with 9 additions and 144 deletions

View File

@@ -25,6 +25,7 @@
#include <openrct2/actions/GameAction.h>
#include <openrct2/actions/RideSetAppearanceAction.hpp>
#include <openrct2/actions/RideSetColourScheme.hpp>
#include <openrct2/actions/RideSetPriceAction.hpp>
#include <openrct2/audio/audio.h>
#include <openrct2/config/Config.h>
#include <openrct2/localisation/Date.h>
@@ -47,7 +48,6 @@
#include <openrct2/sprites.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/world/Park.h>
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);
}
/**

View File

@@ -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,

View File

@@ -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,

View File

@@ -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;

View File

@@ -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);