From aacbccb2d59d3d985ee211237f9b5098492d1c2e Mon Sep 17 00:00:00 2001 From: Avril Date: Sat, 5 Jun 2021 20:35:09 +0100 Subject: [PATCH] contrived bs example test --- src/test/main.cpp | 80 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/src/test/main.cpp b/src/test/main.cpp index 15d1753..79d3c55 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -4,8 +4,88 @@ #include #include +#include + using namespace _cow_util; +namespace Tiling { + struct Map; + + enum class Direction { + Up, Right, Down, Left + }; + + // Quad-linked list to upper, right, lower, left segments. + struct Segment { + friend class Map; + Segment(size_t id) : id(id) {} + //Segment(Map& owner) : owner(owner){} + + ~Segment() { + // Unset pointers of neighbours. + if(above) above->below = nullptr; + if(right) right->left = nullptr; + if(below) below->above = nullptr; + if(left) left->right = nullptr; + } + private: + size_t id; + + //TODO + //Cow raw_tiles; + //Cow taw_graphics; + + // Links will be NULL if there is no loaded segment in their position. + // The objects themselves live in Map's segment registry (seg_reg). + Segment* above; + Segment* right; + Segment* below; + Segment* left; + }; + + struct Map { + // Remove a registered Segment. Resetting its neighbours' links if needed. + // The reference will be invalid after calling this function. + void unregister_segment(Segment& segment) + { + if(segment.id seg_reg; + }; +} + template void print_slice(Slice memory) {