| 199 | } |
| 200 | |
| 201 | int PointCollisionData::GetWaterBottomHeight() |
| 202 | { |
| 203 | if (_waterBottomHeight.has_value()) |
| 204 | return *_waterBottomHeight; |
| 205 | |
| 206 | FloorInfo* sector = nullptr; |
| 207 | auto* room = &g_Level.Rooms[_roomNumber]; |
| 208 | short roomNumber = _roomNumber; |
| 209 | |
| 210 | int adjoiningRoomNumber = NO_VALUE; |
| 211 | do |
| 212 | { |
| 213 | int x = (_position.x - room->Position.x) / BLOCK(1); |
| 214 | int z = (_position.z - room->Position.z) / BLOCK(1); |
| 215 | |
| 216 | if (z <= 0) |
| 217 | { |
| 218 | z = 0; |
| 219 | if (x < 1) |
| 220 | { |
| 221 | x = 1; |
| 222 | } |
| 223 | else if (x > (room->XSize - 2)) |
| 224 | { |
| 225 | x = room->XSize - 2; |
| 226 | } |
| 227 | } |
| 228 | else if (z >= (room->ZSize - 1)) |
| 229 | { |
| 230 | z = room->ZSize - 1; |
| 231 | if (x < 1) |
| 232 | { |
| 233 | x = 1; |
| 234 | } |
| 235 | else if (x > (room->XSize - 2)) |
| 236 | { |
| 237 | x = room->XSize - 2; |
| 238 | } |
| 239 | } |
| 240 | else if (x < 0) |
| 241 | { |
| 242 | x = 0; |
| 243 | } |
| 244 | else if (x >= room->XSize) |
| 245 | { |
| 246 | x = room->XSize - 1; |
| 247 | } |
| 248 | |
| 249 | sector = &room->Sectors[z + (x * room->ZSize)]; |
| 250 | adjoiningRoomNumber = sector->SidePortalRoomNumber; |
| 251 | if (adjoiningRoomNumber != NO_VALUE) |
| 252 | { |
| 253 | roomNumber = adjoiningRoomNumber; |
| 254 | room = &g_Level.Rooms[adjoiningRoomNumber]; |
| 255 | } |
| 256 | } |
| 257 | while (adjoiningRoomNumber != NO_VALUE); |
| 258 | |