From ae3c1037ad04dea9611b5864dadf52ec66a86913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Sat, 26 Aug 2023 20:50:06 +0300 Subject: [PATCH] Properly name what the getter/setter for surface object index is --- src/openrct2/EditorObjectSelectionSession.cpp | 2 +- src/openrct2/actions/SurfaceSetStyleAction.cpp | 6 +++--- src/openrct2/paint/tile_element/Paint.Surface.cpp | 4 ++-- src/openrct2/rct1/S4Importer.cpp | 2 +- src/openrct2/rct2/S6Importer.cpp | 2 +- src/openrct2/ride/TrackDesign.cpp | 2 +- src/openrct2/scripting/bindings/world/ScTileElement.cpp | 4 ++-- src/openrct2/world/Map.cpp | 6 +++--- src/openrct2/world/MapGen.cpp | 8 ++++---- src/openrct2/world/Surface.cpp | 8 ++++---- src/openrct2/world/TileElement.h | 4 ++-- test/tests/Pathfinding.cpp | 4 ++-- 12 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/openrct2/EditorObjectSelectionSession.cpp b/src/openrct2/EditorObjectSelectionSession.cpp index e00d02cfee..de6c3a36a6 100644 --- a/src/openrct2/EditorObjectSelectionSession.cpp +++ b/src/openrct2/EditorObjectSelectionSession.cpp @@ -150,7 +150,7 @@ void SetupInUseSelectionFlags() case TileElementType::Surface: { auto surfaceEl = iter.element->AsSurface(); - auto surfaceIndex = surfaceEl->GetSurfaceStyle(); + auto surfaceIndex = surfaceEl->GetSurfaceObjectIndex(); auto edgeIndex = surfaceEl->GetEdgeStyle(); Editor::SetSelectedObject(ObjectType::TerrainSurface, surfaceIndex, ObjectSelectionFlags::InUse); diff --git a/src/openrct2/actions/SurfaceSetStyleAction.cpp b/src/openrct2/actions/SurfaceSetStyleAction.cpp index 217667c29e..266bf1614a 100644 --- a/src/openrct2/actions/SurfaceSetStyleAction.cpp +++ b/src/openrct2/actions/SurfaceSetStyleAction.cpp @@ -113,7 +113,7 @@ GameActions::Result SurfaceSetStyleAction::Query() const if (_surfaceStyle != OBJECT_ENTRY_INDEX_NULL) { - uint8_t curSurfaceStyle = surfaceElement->GetSurfaceStyle(); + uint8_t curSurfaceStyle = surfaceElement->GetSurfaceObjectIndex(); if (_surfaceStyle != curSurfaceStyle) { @@ -181,7 +181,7 @@ GameActions::Result SurfaceSetStyleAction::Execute() const if (_surfaceStyle != OBJECT_ENTRY_INDEX_NULL) { - uint8_t curSurfaceStyle = surfaceElement->GetSurfaceStyle(); + uint8_t curSurfaceStyle = surfaceElement->GetSurfaceObjectIndex(); if (_surfaceStyle != curSurfaceStyle) { @@ -192,7 +192,7 @@ GameActions::Result SurfaceSetStyleAction::Execute() const { surfaceCost += surfaceObject->Price; - surfaceElement->SetSurfaceStyle(_surfaceStyle); + surfaceElement->SetSurfaceObjectIndex(_surfaceStyle); MapInvalidateTileFull(coords); FootpathRemoveLitter({ coords, TileElementHeight(coords) }); diff --git a/src/openrct2/paint/tile_element/Paint.Surface.cpp b/src/openrct2/paint/tile_element/Paint.Surface.cpp index e059180154..ecb093a8f6 100644 --- a/src/openrct2/paint/tile_element/Paint.Surface.cpp +++ b/src/openrct2/paint/tile_element/Paint.Surface.cpp @@ -1029,7 +1029,7 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con const auto zoomLevel = session.DPI.zoom_level; const uint8_t rotation = session.CurrentRotation; - const auto terrain_type = tileElement.GetSurfaceStyle(); + const auto terrain_type = tileElement.GetSurfaceObjectIndex(); const uint8_t surfaceShape = ViewportSurfacePaintSetupGetRelativeSlope(tileElement, rotation); const CoordsXY& base = session.SpritePosition; const CornerHeight& cornerHeights = corner_heights[surfaceShape]; @@ -1076,7 +1076,7 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con descriptor.tile_coords = TileCoordsXY{ position }; descriptor.tile_element = reinterpret_cast(surfaceElement); - descriptor.terrain = surfaceElement->GetSurfaceStyle(); + descriptor.terrain = surfaceElement->GetSurfaceObjectIndex(); descriptor.slope = surfaceSlope; descriptor.corner_heights.top = baseHeight + ch.top; descriptor.corner_heights.right = baseHeight + ch.right; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index a40003c398..16c7a26e58 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1579,7 +1579,7 @@ namespace RCT1 auto edgeStyle = _terrainEdgeTypeToEntryMap[src2->GetEdgeStyle()]; dst2->SetSlope(src2->GetSlope()); - dst2->SetSurfaceStyle(surfaceStyle); + dst2->SetSurfaceObjectIndex(surfaceStyle); dst2->SetEdgeStyle(edgeStyle); dst2->SetGrassLength(src2->GetGrassLength()); dst2->SetOwnership(src2->GetOwnership()); diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 8cf091931d..e38f701a2f 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -1373,7 +1373,7 @@ namespace RCT2 dst2->SetSlope(src2->GetSlope()); - dst2->SetSurfaceStyle(src2->GetSurfaceStyle()); + dst2->SetSurfaceObjectIndex(src2->GetSurfaceStyle()); dst2->SetEdgeStyle(src2->GetEdgeStyle()); dst2->SetGrassLength(src2->GetGrassLength()); diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 12a7782b1d..2f4356f01a 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -2228,7 +2228,7 @@ static void TrackDesignPreviewClearMap() element->SetLastForTile(true); element->AsSurface()->SetSlope(TILE_ELEMENT_SLOPE_FLAT); element->AsSurface()->SetWaterHeight(0); - element->AsSurface()->SetSurfaceStyle(0); + element->AsSurface()->SetSurfaceObjectIndex(0); element->AsSurface()->SetEdgeStyle(0); element->AsSurface()->SetGrassLength(GRASS_LENGTH_CLEAR_0); element->AsSurface()->SetOwnership(OWNERSHIP_OWNED); diff --git a/src/openrct2/scripting/bindings/world/ScTileElement.cpp b/src/openrct2/scripting/bindings/world/ScTileElement.cpp index 1fd3c55e88..94c494b702 100644 --- a/src/openrct2/scripting/bindings/world/ScTileElement.cpp +++ b/src/openrct2/scripting/bindings/world/ScTileElement.cpp @@ -223,7 +223,7 @@ namespace OpenRCT2::Scripting auto* el = _element->AsSurface(); if (el != nullptr) { - duk_push_int(ctx, el->GetSurfaceStyle()); + duk_push_int(ctx, el->GetSurfaceObjectIndex()); } else { @@ -243,7 +243,7 @@ namespace OpenRCT2::Scripting return; } - el->SetSurfaceStyle(value); + el->SetSurfaceObjectIndex(value); Invalidate(); } diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 3882cbd1e6..6d7a5eab54 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -158,7 +158,7 @@ static TileElement GetDefaultSurfaceElement() el.AsSurface()->SetGrassLength(GRASS_LENGTH_CLEAR_0); el.AsSurface()->SetOwnership(OWNERSHIP_UNOWNED); el.AsSurface()->SetParkFences(0); - el.AsSurface()->SetSurfaceStyle(0); + el.AsSurface()->SetSurfaceObjectIndex(0); el.AsSurface()->SetEdgeStyle(0); return el; } @@ -1352,7 +1352,7 @@ void MapRemoveOutOfRangeElements() static void MapExtendBoundarySurfaceExtendTile(const SurfaceElement& sourceTile, SurfaceElement& destTile) { - destTile.SetSurfaceStyle(sourceTile.GetSurfaceStyle()); + destTile.SetSurfaceObjectIndex(sourceTile.GetSurfaceObjectIndex()); destTile.SetEdgeStyle(sourceTile.GetEdgeStyle()); destTile.SetGrassLength(sourceTile.GetGrassLength()); destTile.SetOwnership(OWNERSHIP_UNOWNED); @@ -1439,7 +1439,7 @@ static void ClearElementAt(const CoordsXY& loc, TileElement** elementPtr) element->ClearanceHeight = MINIMUM_LAND_HEIGHT; element->Owner = 0; element->AsSurface()->SetSlope(TILE_ELEMENT_SLOPE_FLAT); - element->AsSurface()->SetSurfaceStyle(0); + element->AsSurface()->SetSurfaceObjectIndex(0); element->AsSurface()->SetEdgeStyle(0); element->AsSurface()->SetGrassLength(GRASS_LENGTH_CLEAR_0); element->AsSurface()->SetOwnership(OWNERSHIP_UNOWNED); diff --git a/src/openrct2/world/MapGen.cpp b/src/openrct2/world/MapGen.cpp index 5a74d19e6c..cd8026565d 100644 --- a/src/openrct2/world/MapGen.cpp +++ b/src/openrct2/world/MapGen.cpp @@ -129,7 +129,7 @@ void MapGenGenerateBlank(MapGenSettings* settings) auto surfaceElement = MapGetSurfaceElementAt(TileCoordsXY{ x, y }); if (surfaceElement != nullptr) { - surfaceElement->SetSurfaceStyle(settings->floor); + surfaceElement->SetSurfaceObjectIndex(settings->floor); surfaceElement->SetEdgeStyle(settings->wall); surfaceElement->BaseHeight = settings->height; surfaceElement->ClearanceHeight = settings->height; @@ -193,7 +193,7 @@ void MapGenGenerate(MapGenSettings* settings) auto surfaceElement = MapGetSurfaceElementAt(TileCoordsXY{ x, y }); if (surfaceElement != nullptr) { - surfaceElement->SetSurfaceStyle(floorTextureId); + surfaceElement->SetSurfaceObjectIndex(floorTextureId); surfaceElement->SetEdgeStyle(edgeTextureId); surfaceElement->BaseHeight = settings->height; surfaceElement->ClearanceHeight = settings->height; @@ -243,7 +243,7 @@ void MapGenGenerate(MapGenSettings* settings) auto surfaceElement = MapGetSurfaceElementAt(TileCoordsXY{ x, y }); if (surfaceElement != nullptr && surfaceElement->BaseHeight < waterLevel + 6) - surfaceElement->SetSurfaceStyle(beachTextureId); + surfaceElement->SetSurfaceObjectIndex(beachTextureId); } } @@ -354,7 +354,7 @@ static void MapGenPlaceTrees() // vegetation float oasisScore = 0.0f; ObjectEntryIndex treeObjectEntryIndex = OBJECT_ENTRY_INDEX_NULL; - const auto& surfaceStyleObject = *TerrainSurfaceObject::GetById(surfaceElement->GetSurfaceStyle()); + const auto& surfaceStyleObject = *TerrainSurfaceObject::GetById(surfaceElement->GetSurfaceObjectIndex()); if (MapGenSurfaceTakesSandTrees(surfaceStyleObject)) { oasisScore = -0.5f; diff --git a/src/openrct2/world/Surface.cpp b/src/openrct2/world/Surface.cpp index 73209d4fdc..3f3ab83963 100644 --- a/src/openrct2/world/Surface.cpp +++ b/src/openrct2/world/Surface.cpp @@ -17,7 +17,7 @@ #include "Location.hpp" #include "Map.h" -ObjectEntryIndex SurfaceElement::GetSurfaceStyle() const +ObjectEntryIndex SurfaceElement::GetSurfaceObjectIndex() const { return SurfaceStyle; } @@ -25,7 +25,7 @@ ObjectEntryIndex SurfaceElement::GetSurfaceStyle() const TerrainSurfaceObject* SurfaceElement::GetSurfaceStyleObject() const { auto& objManager = OpenRCT2::GetContext()->GetObjectManager(); - return static_cast(objManager.GetLoadedObject(ObjectType::TerrainSurface, GetSurfaceStyle())); + return static_cast(objManager.GetLoadedObject(ObjectType::TerrainSurface, GetSurfaceObjectIndex())); } uint32_t SurfaceElement::GetEdgeStyle() const @@ -39,7 +39,7 @@ TerrainEdgeObject* SurfaceElement::GetEdgeStyleObject() const return static_cast(objManager.GetLoadedObject(ObjectType::TerrainEdge, GetEdgeStyle())); } -void SurfaceElement::SetSurfaceStyle(ObjectEntryIndex newStyle) +void SurfaceElement::SetSurfaceObjectIndex(ObjectEntryIndex newStyle) { SurfaceStyle = static_cast(newStyle); } @@ -61,7 +61,7 @@ void SurfaceElement::SetWaterHeight(int32_t newWaterHeight) bool SurfaceElement::CanGrassGrow() const { - auto surfaceStyle = GetSurfaceStyle(); + auto surfaceStyle = GetSurfaceObjectIndex(); auto& objMgr = OpenRCT2::GetContext()->GetObjectManager(); auto obj = objMgr.GetLoadedObject(ObjectType::TerrainSurface, surfaceStyle); if (obj != nullptr) diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index a4d46079be..6b0b9937d5 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -205,9 +205,9 @@ public: uint8_t GetSlope() const; void SetSlope(uint8_t newSlope); - ObjectEntryIndex GetSurfaceStyle() const; + ObjectEntryIndex GetSurfaceObjectIndex() const; TerrainSurfaceObject* GetSurfaceStyleObject() const; - void SetSurfaceStyle(ObjectEntryIndex newStyle); + void SetSurfaceObjectIndex(ObjectEntryIndex newStyle); uint32_t GetEdgeStyle() const; TerrainEdgeObject* GetEdgeStyleObject() const; diff --git a/test/tests/Pathfinding.cpp b/test/tests/Pathfinding.cpp index b956ead827..aba206e43e 100644 --- a/test/tests/Pathfinding.cpp +++ b/test/tests/Pathfinding.cpp @@ -136,7 +136,7 @@ protected: static ::testing::AssertionResult AssertIsStartPosition(const char*, const TileCoordsXYZ& location) { const uint32_t expectedSurfaceStyle = 11u; - const uint32_t style = MapGetSurfaceElementAt(location.ToCoordsXYZ())->GetSurfaceStyle(); + const uint32_t style = MapGetSurfaceElementAt(location.ToCoordsXYZ())->GetSurfaceObjectIndex(); if (style != expectedSurfaceStyle) return ::testing::AssertionFailure() @@ -151,7 +151,7 @@ protected: { const uint32_t forbiddenSurfaceStyle = 8u; - const uint32_t style = MapGetSurfaceElementAt(location.ToCoordsXYZ())->GetSurfaceStyle(); + const uint32_t style = MapGetSurfaceElementAt(location.ToCoordsXYZ())->GetSurfaceObjectIndex(); if (style == forbiddenSurfaceStyle) return ::testing::AssertionFailure()