Reduce the number of temporary variables

This commit is contained in:
duncanspumpkin 2019-08-18 12:21:17 +01:00
parent b77f15c4b7
commit 11aa41c4c4
31 changed files with 59 additions and 59 deletions

View File

@ -60,7 +60,7 @@ public:
return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_CANT_POSITION_THIS_HERE);
}
if (!map_is_location_valid({ _loc.x, _loc.y }))
if (!map_is_location_valid(_loc))
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE);
}
@ -72,7 +72,7 @@ public:
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE, STR_CAN_ONLY_BE_BUILT_ACROSS_PATHS);
}
if (!map_can_build_at({ _loc.x, _loc.y, _loc.z }))
if (!map_can_build_at(_loc))
{
return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_POSITION_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK);
}

View File

@ -68,7 +68,7 @@ public:
res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
res->Position.x = banner->position.x * 32 + 16;
res->Position.y = banner->position.y * 32 + 16;
res->Position.z = tile_element_height({ res->Position.x, res->Position.y });
res->Position.z = tile_element_height(res->Position);
TileElement* tileElement = banner_get_tile_element(_bannerIndex);
@ -118,7 +118,7 @@ public:
res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
res->Position.x = banner->position.x * 32 + 16;
res->Position.y = banner->position.y * 32 + 16;
res->Position.z = tile_element_height({ res->Position.x, res->Position.y });
res->Position.z = tile_element_height(res->Position);
TileElement* tileElement = banner_get_tile_element(_bannerIndex);

View File

@ -63,7 +63,7 @@ public:
gFootpathGroundFlags = 0;
if (map_is_edge({ _loc.x, _loc.y }))
if (map_is_edge(_loc))
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_FOOTPATH_HERE, STR_OFF_EDGE_OF_MAP);
}
@ -251,7 +251,7 @@ private:
return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_BUILD_FOOTPATH_HERE, STR_CANT_BUILD_THIS_UNDERWATER);
}
auto surfaceElement = map_get_surface_element_at({ _loc.x, _loc.y });
auto surfaceElement = map_get_surface_element_at(_loc);
if (surfaceElement == nullptr)
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_FOOTPATH_HERE);
@ -312,7 +312,7 @@ private:
gFootpathGroundFlags = gMapGroundFlags;
auto surfaceElement = map_get_surface_element_at({ _loc.x, _loc.y });
auto surfaceElement = map_get_surface_element_at(_loc);
if (surfaceElement == nullptr)
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_FOOTPATH_HERE);

View File

@ -63,7 +63,7 @@ public:
gFootpathGroundFlags = 0;
if (map_is_edge({ _loc.x, _loc.y }))
if (map_is_edge(_loc))
{
return MakeResult(
GA_ERROR::INVALID_PARAMETERS, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_OFF_EDGE_OF_MAP);
@ -163,7 +163,7 @@ private:
GA_ERROR::DISALLOWED, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_CANT_BUILD_THIS_UNDERWATER);
}
auto surfaceElement = map_get_surface_element_at({ _loc.x, _loc.y });
auto surfaceElement = map_get_surface_element_at(_loc);
if (surfaceElement == nullptr)
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE);
@ -226,7 +226,7 @@ private:
gFootpathGroundFlags = gMapGroundFlags;
auto surfaceElement = map_get_surface_element_at({ _loc.x, _loc.y });
auto surfaceElement = map_get_surface_element_at(_loc);
if (surfaceElement == nullptr)
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE);

View File

@ -53,7 +53,7 @@ public:
auto res = MakeResult();
res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
res->Position = _loc;
if (!map_is_location_valid({ _loc.x, _loc.y }))
if (!map_is_location_valid(_loc))
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE, STR_OFF_EDGE_OF_MAP);
}

View File

@ -47,7 +47,7 @@ public:
GameActionResult::Ptr Query() const override
{
if (!map_is_location_valid({ _loc.x, _loc.y }))
if (!map_is_location_valid(_loc))
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_OFF_EDGE_OF_MAP);
}

