mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #8762 from duncanspumpkin/entranceexit_remove_ga
Entrance Exit Remove GameAction
This commit is contained in:
commit
453855993d
|
@ -27,6 +27,9 @@
|
|||
2A43D2BA2225B8D900E8F73B /* RideSetVehiclesAction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2A43D2B72225B8D900E8F73B /* RideSetVehiclesAction.hpp */; };
|
||||
2A43D2BB2225B8D900E8F73B /* SmallSceneryPlaceAction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2A43D2B82225B8D900E8F73B /* SmallSceneryPlaceAction.hpp */; };
|
||||
2A43D2BC2225B8D900E8F73B /* LoadOrQuitAction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2A43D2B92225B8D900E8F73B /* LoadOrQuitAction.hpp */; };
|
||||
2A43D2C02225B91A00E8F73B /* RideSetVehiclesAction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2A43D2BD2225B91A00E8F73B /* RideSetVehiclesAction.hpp */; };
|
||||
2A43D2C12225B91A00E8F73B /* RideEntranceExitRemoveAction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2A43D2BE2225B91A00E8F73B /* RideEntranceExitRemoveAction.hpp */; };
|
||||
2A43D2C22225B91A00E8F73B /* LoadOrQuitAction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2A43D2BF2225B91A00E8F73B /* LoadOrQuitAction.hpp */; };
|
||||
2A5354E922099C4F00A5440F /* Network.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2A5354E822099C4F00A5440F /* Network.cpp */; };
|
||||
2A5C1368221E9F9000F8C245 /* TrackRemoveAction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2A5C1367221E9F9000F8C245 /* TrackRemoveAction.hpp */; };
|
||||
2AA050322209A8E300D3A922 /* StaffSetCostumeAction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2AA050302209A8E300D3A922 /* StaffSetCostumeAction.hpp */; };
|
||||
|
@ -628,6 +631,9 @@
|
|||
2A43D2B72225B8D900E8F73B /* RideSetVehiclesAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RideSetVehiclesAction.hpp; sourceTree = "<group>"; };
|
||||
2A43D2B82225B8D900E8F73B /* SmallSceneryPlaceAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SmallSceneryPlaceAction.hpp; sourceTree = "<group>"; };
|
||||
2A43D2B92225B8D900E8F73B /* LoadOrQuitAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LoadOrQuitAction.hpp; sourceTree = "<group>"; };
|
||||
2A43D2BD2225B91A00E8F73B /* RideSetVehiclesAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RideSetVehiclesAction.hpp; sourceTree = "<group>"; };
|
||||
2A43D2BE2225B91A00E8F73B /* RideEntranceExitRemoveAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RideEntranceExitRemoveAction.hpp; sourceTree = "<group>"; };
|
||||
2A43D2BF2225B91A00E8F73B /* LoadOrQuitAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LoadOrQuitAction.hpp; sourceTree = "<group>"; };
|
||||
2A5354E822099C4F00A5440F /* Network.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Network.cpp; sourceTree = "<group>"; };
|
||||
2A5354EA22099C7200A5440F /* CircularBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CircularBuffer.h; sourceTree = "<group>"; };
|
||||
2A5354EB22099D7700A5440F /* SignSetStyleAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SignSetStyleAction.hpp; sourceTree = "<group>"; };
|
||||
|
@ -2022,6 +2028,9 @@
|
|||
2A43D2B92225B8D900E8F73B /* LoadOrQuitAction.hpp */,
|
||||
2A43D2B72225B8D900E8F73B /* RideSetVehiclesAction.hpp */,
|
||||
2A43D2B82225B8D900E8F73B /* SmallSceneryPlaceAction.hpp */,
|
||||
2A43D2BF2225B91A00E8F73B /* LoadOrQuitAction.hpp */,
|
||||
2A43D2BE2225B91A00E8F73B /* RideEntranceExitRemoveAction.hpp */,
|
||||
2A43D2BD2225B91A00E8F73B /* RideSetVehiclesAction.hpp */,
|
||||
2A5C1367221E9F9000F8C245 /* TrackRemoveAction.hpp */,
|
||||
2AAFD7FF220DD3D2002461A4 /* LandSetHeightAction.hpp */,
|
||||
2AAFD7FB220DD336002461A4 /* RideSetPriceAction.hpp */,
|
||||
|
@ -3323,6 +3332,7 @@
|
|||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
2A43D2C12225B91A00E8F73B /* RideEntranceExitRemoveAction.hpp in Headers */,
|
||||
C67B28172002D67A00109C93 /* Viewport.h in Headers */,
|
||||
939A359C20C12FC800630B3F /* Paint.Sprite.h in Headers */,
|
||||
9308DA04209908090079EE96 /* TileElement.h in Headers */,
|
||||
|
@ -3342,7 +3352,9 @@
|
|||
C6352B941F477032006CCEE3 /* PlaceParkEntranceAction.hpp in Headers */,
|
||||
C6352B911F477032006CCEE3 /* GameAction.h in Headers */,
|
||||
2A43D2BA2225B8D900E8F73B /* RideSetVehiclesAction.hpp in Headers */,
|
||||
2A43D2C02225B91A00E8F73B /* RideSetVehiclesAction.hpp in Headers */,
|
||||
2AA050322209A8E300D3A922 /* StaffSetCostumeAction.hpp in Headers */,
|
||||
2A43D2C22225B91A00E8F73B /* LoadOrQuitAction.hpp in Headers */,
|
||||
C62D838B1FD36D6F008C04F1 /* EditorObjectSelectionSession.h in Headers */,
|
||||
2A43D2BC2225B8D900E8F73B /* LoadOrQuitAction.hpp in Headers */,
|
||||
9344BEF920C1E6180047D165 /* Crypt.h in Headers */,
|
||||
|
|
|
@ -1273,7 +1273,7 @@ GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT] = {
|
|||
game_command_set_ride_name,
|
||||
nullptr,
|
||||
game_command_place_ride_entrance_or_exit,
|
||||
game_command_remove_ride_entrance_or_exit,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
game_command_set_water_height,
|
||||
|
|
|
@ -31,9 +31,9 @@ enum GAME_COMMAND
|
|||
GAME_COMMAND_SET_RIDE_NAME, // GA
|
||||
GAME_COMMAND_SET_RIDE_SETTING, // GA
|
||||
GAME_COMMAND_PLACE_RIDE_ENTRANCE_OR_EXIT,
|
||||
GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT,
|
||||
GAME_COMMAND_REMOVE_SCENERY, // GA
|
||||
GAME_COMMAND_PLACE_SCENERY, // GA
|
||||
GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, // GA
|
||||
GAME_COMMAND_REMOVE_SCENERY, // GA
|
||||
GAME_COMMAND_PLACE_SCENERY, // GA
|
||||
GAME_COMMAND_SET_WATER_HEIGHT,
|
||||
GAME_COMMAND_PLACE_PATH,
|
||||
GAME_COMMAND_PLACE_PATH_FROM_TRACK,
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "PlacePeepSpawnAction.hpp"
|
||||
#include "RideCreateAction.hpp"
|
||||
#include "RideDemolishAction.hpp"
|
||||
#include "RideEntranceExitRemoveAction.hpp"
|
||||
#include "RideSetAppearanceAction.hpp"
|
||||
#include "RideSetColourScheme.hpp"
|
||||
#include "RideSetName.hpp"
|
||||
|
@ -63,6 +64,7 @@ namespace GameActions
|
|||
Register<PlacePeepSpawnAction>();
|
||||
Register<RideCreateAction>();
|
||||
Register<RideDemolishAction>();
|
||||
Register<RideEntranceExitRemoveAction>();
|
||||
Register<RideSetColourSchemeAction>();
|
||||
Register<RideSetNameAction>();
|
||||
Register<RideSetPriceAction>();
|
||||
|
|
|
@ -0,0 +1,194 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2019 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../ride/Ride.h"
|
||||
#include "../ride/Station.h"
|
||||
#include "../world/Entrance.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
DEFINE_GAME_ACTION(RideEntranceExitRemoveAction, GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, GameActionResult)
|
||||
{
|
||||
private:
|
||||
CoordsXY _loc;
|
||||
NetworkRideId_t _rideIndex;
|
||||
uint8_t _stationNum;
|
||||
bool _isExit;
|
||||
|
||||
public:
|
||||
RideEntranceExitRemoveAction() = default;
|
||||
|
||||
RideEntranceExitRemoveAction(CoordsXY loc, ride_id_t rideIndex, uint8_t stationNum, bool isExit)
|
||||
: _loc(loc)
|
||||
, _rideIndex(rideIndex)
|
||||
, _stationNum(stationNum)
|
||||
, _isExit(isExit)
|
||||
{
|
||||
}
|
||||
|
||||
uint16_t GetActionFlags() const override
|
||||
{
|
||||
return GameAction::GetActionFlags();
|
||||
}
|
||||
|
||||
void Serialise(DataSerialiser & stream) override
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_loc) << DS_TAG(_rideIndex) << DS_TAG(_stationNum) << DS_TAG(_isExit);
|
||||
}
|
||||
|
||||
GameActionResult::Ptr Query() const override
|
||||
{
|
||||
if (_rideIndex >= MAX_RIDES || _rideIndex == RIDE_ID_NULL)
|
||||
{
|
||||
log_warning("Invalid game command for ride %u", uint32_t(_rideIndex));
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
|
||||
}
|
||||
|
||||
Ride* ride = get_ride(_rideIndex);
|
||||
if (ride == nullptr || ride->type == RIDE_TYPE_NULL)
|
||||
{
|
||||
log_warning("Invalid ride id %u for entrance/exit removal", _rideIndex);
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
|
||||
}
|
||||
|
||||
if (ride->status != RIDE_STATUS_CLOSED)
|
||||
{
|
||||
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_MUST_BE_CLOSED_FIRST);
|
||||
}
|
||||
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK)
|
||||
{
|
||||
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NOT_ALLOWED_TO_MODIFY_STATION);
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
TileElement* tileElement = map_get_first_element_at(_loc.x / 32, _loc.y / 32);
|
||||
|
||||
do
|
||||
{
|
||||
if (tileElement == nullptr)
|
||||
break;
|
||||
|
||||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE)
|
||||
continue;
|
||||
|
||||
if (tile_element_get_ride_index(tileElement) != _rideIndex)
|
||||
continue;
|
||||
|
||||
if (tileElement->AsEntrance()->GetStationIndex() != _stationNum)
|
||||
continue;
|
||||
|
||||
if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) && !(tileElement->IsGhost()))
|
||||
continue;
|
||||
|
||||
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE)
|
||||
continue;
|
||||
|
||||
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE && _isExit)
|
||||
continue;
|
||||
|
||||
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_RIDE_EXIT && !_isExit)
|
||||
continue;
|
||||
|
||||
found = true;
|
||||
break;
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
|
||||
if (!found)
|
||||
{
|
||||
log_warning(
|
||||
"Track Element not found. x = %d, y = %d, ride = %d, station = %d", _loc.x, _loc.y, _rideIndex, _stationNum);
|
||||
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
|
||||
}
|
||||
|
||||
return MakeResult();
|
||||
}
|
||||
|
||||
GameActionResult::Ptr Execute() const override
|
||||
{
|
||||
Ride* ride = get_ride(_rideIndex);
|
||||
if (ride == nullptr || ride->type == RIDE_TYPE_NULL)
|
||||
{
|
||||
log_warning("Invalid ride id %u for entrance/exit removal", _rideIndex);
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
|
||||
}
|
||||
|
||||
ride_clear_for_construction(ride);
|
||||
ride_remove_peeps(ride);
|
||||
invalidate_test_results(ride);
|
||||
|
||||
bool found = false;
|
||||
TileElement* tileElement = map_get_first_element_at(_loc.x / 32, _loc.y / 32);
|
||||
|
||||
do
|
||||
{
|
||||
if (tileElement == nullptr)
|
||||
break;
|
||||
|
||||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE)
|
||||
continue;
|
||||
|
||||
if (tile_element_get_ride_index(tileElement) != _rideIndex)
|
||||
continue;
|
||||
|
||||
if (tileElement->AsEntrance()->GetStationIndex() != _stationNum)
|
||||
continue;
|
||||
|
||||
if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) && !tileElement->IsGhost())
|
||||
continue;
|
||||
|
||||
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE)
|
||||
continue;
|
||||
|
||||
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE && _isExit)
|
||||
continue;
|
||||
|
||||
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_RIDE_EXIT && !_isExit)
|
||||
continue;
|
||||
|
||||
found = true;
|
||||
break;
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
|
||||
if (!found)
|
||||
{
|
||||
log_warning(
|
||||
"Track Element not found. x = %d, y = %d, ride = %d, station = %d", _loc.x, _loc.y, _rideIndex, _stationNum);
|
||||
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
|
||||
}
|
||||
|
||||
auto res = MakeResult();
|
||||
res->Position.x = _loc.x + 16;
|
||||
res->Position.y = _loc.y + 16;
|
||||
res->Position.z = tile_element_height(res->Position.x, res->Position.y);
|
||||
|
||||
footpath_queue_chain_reset();
|
||||
maze_entrance_hedge_replacement(_loc.x, _loc.y, tileElement);
|
||||
footpath_remove_edges_at(_loc.x, _loc.y, tileElement);
|
||||
|
||||
tile_element_remove(tileElement);
|
||||
|
||||
if (_isExit)
|
||||
{
|
||||
ride_clear_exit_location(ride, _stationNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
ride_clear_entrance_location(ride, _stationNum);
|
||||
}
|
||||
|
||||
footpath_update_queue_chains();
|
||||
|
||||
map_invalidate_tile_full(_loc.x, _loc.y);
|
||||
return res;
|
||||
}
|
||||
};
|
|
@ -31,7 +31,7 @@
|
|||
// This string specifies which version of network stream current build uses.
|
||||
// It is used for making sure only compatible builds get connected, even within
|
||||
// single OpenRCT2 version.
|
||||
#define NETWORK_STREAM_VERSION "48"
|
||||
#define NETWORK_STREAM_VERSION "49"
|
||||
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
|
||||
|
||||
static rct_peep* _pickup_peep = nullptr;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "../Game.h"
|
||||
#include "../Input.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../actions/RideEntranceExitRemoveAction.hpp"
|
||||
#include "../actions/RideSetSetting.hpp"
|
||||
#include "../actions/RideSetVehiclesAction.hpp"
|
||||
#include "../actions/TrackRemoveAction.hpp"
|
||||
|
@ -1917,12 +1918,17 @@ static int32_t ride_modify_entrance_or_exit(TileElement* tileElement, int32_t x,
|
|||
else
|
||||
{
|
||||
// Remove entrance / exit
|
||||
game_do_command(
|
||||
x, (GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_APPLY), y, rideIndex,
|
||||
GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, stationIndex, entranceType == ENTRANCE_TYPE_RIDE_EXIT);
|
||||
gCurrentToolWidget.widget_index = entranceType == ENTRANCE_TYPE_RIDE_ENTRANCE ? WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE
|
||||
: WC_RIDE_CONSTRUCTION__WIDX_EXIT;
|
||||
gRideEntranceExitPlaceType = entranceType;
|
||||
auto rideEntranceExitRemove = RideEntranceExitRemoveAction(
|
||||
{ x, y }, rideIndex, stationIndex, entranceType == ENTRANCE_TYPE_RIDE_EXIT);
|
||||
|
||||
rideEntranceExitRemove.SetCallback([=](const GameAction* ga, const GameActionResult* result) {
|
||||
gCurrentToolWidget.widget_index = entranceType == ENTRANCE_TYPE_RIDE_ENTRANCE ? WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE
|
||||
: WC_RIDE_CONSTRUCTION__WIDX_EXIT;
|
||||
gRideEntranceExitPlaceType = entranceType;
|
||||
window_invalidate_by_class(WC_RIDE_CONSTRUCTION);
|
||||
});
|
||||
|
||||
GameActions::Execute(&rideEntranceExitRemove);
|
||||
}
|
||||
|
||||
window_invalidate_by_class(WC_RIDE_CONSTRUCTION);
|
||||
|
|
|
@ -1144,8 +1144,6 @@ void game_command_set_ride_vehicles(
|
|||
|
||||
void game_command_place_ride_entrance_or_exit(
|
||||
int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp);
|
||||
void game_command_remove_ride_entrance_or_exit(
|
||||
int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp);
|
||||
|
||||
void ride_set_to_default_inspection_interval(Ride* ride);
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "../Cheats.h"
|
||||
#include "../Game.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../actions/RideEntranceExitRemoveAction.hpp"
|
||||
#include "../localisation/StringIds.h"
|
||||
#include "../management/Finance.h"
|
||||
#include "../network/network.h"
|
||||
|
@ -209,10 +210,13 @@ static money32 RideEntranceExitPlace(
|
|||
|
||||
if (requiresRemove)
|
||||
{
|
||||
money32 success = game_do_command(
|
||||
removeCoord.x, flags, removeCoord.y, rideIndex, GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, stationNum, isExit);
|
||||
auto rideEntranceExitRemove = RideEntranceExitRemoveAction(
|
||||
{ removeCoord.x, removeCoord.y }, rideIndex, stationNum, isExit);
|
||||
rideEntranceExitRemove.SetFlags(flags);
|
||||
|
||||
if (success == MONEY32_UNDEFINED)
|
||||
auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&rideEntranceExitRemove)
|
||||
: GameActions::QueryNested(&rideEntranceExitRemove);
|
||||
if (res->Error != GA_ERROR::OK)
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
@ -307,118 +311,6 @@ static money32 RideEntranceExitPlace(
|
|||
return cost;
|
||||
}
|
||||
|
||||
static money32 RideEntranceExitRemove(int16_t x, int16_t y, ride_id_t rideIndex, uint8_t stationNum, uint8_t flags, bool isExit)
|
||||
{
|
||||
if (rideIndex >= MAX_RIDES)
|
||||
{
|
||||
log_warning("Invalid game command for ride %u", rideIndex);
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
Ride* ride = get_ride(rideIndex);
|
||||
if (ride->type == RIDE_TYPE_NULL)
|
||||
{
|
||||
log_warning("Invalid ride id %u for entrance/exit removal", rideIndex);
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (!(flags & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && game_is_paused() && !gCheatsBuildInPauseMode)
|
||||
{
|
||||
gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
if (ride->status != RIDE_STATUS_CLOSED)
|
||||
{
|
||||
gGameCommandErrorText = STR_MUST_BE_CLOSED_FIRST;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK)
|
||||
{
|
||||
gGameCommandErrorText = STR_NOT_ALLOWED_TO_MODIFY_STATION;
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
if (flags & GAME_COMMAND_FLAG_APPLY)
|
||||
{
|
||||
ride_clear_for_construction(ride);
|
||||
ride_remove_peeps(ride);
|
||||
invalidate_test_results(ride);
|
||||
|
||||
bool found = false;
|
||||
TileElement* tileElement = map_get_first_element_at(x / 32, y / 32);
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
log_warning("Invalid coordinates for entrance/exit removal x = %d, y = %d", x, y);
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE)
|
||||
continue;
|
||||
|
||||
if (tile_element_get_ride_index(tileElement) != rideIndex)
|
||||
continue;
|
||||
|
||||
if (tileElement->AsEntrance()->GetStationIndex() != stationNum)
|
||||
continue;
|
||||
|
||||
if (flags & GAME_COMMAND_FLAG_5 && !(tileElement->IsGhost()))
|
||||
continue;
|
||||
|
||||
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE)
|
||||
continue;
|
||||
|
||||
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE && isExit)
|
||||
continue;
|
||||
|
||||
if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_RIDE_EXIT && !isExit)
|
||||
continue;
|
||||
|
||||
found = true;
|
||||
break;
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
|
||||
if (!found)
|
||||
{
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
|
||||
LocationXYZ16 coord;
|
||||
coord.x = x + 16;
|
||||
coord.y = y + 16;
|
||||
coord.z = tile_element_height(coord.x, coord.y);
|
||||
network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord);
|
||||
|
||||
footpath_queue_chain_reset();
|
||||
maze_entrance_hedge_replacement(x, y, tileElement);
|
||||
footpath_remove_edges_at(x, y, tileElement);
|
||||
|
||||
tile_element_remove(tileElement);
|
||||
|
||||
if (isExit)
|
||||
{
|
||||
ride_clear_exit_location(ride, stationNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
ride_clear_entrance_location(ride, stationNum);
|
||||
}
|
||||
|
||||
footpath_update_queue_chains();
|
||||
|
||||
map_invalidate_tile_full(x, y);
|
||||
}
|
||||
|
||||
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static money32 RideEntranceExitPlaceGhost(
|
||||
ride_id_t rideIndex, int16_t x, int16_t y, uint8_t direction, uint8_t placeType, uint8_t stationNum)
|
||||
{
|
||||
|
@ -488,11 +380,12 @@ void ride_entrance_exit_remove_ghost()
|
|||
{
|
||||
if (_currentTrackSelectionFlags & TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT)
|
||||
{
|
||||
game_do_command(
|
||||
gRideEntranceExitGhostPosition.x,
|
||||
(GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_APPLY),
|
||||
gRideEntranceExitGhostPosition.y, _currentRideIndex, GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT,
|
||||
auto rideEntranceExitRemove = RideEntranceExitRemoveAction(
|
||||
{ gRideEntranceExitGhostPosition.x, gRideEntranceExitGhostPosition.y }, _currentRideIndex,
|
||||
gRideEntranceExitGhostStationIndex, gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_EXIT);
|
||||
|
||||
rideEntranceExitRemove.SetFlags(GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED);
|
||||
GameActions::Execute(&rideEntranceExitRemove);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -530,17 +423,6 @@ void game_command_place_ride_entrance_or_exit(
|
|||
((*edx >> 8) & 0xFF) != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0066640B
|
||||
*/
|
||||
void game_command_remove_ride_entrance_or_exit(
|
||||
int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, [[maybe_unused]] int32_t* esi, int32_t* edi,
|
||||
[[maybe_unused]] int32_t* ebp)
|
||||
{
|
||||
*ebx = RideEntranceExitRemove(*eax & 0xFFFF, *ecx & 0xFFFF, *edx & 0xFF, *edi & 0xFF, *ebx & 0xFF, *ebp & 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the outer hedge walls for an entrance placement removal.
|
||||
* rct2: 0x00666D6F
|
||||
|
|
Loading…
Reference in New Issue