Working on the client side map code (read more)

I've also added in some debug code to the map classes, because I was
hunting down a std::bad_alloc beingthrown. Turns out I forgot to set the
map sizes in the client's InWorld constructor. I'm committing the fix, and
the debug code.
This commit is contained in:
Kayne Ruse
2014-04-06 02:25:55 +11:00
parent 962f3f5dd0
commit 27bda5dc28
7 changed files with 113 additions and 24 deletions
+9 -3
View File
@@ -21,6 +21,12 @@
*/
#include "region.hpp"
#include <stdexcept>
#include <iostream>
//decorator
#define TRY(x) try { x } catch(std::exception& e) { throw std::runtime_error(std::string() + e.what() + ": " + #x); }
Region::Region(int argWidth, int argHeight, int argDepth, int argX, int argY):
width(argWidth),
height(argHeight),
@@ -28,11 +34,11 @@ Region::Region(int argWidth, int argHeight, int argDepth, int argX, int argY):
x(argX),
y(argY)
{
tiles = new type_t**[width];
TRY(tiles = new type_t**[width];)
for (register int i = 0; i < width; ++i) {
tiles[i] = new type_t*[height];
TRY(tiles[i] = new type_t*[height];)
for (register int j = 0; j < height; ++j) {
tiles[i][j] = new type_t[depth];
TRY(tiles[i][j] = new type_t[depth];)
for (register int k = 0; k < depth; ++k) {
tiles[i][j][k] = 0;
}