View File

@ -93,7 +93,7 @@ private:
CoordsXYZ centre{ (validRange.GetLeft() + validRange.GetRight()) / 2 + 16,
(validRange.GetTop() + validRange.GetBottom()) / 2 + 16, 0 };
centre.z = tile_element_height({ centre.x, centre.y });
centre.z = tile_element_height(centre);
res->Position = centre;
res->ExpenditureType = RCT_EXPENDITURE_TYPE_LAND_PURCHASE;

View File

@ -97,7 +97,7 @@ private:
CoordsXYZ centre{ (validRange.GetLeft() + validRange.GetRight()) / 2 + 16,
(validRange.GetTop() + validRange.GetBottom()) / 2 + 16, 0 };
centre.z = tile_element_height({ centre.x, centre.y });
centre.z = tile_element_height(centre);
res->Position = centre;
res->ExpenditureType = RCT_EXPENDITURE_TYPE_LAND_PURCHASE;

View File

@ -89,7 +89,7 @@ public:
auto res = std::make_unique<LargeSceneryPlaceActionResult>();
res->ErrorTitle = STR_CANT_POSITION_THIS_HERE;
res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
int16_t surfaceHeight = tile_element_height({ _loc.x, _loc.y });
int16_t surfaceHeight = tile_element_height(_loc);
res->Position.x = _loc.x + 16;
res->Position.y = _loc.y + 16;
res->Position.z = surfaceHeight;
@ -214,7 +214,7 @@ public:
auto res = std::make_unique<LargeSceneryPlaceActionResult>();
res->ErrorTitle = STR_CANT_POSITION_THIS_HERE;
int16_t surfaceHeight = tile_element_height({ _loc.x, _loc.y });
int16_t surfaceHeight = tile_element_height(_loc);
res->Position.x = _loc.x + 16;
res->Position.y = _loc.y + 16;
res->Position.z = surfaceHeight;
@ -369,7 +369,7 @@ private:
continue;
}
auto* surfaceElement = map_get_surface_element_at({ curTile.x, curTile.y });
auto* surfaceElement = map_get_surface_element_at(curTile);
if (surfaceElement == nullptr)
continue;

View File

@ -56,7 +56,7 @@ public:
const uint32_t flags = GetFlags();
int32_t z = tile_element_height({ _loc.x, _loc.x });
int32_t z = tile_element_height(_loc);
res->Position.x = _loc.x + 16;
res->Position.y = _loc.y + 16;
res->Position.z = z;
@ -126,7 +126,7 @@ public:
const uint32_t flags = GetFlags();
int32_t z = tile_element_height({ _loc.x, _loc.y });
int32_t z = tile_element_height(_loc);
res->Position.x = _loc.x + 16;
res->Position.y = _loc.y + 16;
res->Position.z = z;

View File

@ -62,7 +62,7 @@ private:
res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
res->Position.x = _loc.x + 16;
res->Position.y = _loc.y + 16;
res->Position.z = tile_element_height({ _loc.x, _loc.y });
res->Position.z = tile_element_height(_loc);
res->ErrorTitle = STR_CANT_REPAINT_THIS;
if (_loc.x < 0 || _loc.y < 0 || _loc.x > gMapSizeMaxXY || _loc.y > gMapSizeMaxXY)

View File

