mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Fix formating and other issues
Refactor as per comments. Simplified some of the code as well Use constants
This commit is contained in:
@@ -3941,8 +3941,7 @@ static void ride_construction_tooldown_entrance_exit(int32_t screenX, int32_t sc
|
||||
|
||||
auto rideEntranceExitPlaceAction = RideEntranceExitPlaceAction(
|
||||
{ _unkF44188.x, _unkF44188.y }, direction_reverse(gRideEntranceExitPlaceDirection), gRideEntranceExitPlaceRideIndex,
|
||||
gRideEntranceExitPlaceStationIndex,
|
||||
gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_EXIT);
|
||||
gRideEntranceExitPlaceStationIndex, gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_EXIT);
|
||||
|
||||
rideEntranceExitPlaceAction.SetCallback([=](const GameAction* ga, const GameActionResult* result) {
|
||||
if (result->Error != GA_ERROR::OK)
|
||||
@@ -3956,7 +3955,7 @@ static void ride_construction_tooldown_entrance_exit(int32_t screenX, int32_t sc
|
||||
tool_cancel();
|
||||
if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_NO_TRACK))
|
||||
{
|
||||
window_close_by_class(WC_RIDE_CONSTRUCTION);
|
||||
window_close_by_class(WC_RIDE_CONSTRUCTION);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -506,12 +506,12 @@ namespace OpenRCT2
|
||||
}
|
||||
case GAME_COMMAND_PLACE_RIDE_ENTRANCE_OR_EXIT:
|
||||
{
|
||||
CoordsXY loc = {command.eax & 0xFFFF, command.ecx & 0xFFFF};
|
||||
CoordsXY loc = { (int32_t)(command.eax & 0xFFFF), (int32_t)(command.ecx & 0xFFFF) };
|
||||
Direction direction = (command.ebx >> 8) & 0xFF;
|
||||
ride_id_t rideId = command.edx & 0xFF;
|
||||
uint8_t stationNum = command.edi & 0xFF;
|
||||
bool isExit = ((command.edx >> 8) & 0xFF) != 0;
|
||||
result.action = std::make_unique<RideEntranceExitPlaceAction>(loc,direction,rideId,stationNum,isExit);
|
||||
result.action = std::make_unique<RideEntranceExitPlaceAction>(loc, direction, rideId, stationNum, isExit);
|
||||
result.action->SetFlags(command.ebx & 0xFF);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "../actions/RideEntranceExitRemoveAction.hpp"
|
||||
#include "../management/Finance.h"
|
||||
#include "../ride/Ride.h"
|
||||
#include "../ride/Station.h"
|
||||
#include "../world/Entrance.h"
|
||||
#include "../world/MapAnimation.h"
|
||||
#include "../management/Finance.h"
|
||||
#include "../world/Sprite.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
@@ -92,44 +92,13 @@ public:
|
||||
ride_clear_for_construction(ride);
|
||||
ride_remove_peeps(ride);
|
||||
|
||||
bool requiresRemove = false;
|
||||
LocationXY16 removeCoord = { 0, 0 };
|
||||
const auto location = _isExit ? ride_get_exit_location(ride, _stationNum)
|
||||
: ride_get_entrance_location(ride, _stationNum);
|
||||
|
||||
if (_isExit)
|
||||
{
|
||||
const auto exit = ride_get_exit_location(ride, _stationNum);
|
||||
if (!exit.isNull())
|
||||
{
|
||||
if (GetFlags() & GAME_COMMAND_FLAG_GHOST)
|
||||
{
|
||||
return MakeResult(GA_ERROR::DISALLOWED, errorTitle);
|
||||
}
|
||||
|
||||
removeCoord.x = exit.x * 32;
|
||||
removeCoord.y = exit.y * 32;
|
||||
requiresRemove = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto entrance = ride_get_entrance_location(ride, _stationNum);
|
||||
if (!entrance.isNull())
|
||||
{
|
||||
if (GetFlags() & GAME_COMMAND_FLAG_GHOST)
|
||||
{
|
||||
return MakeResult(GA_ERROR::DISALLOWED, errorTitle);
|
||||
}
|
||||
|
||||
removeCoord.x = entrance.x * 32;
|
||||
removeCoord.y = entrance.y * 32;
|
||||
requiresRemove = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (requiresRemove)
|
||||
if (!location.isNull())
|
||||
{
|
||||
auto rideEntranceExitRemove = RideEntranceExitRemoveAction(
|
||||
{ removeCoord.x, removeCoord.y }, _rideIndex, _stationNum, _isExit);
|
||||
{ location.x * 32, location.y * 32 }, _rideIndex, _stationNum, _isExit);
|
||||
rideEntranceExitRemove.SetFlags(GetFlags());
|
||||
|
||||
auto result = GameActions::QueryNested(&rideEntranceExitRemove);
|
||||
@@ -161,7 +130,7 @@ public:
|
||||
return MakeResult(GA_ERROR::DISALLOWED, errorTitle, STR_RIDE_CANT_BUILD_THIS_UNDERWATER);
|
||||
}
|
||||
|
||||
if (z / 8 > 244)
|
||||
if (z / 8 > MaxRideEntranceOrExitHeight)
|
||||
{
|
||||
return MakeResult(GA_ERROR::DISALLOWED, errorTitle, STR_TOO_HIGH);
|
||||
}
|
||||
@@ -190,34 +159,12 @@ public:
|
||||
ride_clear_for_construction(ride);
|
||||
ride_remove_peeps(ride);
|
||||
|
||||
bool requiresRemove = false;
|
||||
LocationXY16 removeCoord = { 0, 0 };
|
||||
|
||||
if (_isExit)
|
||||
{
|
||||
const auto exit = ride_get_exit_location(ride, _stationNum);
|
||||
if (!exit.isNull())
|
||||
{
|
||||
removeCoord.x = exit.x * 32;
|
||||
removeCoord.y = exit.y * 32;
|
||||
requiresRemove = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto entrance = ride_get_entrance_location(ride, _stationNum);
|
||||
if (!entrance.isNull())
|
||||
{
|
||||
removeCoord.x = entrance.x * 32;
|
||||
removeCoord.y = entrance.y * 32;
|
||||
requiresRemove = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (requiresRemove)
|
||||
const auto location = _isExit ? ride_get_exit_location(ride, _stationNum)
|
||||
: ride_get_entrance_location(ride, _stationNum);
|
||||
if (!location.isNull())
|
||||
{
|
||||
auto rideEntranceExitRemove = RideEntranceExitRemoveAction(
|
||||
{ removeCoord.x, removeCoord.y }, _rideIndex, _stationNum, _isExit);
|
||||
{ location.x * 32, location.y * 32 }, _rideIndex, _stationNum, _isExit);
|
||||
rideEntranceExitRemove.SetFlags(GetFlags());
|
||||
|
||||
auto result = GameActions::ExecuteNested(&rideEntranceExitRemove);
|
||||
@@ -324,7 +271,7 @@ public:
|
||||
return MakeResult(GA_ERROR::DISALLOWED, errorTitle, STR_RIDE_CANT_BUILD_THIS_UNDERWATER);
|
||||
}
|
||||
|
||||
if (baseZ > 244)
|
||||
if (baseZ > MaxRideEntranceOrExitHeight)
|
||||
{
|
||||
return MakeResult(GA_ERROR::DISALLOWED, errorTitle, STR_TOO_HIGH);
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ template<> struct DataSerializerTraits<CoordsXY>
|
||||
{
|
||||
auto x = ByteSwapBE(stream->ReadValue<int32_t>());
|
||||
auto y = ByteSwapBE(stream->ReadValue<int32_t>());
|
||||
coords = CoordsXY{x, y};
|
||||
coords = CoordsXY{ x, y };
|
||||
}
|
||||
static void log(IStream* stream, const CoordsXY& coords)
|
||||
{
|
||||
|
||||
@@ -1218,7 +1218,7 @@ static int32_t track_design_place_maze(rct_track_td6* td6, int16_t x, int16_t y,
|
||||
|
||||
if (_trackDesignPlaceOperation == PTD_OPERATION_1)
|
||||
{
|
||||
auto res = RideEntranceExitPlaceAction::TrackPlaceQuery({mapCoord.x, mapCoord.y, z}, false);
|
||||
auto res = RideEntranceExitPlaceAction::TrackPlaceQuery({ mapCoord.x, mapCoord.y, z }, false);
|
||||
cost = res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -37,6 +37,8 @@ extern uint8_t gParkEntranceGhostDirection;
|
||||
|
||||
#define MAX_PARK_ENTRANCES 4
|
||||
|
||||
constexpr int32_t MaxRideEntranceOrExitHeight = 244;
|
||||
|
||||
extern std::vector<CoordsXYZD> gParkEntrances;
|
||||
|
||||
extern CoordsXYZD gRideEntranceExitGhostPosition;
|
||||
|
||||
Reference in New Issue
Block a user