1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-22 22:34:33 +01:00

Extra checks for nullptrs and bad values

This commit is contained in:
duncanspumpkin
2019-04-02 18:52:52 +01:00
parent 09875311b3
commit 78527f7af4

View File

@@ -25,9 +25,9 @@
DEFINE_GAME_ACTION(WallPlaceAction, GAME_COMMAND_PLACE_WALL, GameActionResult)
{
private:
int32_t _wallType;
int32_t _wallType{ -1 };
CoordsXYZ _loc;
uint8_t _edge;
uint8_t _edge{ std::numeric_limits<uint8_t>::max() };
int32_t _primaryColour;
int32_t _secondaryColour;
int32_t _tertiaryColour;
@@ -91,6 +91,16 @@ public:
return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_BUILD_PARK_ENTRANCE_HERE);
}
}
else if ((_loc.x > gMapSizeMaxXY || _loc.y > gMapSizeMaxXY))
{
log_error("Invalid x/y coordinates. x = %d y = %d", _loc.x, _loc.y);
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_PARK_ENTRANCE_HERE);
}
if (_edge > 3)
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_PARK_ENTRANCE_HERE);
}
uint8_t edgeSlope = 0;
auto targetHeight = _loc.z;
@@ -448,6 +458,10 @@ private:
int32_t sequence = trackElement->GetSequenceIndex();
int32_t direction = (_edge - trackElement->GetDirection()) & TILE_ELEMENT_DIRECTION_MASK;
Ride* ride = get_ride(trackElement->GetRideIndex());
if (ride == nullptr)
{
return false;
}
if (TrackIsAllowedWallEdges(ride->type, trackType, sequence, direction))
{
@@ -461,7 +475,16 @@ private:
if (RideGroupManager::RideTypeHasRideGroups(ride->type))
{
auto rideGroup = RideGroupManager::GetRideGroup(ride->type, get_ride_entry(ride->subtype));
auto rideEntry = get_ride_entry(ride->subtype);
if (rideEntry == nullptr)
{
return false;
}
auto rideGroup = RideGroupManager::GetRideGroup(ride->type, rideEntry);
if (rideGroup == nullptr)
{
return false;
}
if (!(rideGroup->Flags & RIDE_GROUP_FLAG_ALLOW_DOORS_ON_TRACK))
{
return false;