diff options
Diffstat (limited to 'Source/Puzzle.cpp')
-rw-r--r-- | Source/Puzzle.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Source/Puzzle.cpp b/Source/Puzzle.cpp index 72af129..d0ede27 100644 --- a/Source/Puzzle.cpp +++ b/Source/Puzzle.cpp | |||
@@ -2,18 +2,17 @@ | |||
2 | #include "Memory.h" | 2 | #include "Memory.h" |
3 | #include <cassert> | 3 | #include <cassert> |
4 | 4 | ||
5 | 5 | Cell Puzzle::GetCell(int x, int y) const { | |
6 | inline Cell Puzzle::GetCell(int x, int y) const { | ||
7 | x = Mod(x); | 6 | x = Mod(x); |
8 | if (!SafeCell(x, y)) return Cell::Undefined(); | 7 | if (!SafeCell(x, y)) return Cell::Undefined(); |
9 | return grid[x][y]; | 8 | return grid[x][y]; |
10 | } | 9 | } |
11 | 10 | ||
12 | inline Cell::Color Puzzle::GetLine(int x, int y) const { | 11 | Cell::Color Puzzle::GetLine(int x, int y) const { |
13 | return grid[x][y].color; | 12 | return grid[x][y].color; |
14 | } | 13 | } |
15 | 14 | ||
16 | inline void Puzzle::NewGrid(int newWidth, int newHeight) { | 15 | void Puzzle::NewGrid(int newWidth, int newHeight) { |
17 | if (newWidth == 0) { | 16 | if (newWidth == 0) { |
18 | assert(false); | 17 | assert(false); |
19 | newWidth = width; | 18 | newWidth = width; |
@@ -28,12 +27,12 @@ inline void Puzzle::NewGrid(int newWidth, int newHeight) { | |||
28 | for (int x=0; x<width; x++) grid[x].resize(height); | 27 | for (int x=0; x<width; x++) grid[x].resize(height); |
29 | } | 28 | } |
30 | 29 | ||
31 | inline int Puzzle::Mod(int x) const { | 30 | int Puzzle::Mod(int x) const { |
32 | if (!pillar) return x; | 31 | if (!pillar) return x; |
33 | return (x + width * height * 2) % width; | 32 | return (x + width * height * 2) % width; |
34 | } | 33 | } |
35 | 34 | ||
36 | inline bool Puzzle::SafeCell(int x, int y) const { | 35 | bool Puzzle::SafeCell(int x, int y) const { |
37 | if (x < 0 || x >= width) return false; | 36 | if (x < 0 || x >= width) return false; |
38 | if (y < 0 || y >= height) return false; | 37 | if (y < 0 || y >= height) return false; |
39 | return true; | 38 | return true; |