diff --git a/include/MetroidPrime/CRippleManager.hpp b/include/MetroidPrime/CRippleManager.hpp index abfcbf32..001072fe 100644 --- a/include/MetroidPrime/CRippleManager.hpp +++ b/include/MetroidPrime/CRippleManager.hpp @@ -20,6 +20,15 @@ public: void Update(float dt); float GetLastRippleDeltaTime(TUniqueId rippler) const; void AddRipple(const CRipple& ripple); + + void SetMaxTimeFalloff(float time) { x0_maxTimeFalloff = time; } + float GetMaxTimeFalloff() const { return x0_maxTimeFalloff; } + + rstl::vector& Ripples() { return x4_ripples; } + const rstl::vector& GetRipples() const { return x4_ripples; } + + void SetAlpha(float a) { x14_alpha = a; } + float GetAlpha() const { return x14_alpha; } }; #endif // _CRIPPLEMANAGER diff --git a/src/MetroidPrime/CRippleManager.cpp b/src/MetroidPrime/CRippleManager.cpp index 6f8e5e10..e73d09fb 100644 --- a/src/MetroidPrime/CRippleManager.cpp +++ b/src/MetroidPrime/CRippleManager.cpp @@ -42,22 +42,23 @@ float CRippleManager::GetLastRippleDeltaTime(TUniqueId rippler) const { void CRippleManager::AddRipple(const CRipple& ripple) { float maxTime = 0.f; - float itTime; - rstl::vector< CRipple >::iterator t; rstl::vector< CRipple >::iterator oldestRipple = x4_ripples.end(); - rstl::vector< CRipple >::iterator it = x4_ripples.begin(); - for (; (t = oldestRipple, - it != x4_ripples.end() && (itTime = it->GetTime(), t = it, itTime != 9999.0f)); - ++it) { - if (itTime > maxTime) { + for (rstl::vector< CRipple >::iterator it = x4_ripples.begin(); it != x4_ripples.end(); ++it) { + if (it->GetTime() == 9999.0f) { oldestRipple = it; - maxTime = itTime; + break; + } + + if (it->GetTime() > maxTime) { + oldestRipple = it; + maxTime = it->GetTime(); } } - if (t != x4_ripples.end()) { - *t = ripple; - x0_maxTimeFalloff = rstl::max_val(x0_maxTimeFalloff, ripple.GetTimeFalloff()); + if (oldestRipple != x4_ripples.end()) { + *oldestRipple = ripple; + oldestRipple->SetTime(0.f); + SetMaxTimeFalloff(rstl::max_val(GetMaxTimeFalloff(), ripple.GetTimeFalloff())); } }