Prefer std::optional over LOCATION_NULL on Viewport (#10297)

This commit is contained in:
Tulio Leao 2019-11-29 13:17:01 -03:00 committed by Michael Steenbeek
parent 7e96ddf1d6
commit 4537c061d9
9 changed files with 161 additions and 133 deletions

View File

@ -295,9 +295,9 @@ static void window_land_rights_tool_update_land_rights(ScreenCoordsXY screenCoor
map_invalidate_selection_rect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
CoordsXY mapTile = screen_get_map_xy(screenCoords, nullptr);
auto mapTile = screen_get_map_xy(screenCoords, nullptr);
if (mapTile.x == LOCATION_NULL)
if (!mapTile)
{
if (_landRightsCost != MONEY32_UNDEFINED)
{
@ -328,35 +328,35 @@ static void window_land_rights_tool_update_land_rights(ScreenCoordsXY screenCoor
int16_t tool_length = (tool_size - 1) * 32;
// Move to tool bottom left
mapTile.x -= (tool_size - 1) * 16;
mapTile.y -= (tool_size - 1) * 16;
mapTile.x &= 0xFFE0;
mapTile.y &= 0xFFE0;
mapTile->x -= (tool_size - 1) * 16;
mapTile->y -= (tool_size - 1) * 16;
mapTile->x &= 0xFFE0;
mapTile->y &= 0xFFE0;
if (gMapSelectPositionA.x != mapTile.x)
if (gMapSelectPositionA.x != mapTile->x)
{
gMapSelectPositionA.x = mapTile.x;
gMapSelectPositionA.x = mapTile->x;
state_changed++;
}
if (gMapSelectPositionA.y != mapTile.y)
if (gMapSelectPositionA.y != mapTile->y)
{
gMapSelectPositionA.y = mapTile.y;
gMapSelectPositionA.y = mapTile->y;
state_changed++;
}
mapTile.x += tool_length;
mapTile.y += tool_length;
mapTile->x += tool_length;
mapTile->y += tool_length;
if (gMapSelectPositionB.x != mapTile.x)
if (gMapSelectPositionB.x != mapTile->x)
{
gMapSelectPositionB.x = mapTile.x;
gMapSelectPositionB.x = mapTile->x;
state_changed++;
}
if (gMapSelectPositionB.y != mapTile.y)
if (gMapSelectPositionB.y != mapTile->y)
{
gMapSelectPositionB.y = mapTile.y;
gMapSelectPositionB.y = mapTile->y;
state_changed++;
}

View File

@ -1162,8 +1162,8 @@ static void window_map_set_land_rights_tool_update(ScreenCoordsXY screenCoords)
map_invalidate_selection_rect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
CoordsXY mapCoords = screen_get_map_xy(screenCoords, &viewport);
if (mapCoords.x == LOCATION_NULL)
auto mapCoords = screen_get_map_xy(screenCoords, &viewport);
if (!mapCoords)
return;
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
@ -1175,12 +1175,12 @@ static void window_map_set_land_rights_tool_update(ScreenCoordsXY screenCoords)
int32_t size = (landRightsToolSize * 32) - 32;
int32_t radius = (landRightsToolSize * 16) - 16;
mapCoords.x = (mapCoords.x - radius) & 0xFFE0;
mapCoords.y = (mapCoords.y - radius) & 0xFFE0;
gMapSelectPositionA.x = mapCoords.x;
gMapSelectPositionA.y = mapCoords.y;
gMapSelectPositionB.x = mapCoords.x + size;
gMapSelectPositionB.y = mapCoords.y + size;
mapCoords->x = (mapCoords->x - radius) & 0xFFE0;
mapCoords->y = (mapCoords->y - radius) & 0xFFE0;
gMapSelectPositionA.x = mapCoords->x;
gMapSelectPositionA.y = mapCoords->y;
gMapSelectPositionB.x = mapCoords->x + size;
gMapSelectPositionB.y = mapCoords->y + size;
map_invalidate_selection_rect();
}

View File

@ -2192,7 +2192,15 @@ static std::optional<CoordsXY> ride_get_place_position_from_screen_position(Scre
else
{
auto mapZ = _trackPlaceCtrlZ;
mapCoords = screen_get_map_xy_with_z(screenCoords, mapZ);
auto mapXYCoords = screen_get_map_xy_with_z(screenCoords, mapZ);
if (mapXYCoords)
{
mapCoords = *mapXYCoords;
}
else
{
return std::nullopt;
}
if (_trackPlaceShiftState != 0)
{

View File

@ -1346,12 +1346,14 @@ static void sub_6E1F34(
// If CTRL not pressed
if (!gSceneryCtrlPressed)
{
CoordsXY gridCoords = screen_get_map_xy_quadrant({ x, y }, &cl);
*grid_x = gridCoords.x;
*grid_y = gridCoords.y;
if (*grid_x == LOCATION_NULL)
auto gridCoords = screen_get_map_xy_quadrant({ x, y }, &cl);
if (!gridCoords)
{
*grid_x = LOCATION_NULL;
return;
}
*grid_x = gridCoords->x;
*grid_y = gridCoords->y;
gSceneryPlaceZ = 0;
@ -1467,8 +1469,15 @@ static void sub_6E1F34(
{
int16_t z = gSceneryCtrlPressZ;
auto coords = screen_get_map_xy_with_z({ x, y }, z);
*grid_x = coords.x;
*grid_y = coords.y;
if (coords)
{
*grid_x = coords->x;
*grid_y = coords->y;
}
else
{
*grid_x = LOCATION_NULL;
}
// If SHIFT pressed
if (gSceneryShiftPressed)
{
@ -1538,12 +1547,14 @@ static void sub_6E1F34(
// If CTRL not pressed
if (!gSceneryCtrlPressed)
{
CoordsXY gridCoords = screen_get_map_xy_side({ x, y }, &cl);
*grid_x = gridCoords.x;
*grid_y = gridCoords.y;
if (*grid_x == LOCATION_NULL)
auto gridCoords = screen_get_map_xy_side({ x, y }, &cl);
if (!gridCoords)
{
*grid_x = LOCATION_NULL;
return;
}
*grid_x = gridCoords->x;
*grid_y = gridCoords->y;
gSceneryPlaceZ = 0;
@ -1638,8 +1649,15 @@ static void sub_6E1F34(
{
int16_t z = gSceneryCtrlPressZ;
auto coords = screen_get_map_xy_with_z({ x, y }, z);
*grid_x = coords.x;
*grid_y = coords.y;
if (coords)
{
*grid_x = coords->x;
*grid_y = coords->y;
}
else
{
*grid_x = LOCATION_NULL;
}
// If SHIFT pressed
if (gSceneryShiftPressed)
@ -2000,9 +2018,9 @@ static uint8_t top_toolbar_tool_update_land_paint(int16_t x, int16_t y)
map_invalidate_selection_rect();
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
CoordsXY mapTile = screen_get_map_xy({ x, y }, nullptr);
auto mapTile = screen_get_map_xy({ x, y }, nullptr);
if (mapTile.x == LOCATION_NULL)
if (!mapTile)
{
if (gClearSceneryCost != MONEY32_UNDEFINED)
{
@ -2028,35 +2046,35 @@ static uint8_t top_toolbar_tool_update_land_paint(int16_t x, int16_t y)
int16_t tool_length = (tool_size - 1) * 32;
// Move to tool bottom left
mapTile.x -= (tool_size - 1) * 16;
mapTile.y -= (tool_size - 1) * 16;
mapTile.x &= 0xFFE0;
mapTile.y &= 0xFFE0;
mapTile->x -= (tool_size - 1) * 16;
mapTile->y -= (tool_size - 1) * 16;
mapTile->x &= 0xFFE0;
mapTile->y &= 0xFFE0;
if (gMapSelectPositionA.x != mapTile.x)
if (gMapSelectPositionA.x != mapTile->x)
{
gMapSelectPositionA.x = mapTile.x;
gMapSelectPositionA.x = mapTile->x;
state_changed++;
}
if (gMapSelectPositionA.y != mapTile.y)
if (gMapSelectPositionA.y != mapTile->y)
{
gMapSelectPositionA.y = mapTile.y;
gMapSelectPositionA.y = mapTile->y;
state_changed++;
}
mapTile.x += tool_length;
mapTile.y += tool_length;
mapTile->x += tool_length;
mapTile->y += tool_length;
if (gMapSelectPositionB.x != mapTile.x)
if (gMapSelectPositionB.x != mapTile->x)
{
gMapSelectPositionB.x = mapTile.x;
gMapSelectPositionB.x = mapTile->x;
state_changed++;
}
if (gMapSelectPositionB.y != mapTile.y)
if (gMapSelectPositionB.y != mapTile->y)
{
gMapSelectPositionB.y = mapTile.y;
gMapSelectPositionB.y = mapTile->y;
state_changed++;
}
@ -2111,7 +2129,7 @@ static void top_toolbar_tool_update_land(int16_t x, int16_t y)
}
int16_t tool_size = gLandToolSize;
CoordsXY mapTile;
std::optional<CoordsXY> mapTile;
uint8_t side;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
@ -2122,7 +2140,7 @@ static void top_toolbar_tool_update_land(int16_t x, int16_t y)
screen_pos_to_map_pos({ x, y }, &selectionType);
mapTile = screen_get_map_xy_side({ x, y }, &side);
if (mapTile.x == LOCATION_NULL)
if (!mapTile)
{
money32 lower_cost = MONEY32_UNDEFINED;
money32 raise_cost = MONEY32_UNDEFINED;
@ -2156,27 +2174,27 @@ static void top_toolbar_tool_update_land(int16_t x, int16_t y)
state_changed++;
}
if (gMapSelectPositionA.x != mapTile.x)
if (gMapSelectPositionA.x != mapTile->x)
{
gMapSelectPositionA.x = mapTile.x;
gMapSelectPositionA.x = mapTile->x;
state_changed++;
}
if (gMapSelectPositionA.y != mapTile.y)
if (gMapSelectPositionA.y != mapTile->y)
{
gMapSelectPositionA.y = mapTile.y;
gMapSelectPositionA.y = mapTile->y;
state_changed++;
}
if (gMapSelectPositionB.x != mapTile.x)
if (gMapSelectPositionB.x != mapTile->x)
{
gMapSelectPositionB.x = mapTile.x;
gMapSelectPositionB.x = mapTile->x;
state_changed++;
}
if (gMapSelectPositionB.y != mapTile.y)
if (gMapSelectPositionB.y != mapTile->y)
{
gMapSelectPositionB.y = mapTile.y;
gMapSelectPositionB.y = mapTile->y;
state_changed++;
}
@ -2199,7 +2217,7 @@ static void top_toolbar_tool_update_land(int16_t x, int16_t y)
// Get map coordinates and the side of the tile that is being hovered over
mapTile = screen_get_map_xy_side({ x, y }, &side);
if (mapTile.x == LOCATION_NULL)
if (!mapTile)
{
money32 lower_cost = MONEY32_UNDEFINED;
money32 raise_cost = MONEY32_UNDEFINED;
@ -2244,33 +2262,33 @@ static void top_toolbar_tool_update_land(int16_t x, int16_t y)
case MAP_SELECT_TYPE_EDGE_0:
case MAP_SELECT_TYPE_EDGE_2:
// Line
mapTile.y -= (tool_size - 1) * 16;
mapTile.y &= 0xFFE0;
mapTile->y -= (tool_size - 1) * 16;
mapTile->y &= 0xFFE0;
break;
case MAP_SELECT_TYPE_EDGE_1:
case MAP_SELECT_TYPE_EDGE_3:
// Line
mapTile.x -= (tool_size - 1) * 16;
mapTile.x &= 0xFFE0;
mapTile->x -= (tool_size - 1) * 16;
mapTile->x &= 0xFFE0;
break;
default:
// Move to tool bottom left
mapTile.x -= (tool_size - 1) * 16;
mapTile.y -= (tool_size - 1) * 16;
mapTile.x &= 0xFFE0;
mapTile.y &= 0xFFE0;
mapTile->x -= (tool_size - 1) * 16;
mapTile->y -= (tool_size - 1) * 16;
mapTile->x &= 0xFFE0;
mapTile->y &= 0xFFE0;
break;
}
if (gMapSelectPositionA.x != mapTile.x)
if (gMapSelectPositionA.x != mapTile->x)
{
gMapSelectPositionA.x = mapTile.x;
gMapSelectPositionA.x = mapTile->x;
state_changed++;
}
if (gMapSelectPositionA.y != mapTile.y)
if (gMapSelectPositionA.y != mapTile->y)
{
gMapSelectPositionA.y = mapTile.y;
gMapSelectPositionA.y = mapTile->y;
state_changed++;
}
@ -2280,30 +2298,30 @@ static void top_toolbar_tool_update_land(int16_t x, int16_t y)
case MAP_SELECT_TYPE_EDGE_0:
case MAP_SELECT_TYPE_EDGE_2:
// Line
mapTile.y += tool_length;
mapTile->y += tool_length;
gMapSelectType = MAP_SELECT_TYPE_FULL;
break;
case MAP_SELECT_TYPE_EDGE_1:
case MAP_SELECT_TYPE_EDGE_3:
// Line
mapTile.x += tool_length;
mapTile->x += tool_length;
gMapSelectType = MAP_SELECT_TYPE_FULL;
break;
default:
mapTile.x += tool_length;
mapTile.y += tool_length;
mapTile->x += tool_length;
mapTile->y += tool_length;
break;
}
if (gMapSelectPositionB.x != mapTile.x)
if (gMapSelectPositionB.x != mapTile->x)
{
gMapSelectPositionB.x = mapTile.x;
gMapSelectPositionB.x = mapTile->x;
state_changed++;
}
if (gMapSelectPositionB.y != mapTile.y)
if (gMapSelectPositionB.y != mapTile->y)
{
gMapSelectPositionB.y = mapTile.y;
gMapSelectPositionB.y = mapTile->y;
state_changed++;
}

View File

@ -998,21 +998,21 @@ static void viewport_paint_weather_gloom(rct_drawpixelinfo* dpi)
*/
CoordsXY screen_pos_to_map_pos(ScreenCoordsXY screenCoords, int32_t* direction)
{
CoordsXY mapCoords = screen_get_map_xy(screenCoords, nullptr);
if (mapCoords.x == LOCATION_NULL)
auto mapCoords = screen_get_map_xy(screenCoords, nullptr);
if (!mapCoords)
return {};
int32_t my_direction;
int32_t dist_from_centre_x = abs(mapCoords.x % 32);
int32_t dist_from_centre_y = abs(mapCoords.y % 32);
int32_t dist_from_centre_x = abs(mapCoords->x % 32);
int32_t dist_from_centre_y = abs(mapCoords->y % 32);
if (dist_from_centre_x > 8 && dist_from_centre_x < 24 && dist_from_centre_y > 8 && dist_from_centre_y < 24)
{
my_direction = 4;
}
else
{
int16_t mod_x = mapCoords.x & 0x1F;
int16_t mod_y = mapCoords.y & 0x1F;
int16_t mod_x = mapCoords->x & 0x1F;
int16_t mod_y = mapCoords->y & 0x1F;
if (mod_x <= 16)
{
if (mod_y < 16)
@ -1037,11 +1037,11 @@ CoordsXY screen_pos_to_map_pos(ScreenCoordsXY screenCoords, int32_t* direction)
}
}
mapCoords.x = mapCoords.x & ~0x1F;
mapCoords.y = mapCoords.y & ~0x1F;
mapCoords->x = mapCoords->x & ~0x1F;
mapCoords->y = mapCoords->y & ~0x1F;
if (direction != nullptr)
*direction = my_direction;
return mapCoords;
return *mapCoords;
}
LocationXY16 screen_coord_to_viewport_coord(rct_viewport* viewport, ScreenCoordsXY screenCoords)
@ -1753,7 +1753,7 @@ static rct_viewport* viewport_find_from_point(ScreenCoordsXY screenCoords)
* tile_element: edx ?
* viewport: edi
*/
CoordsXY screen_get_map_xy(ScreenCoordsXY screenCoords, rct_viewport** viewport)
std::optional<CoordsXY> screen_get_map_xy(ScreenCoordsXY screenCoords, rct_viewport** viewport)
{
int32_t interactionType;
rct_viewport* myViewport = nullptr;
@ -1762,7 +1762,7 @@ CoordsXY screen_get_map_xy(ScreenCoordsXY screenCoords, rct_viewport** viewport)
screenCoords, VIEWPORT_INTERACTION_MASK_TERRAIN, map_pos, &interactionType, nullptr, &myViewport);
if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE)
{
return { LOCATION_NULL, 0 };
return std::nullopt;
}
LocationXY16 start_vp_pos = screen_coord_to_viewport_coord(myViewport, screenCoords);
@ -1786,20 +1786,19 @@ CoordsXY screen_get_map_xy(ScreenCoordsXY screenCoords, rct_viewport** viewport)
*
* rct2: 0x006894D4
*/
CoordsXY screen_get_map_xy_with_z(ScreenCoordsXY screenCoords, int16_t z)
std::optional<CoordsXY> screen_get_map_xy_with_z(ScreenCoordsXY screenCoords, int16_t z)
{
CoordsXY ret{ LOCATION_NULL, 0 };
rct_viewport* viewport = viewport_find_from_point(screenCoords);
if (viewport == nullptr)
{
return ret;
return std::nullopt;
}
auto vpCoords = screen_coord_to_viewport_coord(viewport, screenCoords);
auto mapPosition = viewport_coord_to_map_coord(vpCoords.x, vpCoords.y, z);
if (!map_is_location_valid(mapPosition))
{
return ret;
return std::nullopt;
}
return mapPosition;
@ -1809,14 +1808,14 @@ CoordsXY screen_get_map_xy_with_z(ScreenCoordsXY screenCoords, int16_t z)
*
* rct2: 0x00689604
*/
CoordsXY screen_get_map_xy_quadrant(ScreenCoordsXY screenCoords, uint8_t* quadrant)
std::optional<CoordsXY> screen_get_map_xy_quadrant(ScreenCoordsXY screenCoords, uint8_t* quadrant)
{
CoordsXY mapCoords = screen_get_map_xy(screenCoords, nullptr);
if (mapCoords.x == LOCATION_NULL)
return mapCoords;
auto mapCoords = screen_get_map_xy(screenCoords, nullptr);
if (!mapCoords)
return std::nullopt;
*quadrant = map_get_tile_quadrant(mapCoords.x, mapCoords.y);
return { floor2(mapCoords.x, 32), floor2(mapCoords.y, 32) };
*quadrant = map_get_tile_quadrant(mapCoords->x, mapCoords->y);
return CoordsXY(floor2(mapCoords->x, 32), floor2(mapCoords->y, 32));
}
/**
@ -1826,25 +1825,25 @@ CoordsXY screen_get_map_xy_quadrant(ScreenCoordsXY screenCoords, uint8_t* quadra
std::optional<CoordsXY> screen_get_map_xy_quadrant_with_z(ScreenCoordsXY screenCoords, int16_t z, uint8_t* quadrant)
{
auto mapCoords = screen_get_map_xy_with_z(screenCoords, z);
if (mapCoords.x == LOCATION_NULL)
if (!mapCoords)
return std::nullopt;
*quadrant = map_get_tile_quadrant(mapCoords.x, mapCoords.y);
return CoordsXY(floor2(mapCoords.x, 32), floor2(mapCoords.y, 32));
*quadrant = map_get_tile_quadrant(mapCoords->x, mapCoords->y);
return CoordsXY(floor2(mapCoords->x, 32), floor2(mapCoords->y, 32));
}
/**
*
* rct2: 0x00689692
*/
CoordsXY screen_get_map_xy_side(ScreenCoordsXY screenCoords, uint8_t* side)
std::optional<CoordsXY> screen_get_map_xy_side(ScreenCoordsXY screenCoords, uint8_t* side)
{
CoordsXY mapCoords = screen_get_map_xy(screenCoords, nullptr);
if (mapCoords.x == LOCATION_NULL)
return mapCoords;
auto mapCoords = screen_get_map_xy(screenCoords, nullptr);
if (!mapCoords)
return std::nullopt;
*side = map_get_tile_side(mapCoords.x, mapCoords.y);
return { floor2(mapCoords.x, 32), floor2(mapCoords.y, 32) };
*side = map_get_tile_side(mapCoords->x, mapCoords->y);
return CoordsXY(floor2(mapCoords->x, 32), floor2(mapCoords->y, 32));
}
/**
@ -1854,11 +1853,11 @@ CoordsXY screen_get_map_xy_side(ScreenCoordsXY screenCoords, uint8_t* side)
std::optional<CoordsXY> screen_get_map_xy_side_with_z(ScreenCoordsXY screenCoords, int16_t z, uint8_t* side)
{
auto mapCoords = screen_get_map_xy_with_z(screenCoords, z);
if (mapCoords.x == LOCATION_NULL)
if (!mapCoords)
return std::nullopt;
*side = map_get_tile_side(mapCoords.x, mapCoords.y);
return CoordsXY(floor2(mapCoords.x, 32), floor2(mapCoords.y, 32));
*side = map_get_tile_side(mapCoords->x, mapCoords->y);
return CoordsXY(floor2(mapCoords->x, 32), floor2(mapCoords->y, 32));
}
/**

View File

@ -171,11 +171,11 @@ void sub_68B2B7(paint_session* session, CoordsXY mapCoords);
void viewport_invalidate(rct_viewport* viewport, int32_t left, int32_t top, int32_t right, int32_t bottom);
CoordsXY screen_get_map_xy(ScreenCoordsXY screenCoords, rct_viewport** viewport);
CoordsXY screen_get_map_xy_with_z(ScreenCoordsXY screenCoords, int16_t z);
CoordsXY screen_get_map_xy_quadrant(ScreenCoordsXY screenCoords, uint8_t* quadrant);
std::optional<CoordsXY> screen_get_map_xy(ScreenCoordsXY screenCoords, rct_viewport** viewport);
std::optional<CoordsXY> screen_get_map_xy_with_z(ScreenCoordsXY screenCoords, int16_t z);
std::optional<CoordsXY> screen_get_map_xy_quadrant(ScreenCoordsXY screenCoords, uint8_t* quadrant);
std::optional<CoordsXY> screen_get_map_xy_quadrant_with_z(ScreenCoordsXY screenCoords, int16_t z, uint8_t* quadrant);
CoordsXY screen_get_map_xy_side(ScreenCoordsXY screenCoords, uint8_t* side);
std::optional<CoordsXY> screen_get_map_xy_side(ScreenCoordsXY screenCoords, uint8_t* side);
std::optional<CoordsXY> screen_get_map_xy_side_with_z(ScreenCoordsXY screenCoords, int16_t z, uint8_t* side);
uint8_t get_current_rotation();

View File

@ -915,11 +915,12 @@ void window_rotate_camera(rct_window* w, int32_t direction)
// has something to do with checking if middle of the viewport is obstructed
rct_viewport* other;
CoordsXYZ coords{ screen_get_map_xy({ x, y }, &other), 0 };
auto mapXYCoords = screen_get_map_xy({ x, y }, &other);
CoordsXYZ coords{};
// other != viewport probably triggers on viewports in ride or guest window?
// x is LOCATION_NULL if middle of viewport is obstructed by another window?
if (coords.x == LOCATION_NULL || other != viewport)
// naoXYCoords is nullopt if middle of viewport is obstructed by another window?
if (!mapXYCoords || other != viewport)
{
int16_t view_x = (viewport->view_width >> 1) + viewport->view_x;
int16_t view_y = (viewport->view_height >> 1) + viewport->view_y;
@ -928,6 +929,8 @@ void window_rotate_camera(rct_window* w, int32_t direction)
}
else
{
coords.x = mapXYCoords->x;
coords.y = mapXYCoords->y;
coords.z = tile_element_height(coords);
}

View File

@ -6218,16 +6218,16 @@ CoordsXYZD ride_get_entrance_or_exit_position_from_screen_position(ScreenCoordsX
stationHeight = ride->stations[gRideEntranceExitPlaceStationIndex].Height;
auto coords = screen_get_map_xy_with_z(screenCoords, stationHeight * 8);
if (coords.x == LOCATION_NULL)
if (!coords)
{
entranceExitCoords.x = LOCATION_NULL;
return entranceExitCoords;
}
word_F4418C = coords.x;
word_F4418E = coords.y;
word_F4418C = coords->x;
word_F4418E = coords->y;
entranceExitCoords = { floor2(coords.x, 32), floor2(coords.y, 32), stationHeight, INVALID_DIRECTION };
entranceExitCoords = { floor2(coords->x, 32), floor2(coords->y, 32), stationHeight, INVALID_DIRECTION };
if (ride->type == RIDE_TYPE_NULL)
{

View File

@ -94,12 +94,12 @@ void rct_money_effect::Create(money32 value)
return;
rct_viewport* mainViewport = window_get_viewport(mainWindow);
CoordsXY mapPositionXY = screen_get_map_xy(
auto mapPositionXY = screen_get_map_xy(
{ mainViewport->x + (mainViewport->width / 2), mainViewport->y + (mainViewport->height / 2) }, nullptr);
if (mapPositionXY.x == LOCATION_NULL)
if (!mapPositionXY)
return;
mapPosition = { mapPositionXY, tile_element_height(mapPositionXY) };
mapPosition = { *mapPositionXY, tile_element_height(*mapPositionXY) };
}
mapPosition.z += 10;
CreateAt(-value, mapPosition.x, mapPosition.y, mapPosition.z, false);