1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Break up sub_6E1F34()

This commit is contained in:
Gymnasiast
2020-11-15 14:58:36 +01:00
parent 4746d025c3
commit 64959b0048

View File

@@ -1148,66 +1148,9 @@ static void scenery_eyedropper_tool_down(const ScreenCoordsXY& windowPos, rct_wi
} }
} }
/** static void sub_6E1F34_update_screen_coords_and_buttons_pressed(bool canRaiseItem, ScreenCoordsXY& screenPos)
*
* rct2: 0x006E1F34
* Outputs
* eax : gridX
* ebx : parameter_1
* ecx : gridY
* edx : parameter_2
* edi : parameter_3
*/
static void sub_6E1F34(
const ScreenCoordsXY& sourceScreenPos, ScenerySelection selection, CoordsXY& gridPos, uint32_t* parameter_1,
uint32_t* parameter_2, uint32_t* parameter_3)
{ {
rct_window* w = window_find_by_class(WC_SCENERY); if (!canRaiseItem && !gCheatsDisableSupportLimits)
if (w == nullptr)
{
gridPos.setNull();
return;
}
auto screenPos = sourceScreenPos;
uint16_t maxPossibleHeight = (std::numeric_limits<decltype(TileElement::base_height)>::max() - 32) * ZoomLevel::max();
bool can_raise_item = false;
if (selection.SceneryType == SCENERY_TYPE_SMALL)
{
rct_scenery_entry* scenery_entry = get_small_scenery_entry(selection.EntryIndex);
maxPossibleHeight -= scenery_entry->small_scenery.height;
if (scenery_small_entry_has_flag(scenery_entry, SMALL_SCENERY_FLAG_STACKABLE))
{
can_raise_item = true;
}
}
else if (selection.SceneryType == SCENERY_TYPE_WALL)
{
rct_scenery_entry* scenery_entry = get_wall_entry(selection.EntryIndex);
if (scenery_entry)
{
maxPossibleHeight -= scenery_entry->wall.height;
}
can_raise_item = true;
}
else if (selection.SceneryType == SCENERY_TYPE_LARGE)
{
rct_scenery_entry* scenery_entry = get_large_scenery_entry(selection.EntryIndex);
if (scenery_entry)
{
int16_t maxClearZ = 0;
for (int32_t i = 0; scenery_entry->large_scenery.tiles[i].x_offset != -1; ++i)
{
maxClearZ = std::max<int16_t>(maxClearZ, scenery_entry->large_scenery.tiles[i].z_clearance);
}
maxPossibleHeight = std::max(0, maxPossibleHeight - maxClearZ);
}
can_raise_item = true;
}
if (!can_raise_item && !gCheatsDisableSupportLimits)
{ {
gSceneryCtrlPressed = false; gSceneryCtrlPressed = false;
gSceneryShiftPressed = false; gSceneryShiftPressed = false;
@@ -1275,13 +1218,34 @@ static void sub_6E1F34(
} }
} }
} }
}
switch (selection.SceneryType) static void sub_6E1F34_small_scenery(
const ScreenCoordsXY& sourceScreenPos, ObjectEntryIndex sceneryIndex, CoordsXY& gridPos, uint8_t* outQuadrant,
colour_t* outPrimaryColour, colour_t* outSecondaryColour, Direction* outRotation)
{
rct_window* w = window_find_by_class(WC_SCENERY);
if (w == nullptr)
{ {
case SCENERY_TYPE_SMALL: gridPos.setNull();
return;
}
auto screenPos = sourceScreenPos;
uint16_t maxPossibleHeight = (std::numeric_limits<decltype(TileElement::base_height)>::max() - 32) * ZoomLevel::max();
bool can_raise_item = false;
rct_scenery_entry* scenery = get_small_scenery_entry(sceneryIndex);
maxPossibleHeight -= scenery->small_scenery.height;
if (scenery_small_entry_has_flag(scenery, SMALL_SCENERY_FLAG_STACKABLE))
{ {
can_raise_item = true;
}
sub_6E1F34_update_screen_coords_and_buttons_pressed(can_raise_item, screenPos);
// Small scenery // Small scenery
rct_scenery_entry* scenery = get_small_scenery_entry(selection.EntryIndex);
if (!scenery_small_entry_has_flag(scenery, SMALL_SCENERY_FLAG_FULL_TILE)) if (!scenery_small_entry_has_flag(scenery, SMALL_SCENERY_FLAG_FULL_TILE))
{ {
uint8_t quadrant = 0; uint8_t quadrant = 0;
@@ -1354,16 +1318,16 @@ static void sub_6E1F34(
rotation -= get_current_rotation(); rotation -= get_current_rotation();
rotation &= 0x3; rotation &= 0x3;
// Also places it in lower but think thats for clobbering
*parameter_1 = selection.EntryIndex << 8;
*parameter_2 = (quadrant ^ (1 << 1)) | (gWindowSceneryPrimaryColour << 8);
*parameter_3 = rotation | (gWindowScenerySecondaryColour << 16);
if (gConfigGeneral.virtual_floor_style != VirtualFloorStyles::Off) if (gConfigGeneral.virtual_floor_style != VirtualFloorStyles::Off)
{ {
virtual_floor_set_height(gSceneryPlaceZ); virtual_floor_set_height(gSceneryPlaceZ);
} }
*outQuadrant = quadrant ^ 2;
*outPrimaryColour = gWindowSceneryPrimaryColour;
*outSecondaryColour = gWindowScenerySecondaryColour;
*outRotation = rotation;
return; return;
} }
@@ -1440,14 +1404,31 @@ static void sub_6E1F34(
rotation -= get_current_rotation(); rotation -= get_current_rotation();
rotation &= 0x3; rotation &= 0x3;
// Also places it in lower but think thats for clobbering if (gConfigGeneral.virtual_floor_style != VirtualFloorStyles::Off)
*parameter_1 = selection.EntryIndex << 8;
*parameter_2 = 0 | (gWindowSceneryPrimaryColour << 8);
*parameter_3 = rotation | (gWindowScenerySecondaryColour << 16);
break;
}
case SCENERY_TYPE_PATH_ITEM:
{ {
virtual_floor_set_height(gSceneryPlaceZ);
}
*outQuadrant = 0;
*outPrimaryColour = gWindowSceneryPrimaryColour;
*outSecondaryColour = gWindowScenerySecondaryColour;
*outRotation = rotation;
}
static void sub_6E1F34_path_item(
const ScreenCoordsXY& sourceScreenPos, ObjectEntryIndex sceneryIndex, CoordsXY& gridPos, int32_t* outZ)
{
rct_window* w = window_find_by_class(WC_SCENERY);
if (w == nullptr)
{
gridPos.setNull();
return;
}
auto screenPos = sourceScreenPos;
sub_6E1F34_update_screen_coords_and_buttons_pressed(false, screenPos);
// Path bits // Path bits
auto flags = VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_FOOTPATH_ITEM; auto flags = VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_FOOTPATH_ITEM;
@@ -1460,26 +1441,43 @@ static void sub_6E1F34(
return; return;
} }
*parameter_1 = info.Element->AsPath()->GetSlopeDirection() << 8; if (gConfigGeneral.virtual_floor_style != VirtualFloorStyles::Off)
if (info.Element->AsPath()->IsSloped())
*parameter_1 |= FOOTPATH_PROPERTIES_FLAG_IS_SLOPED << 8;
*parameter_2 = info.Element->base_height;
*parameter_2 |= (info.Element->AsPath()->GetSurfaceEntryIndex() << 8);
if (info.Element->AsPath()->IsQueue())
{ {
*parameter_2 |= LOCATION_NULL; virtual_floor_set_height(gSceneryPlaceZ);
} }
*parameter_3 = selection.EntryIndex + 1;
break; *outZ = info.Element->GetBaseZ();
} }
case SCENERY_TYPE_WALL:
static void sub_6E1F34_wall(
const ScreenCoordsXY& sourceScreenPos, ObjectEntryIndex sceneryIndex, CoordsXY& gridPos, colour_t* outPrimaryColour,
uint8_t* outEdges)
{
rct_window* w = window_find_by_class(WC_SCENERY);
if (w == nullptr)
{ {
gridPos.setNull();
return;
}
auto screenPos = sourceScreenPos;
uint16_t maxPossibleHeight = (std::numeric_limits<decltype(TileElement::base_height)>::max() - 32) * ZoomLevel::max();
rct_scenery_entry* scenery_entry = get_wall_entry(sceneryIndex);
if (scenery_entry)
{
maxPossibleHeight -= scenery_entry->wall.height;
}
sub_6E1F34_update_screen_coords_and_buttons_pressed(true, screenPos);
// Walls // Walls
uint8_t cl; uint8_t edge;
// If CTRL not pressed // If CTRL not pressed
if (!gSceneryCtrlPressed) if (!gSceneryCtrlPressed)
{ {
auto gridCoords = screen_get_map_xy_side(screenPos, &cl); auto gridCoords = screen_get_map_xy_side(screenPos, &edge);
if (!gridCoords) if (!gridCoords)
{ {
gridPos.setNull(); gridPos.setNull();
@@ -1511,7 +1509,7 @@ static void sub_6E1F34(
else else
{ {
int16_t z = gSceneryCtrlPressZ; int16_t z = gSceneryCtrlPressZ;
auto mapCoords = screen_get_map_xy_side_with_z(screenPos, z, &cl); auto mapCoords = screen_get_map_xy_side_with_z(screenPos, z, &edge);
if (!mapCoords) if (!mapCoords)
{ {
gridPos.setNull(); gridPos.setNull();
@@ -1535,14 +1533,44 @@ static void sub_6E1F34(
_secondaryColour = gWindowScenerySecondaryColour; _secondaryColour = gWindowScenerySecondaryColour;
_tertiaryColour = gWindowSceneryTertiaryColour; _tertiaryColour = gWindowSceneryTertiaryColour;
// Also places it in lower but think thats for clobbering
*parameter_1 = selection.EntryIndex << 8; if (gConfigGeneral.virtual_floor_style != VirtualFloorStyles::Off)
*parameter_2 = cl | (gWindowSceneryPrimaryColour << 8);
*parameter_3 = 0;
break;
}
case SCENERY_TYPE_LARGE:
{ {
virtual_floor_set_height(gSceneryPlaceZ);
}
*outPrimaryColour = gWindowSceneryPrimaryColour;
*outEdges = edge;
}
static void sub_6E1F34_large_scenery(
const ScreenCoordsXY& sourceScreenPos, ObjectEntryIndex sceneryIndex, CoordsXY& gridPos, colour_t* outPrimaryColour,
colour_t* outSecondaryColour, Direction* outDirection)
{
rct_window* w = window_find_by_class(WC_SCENERY);
if (w == nullptr)
{
gridPos.setNull();
return;
}
auto screenPos = sourceScreenPos;
uint16_t maxPossibleHeight = (std::numeric_limits<decltype(TileElement::base_height)>::max() - 32) * ZoomLevel::max();
rct_scenery_entry* scenery_entry = get_large_scenery_entry(sceneryIndex);
if (scenery_entry)
{
int16_t maxClearZ = 0;
for (int32_t i = 0; scenery_entry->large_scenery.tiles[i].x_offset != -1; ++i)
{
maxClearZ = std::max<int16_t>(maxClearZ, scenery_entry->large_scenery.tiles[i].z_clearance);
}
maxPossibleHeight = std::max(0, maxPossibleHeight - maxClearZ);
}
sub_6E1F34_update_screen_coords_and_buttons_pressed(true, screenPos);
// Large scenery // Large scenery
// If CTRL not pressed // If CTRL not pressed
if (!gSceneryCtrlPressed) if (!gSceneryCtrlPressed)
@@ -1603,17 +1631,35 @@ static void sub_6E1F34(
gridPos = gridPos.ToTileStart(); gridPos = gridPos.ToTileStart();
uint8_t rotation = gWindowSceneryRotation; Direction rotation = gWindowSceneryRotation;
rotation -= get_current_rotation(); rotation -= get_current_rotation();
rotation &= 0x3; rotation &= 0x3;
*parameter_1 = (rotation << 8); if (gConfigGeneral.virtual_floor_style != VirtualFloorStyles::Off)
*parameter_2 = gWindowSceneryPrimaryColour | (gWindowScenerySecondaryColour << 8);
*parameter_3 = selection.EntryIndex;
break;
}
case SCENERY_TYPE_BANNER:
{ {
virtual_floor_set_height(gSceneryPlaceZ);
}
*outPrimaryColour = gWindowSceneryPrimaryColour;
*outSecondaryColour = gWindowScenerySecondaryColour;
*outDirection = rotation;
}
static void sub_6E1F34_banner(
const ScreenCoordsXY& sourceScreenPos, ObjectEntryIndex sceneryIndex, CoordsXY& gridPos, int32_t* outZ,
Direction* outDirection)
{
rct_window* w = window_find_by_class(WC_SCENERY);
if (w == nullptr)
{
gridPos.setNull();
return;
}
auto screenPos = sourceScreenPos;
sub_6E1F34_update_screen_coords_and_buttons_pressed(false, screenPos);
// Banner // Banner
auto flags = VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_FOOTPATH_ITEM; auto flags = VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_FOOTPATH_ITEM;
@@ -1630,23 +1676,13 @@ static void sub_6E1F34(
rotation -= get_current_rotation(); rotation -= get_current_rotation();
rotation &= 0x3; rotation &= 0x3;
int16_t z = info.Element->base_height; auto z = info.Element->GetBaseZ();
if (info.Element->AsPath()->IsSloped()) if (info.Element->AsPath()->IsSloped())
{ {
if (rotation != direction_reverse(info.Element->AsPath()->GetSlopeDirection())) if (rotation != direction_reverse(info.Element->AsPath()->GetSlopeDirection()))
{ {
z += 2; z += (2 * COORDS_Z_STEP);
}
}
z /= 2;
// Also places it in lower but think thats for clobbering
*parameter_1 = selection.EntryIndex << 8;
*parameter_2 = z | (rotation << 8);
*parameter_3 = gWindowSceneryPrimaryColour;
break;
} }
} }
@@ -1654,59 +1690,9 @@ static void sub_6E1F34(
{ {
virtual_floor_set_height(gSceneryPlaceZ); virtual_floor_set_height(gSceneryPlaceZ);
} }
}
static void sub_6E1F34_small_scenery( *outDirection = rotation;
const ScreenCoordsXY& screenCoords, uint16_t sceneryIndex, CoordsXY& gridPos, uint8_t* outQuadrant, *outZ = z;
colour_t* outPrimaryColour, colour_t* outSecondaryColour, Direction* outRotation)
{
uint32_t parameter1 = 0, parameter2 = 0, parameter3 = 0;
sub_6E1F34(screenCoords, { SCENERY_TYPE_SMALL, sceneryIndex }, gridPos, &parameter1, &parameter2, &parameter3);
*outQuadrant = parameter2 & 0xFF;
*outPrimaryColour = (parameter2 >> 8) & 0xFF;
*outSecondaryColour = (parameter3 >> 16) & 0xFF;
*outRotation = parameter3 & 0xFF;
}
static void sub_6E1F34_path_item(const ScreenCoordsXY& screenCoords, uint16_t sceneryIndex, CoordsXY& gridPos, int32_t* outZ)
{
uint32_t parameter1 = 0, parameter2 = 0, parameter3 = 0;
sub_6E1F34(screenCoords, { SCENERY_TYPE_PATH_ITEM, sceneryIndex }, gridPos, &parameter1, &parameter2, &parameter3);
*outZ = (parameter2 & 0xFF) * COORDS_Z_STEP;
}
static void sub_6E1F34_wall(
const ScreenCoordsXY& screenCoords, uint16_t sceneryIndex, CoordsXY& gridPos, colour_t* outPrimaryColour, uint8_t* outEdges)
{
uint32_t parameter1 = 0, parameter2 = 0, parameter3 = 0;
sub_6E1F34(screenCoords, { SCENERY_TYPE_WALL, sceneryIndex }, gridPos, &parameter1, &parameter2, &parameter3);
*outPrimaryColour = (parameter2 >> 8) & 0xFF;
*outEdges = parameter2 & 0xFF;
}
static void sub_6E1F34_large_scenery(
const ScreenCoordsXY& screenCoords, uint16_t sceneryIndex, CoordsXY& gridPos, colour_t* outPrimaryColour,
colour_t* outSecondaryColour, Direction* outDirection)
{
uint32_t parameter1 = 0, parameter2 = 0, parameter3 = 0;
sub_6E1F34(screenCoords, { SCENERY_TYPE_LARGE, sceneryIndex }, gridPos, &parameter1, &parameter2, &parameter3);
*outPrimaryColour = parameter2 & 0xFF;
*outSecondaryColour = (parameter2 >> 8) & 0xFF;
*outDirection = (parameter1 & 0xFF00) >> 8;
}
static void sub_6E1F34_banner(
const ScreenCoordsXY& screenCoords, uint16_t sceneryIndex, CoordsXY& gridPos, int32_t* outZ, Direction* outDirection)
{
uint32_t parameter1 = 0, parameter2 = 0, parameter3 = 0;
sub_6E1F34(screenCoords, { SCENERY_TYPE_BANNER, sceneryIndex }, gridPos, &parameter1, &parameter2, &parameter3);
*outDirection = (parameter2 >> 8) & 0xFF;
*outZ = (parameter2 & 0xFF) * COORDS_Z_PER_TINY_Z;
} }
/** /**