From a7306ed64ae96a0665b060db63b25f1dbb27ce32 Mon Sep 17 00:00:00 2001 From: PancakeTAS Date: Fri, 18 Jul 2025 15:30:08 +0200 Subject: [PATCH] add config version --- include/config/default_conf.hpp | 2 +- src/config/config.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/config/default_conf.hpp b/include/config/default_conf.hpp index 8d5f0ac..4649e9a 100644 --- a/include/config/default_conf.hpp +++ b/include/config/default_conf.hpp @@ -2,7 +2,7 @@ #include -const std::string DEFAULT_CONFIG = R"( +const std::string DEFAULT_CONFIG = R"(version = 1 [global] # override the location of Lossless Scaling # dll = "/games/Lossless Scaling" diff --git a/src/config/config.cpp b/src/config/config.cpp index c8ec68a..91472bb 100644 --- a/src/config/config.cpp +++ b/src/config/config.cpp @@ -204,6 +204,10 @@ void Config::updateConfig(const std::string& file) { std::optional parsed; try { parsed.emplace(toml::parse(file)); + if (!parsed->contains("version")) + throw std::runtime_error("Configuration file is missing 'version' field"); + if (parsed->at("version").as_integer() != 1) + throw std::runtime_error("Configuration file version is not supported, expected 1"); } catch (const std::exception& e) { throw LSFG::rethrowable_error("Unable to parse configuration file", e); }