Refactored the map system (read more)
The region's width, height and depth are all defined by preprocessor macros. The rest of the map system has been updated to match. The programs proper need to be updated as well. It would be a good idea to include the macros' values as part of the initial communication protocols, so that the clients don't connect to a server that is using the wrong sized regions.
This commit is contained in:
+3
-10
@@ -22,7 +22,6 @@
|
||||
#ifndef REGION_HPP_
|
||||
#define REGION_HPP_
|
||||
|
||||
//temporary?
|
||||
#define REGION_WIDTH 20
|
||||
#define REGION_HEIGHT 20
|
||||
#define REGION_DEPTH 3
|
||||
@@ -32,26 +31,20 @@ public:
|
||||
typedef unsigned short type_t;
|
||||
|
||||
Region() = delete;
|
||||
Region(int width, int height, int depth, int x, int y);
|
||||
~Region();
|
||||
Region(int x, int y);
|
||||
~Region() = default;
|
||||
|
||||
type_t SetTile(int x, int y, int z, type_t v);
|
||||
type_t GetTile(int x, int y, int z);
|
||||
|
||||
//accessors
|
||||
int GetWidth() const { return width; }
|
||||
int GetHeight() const { return height; }
|
||||
int GetDepth() const { return depth; }
|
||||
int GetX() const { return x; }
|
||||
int GetY() const { return y; }
|
||||
private:
|
||||
const int width;
|
||||
const int height;
|
||||
const int depth;
|
||||
const int x;
|
||||
const int y;
|
||||
|
||||
type_t*** tiles = nullptr;
|
||||
type_t tiles[REGION_WIDTH][REGION_HEIGHT][REGION_DEPTH];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user