@ -101,7 +101,7 @@ public:
return res;
}
auto surfaceElement = map_get_surface_element_at(_loc.x / 32, _loc.y / 32);
auto surfaceElement = map_get_surface_element_at(_loc);
if (surfaceElement == nullptr)
{
res->Error = GA_ERROR::UNKNOWN;

View File

@ -80,7 +80,7 @@ public:
}
// Verify location is unowned
auto surfaceMapElement = map_get_surface_element_at(_location.x >> 5, _location.y >> 5);
auto surfaceMapElement = map_get_surface_element_at(_location);
if (surfaceMapElement == nullptr)
{
return std::make_unique<GameActionResult>(GA_ERROR::UNKNOWN, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_NONE);

View File

@ -129,7 +129,7 @@ public:
auto res = MakeResult();
res->Position.x = _loc.x + 16;
res->Position.y = _loc.y + 16;
res->Position.z = tile_element_height({ _loc.x, _loc.y });
res->Position.z = tile_element_height(_loc);
res->ExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION;
return res;
}
@ -189,7 +189,7 @@ public:
auto res = MakeResult();
res->Position.x = _loc.x + 16;
res->Position.y = _loc.y + 16;
res->Position.z = tile_element_height({ _loc.x, _loc.y });
res->Position.z = tile_element_height(_loc);
res->ExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION;
TileElement* tileElement = tile_element_insert({ _loc.x / 32, _loc.y / 32, z / 8 }, 0b1111);
@ -272,7 +272,7 @@ public:
auto res = MakeResult();
res->Position.x = loc.x + 16;
res->Position.y = loc.y + 16;
res->Position.z = tile_element_height({ loc.x, loc.y });
res->Position.z = tile_element_height(loc);
res->ExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION;
return res;
}

View File

@ -168,7 +168,7 @@ public:
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 });
res->Position.z = tile_element_height(res->Position);
footpath_queue_chain_reset();
maze_entrance_hedge_replacement(_loc.x, _loc.y, tileElement);

View File

@ -163,7 +163,7 @@ public:
{
res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16;
res->Position.z = tile_element_height({ res->Position.x, res->Position.y });
res->Position.z = tile_element_height(res->Position);
}
return res;

View File

@ -97,7 +97,7 @@ public:
auto res = std::make_unique<GameActionResult>();
res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16;
res->Position.z = tile_element_height({ res->Position.x, res->Position.y });
res->Position.z = tile_element_height(res->Position);
return res;
}

View File

@ -97,7 +97,7 @@ public:
{
res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16;
res->Position.z = tile_element_height({ res->Position.x, res->Position.y });
res->Position.z = tile_element_height(res->Position);
}
uint32_t shopItem;

View File

@ -246,7 +246,7 @@ public:
{
res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16;
res->Position.z = tile_element_height({ res->Position.x, res->Position.y });
res->Position.z = tile_element_height(res->Position);
}
window_invalidate_by_number(WC_RIDE, _rideIndex);
return res;

View File

@ -124,7 +124,7 @@ public:
{
res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16;
res->Position.z = tile_element_height({ res->Position.x, res->Position.y });
res->Position.z = tile_element_height(res->Position);
}
switch (_status)

View File

@ -205,7 +205,7 @@ public:
{
res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16;
res->Position.z = tile_element_height({ res->Position.x, res->Position.y });
res->Position.z = tile_element_height(res->Position);
}
auto intent = Intent(INTENT_ACTION_RIDE_PAINT_RESET_VEHICLE);

View File

