Moved the snapToBase() utility function to region.*pp

I've also adjusted the TODO file, which really shouldn't be committed.
Still, it's there now, so it stays. I don't think the logger is going to
be possible any time soon, so I'll probably look into the disconnection
handler.
This commit is contained in:
Kayne Ruse
2014-08-24 13:23:50 +10:00
parent af8e7b70a0
commit 4ed512e0e2
9 changed files with 9 additions and 31 deletions
+4 -2
View File
@@ -21,11 +21,13 @@
*/
#include "region.hpp"
#include "utility.hpp"
#include <stdexcept>
#include <cstring>
int snapToBase(int base, int x) {
return floor((double)x / base) * base;
}
Region::Region(int argX, int argY): x(argX), y(argY) {
if (x != snapToBase(REGION_WIDTH, x) || y != snapToBase(REGION_HEIGHT, y)) {
throw(std::invalid_argument("Region location is off grid"));
+3
View File
@@ -33,6 +33,9 @@ constexpr int REGION_DEPTH = 3;
//the size of the solid map
constexpr int REGION_SOLID_FOOTPRINT = ceil(REGION_WIDTH * REGION_HEIGHT / 8.0);
//utility function
int snapToBase(int base, int x);
class Region {
public:
typedef unsigned char type_t;
-2
View File
@@ -24,8 +24,6 @@
#include "region_pager_lua.hpp"
#include "region.hpp"
#include <string>
//DOCS: These glue functions simply wrap RegionPagerLua's methods
static int setTile(lua_State* L) {
-2
View File
@@ -21,8 +21,6 @@
*/
#include "region_pager_base.hpp"
#include "utility.hpp"
#include <stdexcept>
#include <algorithm>
-2
View File
@@ -21,8 +21,6 @@
*/
#include "region_pager_lua.hpp"
#include "utility.hpp"
#include <stdexcept>
//TODO: Could I push the pager to the API functions too?