Brought the programs into line, (BUG, read more)

It seems that the serialization code has a bug in it. I was expecting
something like this. When the server tries to send the region content, it
exits. I'll try and find the cause of the error, but I'm committing my
changes anyway.
This commit is contained in:
Kayne Ruse
2014-04-20 04:27:28 +10:00
parent fba183fa27
commit eb0b18af6f
8 changed files with 44 additions and 51 deletions
+11 -11
View File
@@ -29,8 +29,8 @@
class RegionPagerBase {
public:
RegionPagerBase() = default;
virtual ~RegionPagerBase() = default;
RegionPagerBase() {};
virtual ~RegionPagerBase() {};
//tile manipulation
Region::type_t SetTile(int x, int y, int z, Region::type_t v);
@@ -54,10 +54,10 @@ protected:
std::list<Region*> regionList;
};
template<typename MapGenerator, typename MapFileFormat>
template<typename Allocator, typename FileFormat>
class RegionPager : public RegionPagerBase {
public:
RegionPager() = default;
RegionPager() {};
~RegionPager() {
UnloadAll();
}
@@ -96,7 +96,7 @@ public:
//create and push the object
Region* ptr = nullptr;
generator.Create(&ptr, x, y);
allocator.Create(&ptr, x, y);
return PushRegion(ptr);
}
@@ -108,7 +108,7 @@ public:
//custom loop
for (std::list<Region*>::iterator it = regionList.begin(); it != regionList.end(); /* EMPTY */) {
if ((*it)->GetX() == x && (*it)->GetY() == y) {
generator.Unload(*it);
allocator.Unload(*it);
regionList.erase(it);
//reset the loop, because of reasons
@@ -120,17 +120,17 @@ public:
}
void UnloadAll() {
for (auto& it : regionList) {
generator.Unload(it);
allocator.Unload(it);
}
regionList.clear();
}
//accessors
MapGenerator* GetGenerator() { return &generator; }
MapFileFormat* GetFormat() { return &format; }
Allocator* GetAllocator() { return &allocator; }
FileFormat* GetFormat() { return &format; }
protected:
MapGenerator generator;
MapFileFormat format;
Allocator allocator;
FileFormat format;
};
#endif
+1
View File
@@ -167,6 +167,7 @@ void deserializeRegionContent(NetworkPacket* packet, char* buffer) {
memcpy(&packet->regionInfo.x, buffer, sizeof(int));
buffer += sizeof(int);
memcpy(&packet->regionInfo.y, buffer, sizeof(int));
buffer += sizeof(int);
//content
BlankAllocator().Create(