mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix importing maps containing 255 height elements
This commit is contained in:
parent
915e6447f9
commit
c4b4595708
|
@ -1542,13 +1542,8 @@ namespace RCT1
|
||||||
{
|
{
|
||||||
for (coords.x = 0; coords.x < MAXIMUM_MAP_SIZE_TECHNICAL; coords.x++)
|
for (coords.x = 0; coords.x < MAXIMUM_MAP_SIZE_TECHNICAL; coords.x++)
|
||||||
{
|
{
|
||||||
if (coords.x >= RCT1_MAX_MAP_SIZE || coords.y >= RCT1_MAX_MAP_SIZE)
|
auto tileAdded = false;
|
||||||
{
|
if (coords.x < RCT1_MAX_MAP_SIZE && coords.y < RCT1_MAX_MAP_SIZE)
|
||||||
auto& dstElement = tileElements.emplace_back();
|
|
||||||
dstElement.ClearAs(TILE_ELEMENT_TYPE_SURFACE);
|
|
||||||
dstElement.SetLastForTile(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// This is the equivalent of map_get_first_element_at(x, y), but on S4 data.
|
// This is the equivalent of map_get_first_element_at(x, y), but on S4 data.
|
||||||
RCT12TileElement* srcElement = tilePointerIndex.GetFirstElementAt(coords);
|
RCT12TileElement* srcElement = tilePointerIndex.GetFirstElementAt(coords);
|
||||||
|
@ -1564,12 +1559,20 @@ namespace RCT1
|
||||||
auto numAddedElements = ImportTileElement(dstElement, srcElement);
|
auto numAddedElements = ImportTileElement(dstElement, srcElement);
|
||||||
tileElements.resize(originalSize + numAddedElements);
|
tileElements.resize(originalSize + numAddedElements);
|
||||||
} while (!(srcElement++)->IsLastForTile());
|
} while (!(srcElement++)->IsLastForTile());
|
||||||
|
}
|
||||||
|
|
||||||
// Set last element flag in case the original last element was never added
|
if (!tileAdded)
|
||||||
if (tileElements.size() > 0)
|
{
|
||||||
{
|
// Add a default surface element, we always need at least one element per tile
|
||||||
tileElements.back().SetLastForTile(true);
|
auto& dstElement = tileElements.emplace_back();
|
||||||
}
|
dstElement.ClearAs(TILE_ELEMENT_TYPE_SURFACE);
|
||||||
|
dstElement.SetLastForTile(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set last element flag in case the original last element was never added
|
||||||
|
if (tileElements.size() > 0)
|
||||||
|
{
|
||||||
|
tileElements.back().SetLastForTile(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1096,52 +1096,52 @@ public:
|
||||||
nextElementInvisible = false;
|
nextElementInvisible = false;
|
||||||
restOfTileInvisible = false;
|
restOfTileInvisible = false;
|
||||||
|
|
||||||
if (coords.x >= RCT2_MAXIMUM_MAP_SIZE_TECHNICAL || coords.y >= RCT2_MAXIMUM_MAP_SIZE_TECHNICAL)
|
auto tileAdded = false;
|
||||||
|
if (coords.x < RCT2_MAXIMUM_MAP_SIZE_TECHNICAL && coords.y < RCT2_MAXIMUM_MAP_SIZE_TECHNICAL)
|
||||||
{
|
{
|
||||||
|
const auto* srcElement = tilePointerIndex.GetFirstElementAt(coords);
|
||||||
|
if (srcElement != nullptr)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (srcElement->base_height == RCT12_MAX_ELEMENT_HEIGHT)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto tileElementType = static_cast<RCT12TileElementType>(srcElement->GetType());
|
||||||
|
if (tileElementType == RCT12TileElementType::Corrupt)
|
||||||
|
{
|
||||||
|
// One property of corrupt elements was to hide tops of tower tracks, and to avoid the next
|
||||||
|
// element from being hidden, multiple consecutive corrupt elements were sometimes used. This
|
||||||
|
// would essentially toggle the flag, so we inverse nextElementInvisible here instead of always
|
||||||
|
// setting it to true.
|
||||||
|
nextElementInvisible = !nextElementInvisible;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (tileElementType == RCT12TileElementType::EightCarsCorrupt14
|
||||||
|
|| tileElementType == RCT12TileElementType::EightCarsCorrupt15)
|
||||||
|
{
|
||||||
|
restOfTileInvisible = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& dstElement = tileElements.emplace_back();
|
||||||
|
ImportTileElement(&dstElement, srcElement, nextElementInvisible || restOfTileInvisible);
|
||||||
|
nextElementInvisible = false;
|
||||||
|
tileAdded = true;
|
||||||
|
} while (!(srcElement++)->IsLastForTile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tileAdded)
|
||||||
|
{
|
||||||
|
// Add a default surface element, we always need at least one element per tile
|
||||||
auto& dstElement = tileElements.emplace_back();
|
auto& dstElement = tileElements.emplace_back();
|
||||||
dstElement.ClearAs(TILE_ELEMENT_TYPE_SURFACE);
|
dstElement.ClearAs(TILE_ELEMENT_TYPE_SURFACE);
|
||||||
dstElement.SetLastForTile(true);
|
dstElement.SetLastForTile(true);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RCT12TileElement* srcElement = tilePointerIndex.GetFirstElementAt(coords);
|
|
||||||
// This might happen with damaged parks. Make sure there is *something* to avoid crashes.
|
|
||||||
if (srcElement == nullptr)
|
|
||||||
{
|
|
||||||
auto& dstElement = tileElements.emplace_back();
|
|
||||||
dstElement.ClearAs(TILE_ELEMENT_TYPE_SURFACE);
|
|
||||||
dstElement.SetLastForTile(true);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (srcElement->base_height == RCT12_MAX_ELEMENT_HEIGHT)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto tileElementType = static_cast<RCT12TileElementType>(srcElement->GetType());
|
|
||||||
if (tileElementType == RCT12TileElementType::Corrupt)
|
|
||||||
{
|
|
||||||
// One property of corrupt elements was to hide tops of tower tracks, and to avoid the next element from
|
|
||||||
// being hidden, multiple consecutive corrupt elements were sometimes used. This would essentially
|
|
||||||
// toggle the flag, so we inverse nextElementInvisible here instead of always setting it to true.
|
|
||||||
nextElementInvisible = !nextElementInvisible;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (tileElementType == RCT12TileElementType::EightCarsCorrupt14
|
|
||||||
|| tileElementType == RCT12TileElementType::EightCarsCorrupt15)
|
|
||||||
{
|
|
||||||
restOfTileInvisible = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto& dstElement = tileElements.emplace_back();
|
|
||||||
ImportTileElement(&dstElement, srcElement, nextElementInvisible || restOfTileInvisible);
|
|
||||||
nextElementInvisible = false;
|
|
||||||
} while (!(srcElement++)->IsLastForTile());
|
|
||||||
|
|
||||||
// Set last element flag in case the original last element was never added
|
// Set last element flag in case the original last element was never added
|
||||||
if (tileElements.size() > 0)
|
if (tileElements.size() > 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue