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:
Kayne Ruse
2014-04-20 03:31:37 +10:00
parent ac27fb0ca7
commit c5a627004a
10 changed files with 60 additions and 159 deletions
+3 -23
View File
@@ -21,35 +21,15 @@
*/
#include "region.hpp"
Region::Region(int argWidth, int argHeight, int argDepth, int argX, int argY):
width(argWidth),
height(argHeight),
depth(argDepth),
Region::Region(int argX, int argY):
x(argX),
y(argY)
{
tiles = new type_t**[width];
for (register int i = 0; i < width; ++i) {
tiles[i] = new type_t*[height];
for (register int j = 0; j < height; ++j) {
tiles[i][j] = new type_t[depth];
for (register int k = 0; k < depth; ++k) {
tiles[i][j][k] = 0;
}
}
for (register int i = 0; i < REGION_WIDTH*REGION_HEIGHT*REGION_DEPTH; ++i) {
*(reinterpret_cast<type_t*>(tiles) + i) = 0;
}
}
Region::~Region() {
for (register int i = 0; i < width; ++i) {
for (register int j = 0; j < height; j++) {
delete tiles[i][j];
}
delete tiles[i];
}
delete tiles;
}
Region::type_t Region::SetTile(int x, int y, int z, type_t v) {
return tiles[x][y][z] = v;
}