diff options
author | Vittorio Romeo <vittorio.romeo@outlook.com> | 2021-11-04 21:54:54 +0000 |
---|---|---|
committer | Vittorio Romeo <vittorio.romeo@outlook.com> | 2021-11-04 21:54:54 +0000 |
commit | 542751ee9657b33b7ba2ecea2004eabf7eb4652d (patch) | |
tree | 9e9ccac745dbff0e8553326dace4fc8201b0aab0 | |
parent | cdd9680b20f0922417bcc0ce38a72361f391d90d (diff) |
Fix incorrect access to std::optional
-rw-r--r-- | src/SSVOpenHexagon/Core/HGUpdate.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/SSVOpenHexagon/Core/HGUpdate.cpp b/src/SSVOpenHexagon/Core/HGUpdate.cpp index dff026fd..afe5eb47 100644 --- a/src/SSVOpenHexagon/Core/HGUpdate.cpp +++ b/src/SSVOpenHexagon/Core/HGUpdate.cpp @@ -786,30 +786,34 @@ void HexagonGame::updateRotation(ssvu::FT mFT) void HexagonGame::updateCameraShake(ssvu::FT mFT) { - if(!backgroundCamera.has_value() || !overlayCamera.has_value()) + if(!backgroundCamera.has_value() || !overlayCamera.has_value() || + status.cameraShake <= 0) { return; } - if(status.cameraShake <= 0) - { - backgroundCamera->setCenter( - preShakeCenters->backgroundCameraPreShakeCenter); - - overlayCamera->setCenter(preShakeCenters->overlayCameraPreShakeCenter); - - preShakeCenters.reset(); - return; - } - status.cameraShake -= mFT; if(!preShakeCenters.has_value()) { + if(status.cameraShake <= 0) + { + backgroundCamera->setCenter( + preShakeCenters->backgroundCameraPreShakeCenter); + + overlayCamera->setCenter( + preShakeCenters->overlayCameraPreShakeCenter); + + preShakeCenters.reset(); + return; + } + preShakeCenters = PreShakeCenters{ backgroundCamera->getCenter(), overlayCamera->getCenter()}; } + SSVOH_ASSERT(backgroundCamera.has_value()); + SSVOH_ASSERT(overlayCamera.has_value()); SSVOH_ASSERT(preShakeCenters.has_value()); const auto makeShakeVec = [this] |