about summary refs log tree commit diff stats
path: root/Source/Puzzle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Puzzle.cpp')
-rw-r--r--Source/Puzzle.cpp11
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 5Cell Puzzle::GetCell(int x, int y) const {
6inline 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
12inline Cell::Color Puzzle::GetLine(int x, int y) const { 11Cell::Color Puzzle::GetLine(int x, int y) const {
13 return grid[x][y].color; 12 return grid[x][y].color;
14} 13}
15 14
16inline void Puzzle::NewGrid(int newWidth, int newHeight) { 15void 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
31inline int Puzzle::Mod(int x) const { 30int 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
36inline bool Puzzle::SafeCell(int x, int y) const { 35bool 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;