diff --git a/TombEngine/Game/Lara/lara.cpp b/TombEngine/Game/Lara/lara.cpp index 8d658e7c3..e86b1a231 100644 --- a/TombEngine/Game/Lara/lara.cpp +++ b/TombEngine/Game/Lara/lara.cpp @@ -495,7 +495,7 @@ void LaraControl(ItemInfo* item, CollisionInfo* coll) player.Context.WaterSurfaceDist = -water.HeightFromWater; if (player.Context.Vehicle == NO_ITEM) - WadeSplash(item, water.WaterHeight, water.WaterDepth); + SpawnPlayerSplash(*item, water.WaterHeight, water.WaterDepth); bool isWaterOnHeadspace = false; @@ -558,7 +558,7 @@ void LaraControl(ItemInfo* item, CollisionInfo* coll) { player.Control.WaterStatus = WaterStatus::Wade; - // Make splash ONLY within this particular threshold before swim depth while airborne (WadeSplash() above interferes otherwise). + // Make splash ONLY within this particular threshold before swim depth while airborne (SpawnPlayerSplash() above interferes otherwise). if (water.WaterDepth > (SWIM_WATER_DEPTH - CLICK(1)) && item->Animation.IsAirborne && !water.IsSwamp) { diff --git a/TombEngine/Game/effects/effects.cpp b/TombEngine/Game/effects/effects.cpp index 1d6202e4d..fa93e7b60 100644 --- a/TombEngine/Game/effects/effects.cpp +++ b/TombEngine/Game/effects/effects.cpp @@ -1236,43 +1236,58 @@ void TriggerDynamicLight(int x, int y, int z, short falloff, byte r, byte g, byt g_Renderer.AddDynamicLight(x, y, z, falloff, r, g, b); } -void WadeSplash(ItemInfo* item, int wh, int wd) +// TODO: Better implementation. +void SpawnPlayerSplash(const ItemInfo& item, int waterHeight, int waterDepth) { - auto probe1 = GetCollision(item); - auto probe2 = GetCollision(probe1.Block, item->Pose.Position.x, probe1.Position.Ceiling, item->Pose.Position.z); + // Get point collision. + auto pointColl0 = GetCollision(item); + auto pointColl1 = GetCollision(pointColl0.Block, item.Pose.Position.x, pointColl0.Position.Ceiling, item.Pose.Position.z); - if (!TestEnvironment(ENV_FLAG_WATER, probe1.RoomNumber) || - TestEnvironment(ENV_FLAG_WATER, probe1.RoomNumber) == TestEnvironment(ENV_FLAG_WATER, probe2.RoomNumber)) + if (!TestEnvironment(ENV_FLAG_WATER, pointColl0.RoomNumber) || + TestEnvironment(ENV_FLAG_WATER, pointColl0.RoomNumber) == TestEnvironment(ENV_FLAG_WATER, pointColl1.RoomNumber)) + { + return; + } + + const auto& bounds = GetBestFrame(item).BoundingBox; + if (item.Pose.Position.y + bounds.Y1 > waterHeight) return; - const auto& bounds = GetBestFrame(*item).BoundingBox; - if (item->Pose.Position.y + bounds.Y1 > wh) + if (item.Pose.Position.y + bounds.Y2 < waterHeight) return; - if (item->Pose.Position.y + bounds.Y2 < wh) - return; - - if (item->Animation.Velocity.y <= 0.0f || wd >= 474 || SplashCount != 0) + if (item.Animation.Velocity.y <= 0.0f || waterDepth >= 474 || SplashCount != 0) { if (!(Wibble & 0xF)) { - if (!(GetRandomControl() & 0xF) || item->Animation.ActiveState != LS_IDLE) + if (!(GetRandomControl() & 0xF) || item.Animation.ActiveState != LS_IDLE) { - if (item->Animation.ActiveState != LS_IDLE) - SpawnRipple(Vector3(item->Pose.Position.x, wh - 1, item->Pose.Position.z), item->RoomNumber, 112 + (GetRandomControl() & 15), (int)RippleFlags::SlowFade | (int)RippleFlags::LowOpacity); + if (item.Animation.ActiveState != LS_IDLE) + { + SpawnRipple( + Vector3(item.Pose.Position.x, waterHeight - 1, item.Pose.Position.z), + item.RoomNumber, 112 + (GetRandomControl() & 15), + (int)RippleFlags::SlowFade | (int)RippleFlags::LowOpacity); + } else - SpawnRipple(Vector3(item->Pose.Position.x, wh - 1, item->Pose.Position.z), item->RoomNumber, 112 + (GetRandomControl() & 15), (int)RippleFlags::LowOpacity); + { + SpawnRipple( + Vector3(item.Pose.Position.x, waterHeight - 1, item.Pose.Position.z), + item.RoomNumber, 112 + (GetRandomControl() & 15), + (int)RippleFlags::LowOpacity); + } } } } else { - SplashSetup.y = wh - 1; - SplashSetup.x = item->Pose.Position.x; - SplashSetup.z = item->Pose.Position.z; + SplashSetup.x = item.Pose.Position.x; + SplashSetup.y = waterHeight - 1; + SplashSetup.z = item.Pose.Position.z; SplashSetup.innerRadius = 16; - SplashSetup.splashPower = item->Animation.Velocity.z; - SetupSplash(&SplashSetup, probe1.RoomNumber); + SplashSetup.splashPower = item.Animation.Velocity.z; + + SetupSplash(&SplashSetup, pointColl0.RoomNumber); SplashCount = 16; } } diff --git a/TombEngine/Game/effects/effects.h b/TombEngine/Game/effects/effects.h index 4ac8024c2..7fb76b97b 100644 --- a/TombEngine/Game/effects/effects.h +++ b/TombEngine/Game/effects/effects.h @@ -273,7 +273,7 @@ void TriggerFlashSmoke(int x, int y, int z, short roomNumber); void TriggerMetalSparks(int x, int y, int z, int xv, int yv, int zv, const Vector3& color, int additional); void SpawnCorpseEffect(const Vector3& pos); void TriggerAttackFlame(const Vector3i& pos, const Vector3& color, int scale); -void WadeSplash(ItemInfo* item, int wh, int wd); +void SpawnPlayerSplash(const ItemInfo& item, int waterHeight, int waterDepth); void Splash(ItemInfo* item); void TriggerRocketFire(int x, int y, int z); void TriggerExplosionBubbles(int x, int y, int z, short roomNumber); diff --git a/TombEngine/Sound/sound.cpp b/TombEngine/Sound/sound.cpp index 82dfd9bbd..b434919dd 100644 --- a/TombEngine/Sound/sound.cpp +++ b/TombEngine/Sound/sound.cpp @@ -631,11 +631,11 @@ void StopSoundTracks(bool excludeAmbience) { for (int i = 0; i < (int)SoundTrackType::Count; i++) { - auto mode = (SoundTrackType)i; - if (excludeAmbience && mode == SoundTrackType::BGM) + auto type = (SoundTrackType)i; + if (excludeAmbience && type == SoundTrackType::BGM) continue; - StopSoundTrack((SoundTrackType)i, SOUND_XFADETIME_ONESHOT); + StopSoundTrack(type, SOUND_XFADETIME_ONESHOT); } }