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:
@@ -21,11 +21,13 @@
|
|||||||
*/
|
*/
|
||||||
#include "region.hpp"
|
#include "region.hpp"
|
||||||
|
|
||||||
#include "utility.hpp"
|
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
int snapToBase(int base, int x) {
|
||||||
|
return floor((double)x / base) * base;
|
||||||
|
}
|
||||||
|
|
||||||
Region::Region(int argX, int argY): x(argX), y(argY) {
|
Region::Region(int argX, int argY): x(argX), y(argY) {
|
||||||
if (x != snapToBase(REGION_WIDTH, x) || y != snapToBase(REGION_HEIGHT, y)) {
|
if (x != snapToBase(REGION_WIDTH, x) || y != snapToBase(REGION_HEIGHT, y)) {
|
||||||
throw(std::invalid_argument("Region location is off grid"));
|
throw(std::invalid_argument("Region location is off grid"));
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ constexpr int REGION_DEPTH = 3;
|
|||||||
//the size of the solid map
|
//the size of the solid map
|
||||||
constexpr int REGION_SOLID_FOOTPRINT = ceil(REGION_WIDTH * REGION_HEIGHT / 8.0);
|
constexpr int REGION_SOLID_FOOTPRINT = ceil(REGION_WIDTH * REGION_HEIGHT / 8.0);
|
||||||
|
|
||||||
|
//utility function
|
||||||
|
int snapToBase(int base, int x);
|
||||||
|
|
||||||
class Region {
|
class Region {
|
||||||
public:
|
public:
|
||||||
typedef unsigned char type_t;
|
typedef unsigned char type_t;
|
||||||
|
|||||||
@@ -24,8 +24,6 @@
|
|||||||
#include "region_pager_lua.hpp"
|
#include "region_pager_lua.hpp"
|
||||||
#include "region.hpp"
|
#include "region.hpp"
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
//DOCS: These glue functions simply wrap RegionPagerLua's methods
|
//DOCS: These glue functions simply wrap RegionPagerLua's methods
|
||||||
|
|
||||||
static int setTile(lua_State* L) {
|
static int setTile(lua_State* L) {
|
||||||
|
|||||||
@@ -21,8 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "region_pager_base.hpp"
|
#include "region_pager_base.hpp"
|
||||||
|
|
||||||
#include "utility.hpp"
|
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "region_pager_lua.hpp"
|
#include "region_pager_lua.hpp"
|
||||||
|
|
||||||
#include "utility.hpp"
|
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
//TODO: Could I push the pager to the API functions too?
|
//TODO: Could I push the pager to the API functions too?
|
||||||
|
|||||||
@@ -23,19 +23,6 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
int snapToBase(int base, int x) {
|
|
||||||
//snap to a grid
|
|
||||||
if (x < 0) {
|
|
||||||
++x;
|
|
||||||
return x / base * base - base;
|
|
||||||
}
|
|
||||||
return x / base * base;
|
|
||||||
}
|
|
||||||
|
|
||||||
double snapToBase(double base, double x) {
|
|
||||||
return floor(x / base) * base;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string truncatePath(std::string pathname) {
|
std::string truncatePath(std::string pathname) {
|
||||||
return std::string(
|
return std::string(
|
||||||
std::find_if(
|
std::find_if(
|
||||||
|
|||||||
@@ -24,9 +24,6 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
int snapToBase(int base, int x);
|
|
||||||
double snapToBase(double base, double x);
|
|
||||||
|
|
||||||
std::string truncatePath(std::string pathname);
|
std::string truncatePath(std::string pathname);
|
||||||
|
|
||||||
//fixing known bugs in g++
|
//fixing known bugs in g++
|
||||||
|
|||||||
@@ -3,11 +3,6 @@
|
|||||||
#MKDIR=mkdir
|
#MKDIR=mkdir
|
||||||
#RM=del /y
|
#RM=del /y
|
||||||
|
|
||||||
#CXXFLAGS+=-static-libgcc -static-libstdc++ -g -fno-inline-functions -Wall
|
|
||||||
#CXXFLAGS+=-static-libgcc -static-libstdc++
|
|
||||||
|
|
||||||
#export
|
|
||||||
|
|
||||||
OUTDIR=out
|
OUTDIR=out
|
||||||
|
|
||||||
all: $(OUTDIR)
|
all: $(OUTDIR)
|
||||||
@@ -23,7 +18,7 @@ release: clean all package
|
|||||||
|
|
||||||
#For use on my machine ONLY
|
#For use on my machine ONLY
|
||||||
package:
|
package:
|
||||||
rar a -r -ep Tortuga.rar out/*.exe out/*.dll
|
rar a -r -ep Tortuga.rar $(OUTDIR)/*.exe $(OUTDIR)/*.dll
|
||||||
rar a -r Tortuga.rar rsc/* copyright.txt
|
rar a -r Tortuga.rar rsc/* copyright.txt
|
||||||
|
|
||||||
$(OUTDIR):
|
$(OUTDIR):
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
TODO: encapsulate the data structures
|
TODO: encapsulate the data structures
|
||||||
TODO: A proper logging system
|
|
||||||
TODO: Ping-pong and keep alive system
|
TODO: Ping-pong and keep alive system
|
||||||
TODO: Move the statistics into their own SQL table, instead of duplicating the structure a dozen times
|
TODO: Move the statistics into their own SQL table, instead of duplicating the structure a dozen times
|
||||||
TODO: Get the rooms working, even if only via hotkeys
|
TODO: Get the rooms working, even if only via hotkeys
|
||||||
@@ -12,3 +11,4 @@ TODO: server is slaved to the client
|
|||||||
|
|
||||||
TODO: Time delay for requesting region packets
|
TODO: Time delay for requesting region packets
|
||||||
TODO: command line parameters overriding config.cfg settings
|
TODO: command line parameters overriding config.cfg settings
|
||||||
|
TODO: A proper logging system
|
||||||
|
|||||||
Reference in New Issue
Block a user