@ -99,8 +99,8 @@ public:
{
supportsRequired = true;
}
int32_t landHeight = tile_element_height({ _loc.x, _loc.y });
int16_t waterHeight = tile_element_water_height({ _loc.x, _loc.y });
int32_t landHeight = tile_element_height(_loc);
int16_t waterHeight = tile_element_water_height(_loc);
int32_t surfaceHeight = landHeight;
// If on water
@ -185,7 +185,7 @@ public:
return std::make_unique<SmallSceneryPlaceActionResult>(GA_ERROR::NOT_OWNED, STR_LAND_NOT_OWNED_BY_PARK);
}
auto* surfaceElement = map_get_surface_element_at({ _loc.x, _loc.y });
auto* surfaceElement = map_get_surface_element_at(_loc);
if (surfaceElement != nullptr && !gCheatsDisableClearanceChecks && surfaceElement->GetWaterHeight() > 0)
{
@ -302,8 +302,8 @@ public:
{
supportsRequired = true;
}
int32_t landHeight = tile_element_height({ _loc.x, _loc.y });
int16_t waterHeight = tile_element_water_height({ _loc.x, _loc.y });
int32_t landHeight = tile_element_height(_loc);
int16_t waterHeight = tile_element_water_height(_loc);
int32_t surfaceHeight = landHeight;
// If on water

View File

@ -56,7 +56,7 @@ public:
{
GameActionResult::Ptr res = std::make_unique<GameActionResult>();
if (!map_is_location_valid({ _loc.x, _loc.y }))
if (!map_is_location_valid(_loc))
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK);
}
@ -124,7 +124,7 @@ public:
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
}
res->Position.z = tile_element_height({ res->Position.x, res->Position.y });
res->Position.z = tile_element_height(res->Position);
map_invalidate_tile_full(_loc.x, _loc.y);
tile_element_remove(tileElement);

View File

@ -255,7 +255,7 @@ private:
res->Position.x = _loc.x;
res->Position.y = _loc.y;
res->Position.z = tile_element_height({ _loc.x, _loc.y });
res->Position.z = tile_element_height(_loc);
return res;
}

View File

