mirror of https://github.com/OpenRCT2/OpenRCT2.git
Make Map::map_set_tile_elements() use TileCoordsXY
This commit is contained in:
parent
9b1395bfb8
commit
d7efe4de90
|
@ -2435,20 +2435,19 @@ static void sub_6CBCE2(
|
|||
int32_t baseZ = (originZ + trackBlock->z) >> 3;
|
||||
int32_t clearanceZ = ((trackBlock->var_07 + RideData5[ride->type].clearance_height) >> 3) + baseZ + 4;
|
||||
|
||||
int32_t tileX = coords.x >> 5;
|
||||
int32_t tileY = coords.y >> 5;
|
||||
auto tileCoords = TileCoordsXY{ coords };
|
||||
|
||||
// Replace map elements with temporary ones containing track
|
||||
_backupTileElementArrays[0] = map_get_first_element_at(tileX + 0, tileY + 0);
|
||||
_backupTileElementArrays[1] = map_get_first_element_at(tileX + 1, tileY + 0);
|
||||
_backupTileElementArrays[2] = map_get_first_element_at(tileX - 1, tileY + 0);
|
||||
_backupTileElementArrays[3] = map_get_first_element_at(tileX + 0, tileY + 1);
|
||||
_backupTileElementArrays[4] = map_get_first_element_at(tileX + 0, tileY - 1);
|
||||
map_set_tile_elements(tileX + 0, tileY + 0, &_tempTrackTileElement);
|
||||
map_set_tile_elements(tileX + 1, tileY + 0, &_tempSideTrackTileElement);
|
||||
map_set_tile_elements(tileX - 1, tileY + 0, &_tempSideTrackTileElement);
|
||||
map_set_tile_elements(tileX + 0, tileY + 1, &_tempSideTrackTileElement);
|
||||
map_set_tile_elements(tileX + 0, tileY - 1, &_tempSideTrackTileElement);
|
||||
_backupTileElementArrays[0] = map_get_first_element_at(tileCoords.x + 0, tileCoords.y + 0);
|
||||
_backupTileElementArrays[1] = map_get_first_element_at(tileCoords.x + 1, tileCoords.y + 0);
|
||||
_backupTileElementArrays[2] = map_get_first_element_at(tileCoords.x - 1, tileCoords.y + 0);
|
||||
_backupTileElementArrays[3] = map_get_first_element_at(tileCoords.x + 0, tileCoords.y + 1);
|
||||
_backupTileElementArrays[4] = map_get_first_element_at(tileCoords.x + 0, tileCoords.y - 1);
|
||||
map_set_tile_elements({ tileCoords.x + 0, tileCoords.y + 0 }, &_tempTrackTileElement);
|
||||
map_set_tile_elements({ tileCoords.x + 1, tileCoords.y + 0 }, &_tempSideTrackTileElement);
|
||||
map_set_tile_elements({ tileCoords.x - 1, tileCoords.y + 0 }, &_tempSideTrackTileElement);
|
||||
map_set_tile_elements({ tileCoords.x + 0, tileCoords.y + 1 }, &_tempSideTrackTileElement);
|
||||
map_set_tile_elements({ tileCoords.x + 0, tileCoords.y - 1 }, &_tempSideTrackTileElement);
|
||||
|
||||
// Set the temporary track element
|
||||
_tempTrackTileElement.SetType(TILE_ELEMENT_TYPE_TRACK);
|
||||
|
@ -2470,11 +2469,11 @@ static void sub_6CBCE2(
|
|||
sub_68B2B7(session, coords);
|
||||
|
||||
// Restore map elements
|
||||
map_set_tile_elements(tileX + 0, tileY + 0, _backupTileElementArrays[0]);
|
||||
map_set_tile_elements(tileX + 1, tileY + 0, _backupTileElementArrays[1]);
|
||||
map_set_tile_elements(tileX - 1, tileY + 0, _backupTileElementArrays[2]);
|
||||
map_set_tile_elements(tileX + 0, tileY + 1, _backupTileElementArrays[3]);
|
||||
map_set_tile_elements(tileX + 0, tileY - 1, _backupTileElementArrays[4]);
|
||||
map_set_tile_elements({ tileCoords.x + 0, tileCoords.y + 0 }, _backupTileElementArrays[0]);
|
||||
map_set_tile_elements({ tileCoords.x + 1, tileCoords.y + 0 }, _backupTileElementArrays[1]);
|
||||
map_set_tile_elements({ tileCoords.x - 1, tileCoords.y + 0 }, _backupTileElementArrays[2]);
|
||||
map_set_tile_elements({ tileCoords.x + 0, tileCoords.y + 1 }, _backupTileElementArrays[3]);
|
||||
map_set_tile_elements({ tileCoords.x + 0, tileCoords.y - 1 }, _backupTileElementArrays[4]);
|
||||
|
||||
trackBlock++;
|
||||
}
|
||||
|
|
|
@ -192,14 +192,14 @@ TileElement* map_get_nth_element_at(const CoordsXY& coords, int32_t n)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void map_set_tile_elements(int32_t x, int32_t y, TileElement* elements)
|
||||
void map_set_tile_elements(const TileCoordsXY& tilePos, TileElement* elements)
|
||||
{
|
||||
if (!map_is_location_valid({ x * 32, y * 32 }))
|
||||
if (!map_is_location_valid(tilePos.ToCoordsXY()))
|
||||
{
|
||||
log_error("Trying to access element outside of range");
|
||||
return;
|
||||
}
|
||||
gTileElementTilePointers[x + y * MAXIMUM_MAP_SIZE_TECHNICAL] = elements;
|
||||
gTileElementTilePointers[tilePos.x + tilePos.y * MAXIMUM_MAP_SIZE_TECHNICAL] = elements;
|
||||
}
|
||||
|
||||
SurfaceElement* map_get_surface_element_at(const CoordsXY& coords)
|
||||
|
|
|
@ -138,7 +138,7 @@ void map_strip_ghost_flag_from_elements();
|
|||
void map_update_tile_pointers();
|
||||
TileElement* map_get_first_element_at(int32_t x, int32_t y);
|
||||
TileElement* map_get_nth_element_at(const CoordsXY& coords, int32_t n);
|
||||
void map_set_tile_elements(int32_t x, int32_t y, TileElement* elements);
|
||||
void map_set_tile_elements(const TileCoordsXY& tilePos, TileElement* elements);
|
||||
int32_t map_height_from_slope(const CoordsXY& coords, int32_t slope, bool isSloped);
|
||||
BannerElement* map_get_banner_element_at(const CoordsXYZ& bannerPos, uint8_t direction);
|
||||
SurfaceElement* map_get_surface_element_at(const CoordsXY& coords);
|
||||
|
|
Loading…
Reference in New Issue