From ecbcb91e95a08201fbf90476ee4a18526cfc80bb Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Sat, 9 Nov 2019 12:04:19 -0800 Subject: Commit early, commit often --- Source/Panel.h | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) (limited to 'Source/Panel.h') diff --git a/Source/Panel.h b/Source/Panel.h index caa7b04..0ee94f8 100644 --- a/Source/Panel.h +++ b/Source/Panel.h @@ -30,30 +30,31 @@ enum Color { struct Decoration { Shape type; Color color; - int polyshape; + int polyshape = 0; // For triangles only - int count; + int count = 0; }; struct Cell { - bool start; + bool start = false; enum class Dir {NONE, LEFT, RIGHT, UP, DOWN}; - Dir end; - std::shared_ptr decoration; + Dir end = Dir::NONE; + std::shared_ptr decoration = nullptr; enum class Dot {NONE, BLACK, BLUE, YELLOW, INVISIBLE}; - Dot dot; + Dot dot = Dot::NONE; enum class Gap {NONE, BREAK, FULL}; - Gap gap; + Gap gap = Gap::NONE; }; struct Puzzle { int16_t height; int16_t width; + bool hasDecorations = false; std::vector> grid; enum class Symmetry {NONE, X, Y, XY}; - Symmetry sym; - bool pillar; + Symmetry sym = Symmetry::NONE; + bool pillar = false; }; class PuzzleSerializer { @@ -65,13 +66,16 @@ public: private: // @Bug: Blue and orange are swapped? enum Flags { - IS_ENDPOINT = 0x1, - IS_STARTPOINT = 0x2, - DOT_IS_BLUE = 0x100, - DOT_IS_ORANGE = 0x200, - DOT_IS_INVISIBLE = 0x1000, - IS_GAP = 0x10000, - HAS_DOT = 0x40020, + IS_ENDPOINT = 0x1, + IS_STARTPOINT = 0x2, + IS_FULL_GAP = 0x8, + HAS_DOT = 0x20, + DOT_IS_BLUE = 0x100, + DOT_IS_ORANGE = 0x200, + DOT_IS_INVISIBLE = 0x1000, + HAS_NO_CONN = 0x100000, + HAS_VERTI_CONN = 0x200000, + HAS_HORIZ_CONN = 0x400000, }; void ReadIntersections(Puzzle& p, int id); @@ -79,12 +83,14 @@ private: void WriteIntersections(const Puzzle& p, int id); void WriteDecorations(const Puzzle& p, int id); - std::tuple loc_to_xy(const Puzzle& p, int location); - int xy_to_loc(const Puzzle& p, int x, int y); + std::tuple loc_to_xy(const Puzzle& p, int location) const; + int xy_to_loc(const Puzzle& p, int x, int y) const; // Decoration location - std::tuple dloc_to_xy(const Puzzle& p, int location); - int xy_to_dloc(const Puzzle& p, int x, int y); - Cell::Dot FlagsToDot(int flags); + std::tuple dloc_to_xy(const Puzzle& p, int location) const; + int xy_to_dloc(const Puzzle& p, int x, int y) const; + Cell::Dot FlagsToDot(int flags) const; + // Iterate connection lists for another location which is connected to us; return that other location. + int FindConnection(int i, const std::vector& connections_a, const std::vector& connections_b) const; std::shared_ptr _memory; }; -- cgit 1.4.1