mirror of https://github.com/OpenRCT2/OpenRCT2.git
Update map tile loop to support large maps
This commit is contained in:
parent
01ee1c5f57
commit
a38154a0f3
|
@ -380,9 +380,8 @@ namespace OpenRCT2
|
||||||
|
|
||||||
cs.ReadWrite(gLandPrice);
|
cs.ReadWrite(gLandPrice);
|
||||||
cs.ReadWrite(gConstructionRightsPrice);
|
cs.ReadWrite(gConstructionRightsPrice);
|
||||||
cs.ReadWrite(gGrassSceneryTileLoopPosition); // TODO (this needs to be xy32)
|
cs.ReadWrite(gGrassSceneryTileLoopPosition);
|
||||||
cs.ReadWrite(gWidePathTileLoopX);
|
cs.ReadWrite(gWidePathTileLoopPosition);
|
||||||
cs.ReadWrite(gWidePathTileLoopY);
|
|
||||||
|
|
||||||
ReadWriteRideRatingCalculationData(cs, gRideRatingsCalcData);
|
ReadWriteRideRatingCalculationData(cs, gRideRatingsCalcData);
|
||||||
});
|
});
|
||||||
|
|
|
@ -447,8 +447,8 @@ public:
|
||||||
|
|
||||||
// pad_13CE730
|
// pad_13CE730
|
||||||
// rct1_scenario_flags
|
// rct1_scenario_flags
|
||||||
gWidePathTileLoopX = _s6.wide_path_tile_loop_x;
|
gWidePathTileLoopPosition.x = _s6.wide_path_tile_loop_x;
|
||||||
gWidePathTileLoopY = _s6.wide_path_tile_loop_y;
|
gWidePathTileLoopPosition.y = _s6.wide_path_tile_loop_y;
|
||||||
// pad_13CE778
|
// pad_13CE778
|
||||||
|
|
||||||
// Fix and set dynamic variables
|
// Fix and set dynamic variables
|
||||||
|
|
|
@ -90,8 +90,7 @@ uint8_t gMapSelectArrowDirection;
|
||||||
|
|
||||||
uint8_t gMapGroundFlags;
|
uint8_t gMapGroundFlags;
|
||||||
|
|
||||||
uint16_t gWidePathTileLoopX;
|
TileCoordsXY gWidePathTileLoopPosition;
|
||||||
uint16_t gWidePathTileLoopY;
|
|
||||||
uint16_t gGrassSceneryTileLoopPosition;
|
uint16_t gGrassSceneryTileLoopPosition;
|
||||||
|
|
||||||
int16_t gMapSizeUnits;
|
int16_t gMapSizeUnits;
|
||||||
|
@ -273,8 +272,7 @@ void map_init(int32_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
gGrassSceneryTileLoopPosition = 0;
|
gGrassSceneryTileLoopPosition = 0;
|
||||||
gWidePathTileLoopX = 0;
|
gWidePathTileLoopPosition = {};
|
||||||
gWidePathTileLoopY = 0;
|
|
||||||
gMapSizeUnits = size * 32 - 32;
|
gMapSizeUnits = size * 32 - 32;
|
||||||
gMapSizeMinus2 = size * 32 - 2;
|
gMapSizeMinus2 = size * 32 - 2;
|
||||||
gMapSize = size;
|
gMapSize = size;
|
||||||
|
@ -599,8 +597,8 @@ void map_update_path_wide_flags()
|
||||||
// Presumably update_path_wide_flags is too computationally expensive to call for every
|
// Presumably update_path_wide_flags is too computationally expensive to call for every
|
||||||
// tile every update, so gWidePathTileLoopX and gWidePathTileLoopY store the x and y
|
// tile every update, so gWidePathTileLoopX and gWidePathTileLoopY store the x and y
|
||||||
// progress. A maximum of 128 calls is done per update.
|
// progress. A maximum of 128 calls is done per update.
|
||||||
uint16_t x = gWidePathTileLoopX;
|
auto x = gWidePathTileLoopPosition.x;
|
||||||
uint16_t y = gWidePathTileLoopY;
|
auto y = gWidePathTileLoopPosition.y;
|
||||||
for (int32_t i = 0; i < 128; i++)
|
for (int32_t i = 0; i < 128; i++)
|
||||||
{
|
{
|
||||||
footpath_update_path_wide_flags({ x, y });
|
footpath_update_path_wide_flags({ x, y });
|
||||||
|
@ -617,8 +615,8 @@ void map_update_path_wide_flags()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gWidePathTileLoopX = x;
|
gWidePathTileLoopPosition.x = x;
|
||||||
gWidePathTileLoopY = y;
|
gWidePathTileLoopPosition.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1485,7 +1483,7 @@ void map_update_tiles()
|
||||||
if (gScreenFlags & ignoreScreenFlags)
|
if (gScreenFlags & ignoreScreenFlags)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Update 43 more tiles
|
// Update 43 more tiles (for each 256x256 block)
|
||||||
for (int32_t j = 0; j < 43; j++)
|
for (int32_t j = 0; j < 43; j++)
|
||||||
{
|
{
|
||||||
int32_t x = 0;
|
int32_t x = 0;
|
||||||
|
@ -1500,13 +1498,20 @@ void map_update_tiles()
|
||||||
interleaved_xy >>= 1;
|
interleaved_xy >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mapPos = TileCoordsXY{ x, y }.ToCoordsXY();
|
// Repeat for each 256x256 block on the map
|
||||||
|
for (int32_t blockY = 0; blockY < gMapSize; blockY += 256)
|
||||||
|
{
|
||||||
|
for (int32_t blockX = 0; blockX < gMapSize; blockX += 256)
|
||||||
|
{
|
||||||
|
auto mapPos = TileCoordsXY{ blockX + x, blockY + y }.ToCoordsXY();
|
||||||
auto* surfaceElement = map_get_surface_element_at(mapPos);
|
auto* surfaceElement = map_get_surface_element_at(mapPos);
|
||||||
if (surfaceElement != nullptr)
|
if (surfaceElement != nullptr)
|
||||||
{
|
{
|
||||||
surfaceElement->UpdateGrassLength(mapPos);
|
surfaceElement->UpdateGrassLength(mapPos);
|
||||||
scenery_update_tile(mapPos);
|
scenery_update_tile(mapPos);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gGrassSceneryTileLoopPosition++;
|
gGrassSceneryTileLoopPosition++;
|
||||||
gGrassSceneryTileLoopPosition &= 0xFFFF;
|
gGrassSceneryTileLoopPosition &= 0xFFFF;
|
||||||
|
|
|
@ -98,8 +98,7 @@ enum
|
||||||
extern const std::array<CoordsXY, 8> CoordsDirectionDelta;
|
extern const std::array<CoordsXY, 8> CoordsDirectionDelta;
|
||||||
extern const TileCoordsXY TileDirectionDelta[];
|
extern const TileCoordsXY TileDirectionDelta[];
|
||||||
|
|
||||||
extern uint16_t gWidePathTileLoopX;
|
extern TileCoordsXY gWidePathTileLoopPosition;
|
||||||
extern uint16_t gWidePathTileLoopY;
|
|
||||||
extern uint16_t gGrassSceneryTileLoopPosition;
|
extern uint16_t gGrassSceneryTileLoopPosition;
|
||||||
|
|
||||||
extern int16_t gMapSizeUnits;
|
extern int16_t gMapSizeUnits;
|
||||||
|
|
Loading…
Reference in New Issue