MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / GetWaterTopHeight

Method GetWaterTopHeight

TombEngine/Game/collision/Point.cpp:302–398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300 }
301
302 int PointCollisionData::GetWaterTopHeight()
303 {
304 if (_waterTopHeight.has_value())
305 return *_waterTopHeight;
306
307 FloorInfo* sector = nullptr;
308 auto* room = &g_Level.Rooms[_roomNumber];
309 int roomNumber = _roomNumber;
310
311 int adjoiningRoomNumber = NO_VALUE;
312 do
313 {
314 int x = (_position.x - room->Position.x) / BLOCK(1);
315 int z = (_position.z - room->Position.z) / BLOCK(1);
316
317 if (z <= 0)
318 {
319 z = 0;
320 if (x < 1)
321 {
322 x = 1;
323 }
324 else if (x > (room->XSize - 2))
325 {
326 x = room->XSize - 2;
327 }
328 }
329 else if (z >= (room->ZSize - 1))
330 {
331 z = room->ZSize - 1;
332 if (x < 1)
333 {
334 x = 1;
335 }
336 else if (x > (room->XSize - 2))
337 {
338 x = room->XSize - 2;
339 }
340 }
341 else if (x < 0)
342 {
343 x = 0;
344 }
345 else if (x >= room->XSize)
346 {
347 x = room->XSize - 1;
348 }
349
350 sector = &room->Sectors[z + (x * room->ZSize)];
351 adjoiningRoomNumber = sector->SidePortalRoomNumber;
352
353 if (adjoiningRoomNumber != NO_VALUE)
354 {
355 roomNumber = adjoiningRoomNumber;
356 room = &g_Level.Rooms[adjoiningRoomNumber];
357 }
358 }
359 while (adjoiningRoomNumber != NO_VALUE);

Callers 15

SpeedboatDynamicsFunction · 0.80
SpeedboatControlFunction · 0.80
GetVehicleWaterHeightFunction · 0.80
DoVehicleWaterMovementFunction · 0.80
GetFishStartPositionFunction · 0.80
UpdateFishSwarmFunction · 0.80
UPVControlFunction · 0.80
RubberBoatDynamicsFunction · 0.80
RubberBoatControlFunction · 0.80
KayakDoRippleFunction · 0.80
KayakToBackgroundFunction · 0.80
KayakControlFunction · 0.80

Calls 6

TestEnvironmentFunction · 0.85
GetSectorFunction · 0.85
GetNextRoomNumberMethod · 0.80
GetSurfaceHeightMethod · 0.80
has_valueMethod · 0.45
IsWallMethod · 0.45

Tested by

no test coverage detected