The client->server->client region protocol is working

This commit is contained in:
Kayne Ruse
2014-04-06 02:48:43 +11:00
parent 27bda5dc28
commit 99aecbfdbb
5 changed files with 37 additions and 43 deletions
+3 -9
View File
@@ -21,12 +21,6 @@
*/
#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),
@@ -34,11 +28,11 @@ Region::Region(int argWidth, int argHeight, int argDepth, int argX, int argY):
x(argX),
y(argY)
{
TRY(tiles = new type_t**[width];)
tiles = new type_t**[width];
for (register int i = 0; i < width; ++i) {
TRY(tiles[i] = new type_t*[height];)
tiles[i] = new type_t*[height];
for (register int j = 0; j < height; ++j) {
TRY(tiles[i][j] = new type_t[depth];)
tiles[i][j] = new type_t[depth];
for (register int k = 0; k < depth; ++k) {
tiles[i][j][k] = 0;
}
+5 -28
View File
@@ -23,11 +23,6 @@
#include "utility.hpp"
#include <stdexcept>
#include <iostream>
using namespace std;
RegionPagerBase::RegionPagerBase(int argWidth, int argHeight, int argDepth):
regionWidth(argWidth),
regionHeight(argHeight),
@@ -59,29 +54,11 @@ Region* RegionPagerBase::GetRegion(int x, int y) {
//TODO: revert this try/catch point
Region* ptr = nullptr;
try {
ptr = FindRegion(x, y);
if (ptr) return ptr;
}
catch(exception& e) {
cerr << "FindRegion Error: " << e.what() << endl;
}
try {
ptr = LoadRegion(x, y);
if (ptr) return ptr;
}
catch(exception& e) {
cerr << "LoadRegion Error: " << e.what() << endl;
}
try {
return CreateRegion(x, y);
}
catch(exception& e) {
cerr << "CreateRegion Error: " << e.what() << endl;
}
return nullptr;
ptr = FindRegion(x, y);
if (ptr) return ptr;
ptr = LoadRegion(x, y);
if (ptr) return ptr;
return CreateRegion(x, y);
}
Region* RegionPagerBase::FindRegion(int x, int y) {