From b1657b9cd5609a5d2414d914890e8d0fe122abb2 Mon Sep 17 00:00:00 2001 From: Unreal-Dan <72595612+Unreal-Dan@users.noreply.github.com> Date: Fri, 22 Sep 2023 16:00:44 -0700 Subject: [PATCH] Fix wrong pattern arg count causing savefile offset (#129) * Fix wrong pattern arg count causing savefile offset * Version 1.1 --- VortexEngine/src/Menus/MenuList/Randomizer.cpp | 2 ++ VortexEngine/src/Patterns/Pattern.cpp | 2 +- VortexEngine/src/Patterns/PatternArgs.cpp | 2 +- VortexEngine/src/VortexConfig.h | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/VortexEngine/src/Menus/MenuList/Randomizer.cpp b/VortexEngine/src/Menus/MenuList/Randomizer.cpp index 50e77116af..d741d3eb71 100644 --- a/VortexEngine/src/Menus/MenuList/Randomizer.cpp +++ b/VortexEngine/src/Menus/MenuList/Randomizer.cpp @@ -222,6 +222,8 @@ bool Randomizer::rollPattern(Random &ctx, Mode *pMode, LedPos pos) newPat = PATTERN_BLEND; // this is the number of blinks to a complementary color args.arg7 = ctx.next8(0, 3); + // up to arg7 is filled now + args.numArgs = 7; } return pMode->setPattern(newPat, pos, &args); } diff --git a/VortexEngine/src/Patterns/Pattern.cpp b/VortexEngine/src/Patterns/Pattern.cpp index 7b2ea29b88..311ee3d0af 100644 --- a/VortexEngine/src/Patterns/Pattern.cpp +++ b/VortexEngine/src/Patterns/Pattern.cpp @@ -63,7 +63,7 @@ void Pattern::serialize(ByteStream &buffer) const PatternArgs defaults = PatternBuilder::getDefaultArgs(m_patternID); // generate a bitmap of which args are defaulted uint8_t argmap = ARG_NONE; - for (uint32_t i = 0; i < args.numArgs; ++i) { + for (uint32_t i = 0; i < MAX_ARGS; ++i) { if (args.args[i] != defaults.args[i]) { ARGMAP_SET(argmap, i); } diff --git a/VortexEngine/src/Patterns/PatternArgs.cpp b/VortexEngine/src/Patterns/PatternArgs.cpp index 9c70218b45..a26389dff8 100644 --- a/VortexEngine/src/Patterns/PatternArgs.cpp +++ b/VortexEngine/src/Patterns/PatternArgs.cpp @@ -174,7 +174,7 @@ uint8_t PatternArgs::operator[](int index) const void PatternArgs::serialize(ByteStream &buffer, ArgMap argmap) const { buffer.serialize(argmap); - for (uint8_t i = 0; i < numArgs; ++i) { + for (uint8_t i = 0; i < MAX_ARGS; ++i) { if (ARGMAP_ISSET(argmap, i)) { buffer.serialize(args[i]); } diff --git a/VortexEngine/src/VortexConfig.h b/VortexEngine/src/VortexConfig.h index 4b0e6852d1..f031a7ea01 100644 --- a/VortexEngine/src/VortexConfig.h +++ b/VortexEngine/src/VortexConfig.h @@ -14,7 +14,7 @@ // a savefile produced by 1.1 should be loadable by an engine on 1.2 // and vice versa. But an engine on 2.0 cannot share savefiles with // either of the engines on version 1.1 or 1.2 -#define VORTEX_VERSION_MINOR 0 +#define VORTEX_VERSION_MINOR 1 // produces a number like 1.0 #define VORTEX_VERSION_NUMBER VORTEX_VERSION_MAJOR.VORTEX_VERSION_MINOR