1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-24 07:14:31 +01:00

make both game commands use same call and rename / use more commands in enum

This commit is contained in:
IntelOrca
2014-08-07 22:25:51 +01:00
parent 4a89b3dd5c
commit 96aaa87543
9 changed files with 27 additions and 104 deletions

View File

@@ -173,7 +173,7 @@ static void set_all_land_owned()
{
int mapSize = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, sint16);
game_do_command(64, 1, 64, 2, 56, (mapSize - 2) * 32, (mapSize - 2) * 32);
game_do_command(64, 1, 64, 2, GAME_COMMAND_56, (mapSize - 2) * 32, (mapSize - 2) * 32);
}
/**

View File

@@ -2087,84 +2087,7 @@ static uint32 game_do_command_table[58];
*/
int game_do_command(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp)
{
int cost, flags, insufficientFunds;
int original_ebx, original_edx, original_esi, original_edi, original_ebp;
original_ebx = ebx;
original_edx = edx;
original_esi = esi;
original_edi = edi;
original_ebp = ebp;
flags = ebx;
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 0xFFFF;
// Increment nest count
RCT2_GLOBAL(0x009A8C28, uint8)++;
ebx &= ~1;
// Primary command
RCT2_CALLFUNC_X(game_do_command_table[esi], &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
cost = ebx;
if (cost != 0x80000000) {
// Check funds
insufficientFunds = 0;
if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(flags & 4) && !(flags & 0x20) && cost != 0)
insufficientFunds = game_check_affordability(cost);
if (insufficientFunds != 0x80000000) {
ebx = original_ebx;
edx = original_edx;
esi = original_esi;
edi = original_edi;
ebp = original_ebp;
if (!(flags & 1)) {
// Decrement nest count
RCT2_GLOBAL(0x009A8C28, uint8)--;
return cost;
}
// Secondary command
RCT2_CALLFUNC_X(game_do_command_table[esi], &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
edx = ebx;
if (edx != 0x80000000 && edx < cost)
cost = edx;
// Decrement nest count
RCT2_GLOBAL(0x009A8C28, uint8)--;
if (RCT2_GLOBAL(0x009A8C28, uint8) != 0)
return cost;
//
if (!(flags & 0x20)) {
// Update money balance
finance_payment(cost, RCT2_GLOBAL(0x0141F56C, uint8));
RCT2_CALLPROC_X(0x0069C674, 0, cost, 0, 0, 0, 0, 0);
if (RCT2_GLOBAL(0x0141F568, uint8) == RCT2_GLOBAL(0x013CA740, uint8)) {
// Create a +/- money text effect
if (cost != 0)
RCT2_CALLPROC_X(0x0069C5D0, 0, cost, 0, 0, 0, 0, 0);
}
}
return cost;
}
}
// Error occured
// Decrement nest count
RCT2_GLOBAL(0x009A8C28, uint8)--;
// Show error window
if (RCT2_GLOBAL(0x009A8C28, uint8) == 0 && (flags & 1) && RCT2_GLOBAL(0x0141F568, uint8) == RCT2_GLOBAL(0x013CA740, uint8) && !(flags & 8))
window_error_open(RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16), RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16));
return 0x80000000;
game_do_command_p(esi, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
}
/**
@@ -2625,7 +2548,7 @@ char save_game()
RCT2_CALLPROC_X(0x006754F5, eax, 0, 0, 0, 0, 0, 0);
// check success?
game_do_command(0, 1047, 0, -1, 0, 0, 0);
game_do_command(0, 1047, 0, -1, GAME_COMMAND_0, 0, 0);
gfx_invalidate_screen();
return 1;

View File

@@ -30,7 +30,7 @@ enum GAME_COMMAND {
GAME_COMMAND_LOAD_OR_QUIT, // 5
GAME_COMMAND_6,
GAME_COMMAND_7,
GAME_COMMAND_8,
GAME_COMMAND_SET_RIDE_OPEN, // 8
GAME_COMMAND_9,
GAME_COMMAND_10,
GAME_COMMAND_11,
@@ -39,9 +39,9 @@ enum GAME_COMMAND {
GAME_COMMAND_14,
GAME_COMMAND_15,
GAME_COMMAND_16,
GAME_COMMAND_17,
GAME_COMMAND_PLACE_PATH, // 17
GAME_COMMAND_18,
GAME_COMMAND_19,
GAME_COMMAND_REMOVE_PATH, // 19
GAME_COMMAND_20,
GAME_COMMAND_21,
GAME_COMMAND_22,
@@ -51,18 +51,18 @@ enum GAME_COMMAND {
GAME_COMMAND_26,
GAME_COMMAND_27,
GAME_COMMAND_28,
GAME_COMMAND_HIRE_NEW_STAFF_MEMBER,
GAME_COMMAND_HIRE_NEW_STAFF_MEMBER, // 29
GAME_COMMAND_30,
GAME_COMMAND_31,
GAME_COMMAND_32,
GAME_COMMAND_33,
GAME_COMMAND_34,
GAME_COMMAND_SET_PARK_OPEN, // 34
GAME_COMMAND_35,
GAME_COMMAND_36,
GAME_COMMAND_37,
GAME_COMMAND_38,
GAME_COMMAND_39,
GAME_COMMAND_UPDATE_STAFF_COLOUR,
GAME_COMMAND_SET_PARK_ENTRANCE_FEE, // 39
GAME_COMMAND_SET_STAFF_COLOUR, // 40
GAME_COMMAND_41,
GAME_COMMAND_42,
GAME_COMMAND_43,
@@ -78,7 +78,7 @@ enum GAME_COMMAND {
GAME_COMMAND_53,
GAME_COMMAND_54,
GAME_COMMAND_55,
GAME_COMMAND_56,
GAME_COMMAND_56, // Set land owned (possibly does other things)
GAME_COMMAND_57
};

View File

@@ -249,13 +249,13 @@ void scenario_load_and_play(const rct_scenario_basic *scenario)
// Set park name
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = STR_CANT_RENAME_PARK;
game_do_command(1, 1, 0, *((int*)(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER + 0)), 33,
game_do_command(1, 1, 0, *((int*)(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER + 0)), GAME_COMMAND_33,
*((int*)(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER + 8)),
*((int*)(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER + 4)));
game_do_command(2, 1, 0, *((int*)(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER + 12)), 33,
game_do_command(2, 1, 0, *((int*)(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER + 12)), GAME_COMMAND_33,
*((int*)(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER + 20)),
*((int*)(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER + 16)));
game_do_command(0, 1, 0, *((int*)(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER + 24)), 33,
game_do_command(0, 1, 0, *((int*)(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER + 24)), GAME_COMMAND_33,
*((int*)(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER + 32)),
*((int*)(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER + 28)));

View File

@@ -387,7 +387,7 @@ static void window_cheats_misc_mouseup()
window_invalidate_by_id(0x40 | WC_BOTTOM_TOOLBAR, 0);
break;
case WIDX_OPEN_CLOSE_PARK:
game_do_command(0, 1, 0, park_is_open() ? 0 : 0x101, 34, 0, 0);
game_do_command(0, 1, 0, park_is_open() ? 0 : 0x101, GAME_COMMAND_SET_PARK_OPEN, 0, 0);
window_invalidate_by_id(0x40 | WC_BOTTOM_TOOLBAR, 0);
break;
case WIDX_DECREASE_GAME_SPEED:

View File

@@ -807,7 +807,7 @@ static int window_footpath_set_provisional_path(int type, int x, int y, int z, i
RCT2_CALLPROC_EBPSAFE(0x006A77FF);
// Try and show provisional path
cost = game_do_command(x, (slope << 8) | 121, y, (type << 8) | z, 17, 0, 0);
cost = game_do_command(x, (slope << 8) | 121, y, (type << 8) | z, GAME_COMMAND_PLACE_PATH, 0, 0);
if (cost != MONEY32_UNDEFINED) {
RCT2_GLOBAL(RCT2_ADDRESS_PROVISIONAL_PATH_X, uint16) = x;
@@ -863,7 +863,7 @@ static void window_footpath_place_path_at_point(int x, int y)
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, uint16) = STR_CANT_BUILD_FOOTPATH_HERE;
// Try and place path
cost = game_do_command(x, (presentType << 8) | 1, y, (selectedType << 8) | z, 17, 0, 0);
cost = game_do_command(x, (presentType << 8) | 1, y, (selectedType << 8) | z, GAME_COMMAND_PLACE_PATH, 0, 0);
if (cost == MONEY32_UNDEFINED) {
RCT2_GLOBAL(RCT2_ADDRESS_PATH_ERROR_OCCURED, uint8) = 1;
@@ -952,7 +952,7 @@ loc_6A78EF:
// Remove path
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, uint16) = STR_CANT_REMOVE_FOOTPATH_FROM_HERE;
game_do_command(RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_FROM_X, uint16), 1, RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_FROM_Y, uint16), mapElement->base_height, 19, 0, 0);
game_do_command(RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_FROM_X, uint16), 1, RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_FROM_Y, uint16), mapElement->base_height, GAME_COMMAND_REMOVE_PATH, 0, 0);
// Move selection
edge ^= 2;

View File

@@ -788,7 +788,7 @@ static void window_park_entrance_dropdown()
dropdownIndex &= 0x00FF;
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = 1723;
}
game_do_command(0, 1, 0, dropdownIndex, 34, 0, 0);
game_do_command(0, 1, 0, dropdownIndex, GAME_COMMAND_SET_PARK_OPEN, 0, 0);
}
}
@@ -997,9 +997,9 @@ static void window_park_entrance_textinput()
if (widgetIndex == WIDX_RENAME) {
if (result) {
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = STR_CANT_RENAME_PARK;
game_do_command(1, 1, 0, *((int*)(text + 0)), 33, *((int*)(text + 8)), *((int*)(text + 4)));
game_do_command(2, 1, 0, *((int*)(text + 12)), 33, *((int*)(text + 20)), *((int*)(text + 16)));
game_do_command(0, 1, 0, *((int*)(text + 24)), 33, *((int*)(text + 32)), *((int*)(text + 28)));
game_do_command(1, 1, 0, *((int*)(text + 0)), GAME_COMMAND_33, *((int*)(text + 8)), *((int*)(text + 4)));
game_do_command(2, 1, 0, *((int*)(text + 12)), GAME_COMMAND_33, *((int*)(text + 20)), *((int*)(text + 16)));
game_do_command(0, 1, 0, *((int*)(text + 24)), GAME_COMMAND_33, *((int*)(text + 32)), *((int*)(text + 28)));
}
}
}
@@ -1616,11 +1616,11 @@ static void window_park_price_mousedown(int widgetIndex, rct_window*w, rct_widge
break;
case WIDX_INCREASE_PRICE:
newFee = min(1000, RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, uint16) + 10);
game_do_command(0, 1, 0, 0, 39, newFee, 0);
game_do_command(0, 1, 0, 0, GAME_COMMAND_SET_PARK_ENTRANCE_FEE, newFee, 0);
break;
case WIDX_DECREASE_PRICE:
newFee = max(0, RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, uint16) - 10);
game_do_command(0, 1, 0, 0, 39, newFee, 0);
game_do_command(0, 1, 0, 0, GAME_COMMAND_SET_PARK_ENTRANCE_FEE, newFee, 0);
break;
}
}

View File

@@ -807,7 +807,7 @@ static void window_ride_list_close_all(rct_window *w)
RCT2_GLOBAL(0x013CE952 + 6, uint16) = w->scrolls[0].v_top;
RCT2_GLOBAL(0x013CE952 + 8, uint32) = w->scrolls[0].v_bottom;
game_do_command(0, 1, 0, i, 8, 0, 0);
game_do_command(0, 1, 0, i, GAME_COMMAND_SET_RIDE_OPEN, 0, 0);
}
}
@@ -824,6 +824,6 @@ static void window_ride_list_open_all(rct_window *w)
RCT2_GLOBAL(0x013CE952 + 6, uint16) = w->scrolls[0].v_top;
RCT2_GLOBAL(0x013CE952 + 8, uint32) = w->scrolls[0].v_bottom;
game_do_command(0, 1, 0, (1 << 8) | i, 8, 0, 0);
game_do_command(0, 1, 0, (1 << 8) | i, GAME_COMMAND_SET_RIDE_OPEN, 0, 0);
}
}

View File

@@ -349,7 +349,7 @@ static void window_staff_dropdown()
(RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) << 8) + 1,
0,
(dropdownIndex << 8) + 4,
GAME_COMMAND_UPDATE_STAFF_COLOUR,
GAME_COMMAND_SET_STAFF_COLOUR,
0,
0);
}