From 040c724a8a74498516ed8a95fc4237db03d1142e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 12 Oct 2019 13:52:37 -0400 Subject: [PATCH] CAutoMapper: Collapse case statements in ProcessMapZoomInput() Same behavior as the game executable, but without the code duplication. --- Runtime/AutoMapper/CAutoMapper.cpp | 40 +++++++++++++----------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/Runtime/AutoMapper/CAutoMapper.cpp b/Runtime/AutoMapper/CAutoMapper.cpp index fca1a7642..7d544b48d 100644 --- a/Runtime/AutoMapper/CAutoMapper.cpp +++ b/Runtime/AutoMapper/CAutoMapper.cpp @@ -615,31 +615,25 @@ void CAutoMapper::ProcessMapZoomInput(const CFinalInput& input, const CStateMana } } - EZoomState nextZoomState = EZoomState::None; - switch (x324_zoomState) { - case EZoomState::None: - if (in) - nextZoomState = EZoomState::In; - else if (out) - nextZoomState = EZoomState::Out; - break; - case EZoomState::In: - if (in) - nextZoomState = EZoomState::In; - else if (out) - nextZoomState = EZoomState::Out; - break; - case EZoomState::Out: - if (in) - nextZoomState = EZoomState::In; - else if (out) - nextZoomState = EZoomState::Out; - break; - default: - break; - } + const EZoomState nextZoomState = [this, in, out] { + switch (x324_zoomState) { + case EZoomState::None: + case EZoomState::In: + case EZoomState::Out: + if (in) { + return EZoomState::In; + } + if (out) { + return EZoomState::Out; + } + return EZoomState::None; + default: + return EZoomState::None; + } + }(); x324_zoomState = nextZoomState; + float delta = input.DeltaTime() * 60.f * (x1bc_state == EAutoMapperState::MapScreen ? 1.f : 4.f) * g_tweakAutoMapper->GetCamZoomUnitsPerFrame() * zoomSpeed; float oldDist = xa8_renderStates[0].x18_camDist;