From 118fcf6d4e95361e457c0f67b48f80ce3108d4ec Mon Sep 17 00:00:00 2001 From: SuperDude88 <82904174+SuperDude88@users.noreply.github.com> Date: Sun, 17 May 2026 22:24:47 -0400 Subject: [PATCH] Use Explicit Template Specialization - Move migration of FrameInterpMode to use a unique specialization of loadFromJson This avoids coding special cases into the main template, which I think is more sustainable in the long-run if we need to migrate other settings ever --- src/dusk/config.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/dusk/config.cpp b/src/dusk/config.cpp index 3d15f1fded..e67365b0d2 100644 --- a/src/dusk/config.cpp +++ b/src/dusk/config.cpp @@ -61,12 +61,7 @@ void ConfigImpl::loadFromJson(ConfigVar& cVar, const json& jsonValue) { using Underlying = std::underlying_type_t; const bool b = jsonValue.get(); - Underlying raw; - if constexpr (std::is_same_v) { - raw = b ? static_cast(2) : static_cast(0); - } else { - raw = b ? static_cast(1) : static_cast(0); - } + const Underlying raw = b ? static_cast(1) : static_cast(0); cVar.setValue(sanitizeEnumValue(cVar, static_cast(raw)), false); return; @@ -175,6 +170,19 @@ namespace dusk::config { template class ConfigImpl; template class ConfigImpl; template class ConfigImpl; + + template<> void ConfigImpl::loadFromJson(ConfigVar& cVar, const json& jsonValue) { + if (jsonValue.is_boolean()) { + const bool b = jsonValue.get(); + + const FrameInterpMode mode = b ? FrameInterpMode::Unlimited : FrameInterpMode::Off; + + cVar.setValue(sanitizeEnumValue(cVar, mode), false); + return; + } + + cVar.setValue(sanitizeEnumValue(cVar, jsonValue.get()), false); + } template class ConfigImpl; }