forked from rosebudai/OpenRCT2-Web
Introduce SurfaceElement::hasOwnership()
This commit is contained in:
11 files changed
+30
-24
No files matched your search
@@ -858,7 +858,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (surfaceElement->getWaterHeight() > 0)
|
||||
colour = kWaterColour;
|
||||
|
||||
if (!(surfaceElement->getOwnership().has(OwnershipFlag::owned)))
|
||||
if (!(surfaceElement->hasOwnership(OwnershipFlag::owned)))
|
||||
colour = MapColourUnowned(colour);
|
||||
|
||||
const int32_t maxSupportedTileElementType = static_cast<int32_t>(std::size(kElementTypeOverwriteColour));
|
||||
@@ -914,7 +914,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (tileElement->asSurface()->getWaterHeight() > 0)
|
||||
// Why is this a different water colour as above (195)?
|
||||
colourB = ColourPair(PaletteIndex::pi194);
|
||||
if (!(tileElement->asSurface()->getOwnership().has(OwnershipFlag::owned)))
|
||||
if (!(tileElement->asSurface()->hasOwnership(OwnershipFlag::owned)))
|
||||
colourB = MapColourUnowned(colourB);
|
||||
break;
|
||||
case TileElementType::path:
|
||||
|
||||
@@ -1156,13 +1156,13 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
// Land ownership
|
||||
StringId landOwnership;
|
||||
if (surfaceEl.getOwnership().has(OwnershipFlag::owned))
|
||||
if (surfaceEl.hasOwnership(OwnershipFlag::owned))
|
||||
landOwnership = STR_LAND_OWNED;
|
||||
else if (surfaceEl.getOwnership().has(OwnershipFlag::forSale))
|
||||
else if (surfaceEl.hasOwnership(OwnershipFlag::forSale))
|
||||
landOwnership = STR_LAND_SALE;
|
||||
else if (surfaceEl.getOwnership().has(OwnershipFlag::constructionRightsOwned))
|
||||
else if (surfaceEl.hasOwnership(OwnershipFlag::constructionRightsOwned))
|
||||
landOwnership = STR_CONSTRUCTION_RIGHTS_OWNED;
|
||||
else if (surfaceEl.getOwnership().has(OwnershipFlag::constructionRightsAvailable))
|
||||
else if (surfaceEl.hasOwnership(OwnershipFlag::constructionRightsAvailable))
|
||||
landOwnership = STR_CONSTRUCTION_RIGHTS_SALE;
|
||||
else
|
||||
landOwnership = STR_TILE_INSPECTOR_LAND_NOT_OWNED_AND_NOT_AVAILABLE;
|
||||
|
||||
@@ -448,7 +448,7 @@ namespace OpenRCT2::GameActions
|
||||
if (surfaceElement == nullptr)
|
||||
continue;
|
||||
|
||||
if (surfaceElement != nullptr && (surfaceElement->getOwnership().has(OwnershipFlag::owned))
|
||||
if (surfaceElement != nullptr && (surfaceElement->hasOwnership(OwnershipFlag::owned))
|
||||
&& surfaceElement->getWaterHeight() == 0 && surfaceElement->canGrassGrow())
|
||||
{
|
||||
surfaceElement->setGrassLength(length);
|
||||
@@ -791,7 +791,7 @@ namespace OpenRCT2::GameActions
|
||||
continue;
|
||||
|
||||
// Ignore already owned tiles.
|
||||
if (surfaceElement->getOwnership().has(OwnershipFlag::owned))
|
||||
if (surfaceElement->hasOwnership(OwnershipFlag::owned))
|
||||
continue;
|
||||
|
||||
int32_t baseZ = surfaceElement->getBaseZ();
|
||||
|
||||
@@ -122,12 +122,12 @@ namespace OpenRCT2::GameActions
|
||||
switch (_setting)
|
||||
{
|
||||
case LandBuyRightSetting::buyLand: // 0
|
||||
if (surfaceElement->getOwnership().has(OwnershipFlag::owned))
|
||||
if (surfaceElement->hasOwnership(OwnershipFlag::owned))
|
||||
{ // If the land is already owned
|
||||
return res;
|
||||
}
|
||||
|
||||
if (gLegacyScene == LegacyScene::scenarioEditor || !surfaceElement->getOwnership().has(OwnershipFlag::forSale))
|
||||
if (gLegacyScene == LegacyScene::scenarioEditor || !surfaceElement->hasOwnership(OwnershipFlag::forSale))
|
||||
{
|
||||
return Result(Status::notOwned, kErrorTitles[EnumValue(_setting)], STR_LAND_NOT_FOR_SALE);
|
||||
}
|
||||
@@ -146,7 +146,7 @@ namespace OpenRCT2::GameActions
|
||||
}
|
||||
|
||||
if (gLegacyScene == LegacyScene::scenarioEditor
|
||||
|| !surfaceElement->getOwnership().has(OwnershipFlag::constructionRightsAvailable))
|
||||
|| !surfaceElement->hasOwnership(OwnershipFlag::constructionRightsAvailable))
|
||||
{
|
||||
return Result(Status::notOwned, kErrorTitles[EnumValue(_setting)], STR_CONSTRUCTION_RIGHTS_NOT_FOR_SALE);
|
||||
}
|
||||
|
||||
@@ -859,7 +859,7 @@ static void PaintSurfaceLandOwnership(
|
||||
auto [aboveWaterHeight, aboveWaterSurfaceShape] = SurfaceGetHeightAboveWater(tileElement, height, surfaceShape);
|
||||
|
||||
// Loc660E9A:
|
||||
if (tileElement.getOwnership().has(OwnershipFlag::owned))
|
||||
if (tileElement.hasOwnership(OwnershipFlag::owned))
|
||||
{
|
||||
assert(static_cast<size_t>(surfaceShape) < std::size(Byte97B444));
|
||||
assert(static_cast<size_t>(aboveWaterSurfaceShape) < std::size(Byte97B444));
|
||||
@@ -877,7 +877,7 @@ static void PaintSurfaceLandOwnership(
|
||||
session.LastPS = backup;
|
||||
}
|
||||
}
|
||||
else if (tileElement.getOwnership().has(OwnershipFlag::forSale))
|
||||
else if (tileElement.hasOwnership(OwnershipFlag::forSale))
|
||||
{
|
||||
const auto pos = CoordsXYZ(session.MapPosition.x + 16, session.MapPosition.y + 16, aboveWaterHeight);
|
||||
const auto height2 = TileElementHeight(pos, aboveWaterSurfaceShape) + ForSaleSignZOffset;
|
||||
@@ -893,7 +893,7 @@ static void PaintSurfaceConstructionRights(
|
||||
{
|
||||
auto [aboveWaterHeight, aboveWaterSurfaceShape] = SurfaceGetHeightAboveWater(tileElement, height, surfaceShape);
|
||||
|
||||
if (tileElement.getOwnership().has(OwnershipFlag::constructionRightsOwned))
|
||||
if (tileElement.hasOwnership(OwnershipFlag::constructionRightsOwned))
|
||||
{
|
||||
assert(static_cast<size_t>(surfaceShape) < std::size(Byte97B444));
|
||||
assert(static_cast<size_t>(aboveWaterSurfaceShape) < std::size(Byte97B444));
|
||||
@@ -911,7 +911,7 @@ static void PaintSurfaceConstructionRights(
|
||||
session.LastPS = backup;
|
||||
}
|
||||
}
|
||||
else if (tileElement.getOwnership().has(OwnershipFlag::constructionRightsAvailable))
|
||||
else if (tileElement.hasOwnership(OwnershipFlag::constructionRightsAvailable))
|
||||
{
|
||||
const auto pos = CoordsXYZ(session.MapPosition.x + 16, session.MapPosition.y + 16, aboveWaterHeight);
|
||||
const auto height2 = TileElementHeight(pos, aboveWaterSurfaceShape) + ForSaleSignZOffset;
|
||||
@@ -1080,7 +1080,7 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con
|
||||
PaintSurfaceLandOwnership(session, tileElement, height, surfaceShape);
|
||||
}
|
||||
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_CONSTRUCTION_RIGHTS && !(tileElement.getOwnership().has(OwnershipFlag::owned)))
|
||||
if (session.ViewFlags & VIEWPORT_FLAG_CONSTRUCTION_RIGHTS && !(tileElement.hasOwnership(OwnershipFlag::owned)))
|
||||
{
|
||||
PaintSurfaceConstructionRights(session, tileElement, height, surfaceShape);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace OpenRCT2
|
||||
}
|
||||
}
|
||||
|
||||
isOutsidePark |= !(surfaceElement->getOwnership().has(OwnershipFlag::owned));
|
||||
isOutsidePark |= !(surfaceElement->hasOwnership(OwnershipFlag::owned));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -362,7 +362,7 @@ namespace OpenRCT2::Scripting
|
||||
auto* el = data->element->asSurface();
|
||||
if (el != nullptr)
|
||||
{
|
||||
return JS_NewBool(ctx, el->getOwnership().has(OwnershipFlag::owned));
|
||||
return JS_NewBool(ctx, el->hasOwnership(OwnershipFlag::owned));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -820,10 +820,10 @@ namespace OpenRCT2
|
||||
auto* surfaceElement = MapGetSurfaceElementAt(loc);
|
||||
if (surfaceElement != nullptr)
|
||||
{
|
||||
if (surfaceElement->getOwnership().has(OwnershipFlag::owned))
|
||||
if (surfaceElement->hasOwnership(OwnershipFlag::owned))
|
||||
return true;
|
||||
|
||||
if (surfaceElement->getOwnership().has(OwnershipFlag::constructionRightsOwned))
|
||||
if (surfaceElement->hasOwnership(OwnershipFlag::constructionRightsOwned))
|
||||
{
|
||||
if (loc.z < surfaceElement->getBaseZ()
|
||||
|| loc.z >= surfaceElement->getBaseZ() + kConstructionRightsClearanceBig)
|
||||
@@ -845,7 +845,7 @@ namespace OpenRCT2
|
||||
auto surfaceElement = MapGetSurfaceElementAt(coords);
|
||||
if (surfaceElement == nullptr)
|
||||
return false;
|
||||
if (surfaceElement->getOwnership().has(OwnershipFlag::owned))
|
||||
if (surfaceElement->hasOwnership(OwnershipFlag::owned))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -860,9 +860,9 @@ namespace OpenRCT2
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (surfaceElement->getOwnership().has(OwnershipFlag::owned))
|
||||
if (surfaceElement->hasOwnership(OwnershipFlag::owned))
|
||||
return true;
|
||||
if (surfaceElement->getOwnership().has(OwnershipFlag::constructionRightsOwned))
|
||||
if (surfaceElement->hasOwnership(OwnershipFlag::constructionRightsOwned))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -641,7 +641,7 @@ namespace OpenRCT2::Park
|
||||
return;
|
||||
|
||||
uint8_t newFences = 0;
|
||||
if (!surfaceElement->getOwnership().has(OwnershipFlag::owned))
|
||||
if (!surfaceElement->hasOwnership(OwnershipFlag::owned))
|
||||
{
|
||||
bool fenceRequired = true;
|
||||
|
||||
|
||||
@@ -204,6 +204,11 @@ namespace OpenRCT2
|
||||
ownership |= (((newOwnership.holder) << 4) & kTileElementSurfaceOwnershipMask);
|
||||
}
|
||||
|
||||
bool SurfaceElement::hasOwnership(OwnershipFlag flag) const
|
||||
{
|
||||
return getOwnership().has(flag);
|
||||
}
|
||||
|
||||
uint8_t SurfaceElement::getParkFences() const
|
||||
{
|
||||
return (ownership & kTileElementSurfaceParkFenceMask);
|
||||
|
||||
@@ -74,6 +74,7 @@ namespace OpenRCT2
|
||||
|
||||
OwnershipFlags getOwnership() const;
|
||||
void setOwnership(OwnershipFlags newOwnership);
|
||||
bool hasOwnership(OwnershipFlag flag) const;
|
||||
|
||||
int32_t getWaterHeight() const;
|
||||
void setWaterHeight(int32_t newWaterHeight);
|
||||
|
||||
Reference in new issue
Block a user