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

Code review

This commit is contained in:
zsilencer
2016-10-18 13:33:43 -06:00
parent 986c2ab97e
commit 3617c2cb93
8 changed files with 40 additions and 18 deletions

View File

@@ -1099,7 +1099,7 @@ void game_load_or_quit_no_save_prompt()
}
}
GAME_COMMAND_POINTER* new_game_command_table[70] = {
GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT] = {
game_command_set_ride_appearance,
game_command_set_land_height,
game_pause_toggle,

View File

@@ -93,6 +93,7 @@ enum GAME_COMMAND {
GAME_COMMAND_PICKUP_GUEST,
GAME_COMMAND_PICKUP_STAFF,
GAME_COMMAND_BALLOON_PRESS,
GAME_COMMAND_COUNT
};
enum {
@@ -132,7 +133,7 @@ extern rct_string_id gGameCommandErrorText;
extern uint8 gErrorType;
extern rct_string_id gErrorStringId;
extern GAME_COMMAND_POINTER* new_game_command_table[70];
extern GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT];
#ifndef NO_RCT2
#define gCurrentTicks RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32)

View File

@@ -1880,20 +1880,23 @@ void peep_pickup_abort(rct_peep* peep, int old_x)
gPickupPeepImage = UINT32_MAX;
}
bool peep_pickup_place(rct_peep* peep, int x, int y, bool apply)
bool peep_pickup_place(rct_peep* peep, int x, int y, int z, bool apply)
{
if (!peep)
return false;
int dest_x, dest_y;
rct_map_element *mapElement;
footpath_get_coordinates_from_pos(x, y + 16, &dest_x, &dest_y, NULL, &mapElement);
rct_map_element *mapElement = map_get_path_element_at(x / 32, y / 32, z);
if (dest_x == (sint16)SPRITE_LOCATION_NULL) {
gGameCommandErrorTitle = STR_ERR_CANT_PLACE_PERSON_HERE;
return false;
if (!mapElement) {
mapElement = map_get_surface_element_at(x / 32, y / 32);
}
if (!mapElement)
return false;
int dest_x = x & 0xFFE0;
int dest_y = y & 0xFFE0;
// Set the coordinate of destination to be exactly
// in the middle of a tile.
dest_x += 16;
@@ -1943,7 +1946,7 @@ bool peep_pickup_place(rct_peep* peep, int x, int y, bool apply)
return true;
}
bool peep_pickup_command(int peepnum, int x, int y, int action, bool apply)
bool peep_pickup_command(int peepnum, int x, int y, int z, int action, bool apply)
{
rct_peep* peep = GET_PEEP(peepnum);
switch (action) {
@@ -1974,7 +1977,7 @@ bool peep_pickup_command(int peepnum, int x, int y, int action, bool apply)
if (network_get_pickup_peep(game_command_playerid) != peep) {
return false;
}
if (!peep_pickup_place(peep, x, y, apply)) {
if (!peep_pickup_place(peep, x, y, z, apply)) {
return false;
}
break;
@@ -1987,7 +1990,9 @@ void game_command_pickup_guest(int* eax, int* ebx, int* ecx, int* edx, int* esi,
int peepnum = *eax;
int x = *edi;
int y = *ebp;
if (peep_pickup_command(peepnum, x, y, *ecx, *ebx & GAME_COMMAND_FLAG_APPLY)) {
int z = *edx;
int action = *ecx;
if (peep_pickup_command(peepnum, x, y, z, action, *ebx & GAME_COMMAND_FLAG_APPLY)) {
*ebx = 0;
}
else

View File

@@ -654,8 +654,8 @@ bool peep_has_item(rct_peep *peep, int peepItem);
int peep_has_food(rct_peep* peep);
void peep_pickup(rct_peep* peep);
void peep_pickup_abort(rct_peep* peep, int old_x);
bool peep_pickup_place(rct_peep* peep, int x, int y, bool apply);
bool peep_pickup_command(int peepnum, int x, int y, int action, bool apply);
bool peep_pickup_place(rct_peep* peep, int x, int y, int z, bool apply);
bool peep_pickup_command(int peepnum, int x, int y, int z, int action, bool apply);
void game_command_pickup_guest(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp);
void peep_sprite_remove(rct_peep* peep);
void peep_remove(rct_peep* peep);

View File

@@ -1371,7 +1371,9 @@ void game_command_pickup_staff(int* eax, int* ebx, int* ecx, int* edx, int* esi,
int peepnum = *eax;
int x = *edi;
int y = *ebp;
if (peep_pickup_command(peepnum, x, y, *ecx, *ebx & GAME_COMMAND_FLAG_APPLY)) {
int z = *edx;
int action = *ecx;
if (peep_pickup_command(peepnum, x, y, z, action, *ebx & GAME_COMMAND_FLAG_APPLY)) {
*ebx = 0;
}
else

View File

@@ -1213,8 +1213,15 @@ void window_guest_overview_tool_down(rct_window* w, int widgetIndex, int x, int
if (widgetIndex != WIDX_PICKUP)
return;
int dest_x, dest_y;
rct_map_element* mapElement;
footpath_get_coordinates_from_pos(x, y + 16, &dest_x, &dest_y, NULL, &mapElement);
if (x == (sint16)0x8000)
return;
game_command_callback = game_command_callback_pickup_guest;
game_do_command(w->number, GAME_COMMAND_FLAG_APPLY, 2, 0, GAME_COMMAND_PICKUP_GUEST, x, y);
game_do_command(w->number, GAME_COMMAND_FLAG_APPLY, 2, mapElement->base_height, GAME_COMMAND_PICKUP_GUEST, dest_x, dest_y);
}
/**

View File

@@ -1158,8 +1158,15 @@ void window_staff_overview_tool_update(rct_window* w, int widgetIndex, int x, in
void window_staff_overview_tool_down(rct_window* w, int widgetIndex, int x, int y)
{
if (widgetIndex == WIDX_PICKUP) {
int dest_x, dest_y;
rct_map_element* mapElement;
footpath_get_coordinates_from_pos(x, y + 16, &dest_x, &dest_y, NULL, &mapElement);
if (x == (sint16)0x8000)
return;
game_command_callback = game_command_callback_pickup_staff;
game_do_command(w->number, GAME_COMMAND_FLAG_APPLY, 2, 0, GAME_COMMAND_PICKUP_STAFF, x, y);
game_do_command(w->number, GAME_COMMAND_FLAG_APPLY, 2, mapElement->base_height, GAME_COMMAND_PICKUP_STAFF, dest_x, dest_y);
}
else if (widgetIndex == WIDX_PATROL){
int dest_x, dest_y;

View File

@@ -81,7 +81,7 @@ void balloon_update(rct_balloon *balloon)
*
* rct2: 0x006E88ED
*/
void balloon_press(rct_balloon *balloon)
static void balloon_press(rct_balloon *balloon)
{
if (balloon->popped == 1)
return;