Minor name tweak
This commit is contained in:
+5
-12
@@ -38,12 +38,12 @@
|
|||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
//TODO: (3) proper checksum
|
//TODO: (3) proper checksum
|
||||||
static int regionChecksum(Region* const region) {
|
static int regionContentCheck(Region const* region) {
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for(int i = 0; i < REGION_WIDTH; i++) {
|
for(int i = 0; i < REGION_WIDTH; i++) {
|
||||||
for (int j = 0; j < REGION_HEIGHT; j++) {
|
for (int j = 0; j < REGION_HEIGHT; j++) {
|
||||||
for (int k = 0; k < REGION_DEPTH; k++) {
|
for (int k = 0; k < REGION_DEPTH; k++) {
|
||||||
sum |= region->GetTile(i, j, k);
|
sum += region->GetTile(i, j, k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -565,18 +565,11 @@ void World::SendRegionRequest(int roomIndex, int x, int y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void World::hRegionContent(RegionPacket* const argPacket) {
|
void World::hRegionContent(RegionPacket* const argPacket) {
|
||||||
//checksum
|
|
||||||
if (regionChecksum(argPacket->region) == 0) {
|
|
||||||
std::ostringstream msg;
|
|
||||||
msg << "Received region checksum failed: " << argPacket->x << ", " << argPacket->y;
|
|
||||||
throw(std::runtime_error(msg.str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
//replace existing regions
|
//replace existing regions
|
||||||
regionPager.UnloadIf([&](Region const& region) -> bool {
|
regionPager.UnloadIf([&](Region const& region) -> bool {
|
||||||
if (region.GetX() == argPacket->x && region.GetY() == argPacket->y) {
|
if (region.GetX() == argPacket->x && region.GetY() == argPacket->y) {
|
||||||
std::cout << "Region Overwrite: " << region.GetX() << ", " << region.GetY();
|
std::cout << "Region Overwrite: " << region.GetX() << ", " << region.GetY();
|
||||||
std::cout << "\t" << region.GetSolid(1,1) << "\t" << argPacket->region->GetSolid(1,1) << std::endl;
|
std::cout << "\t" << regionContentCheck(®ion) << "\t" << regionContentCheck(argPacket->region) << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -615,7 +608,7 @@ void World::UpdateMap() {
|
|||||||
//request absent region
|
//request absent region
|
||||||
SendRegionRequest(roomIndex, i, j);
|
SendRegionRequest(roomIndex, i, j);
|
||||||
}
|
}
|
||||||
else if (regionChecksum(region) == 0) {
|
else if (regionContentCheck(region) == 0) {
|
||||||
//checksum failed
|
//checksum failed
|
||||||
regionPager.UnloadIf([region](Region const& ref) -> bool {
|
regionPager.UnloadIf([region](Region const& ref) -> bool {
|
||||||
//remove the erroneous region
|
//remove the erroneous region
|
||||||
@@ -623,7 +616,7 @@ void World::UpdateMap() {
|
|||||||
});
|
});
|
||||||
SendRegionRequest(roomIndex, i, j);
|
SendRegionRequest(roomIndex, i, j);
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
msg << "Existing region checksum failed: " << roomIndex << ", " << i << ", " << j;
|
msg << "Existing region blank: " << roomIndex << ", " << i << ", " << j;
|
||||||
throw(std::runtime_error(msg.str()));
|
throw(std::runtime_error(msg.str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ Region::type_t Region::SetTile(int x, int y, int z, type_t v) {
|
|||||||
return tiles[x][y][z] = v;
|
return tiles[x][y][z] = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
Region::type_t Region::GetTile(int x, int y, int z) {
|
Region::type_t Region::GetTile(int x, int y, int z) const {
|
||||||
if (x < 0 || y < 0 || z < 0 || x >= REGION_WIDTH || y >= REGION_HEIGHT || z >= REGION_DEPTH) {
|
if (x < 0 || y < 0 || z < 0 || x >= REGION_WIDTH || y >= REGION_HEIGHT || z >= REGION_DEPTH) {
|
||||||
throw(std::out_of_range("Region::GetTile() argument out of range"));
|
throw(std::out_of_range("Region::GetTile() argument out of range"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
~Region() = default;
|
~Region() = default;
|
||||||
|
|
||||||
type_t SetTile(int x, int y, int z, type_t v);
|
type_t SetTile(int x, int y, int z, type_t v);
|
||||||
type_t GetTile(int x, int y, int z);
|
type_t GetTile(int x, int y, int z) const;
|
||||||
|
|
||||||
bool SetSolid(int x, int y, bool b);
|
bool SetSolid(int x, int y, bool b);
|
||||||
bool GetSolid(int x, int y) const;
|
bool GetSolid(int x, int y) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user