From 74a73a4cdb2562c4574d7d78d88db2a43940de70 Mon Sep 17 00:00:00 2001 From: Brian Robinson Date: Fri, 14 Aug 2020 16:06:19 -0400 Subject: [PATCH] Fix array pointer zeroing glitch --- App/Version.h | 2 +- Source/Panel.cpp | 21 ++++++--------------- Source/PuzzleList.cpp | 12 +++++------- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/App/Version.h b/App/Version.h index ce159e2b..6a7665a2 100644 --- a/App/Version.h +++ b/App/Version.h @@ -5,7 +5,7 @@ #define MAJOR 1 #define MINOR 1 -#define PATCH 3 +#define PATCH 4 #define VERSION_STR TO_STRING(MAJOR) L"." TO_STRING(MINOR) L"." TO_STRING(PATCH) #define VERSION MAJOR, MINOR, PATCH diff --git a/Source/Panel.cpp b/Source/Panel.cpp index 6c16ba77..0b54d457 100644 --- a/Source/Panel.cpp +++ b/Source/Panel.cpp @@ -472,12 +472,11 @@ void Panel::WriteDecorations() { } else { _memory->WritePanelData(id, NUM_DECORATIONS, { static_cast(decorations.size()) }); - if (colorMode == ColorMode::Reset || colorMode == ColorMode::Alternate) { - _memory->WritePanelData(id, DECORATION_COLORS, { 0 }); + if (colorMode == ColorMode::WriteColors || colorMode == ColorMode::Treehouse || colorMode == ColorMode::TreehouseLoad || _memory->ReadPanelData(id, DECORATION_COLORS)) + _memory->WriteArray(id, DECORATION_COLORS, decorationColors); + else if (colorMode == ColorMode::Reset || colorMode == ColorMode::Alternate) { _memory->WritePanelData(id, PUSH_SYMBOL_COLORS, { colorMode == ColorMode::Reset ? 0 : 1 }); } - if (colorMode == ColorMode::WriteColors || colorMode == ColorMode::Treehouse || colorMode == ColorMode::TreehouseLoad) - _memory->WriteArray(id, DECORATION_COLORS, decorationColors); if (colorMode == ColorMode::Treehouse || colorMode == ColorMode::TreehouseLoad) { _memory->WritePanelData(id, PUSH_SYMBOL_COLORS, { 1 }); _memory->WritePanelData(id, SYMBOL_A, { { 0, 0, 0, 1 } }); //Black @@ -786,17 +785,9 @@ void Panel::WriteIntersections() { } //Symmetry Data - if (id == 0x00076 && symmetry == Symmetry::None) { - _style &= ~Style::SYMMETRICAL; - //For some reason, removing the symmetry outright sometimes makes the game crash, so this is a workaround - intersectionFlags.push_back(IntersectionFlags::NO_POINT); intersections.push_back(0); intersections.push_back(0); - for (int i = 0; i < intersectionFlags.size(); i++) symmetryData.push_back((int)intersectionFlags.size() - 1); - _memory->WriteArray(id, REFLECTION_DATA, symmetryData); - } - else if (id == 0x01D3F && symmetry == Symmetry::None) { + if (id == 0x01D3F && symmetry == Symmetry::None || id == 0x00076 && symmetry == Symmetry::None) { _style &= ~Style::SYMMETRICAL; - //This has been reported to cause crashes for some people, but this puzzle is stubborn and I can't get it to accept any workarounds - _memory->WritePanelData(id, REFLECTION_DATA, { 0 }); + _memory->WritePanelData(id, REFLECTION_DATA, { 0 }); } else if (symmetryData.size() > 0) { _style |= Style::SYMMETRICAL; @@ -804,7 +795,7 @@ void Panel::WriteIntersections() { } else { _style &= ~Style::SYMMETRICAL; - _memory->WritePanelData(id, REFLECTION_DATA, { 0 }); + _memory->WritePanelData(id, REFLECTION_DATA, { 0 }); } _memory->WritePanelData(id, NUM_DOTS, { static_cast(intersectionFlags.size()) }); diff --git a/Source/PuzzleList.cpp b/Source/PuzzleList.cpp index 7382b788..27c7fd0f 100644 --- a/Source/PuzzleList.cpp +++ b/Source/PuzzleList.cpp @@ -1099,7 +1099,7 @@ void PuzzleList::GenerateSymmetryH() generator->generate(0x00073, Decoration::Poly | Decoration::Color::Yellow, 3, Decoration::Start, 1, Decoration::Exit, 1); generator->setGridSize(7, 7); generator->setFlag(Generate::Config::ResetColors); - generator->generate(0x00077, Decoration::Triangle | Decoration::Color::Orange, 10, Decoration::Start, 1, Decoration::Exit, 1); + generator->generate(0x00077, Decoration::Triangle | Decoration::Color::Yellow, 8, Decoration::Start, 1, Decoration::Exit, 1); generator->setSymmetry(Panel::Symmetry::FlipXY); generator->generate(0x00079, Decoration::Dot | Decoration::Color::Blue, 2, Decoration::Dot | Decoration::Color::Yellow, 2, Decoration::Dot, 8, Decoration::Eraser | Decoration::Color::White, 1, Decoration::Start, 1, Decoration::Exit, 1); @@ -1489,8 +1489,6 @@ void PuzzleList::GenerateTreehouseH() generator->generate(0x17D2D, Decoration::Star | Decoration::Color::Magenta, 4, Decoration::Star | Decoration::Color::Orange, 4, Decoration::Dot_Intersection, 36); generator->generate(0x17D6C, Decoration::Star | Decoration::Color::Magenta, 4, Decoration::Star | Decoration::Color::Orange, 6, Decoration::Dot_Intersection, 36); //Pink Bridge 2 - generator->removeFlag(Generate::Config::TreehouseColors); - generator->setFlag(Generate::Config::ResetColors); generator->setGridSize(4, 4); generator->pathWidth = 1; generator->generate(0x17D9B, Decoration::Triangle | Decoration::Color::Magenta, 4, @@ -1504,8 +1502,6 @@ void PuzzleList::GenerateTreehouseH() generator->generate(0x17D97, Decoration::Triangle | Decoration::Color::Magenta, 4, Decoration::Stone | Decoration::Color::Black, 1, Decoration::Star | Decoration::Color::Black, 1, Decoration::Stone | Decoration::Color::Magenta, 2, Decoration::Star | Decoration::Color::White, 2); - generator->removeFlag(Generate::Config::ResetColors); - generator->setFlag(Generate::Config::TreehouseColors); generator->generate(0x17BDF, Decoration::Triangle | Decoration::Color::Orange, 2, Decoration::Triangle | Decoration::Color::Magenta, 2, Decoration::Star | Decoration::Color::Magenta, 2, Decoration::Star | Decoration::Color::Green, 2, Decoration::Stone | Decoration::Color::Orange, 2, Decoration::Stone | Decoration::Color::Green, 2); @@ -1606,7 +1602,7 @@ void PuzzleList::GenerateTreehouseH() { Decoration::Triangle | Decoration::Color::Orange, 2 }, { Decoration::Triangle | Decoration::Color::Magenta, 2 }, { Decoration::Triangle | Decoration::Color::Green, 1 }, { Decoration::Triangle | Decoration::Color::White, 1 },{ Decoration::Triangle | Decoration::Color::Black, 1 } }); //Green Bridge - generator->removeFlag(Generate::Config::ResetColors); + generator->removeFlag(Generate::Config::TreehouseColors); generator->setFlag(Generate::Config::AlternateColors); generator->setGridSize(5, 5); generator->pathWidth = 0.9f; @@ -1917,6 +1913,8 @@ void PuzzleList::GenerateMountainH() generator->generate(0x0383F, Decoration::Triangle | Decoration::Color::Orange, 4, Decoration::Dot_Intersection, 45, Decoration::Start, 5); specialCase->initPillarSymmetry(generator, 0x09E56, Panel::Symmetry::PillarVertical); + generator->removeFlagOnce(Generate::Config::ResetColors); + generator->setFlagOnce(Generate::Config::TreehouseColors); generator->generate(0x09E56, Decoration::Star | Decoration::Color::Orange, 3, Decoration::Star | Decoration::Color::Magenta, 3, Decoration::Triangle | Decoration::Color::Orange, 2, Decoration::Triangle | Decoration::Color::Magenta, 2, Decoration::Eraser | Decoration::Color::Magenta, 1, Decoration::Start, 3); @@ -2019,7 +2017,7 @@ void PuzzleList::GenerateCavesH() generator->resetConfig(); generator->setFlag(Generate::Config::DecorationsOnly); specialCase->generateCenterPerspective(0x288EA, { { Decoration::Star | Decoration::Color::Black, 8 }, - {Decoration::Star | Decoration::Color::White, 6} }, Decoration::Star); + { Decoration::Star | Decoration::Color::White, 6 } }, Decoration::Star); specialCase->generateCenterPerspective(0x288FC, { { Decoration::Poly, 4 }, { Decoration::Eraser | Decoration::Color::White, 1 } }, Decoration::Eraser); specialCase->generateCenterPerspective(0x289E7, { { Decoration::Triangle | Decoration::Color::Orange, 10},