From 827b75320cd8de9f458b794d106add53e9fa38a6 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sun, 28 Mar 2021 01:40:48 -0500 Subject: [PATCH] Fix profile versioning. Profile version 1 used protocol version 0. Move profile version up to 2 using protocol version 2 and keep them synchronized if a new protocol version is added --- ProfileManager.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ProfileManager.cpp b/ProfileManager.cpp index 8b033124..406cbb39 100644 --- a/ProfileManager.cpp +++ b/ProfileManager.cpp @@ -9,7 +9,7 @@ #include #define OPENRGB_PROFILE_HEADER "OPENRGB_PROFILE" -#define OPENRGB_PROFILE_VERSION 1 +#define OPENRGB_PROFILE_VERSION OPENRGB_SDK_PROTOCOL_VERSION namespace fs = std::experimental::filesystem; @@ -155,6 +155,16 @@ std::vector ProfileManager::LoadProfileToList controller_file.read(profile_string, 16); controller_file.read((char *)&profile_version, sizeof(unsigned int)); + /*---------------------------------------------------------*\ + | Profile version started at 1 and protocol version started | + | at 0. Version 1 profiles should use protocol 0, but 2 or | + | greater should be synchronized | + \*---------------------------------------------------------*/ + if(profile_version == 1) + { + profile_version = 0; + } + controller_offset += 16 + sizeof(unsigned int); controller_file.seekg(controller_offset);