diff options
author | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-18 09:41:22 -0800 |
---|---|---|
committer | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-18 09:41:22 -0800 |
commit | c282663a96ae9704a59c55c9300dbc8c49e0ef39 (patch) | |
tree | 071a26b8e58b8aac4d347c6a8200a4b01663abe1 /Source/Randomizer2.cpp | |
parent | bff40e55c9c55fbc8439bb225d1937b2d805e629 (diff) | |
download | witness-tutorializer-c282663a96ae9704a59c55c9300dbc8c49e0ef39.tar.gz witness-tutorializer-c282663a96ae9704a59c55c9300dbc8c49e0ef39.tar.bz2 witness-tutorializer-c282663a96ae9704a59c55c9300dbc8c49e0ef39.zip |
Add sanity checks for overwriting buffers
Diffstat (limited to 'Source/Randomizer2.cpp')
-rw-r--r-- | Source/Randomizer2.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Source/Randomizer2.cpp b/Source/Randomizer2.cpp index 7a50c7b..c28795a 100644 --- a/Source/Randomizer2.cpp +++ b/Source/Randomizer2.cpp | |||
@@ -14,7 +14,7 @@ Randomizer2::Randomizer2(const std::shared_ptr<Memory>& memory) : _memory(memory | |||
14 | 14 | ||
15 | void Randomizer2::Randomize() { | 15 | void Randomizer2::Randomize() { |
16 | RandomizeTutorial(); | 16 | RandomizeTutorial(); |
17 | RandomizeKeep(); | 17 | // RandomizeKeep(); |
18 | } | 18 | } |
19 | 19 | ||
20 | void Randomizer2::RandomizeTutorial() { | 20 | void Randomizer2::RandomizeTutorial() { |
@@ -24,7 +24,7 @@ void Randomizer2::RandomizeTutorial() { | |||
24 | p.grid[0][8].start = true; | 24 | p.grid[0][8].start = true; |
25 | p.grid[8][0].end = Cell::Dir::UP; | 25 | p.grid[8][0].end = Cell::Dir::UP; |
26 | 26 | ||
27 | for (Pos pos : Randomizer2Core::CutEdges(p, 14)) { | 27 | for (Pos pos : Randomizer2Core::CutEdges(p, 14, true)) { |
28 | p.grid[pos.x][pos.y].gap = Cell::Gap::FULL; | 28 | p.grid[pos.x][pos.y].gap = Cell::Gap::FULL; |
29 | } | 29 | } |
30 | _serializer.WritePuzzle(p, 0x293); | 30 | _serializer.WritePuzzle(p, 0x293); |
@@ -32,7 +32,7 @@ void Randomizer2::RandomizeTutorial() { | |||
32 | 32 | ||
33 | { | 33 | { |
34 | Puzzle p; | 34 | Puzzle p; |
35 | p.NewGrid(7, 7); | 35 | p.NewGrid(6, 6); |
36 | 36 | ||
37 | switch (Random::RandInt(1, 4)) { | 37 | switch (Random::RandInt(1, 4)) { |
38 | case 1: | 38 | case 1: |
@@ -60,7 +60,7 @@ void Randomizer2::RandomizeTutorial() { | |||
60 | break; | 60 | break; |
61 | } | 61 | } |
62 | 62 | ||
63 | for (Pos pos : Randomizer2Core::CutEdges(p, 35)) { | 63 | for (Pos pos : Randomizer2Core::CutEdges(p, 35, true)) { |
64 | p.grid[pos.x][pos.y].gap = Cell::Gap::FULL; | 64 | p.grid[pos.x][pos.y].gap = Cell::Gap::FULL; |
65 | } | 65 | } |
66 | 66 | ||
@@ -88,7 +88,7 @@ void Randomizer2::RandomizeKeep() { | |||
88 | p.grid[4][8].start = true; | 88 | p.grid[4][8].start = true; |
89 | p.grid[6][0].end = Cell::Dir::UP; | 89 | p.grid[6][0].end = Cell::Dir::UP; |
90 | 90 | ||
91 | std::vector<Pos> cutEdges = Randomizer2Core::CutEdges2(p, 5); | 91 | std::vector<Pos> cutEdges = Randomizer2Core::CutEdges(p, 5, false); |
92 | Puzzle copy = p; | 92 | Puzzle copy = p; |
93 | std::vector<int> gates = {0x00344, 0x00488, 0x00489, 0x00495, 0x00496}; | 93 | std::vector<int> gates = {0x00344, 0x00488, 0x00489, 0x00495, 0x00496}; |
94 | for (int i=0; i<gates.size(); i++) { | 94 | for (int i=0; i<gates.size(); i++) { |
@@ -118,7 +118,7 @@ void Randomizer2::RandomizeKeep() { | |||
118 | p.grid[0][8].start = true; | 118 | p.grid[0][8].start = true; |
119 | p.grid[8][0].end = Cell::Dir::RIGHT; | 119 | p.grid[8][0].end = Cell::Dir::RIGHT; |
120 | 120 | ||
121 | std::vector<Pos> cutEdges = Randomizer2Core::CutEdges2(p, 7); | 121 | std::vector<Pos> cutEdges = Randomizer2Core::CutEdges(p, 7, false); |
122 | for (Pos pos : cutEdges) { | 122 | for (Pos pos : cutEdges) { |
123 | p.grid[pos.x][pos.y].gap = Cell::Gap::FULL; | 123 | p.grid[pos.x][pos.y].gap = Cell::Gap::FULL; |
124 | } | 124 | } |
@@ -133,7 +133,7 @@ void Randomizer2::RandomizeKeep() { | |||
133 | q.grid[pos.x][pos.y].gap = Cell::Gap::FULL; | 133 | q.grid[pos.x][pos.y].gap = Cell::Gap::FULL; |
134 | } | 134 | } |
135 | // Cut to 6 of 9 additional edges | 135 | // Cut to 6 of 9 additional edges |
136 | for (Pos pos : Randomizer2Core::CutEdges2(q, 6)) { | 136 | for (Pos pos : Randomizer2Core::CutEdges(q, 6, false)) { |
137 | q.grid[pos.x][pos.y].gap = Cell::Gap::FULL; | 137 | q.grid[pos.x][pos.y].gap = Cell::Gap::FULL; |
138 | } | 138 | } |
139 | _serializer.WritePuzzle(q, 0x19DC); | 139 | _serializer.WritePuzzle(q, 0x19DC); |
@@ -158,7 +158,7 @@ void Randomizer2::RandomizeKeep() { | |||
158 | 158 | ||
159 | std::vector<int> pebbleMarkers = {0x034a9, 0x034b1, 0x034be, 0x034c4}; | 159 | std::vector<int> pebbleMarkers = {0x034a9, 0x034b1, 0x034be, 0x034c4}; |
160 | 160 | ||
161 | std::vector<Pos> cutEdges = Randomizer2Core::CutEdges2(p, 7); | 161 | std::vector<Pos> cutEdges = Randomizer2Core::CutEdges(p, 7, false); |
162 | for (Pos pos : cutEdges) { | 162 | for (Pos pos : cutEdges) { |
163 | p.grid[pos.x][pos.y].gap = Cell::Gap::BREAK; | 163 | p.grid[pos.x][pos.y].gap = Cell::Gap::BREAK; |
164 | } | 164 | } |
@@ -187,7 +187,7 @@ void Randomizer2::RandomizeKeep() { | |||
187 | p.grid[0][8].start = true; | 187 | p.grid[0][8].start = true; |
188 | p.grid[4][0].end = Cell::Dir::UP; | 188 | p.grid[4][0].end = Cell::Dir::UP; |
189 | 189 | ||
190 | std::vector<Pos> cutEdges = Randomizer2Core::CutEdges2(p, 2); | 190 | std::vector<Pos> cutEdges = Randomizer2Core::CutEdges(p, 2, false); |
191 | for (Pos pos : cutEdges) { | 191 | for (Pos pos : cutEdges) { |
192 | p.grid[pos.x][pos.y].gap = Cell::Gap::FULL; | 192 | p.grid[pos.x][pos.y].gap = Cell::Gap::FULL; |
193 | } | 193 | } |
@@ -201,7 +201,7 @@ void Randomizer2::RandomizeKeep() { | |||
201 | for (Pos pos : cutEdges) { | 201 | for (Pos pos : cutEdges) { |
202 | q.grid[pos.x][pos.y].gap = Cell::Gap::FULL; | 202 | q.grid[pos.x][pos.y].gap = Cell::Gap::FULL; |
203 | } | 203 | } |
204 | for (Pos pos : Randomizer2Core::CutEdges2(q, 7)) { | 204 | for (Pos pos : Randomizer2Core::CutEdges(q, 7, false)) { |
205 | q.grid[pos.x][pos.y].gap = Cell::Gap::FULL; | 205 | q.grid[pos.x][pos.y].gap = Cell::Gap::FULL; |
206 | } | 206 | } |
207 | _serializer.WritePuzzle(q, 0x1A0F); | 207 | _serializer.WritePuzzle(q, 0x1A0F); |