diff --git a/src/openrct2/actions/GameAction.cpp b/src/openrct2/actions/GameAction.cpp index 722bb89017..cceb77b871 100644 --- a/src/openrct2/actions/GameAction.cpp +++ b/src/openrct2/actions/GameAction.cpp @@ -165,7 +165,7 @@ namespace GameActions callback(result); } - if (result.Error != GA_ERROR::OK) + if (result.Error != GA_ERROR::OK && !(flags & GAME_COMMAND_FLAG_GHOST)) { // Show the error box Memory::Copy(gCommonFormatArgs, result.ErrorMessageArgs, sizeof(result.ErrorMessageArgs)); diff --git a/src/openrct2/actions/PlaceParkEntranceAction.cpp b/src/openrct2/actions/PlaceParkEntranceAction.cpp index e0ec265bab..3aa7f6aa38 100644 --- a/src/openrct2/actions/PlaceParkEntranceAction.cpp +++ b/src/openrct2/actions/PlaceParkEntranceAction.cpp @@ -26,6 +26,13 @@ extern "C" #include "../world/footpath.h" } +struct PlaceParkEntranceGameActionResult : public GameActionResult { + PlaceParkEntranceGameActionResult(GA_ERROR error, rct_string_id message) :GameActionResult(error, message) + { + ErrorTitle = STR_CANT_BUILD_PARK_ENTRANCE_HERE; + } +}; + class PlaceParkEntranceAction : public IGameAction { public: @@ -64,7 +71,7 @@ public: { if (!(gScreenFlags & SCREEN_FLAGS_EDITOR) && !gCheatsSandboxMode) { - return GameActionResult(GA_ERROR::NOT_IN_EDITOR_MODE, STR_NONE); + return PlaceParkEntranceGameActionResult(GA_ERROR::NOT_IN_EDITOR_MODE, STR_NONE); } gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LAND_PURCHASE; @@ -75,12 +82,12 @@ public: if (!map_check_free_elements_and_reorganise(3)) { - return GameActionResult(GA_ERROR::NO_FREE_ELEMENTS, STR_NONE); + return PlaceParkEntranceGameActionResult(GA_ERROR::NO_FREE_ELEMENTS, STR_NONE); } if (x <= 32 || y <= 32 || x >= (gMapSizeUnits - 32) || y >= (gMapSizeUnits - 32)) { - return GameActionResult(GA_ERROR::INVALID_PARAMETERS, STR_TOO_CLOSE_TO_EDGE_OF_MAP); + return PlaceParkEntranceGameActionResult(GA_ERROR::INVALID_PARAMETERS, STR_TOO_CLOSE_TO_EDGE_OF_MAP); } sint8 entranceNum = -1; @@ -95,7 +102,7 @@ public: if (entranceNum == -1) { - return GameActionResult(GA_ERROR::INVALID_PARAMETERS, STR_ERR_TOO_MANY_PARK_ENTRANCES); + return PlaceParkEntranceGameActionResult(GA_ERROR::INVALID_PARAMETERS, STR_ERR_TOO_MANY_PARK_ENTRANCES); } sint8 zLow = z * 2; @@ -118,7 +125,7 @@ public: { if (!map_can_construct_at(entranceLoc.x, entranceLoc.y, zLow, zHigh, 0xF)) { - return GameActionResult(GA_ERROR::NO_CLEARANCE, STR_NONE); + return PlaceParkEntranceGameActionResult(GA_ERROR::NO_CLEARANCE, STR_NONE); } } @@ -126,7 +133,7 @@ public: rct_map_element* entranceElement = map_get_park_entrance_element_at(entranceLoc.x, entranceLoc.y, zLow, false); if (entranceElement != NULL) { - return GameActionResult(GA_ERROR::ITEM_ALREADY_PLACED, STR_NONE); + return PlaceParkEntranceGameActionResult(GA_ERROR::ITEM_ALREADY_PLACED, STR_NONE); } } return GameActionResult(); @@ -180,7 +187,7 @@ public: } rct_map_element* newElement = map_element_insert(entranceLoc.x / 32, entranceLoc.y / 32, zLow, 0xF); - assert(newElement != NULL); + Guard::Assert(newElement != NULL); newElement->clearance_height = zHigh; if (flags & GAME_COMMAND_FLAG_GHOST) @@ -220,6 +227,23 @@ static auto Factory UNUSED_ATTR = GameActions::Register extern "C" { + money32 place_park_entrance(sint16 x, sint16 y, sint16 z, uint8 direction) + { + auto gameAction = PlaceParkEntranceAction(); + gameAction.x = x; + gameAction.y = y; + gameAction.z = z; + gameAction.direction = direction; + auto result = GameActions::Execute(&gameAction); + if (result.Error == GA_ERROR::OK) + { + return 0; + } + else + { + return MONEY32_UNDEFINED; + } + } /** * @@ -233,29 +257,7 @@ extern "C" sint32* edi, sint32* ebp) { - auto gameAction = PlaceParkEntranceAction(); - gameAction.x = (*eax & 0xFFFF); - gameAction.y = (*ecx & 0xFFFF); - gameAction.z = (*edx & 0xFF); - gameAction.direction = ((*ebx >> 8) & 0xFF); - uint8 flags = (*ebx & 0xFF); - GameActionResult result; - if (flags & GAME_COMMAND_FLAG_APPLY) { - result = GameActions::Execute(&gameAction, flags); - } - else - { - result = GameActions::Query(&gameAction, flags); - } - - if (result.Error != GA_ERROR::OK) - { - *ebx = MONEY32_UNDEFINED; - } - else - { - *ebx = result.Cost; - } + Guard::Assert(false, "GAME_COMMAND_PLACE_PARK_ENTRANCE DEPRECIATED"); } /** diff --git a/src/openrct2/windows/Map.cpp b/src/openrct2/windows/Map.cpp index 518e7f521f..61bb0b750a 100644 --- a/src/openrct2/windows/Map.cpp +++ b/src/openrct2/windows/Map.cpp @@ -1325,15 +1325,7 @@ static void window_map_place_park_entrance_tool_down(sint32 x, sint32 y) place_park_entrance_get_map_position(x, y, &mapX, &mapY, &mapZ, &direction); if (mapX != MAP_LOCATION_NULL) { gGameCommandErrorTitle = STR_CANT_BUILD_PARK_ENTRANCE_HERE; - money32 price = game_do_command( - mapX, - GAME_COMMAND_FLAG_APPLY | (direction << 8), - mapY, - mapZ, - GAME_COMMAND_PLACE_PARK_ENTRANCE, - 0, - 0 - ); + money32 price = place_park_entrance(mapX, mapY, mapZ, direction); if (price != MONEY32_UNDEFINED) { audio_play_sound_at_location( SOUND_PLACE_ITEM, diff --git a/src/openrct2/world/entrance.h b/src/openrct2/world/entrance.h index 60dfb2081d..1805e7fc3d 100644 --- a/src/openrct2/world/entrance.h +++ b/src/openrct2/world/entrance.h @@ -52,6 +52,8 @@ extern uint8 gRideEntranceExitGhostStationIndex; void park_entrance_remove_ghost(); money32 park_entrance_place_ghost(sint32 x, sint32 y, sint32 z, sint32 direction); +money32 place_park_entrance(sint16 x, sint16 y, sint16 z, uint8 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);