@ -308,7 +308,7 @@ public:
if ((rideTypeFlags & RIDE_TYPE_FLAG_TRACK_MUST_BE_ON_WATER) && !byte_9D8150)
{
auto surfaceElement = map_get_surface_element_at({ mapLoc.x, mapLoc.y });
auto surfaceElement = map_get_surface_element_at(mapLoc);
uint8_t waterHeight = surfaceElement->GetWaterHeight() * 2;
if (waterHeight == 0)
@ -350,7 +350,7 @@ public:
}
// 6c5648 12 push
auto surfaceElement = map_get_surface_element_at({ mapLoc.x, mapLoc.y });
auto surfaceElement = map_get_surface_element_at(mapLoc);
if (!gCheatsDisableSupportLimits)
{
int32_t ride_height = clearanceZ - surfaceElement->base_height;
@ -505,7 +505,7 @@ public:
res->GroundFlags = mapGroundFlags;
// 6c5648 12 push
auto surfaceElement = map_get_surface_element_at({ mapLoc.x, mapLoc.y });
auto surfaceElement = map_get_surface_element_at(mapLoc);
int32_t supportHeight = baseZ - surfaceElement->base_height;
if (supportHeight < 0)
@ -672,7 +672,7 @@ public:
if (rideTypeFlags & RIDE_TYPE_FLAG_TRACK_MUST_BE_ON_WATER)
{
auto* waterSurfaceElement = map_get_surface_element_at({ mapLoc.x, mapLoc.y });
auto* waterSurfaceElement = map_get_surface_element_at(mapLoc);
waterSurfaceElement->SetHasTrackThatNeedsWater(true);
tileElement = reinterpret_cast<TileElement*>(waterSurfaceElement);
}

View File

@ -216,7 +216,7 @@ public:
}
}
auto* surfaceElement = map_get_surface_element_at({ mapLoc.x, mapLoc.y });
auto* surfaceElement = map_get_surface_element_at(mapLoc);
if (surfaceElement == nullptr)
{
log_warning("Surface Element not found. x = %d, y = %d", mapLoc.x, mapLoc.y);
@ -411,7 +411,7 @@ public:
}
}
auto* surfaceElement = map_get_surface_element_at({ mapLoc.x, mapLoc.y });
auto* surfaceElement = map_get_surface_element_at(mapLoc);
if (surfaceElement == nullptr)
{
log_warning("Surface Element not found. x = %d, y = %d", mapLoc.x, mapLoc.y);

View File

@ -109,7 +109,7 @@ public:
if (_loc.z == 0)
{
res->Position.z = tile_element_height({ res->Position.x, res->Position.y });
res->Position.z = tile_element_height(res->Position);
}
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !(GetFlags() & GAME_COMMAND_FLAG_PATH_SCENERY)
@ -142,7 +142,7 @@ public:
auto targetHeight = _loc.z;
if (targetHeight == 0)
{
auto* surfaceElement = map_get_surface_element_at({ _loc.x, _loc.y });
auto* surfaceElement = map_get_surface_element_at(_loc);
if (surfaceElement == nullptr)
{
log_error("Surface element not found at %d, %d.", _loc.x, _loc.y);
@ -159,7 +159,7 @@ public:
}
}
auto* surfaceElement = map_get_surface_element_at({ _loc.x, _loc.y });
auto* surfaceElement = map_get_surface_element_at(_loc);
if (surfaceElement == nullptr)
{
log_error("Surface element not found at %d, %d.", _loc.x, _loc.y);
@ -309,14 +309,14 @@ public:
if (res->Position.z == 0)
{
res->Position.z = tile_element_height({ res->Position.x, res->Position.y });
res->Position.z = tile_element_height(res->Position);
}
uint8_t edgeSlope = 0;
auto targetHeight = _loc.z;
if (targetHeight == 0)
{
auto* surfaceElement = map_get_surface_element_at({ _loc.x, _loc.y });
auto* surfaceElement = map_get_surface_element_at(_loc);
if (surfaceElement == nullptr)
{
log_error("Surface element not found at %d, %d.", _loc.x, _loc.y);

View File

@ -44,7 +44,7 @@ public:
res->Cost = 0;
res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
if (!map_is_location_valid({ _loc.x, _loc.y }))
if (!map_is_location_valid(_loc))
{
return std::make_unique<GameActionResult>(
GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
@ -84,7 +84,7 @@ public:
res->Position.x = _loc.x + 16;
res->Position.y = _loc.y + 16;
res->Position.z = tile_element_height({ res->Position.x, res->Position.y });
res->Position.z = tile_element_height(res->Position);
tile_element_remove_banner_entry(wallElement);
map_invalidate_tile_zoom1(_loc.x, _loc.y, wallElement->base_height * 8, (wallElement->base_height * 8) + 72);

View File

@ -63,8 +63,8 @@ private:
res->Position.x = ((validRange.GetLeft() + validRange.GetRight()) / 2) + 16;
res->Position.y = ((validRange.GetTop() + validRange.GetBottom()) / 2) + 16;
int16_t z = tile_element_height({ res->Position.x, res->Position.y });
int16_t waterHeight = tile_element_water_height({ res->Position.x, res->Position.y });
int16_t z = tile_element_height(res->Position);
int16_t waterHeight = tile_element_water_height(res->Position);
if (waterHeight != 0)
{
z = waterHeight;

View File

@ -64,8 +64,8 @@ private:
res->Position.x = ((validRange.GetLeft() + validRange.GetRight()) / 2) + 16;
res->Position.y = ((validRange.GetTop() + validRange.GetBottom()) / 2) + 16;
int32_t z = tile_element_height({ res->Position.x, res->Position.y });
int16_t waterHeight = tile_element_water_height({ res->Position.x, res->Position.y });
int32_t z = tile_element_height(res->Position);
int16_t waterHeight = tile_element_water_height(res->Position);
if (waterHeight != 0)
{
z = waterHeight;

View File

@ -723,9 +723,9 @@ bool map_can_build_at(CoordsXYZ loc)
bool map_is_location_owned(CoordsXYZ loc)
{
// This check is to avoid throwing lots of messages in logs.
if (map_is_location_valid({ loc.x, loc.y }))
if (map_is_location_valid(loc))
{
auto* surfaceElement = map_get_surface_element_at({ loc.x, loc.y });
auto* surfaceElement = map_get_surface_element_at(loc);
if (surfaceElement != nullptr)
{
if (surfaceElement->GetOwnership() & OWNERSHIP_OWNED)