From 8561245fda48448160ecc493d40e9f568abae3e9 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Tue, 29 Jun 2021 18:43:47 +0200 Subject: [PATCH] Minor refactor making use of std::clamp --- components/esm/cellref.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/components/esm/cellref.cpp b/components/esm/cellref.cpp index b4d6ac7a72..20edf00a8b 100644 --- a/components/esm/cellref.cpp +++ b/components/esm/cellref.cpp @@ -72,10 +72,7 @@ void ESM::CellRef::loadData(ESMReader &esm, bool &isDeleted) break; case ESM::FourCC<'X','S','C','L'>::value: esm.getHT(mScale); - if (mScale < 0.5) - mScale = 0.5; - else if (mScale > 2) - mScale = 2; + mScale = std::clamp(mScale, 0.5f, 2.0f); break; case ESM::FourCC<'A','N','A','M'>::value: mOwner = esm.getHString(); @@ -153,12 +150,7 @@ void ESM::CellRef::save (ESMWriter &esm, bool wideRefNum, bool inInventory, bool } if (mScale != 1.0) { - float scale = mScale; - if (scale < 0.5) - scale = 0.5; - else if (scale > 2) - scale = 2; - esm.writeHNT("XSCL", scale); + esm.writeHNT("XSCL", std::clamp(mScale, 0.5f, 2.0f)); } if (!inInventory)