Skip to content

Commit

Permalink
Fix array pointer zeroing glitch
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma144 committed Aug 14, 2020
1 parent db58644 commit 74a73a4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
2 changes: 1 addition & 1 deletion App/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 6 additions & 15 deletions Source/Panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,11 @@ void Panel::WriteDecorations() {
}
else {
_memory->WritePanelData<int>(id, NUM_DECORATIONS, { static_cast<int>(decorations.size()) });
if (colorMode == ColorMode::Reset || colorMode == ColorMode::Alternate) {
_memory->WritePanelData<int>(id, DECORATION_COLORS, { 0 });
if (colorMode == ColorMode::WriteColors || colorMode == ColorMode::Treehouse || colorMode == ColorMode::TreehouseLoad || _memory->ReadPanelData<int>(id, DECORATION_COLORS))
_memory->WriteArray<Color>(id, DECORATION_COLORS, decorationColors);
else if (colorMode == ColorMode::Reset || colorMode == ColorMode::Alternate) {
_memory->WritePanelData<int>(id, PUSH_SYMBOL_COLORS, { colorMode == ColorMode::Reset ? 0 : 1 });
}
if (colorMode == ColorMode::WriteColors || colorMode == ColorMode::Treehouse || colorMode == ColorMode::TreehouseLoad)
_memory->WriteArray<Color>(id, DECORATION_COLORS, decorationColors);
if (colorMode == ColorMode::Treehouse || colorMode == ColorMode::TreehouseLoad) {
_memory->WritePanelData<int>(id, PUSH_SYMBOL_COLORS, { 1 });
_memory->WritePanelData<Color>(id, SYMBOL_A, { { 0, 0, 0, 1 } }); //Black
Expand Down Expand Up @@ -786,25 +785,17 @@ 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<int>(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<int>(id, REFLECTION_DATA, { 0 });
_memory->WritePanelData<long long>(id, REFLECTION_DATA, { 0 });
}
else if (symmetryData.size() > 0) {
_style |= Style::SYMMETRICAL;
_memory->WriteArray<int>(id, REFLECTION_DATA, symmetryData);
}
else {
_style &= ~Style::SYMMETRICAL;
_memory->WritePanelData<int>(id, REFLECTION_DATA, { 0 });
_memory->WritePanelData<long long>(id, REFLECTION_DATA, { 0 });
}

_memory->WritePanelData<int>(id, NUM_DOTS, { static_cast<int>(intersectionFlags.size()) });
Expand Down
12 changes: 5 additions & 7 deletions Source/PuzzleList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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},
Expand Down

0 comments on commit 74a73a4

Please sign in to comment.