mirror of https://github.com/OpenRCT2/OpenRCT2.git
commit
ee0025987a
|
@ -656,15 +656,18 @@ static Peep* viewport_interaction_get_closest_peep(int32_t x, int32_t y, int32_t
|
|||
*
|
||||
* rct2: 0x0068A15E
|
||||
*/
|
||||
void sub_68A15E(int32_t screenX, int32_t screenY, int16_t* x, int16_t* y, int32_t* direction, TileElement** tileElement)
|
||||
void sub_68A15E(int32_t screenX, int32_t screenY, int16_t* x, int16_t* y)
|
||||
{
|
||||
int16_t my_x, my_y;
|
||||
int16_t mapX, mapY;
|
||||
CoordsXY initialPos{};
|
||||
int32_t interactionType;
|
||||
TileElement* myTileElement;
|
||||
TileElement* tileElement;
|
||||
rct_viewport* viewport;
|
||||
get_map_coordinates_from_pos(
|
||||
screenX, screenY, VIEWPORT_INTERACTION_MASK_TERRAIN & VIEWPORT_INTERACTION_MASK_WATER, &my_x, &my_y, &interactionType,
|
||||
&myTileElement, &viewport);
|
||||
screenX, screenY, VIEWPORT_INTERACTION_MASK_TERRAIN & VIEWPORT_INTERACTION_MASK_WATER, &mapX, &mapY, &interactionType,
|
||||
&tileElement, &viewport);
|
||||
initialPos.x = mapX;
|
||||
initialPos.y = mapY;
|
||||
|
||||
if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE)
|
||||
{
|
||||
|
@ -672,58 +675,27 @@ void sub_68A15E(int32_t screenX, int32_t screenY, int16_t* x, int16_t* y, int32_
|
|||
return;
|
||||
}
|
||||
|
||||
int16_t originalZ = 0;
|
||||
int16_t waterHeight = 0;
|
||||
if (interactionType == VIEWPORT_INTERACTION_ITEM_WATER)
|
||||
{
|
||||
originalZ = myTileElement->AsSurface()->GetWaterHeight() << 4;
|
||||
waterHeight = tileElement->AsSurface()->GetWaterHeight() << 4;
|
||||
}
|
||||
|
||||
LocationXY16 start_vp_pos = screen_coord_to_viewport_coord(viewport, screenX, screenY);
|
||||
LocationXY16 map_pos = { (int16_t)(my_x + 16), (int16_t)(my_y + 16) };
|
||||
LocationXY16 initialVPPos = screen_coord_to_viewport_coord(viewport, screenX, screenY);
|
||||
LocationXY16 mapPos = { (int16_t)(initialPos.x + 16), (int16_t)(initialPos.y + 16) };
|
||||
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
{
|
||||
int16_t z = originalZ;
|
||||
int16_t z = waterHeight;
|
||||
if (interactionType != VIEWPORT_INTERACTION_ITEM_WATER)
|
||||
{
|
||||
z = tile_element_height({ map_pos.x, map_pos.y });
|
||||
z = tile_element_height({ mapPos.x, mapPos.y });
|
||||
}
|
||||
map_pos = viewport_coord_to_map_coord(start_vp_pos.x, start_vp_pos.y, z);
|
||||
map_pos.x = std::clamp<int16_t>(map_pos.x, my_x, my_x + 31);
|
||||
map_pos.y = std::clamp<int16_t>(map_pos.y, my_y, my_y + 31);
|
||||
mapPos = viewport_coord_to_map_coord(initialVPPos.x, initialVPPos.y, z);
|
||||
mapPos.x = std::clamp<int16_t>(mapPos.x, initialPos.x, initialPos.x + 31);
|
||||
mapPos.y = std::clamp<int16_t>(mapPos.y, initialPos.y, initialPos.y + 31);
|
||||
}
|
||||
|
||||
// Determine to which edge the cursor is closest
|
||||
int32_t myDirection;
|
||||
int32_t mod_x = map_pos.x & 0x1F;
|
||||
int32_t mod_y = map_pos.y & 0x1F;
|
||||
if (mod_x < mod_y)
|
||||
{
|
||||
if (mod_x + mod_y < 32)
|
||||
{
|
||||
myDirection = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
myDirection = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mod_x + mod_y < 32)
|
||||
{
|
||||
myDirection = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
myDirection = 2;
|
||||
}
|
||||
}
|
||||
|
||||
*x = map_pos.x & ~0x1F;
|
||||
*y = map_pos.y & ~0x1F;
|
||||
if (direction != nullptr)
|
||||
*direction = myDirection;
|
||||
if (tileElement != nullptr)
|
||||
*tileElement = myTileElement;
|
||||
*x = mapPos.x & ~0x1F;
|
||||
*y = mapPos.y & ~0x1F;
|
||||
}
|
||||
|
|
|
@ -1192,9 +1192,7 @@ static void window_map_set_land_rights_tool_update(int32_t x, int32_t y)
|
|||
static void place_park_entrance_get_map_position(
|
||||
int32_t x, int32_t y, int16_t* mapX, int16_t* mapY, int16_t* mapZ, int32_t* direction)
|
||||
{
|
||||
TileElement* tileElement;
|
||||
|
||||
sub_68A15E(x, y, mapX, mapY, direction, &tileElement);
|
||||
sub_68A15E(x, y, mapX, mapY);
|
||||
if (*mapX == LOCATION_NULL)
|
||||
return;
|
||||
|
||||
|
|
|
@ -2109,14 +2109,14 @@ static void window_ride_construction_update(rct_window* w)
|
|||
static bool ride_get_place_position_from_screen_position(int32_t screenX, int32_t screenY, int32_t* outX, int32_t* outY)
|
||||
{
|
||||
int16_t mapX, mapY, mapZ;
|
||||
int32_t interactionType, direction;
|
||||
TileElement* tileElement;
|
||||
rct_viewport* viewport;
|
||||
int32_t interactionType;
|
||||
rct_viewport* viewport = nullptr;
|
||||
|
||||
if (!_trackPlaceCtrlState)
|
||||
{
|
||||
if (gInputPlaceObjectModifier & PLACE_OBJECT_MODIFIER_COPY_Z)
|
||||
{
|
||||
TileElement* tileElement;
|
||||
get_map_coordinates_from_pos(screenX, screenY, 0xFCCA, &mapX, &mapY, &interactionType, &tileElement, &viewport);
|
||||
if (interactionType != 0)
|
||||
{
|
||||
|
@ -2173,7 +2173,7 @@ static bool ride_get_place_position_from_screen_position(int32_t screenX, int32_
|
|||
|
||||
if (!_trackPlaceCtrlState)
|
||||
{
|
||||
sub_68A15E(screenX, screenY, &mapX, &mapY, &direction, &tileElement);
|
||||
sub_68A15E(screenX, screenY, &mapX, &mapY);
|
||||
if (mapX == LOCATION_NULL)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -1581,7 +1581,7 @@ static void sub_6E1F34(
|
|||
// If CTRL not pressed
|
||||
if (!gSceneryCtrlPressed)
|
||||
{
|
||||
sub_68A15E(x, y, grid_x, grid_y, nullptr, nullptr);
|
||||
sub_68A15E(x, y, grid_x, grid_y);
|
||||
|
||||
if (*grid_x == LOCATION_NULL)
|
||||
return;
|
||||
|
|
|
@ -254,7 +254,7 @@ static void window_track_place_toolupdate(rct_window* w, rct_widgetindex widgetI
|
|||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
|
||||
|
||||
// Get the tool map position
|
||||
sub_68A15E(x, y, &mapX, &mapY, nullptr, nullptr);
|
||||
sub_68A15E(x, y, &mapX, &mapY);
|
||||
if (mapX == LOCATION_NULL)
|
||||
{
|
||||
window_track_place_clear_provisional();
|
||||
|
@ -319,7 +319,7 @@ static void window_track_place_tooldown(rct_window* w, rct_widgetindex widgetInd
|
|||
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
|
||||
|
||||
int16_t mapX, mapY;
|
||||
sub_68A15E(x, y, &mapX, &mapY, nullptr, nullptr);
|
||||
sub_68A15E(x, y, &mapX, &mapY);
|
||||
if (mapX == LOCATION_NULL)
|
||||
return;
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ int32_t viewport_interaction_get_item_right(int32_t x, int32_t y, viewport_inter
|
|||
int32_t viewport_interaction_right_over(int32_t x, int32_t y);
|
||||
int32_t viewport_interaction_right_click(int32_t x, int32_t y);
|
||||
|
||||
void sub_68A15E(int32_t screenX, int32_t screenY, int16_t* x, int16_t* y, int32_t* direction, TileElement** tileElement);
|
||||
void sub_68A15E(int32_t screenX, int32_t screenY, int16_t* x, int16_t* y);
|
||||
void sub_68B2B7(paint_session* session, int32_t x, int32_t y);
|
||||
|
||||
void viewport_invalidate(rct_viewport* viewport, int32_t left, int32_t top, int32_t right, int32_t bottom);
|
||||
|
|
Loading…
Reference in New Issue