* * rct2: 0x0068958D */
| 1017 | * rct2: 0x0068958D |
| 1018 | */ |
| 1019 | std::optional<CoordsXY> ScreenPosToMapPos(const ScreenCoordsXY& screenCoords, int32_t* direction) |
| 1020 | { |
| 1021 | auto mapCoords = ScreenGetMapXY(screenCoords, nullptr); |
| 1022 | if (!mapCoords.has_value()) |
| 1023 | return std::nullopt; |
| 1024 | |
| 1025 | int32_t my_direction; |
| 1026 | int32_t dist_from_centre_x = abs(mapCoords->x % 32); |
| 1027 | int32_t dist_from_centre_y = abs(mapCoords->y % 32); |
| 1028 | if (dist_from_centre_x > 8 && dist_from_centre_x < 24 && dist_from_centre_y > 8 && dist_from_centre_y < 24) |
| 1029 | { |
| 1030 | my_direction = 4; |
| 1031 | } |
| 1032 | else |
| 1033 | { |
| 1034 | auto mod_x = mapCoords->x & 0x1F; |
| 1035 | auto mod_y = mapCoords->y & 0x1F; |
| 1036 | if (mod_x <= 16) |
| 1037 | { |
| 1038 | if (mod_y < 16) |
| 1039 | { |
| 1040 | my_direction = 2; |
| 1041 | } |
| 1042 | else |
| 1043 | { |
| 1044 | my_direction = 3; |
| 1045 | } |
| 1046 | } |
| 1047 | else |
| 1048 | { |
| 1049 | if (mod_y < 16) |
| 1050 | { |
| 1051 | my_direction = 1; |
| 1052 | } |
| 1053 | else |
| 1054 | { |
| 1055 | my_direction = 0; |
| 1056 | } |
| 1057 | } |
| 1058 | } |
| 1059 | |
| 1060 | if (direction != nullptr) |
| 1061 | *direction = my_direction; |
| 1062 | return { mapCoords->ToTileStart() }; |
| 1063 | } |
| 1064 | |
| 1065 | [[nodiscard]] bool Viewport::ContainsTile(const TileCoordsXY coords) const noexcept |
| 1066 | { |