From 8c44d62ed97538f07eebec2399a43044c3c224d8 Mon Sep 17 00:00:00 2001 From: Dario Date: Sat, 7 Dec 2024 18:52:22 -0300 Subject: [PATCH] Fix default value for Enums when the key is missing. --- UnleashedRecomp/user/config_detail.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/UnleashedRecomp/user/config_detail.h b/UnleashedRecomp/user/config_detail.h index 4966f68..183bee0 100644 --- a/UnleashedRecomp/user/config_detail.h +++ b/UnleashedRecomp/user/config_detail.h @@ -281,9 +281,16 @@ public: } else if constexpr (std::is_enum_v) { - auto it = EnumTemplate->begin(); - - Value = EnumTemplate->at(section[Name].value_or(static_cast(it->first))); + std::string value = section[Name].value_or(std::string()); + auto it = EnumTemplate->find(value); + if (it != EnumTemplate->end()) + { + Value = it->second; + } + else + { + Value = DefaultValue; + } } else {