Looking for the bug
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#config
|
#config
|
||||||
INCLUDES+=. .. ../client_utilities ../entities ../../common/debugging ../../common/gameplay ../../common/graphics ../../common/map ../../common/network ../../common/network/packet_types ../../common/ui ../../common/utilities
|
INCLUDES+=. .. ../client_utilities ../entities ../../common/gameplay ../../common/graphics ../../common/map ../../common/network ../../common/network/packet_types ../../common/ui ../../common/utilities
|
||||||
LIBS+=
|
LIBS+=
|
||||||
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ void World::FrameEnd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void World::RenderFrame() {
|
void World::RenderFrame() {
|
||||||
SDL_FillRect(GetScreen(), 0, 0);
|
// SDL_FillRect(GetScreen(), 0, 0);
|
||||||
Render(GetScreen());
|
Render(GetScreen());
|
||||||
SDL_Flip(GetScreen());
|
SDL_Flip(GetScreen());
|
||||||
fps.Calculate();
|
fps.Calculate();
|
||||||
|
|||||||
@@ -22,18 +22,30 @@
|
|||||||
#include "world.hpp"
|
#include "world.hpp"
|
||||||
|
|
||||||
#include "channels.hpp"
|
#include "channels.hpp"
|
||||||
#include "region_checksum.hpp"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
//-------------------------
|
||||||
|
//static functions
|
||||||
|
//-------------------------
|
||||||
|
|
||||||
|
static int regionChecksum(Region* const region) {
|
||||||
|
int sum = 0;
|
||||||
|
for(int i = 0; i < REGION_WIDTH; i++) {
|
||||||
|
for (int j = 0; j < REGION_HEIGHT; j++) {
|
||||||
|
for (int k = 0; k < REGION_DEPTH; k++) {
|
||||||
|
sum += region->GetTile(i, j, k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
//map management
|
//map management
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
void World::SendRegionRequest(int roomIndex, int x, int y) {
|
void World::SendRegionRequest(int roomIndex, int x, int y) {
|
||||||
//debugging
|
|
||||||
// std::cout << "SendRegionRequest(" << roomIndex << ", " << x << ", " << y << ")" << std::endl;
|
|
||||||
|
|
||||||
RegionPacket packet;
|
RegionPacket packet;
|
||||||
|
|
||||||
//pack the region's data
|
//pack the region's data
|
||||||
@@ -50,7 +62,7 @@ void World::hRegionContent(RegionPacket* const argPacket) {
|
|||||||
std::cout << "hRegionContent(" << roomIndex << ", " << argPacket->x << ", " << argPacket->y << ")" << std::endl;
|
std::cout << "hRegionContent(" << roomIndex << ", " << argPacket->x << ", " << argPacket->y << ")" << std::endl;
|
||||||
|
|
||||||
//checksum
|
//checksum
|
||||||
if (debugRegionSum(argPacket->region) == 0) {
|
if (regionChecksum(argPacket->region) == 0) {
|
||||||
std::cout << "Received checksum failed: " << argPacket->x << ", " << argPacket->y << std::endl;
|
std::cout << "Received checksum failed: " << argPacket->x << ", " << argPacket->y << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,14 +98,12 @@ void World::UpdateMap() {
|
|||||||
for (int i = xStart; i <= xEnd; i += REGION_WIDTH) {
|
for (int i = xStart; i <= xEnd; i += REGION_WIDTH) {
|
||||||
for (int j = yStart; j <= yEnd; j += REGION_HEIGHT) {
|
for (int j = yStart; j <= yEnd; j += REGION_HEIGHT) {
|
||||||
Region* region = regionPager.FindRegion(i, j);
|
Region* region = regionPager.FindRegion(i, j);
|
||||||
if (!region || debugRegionSum(region) == 0) {
|
if (!region) {
|
||||||
SendRegionRequest(roomIndex, i, j);
|
SendRegionRequest(roomIndex, i, j);
|
||||||
}
|
}
|
||||||
else {
|
else if (regionChecksum(region) == 0) {
|
||||||
//checksum
|
std::cout << "Existing checksum failed: " << roomIndex << ", " << i << ", " << j << std::endl;
|
||||||
if (debugRegionSum(regionPager.FindRegion(i, j)) == 0) {
|
SendRegionRequest(roomIndex, i, j);
|
||||||
std::cout << "Existing checksum failed: " << roomIndex << ", " << i << ", " << j << std::endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#config
|
#config
|
||||||
INCLUDES+=. ../map
|
INCLUDES+=.
|
||||||
LIBS+=
|
LIBS+=
|
||||||
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
#include "region_checksum.hpp"
|
|
||||||
|
|
||||||
int debugRegionSum(Region* const region) {
|
|
||||||
int sum = 0;
|
|
||||||
for(int i = 0; i < REGION_WIDTH; i++) {
|
|
||||||
for (int j = 0; j < REGION_HEIGHT; j++) {
|
|
||||||
for (int k = 0; k < REGION_DEPTH; k++) {
|
|
||||||
sum += region->GetTile(i, j, k);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sum;
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
#ifndef REGIONCHECKSUM_HPP_
|
|
||||||
#define REGIONCHECKSUM_HPP_
|
|
||||||
|
|
||||||
#include "region.hpp"
|
|
||||||
|
|
||||||
//fails if the result is 0
|
|
||||||
int debugRegionSum(Region* const);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
#config
|
#config
|
||||||
INCLUDES+=. ../debugging ../utilities
|
INCLUDES+=. ../utilities
|
||||||
LIBS+=
|
LIBS+=
|
||||||
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,6 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
int snapToBase(int base, int x) {
|
int snapToBase(int base, int x) {
|
||||||
return floor((double)x / base) * base;
|
return floor((double)x / base) * base;
|
||||||
}
|
}
|
||||||
@@ -41,17 +39,6 @@ Region::Region(int argX, int argY): x(argX), y(argY) {
|
|||||||
Region::Region(Region const& rhs): x(rhs.x), y(rhs.y) {
|
Region::Region(Region const& rhs): x(rhs.x), y(rhs.y) {
|
||||||
memcpy(tiles, rhs.tiles, REGION_WIDTH*REGION_HEIGHT*REGION_DEPTH*sizeof(type_t));
|
memcpy(tiles, rhs.tiles, REGION_WIDTH*REGION_HEIGHT*REGION_DEPTH*sizeof(type_t));
|
||||||
solid = rhs.solid;
|
solid = rhs.solid;
|
||||||
|
|
||||||
//debugging
|
|
||||||
std::cout << "Copied: (" << x << ", " << y << "): " << int(***tiles) << ", " << int(***rhs.tiles) << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
Region::Region(Region&& rhs): x(rhs.x), y(rhs.y) {
|
|
||||||
memcpy(tiles, rhs.tiles, REGION_WIDTH*REGION_HEIGHT*REGION_DEPTH*sizeof(type_t));
|
|
||||||
solid = rhs.solid;
|
|
||||||
|
|
||||||
//debugging
|
|
||||||
std::cout << "Moved: (" << x << ", " << y << "): " << int(***tiles) << ", " << int(***rhs.tiles) << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Region::type_t Region::SetTile(int x, int y, int z, type_t v) {
|
Region::type_t Region::SetTile(int x, int y, int z, type_t v) {
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ public:
|
|||||||
Region() = delete;
|
Region() = delete;
|
||||||
Region(int x, int y);
|
Region(int x, int y);
|
||||||
Region(Region const&);
|
Region(Region const&);
|
||||||
Region(Region&&);
|
|
||||||
~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);
|
||||||
|
|||||||
@@ -21,8 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "region_pager_base.hpp"
|
#include "region_pager_base.hpp"
|
||||||
|
|
||||||
#include "region_checksum.hpp"
|
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@@ -74,9 +72,9 @@ Region* RegionPagerBase::FindRegion(int x, int y) {
|
|||||||
Region* RegionPagerBase::PushRegion(Region* const ptr) {
|
Region* RegionPagerBase::PushRegion(Region* const ptr) {
|
||||||
//BUG: Lists seem to not work properly
|
//BUG: Lists seem to not work properly
|
||||||
regionList.push_front(*ptr);
|
regionList.push_front(*ptr);
|
||||||
if (debugRegionSum(®ionList.front()) == 0) {
|
// if (debugRegionSum(®ionList.front()) == 0) {
|
||||||
throw(std::runtime_error("Checksum fail; RegionPagerBase::PushRegion()"));
|
// throw(std::runtime_error("Checksum fail; RegionPagerBase::PushRegion()"));
|
||||||
}
|
// }
|
||||||
return ®ionList.front();
|
return ®ionList.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user