1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-30 18:25:16 +01:00

Fix #18583: Land dropdown is incorrect if there are surface entry holes (#20035)

This commit is contained in:
Ted John
2023-04-24 22:00:12 +01:00
committed by GitHub
parent 0cf24f0100
commit 9dac7f889f
4 changed files with 47 additions and 2 deletions

View File

@@ -21,6 +21,7 @@
- Fix: [#13130] Android always defaulting to UK locale for language, currency and temperature.
- Fix: [#13397] Ride simulation causes strange station behaviour and makes the ride unusable in some cases.
- Fix: [#16791] Rotodrop top piece replicates when walls are placed around it and clearance checks are disabled (original bug).
- Fix: [#18583] Land dropdown is incorrect if there are surface entry index holes.
- Fix: [#18895] Responding mechanic blocked at level crossing.
- Fix: [#19231] Crash due to null pointer to previously deleted banner in tile copy/paste functionality.
- Fix: [#19296] Crash due to a race condition for parallel object loading.

View File

@@ -89,6 +89,26 @@ void LandTool::ShowSurfaceStyleDropdown(WindowBase* w, Widget* widget, ObjectEnt
gDropdownDefaultIndex = defaultIndex;
}
ObjectEntryIndex LandTool::GetSurfaceStyleFromDropdownIndex(size_t index)
{
auto& objManager = GetContext()->GetObjectManager();
auto itemIndex = 0U;
for (size_t i = 0; i < MAX_TERRAIN_SURFACE_OBJECTS; i++)
{
const auto surfaceObj = static_cast<TerrainSurfaceObject*>(objManager.GetLoadedObject(ObjectType::TerrainSurface, i));
// If fallback images are loaded, the RCT1 styles will just look like copies of already existing styles, so hide them.
if (surfaceObj != nullptr && !surfaceObj->UsesFallbackImages())
{
if (itemIndex == index)
{
return static_cast<ObjectEntryIndex>(i);
}
itemIndex++;
}
}
return OBJECT_ENTRY_INDEX_NULL;
}
void LandTool::ShowEdgeStyleDropdown(WindowBase* w, Widget* widget, ObjectEntryIndex currentEdgeType)
{
auto& objManager = GetContext()->GetObjectManager();
@@ -119,3 +139,23 @@ void LandTool::ShowEdgeStyleDropdown(WindowBase* w, Widget* widget, ObjectEntryI
gDropdownDefaultIndex = defaultIndex;
}
ObjectEntryIndex LandTool::GetEdgeStyleFromDropdownIndex(size_t index)
{
auto& objManager = GetContext()->GetObjectManager();
auto itemIndex = 0U;
for (size_t i = 0; i < MAX_TERRAIN_EDGE_OBJECTS; i++)
{
const auto edgeObj = static_cast<TerrainEdgeObject*>(objManager.GetLoadedObject(ObjectType::TerrainEdge, i));
// If fallback images are loaded, the RCT1 styles will just look like copies of already existing styles, so hide them.
if (edgeObj != nullptr && !edgeObj->UsesFallbackImages())
{
if (itemIndex == index)
{
return static_cast<ObjectEntryIndex>(i);
}
itemIndex++;
}
}
return OBJECT_ENTRY_INDEX_NULL;
}

View File

@@ -30,5 +30,7 @@ namespace LandTool
{
uint32_t SizeToSpriteIndex(uint16_t size);
void ShowSurfaceStyleDropdown(WindowBase* w, Widget* widget, ObjectEntryIndex currentSurfaceType);
ObjectEntryIndex GetSurfaceStyleFromDropdownIndex(size_t index);
void ShowEdgeStyleDropdown(WindowBase* w, Widget* widget, ObjectEntryIndex currentEdgeType);
ObjectEntryIndex GetEdgeStyleFromDropdownIndex(size_t index);
} // namespace LandTool

View File

@@ -156,7 +156,8 @@ public:
if (dropdownIndex == -1)
dropdownIndex = gDropdownHighlightedIndex;
type = (dropdownIndex == -1) ? _selectedFloorTexture : dropdownIndex;
type = (dropdownIndex == -1) ? _selectedFloorTexture
: LandTool::GetSurfaceStyleFromDropdownIndex(static_cast<size_t>(dropdownIndex));
if (gLandToolTerrainSurface == type)
{
@@ -173,7 +174,8 @@ public:
if (dropdownIndex == -1)
dropdownIndex = gDropdownHighlightedIndex;
type = (dropdownIndex == -1) ? _selectedWallTexture : dropdownIndex;
type = (dropdownIndex == -1) ? _selectedWallTexture
: LandTool::GetEdgeStyleFromDropdownIndex(static_cast<size_t>(dropdownIndex));
if (gLandToolTerrainEdge == type)
{