diff --git a/client/scenes/world.cpp b/client/scenes/world.cpp index b9331d1..96c1a4b 100644 --- a/client/scenes/world.cpp +++ b/client/scenes/world.cpp @@ -573,7 +573,14 @@ void World::hRegionContent(RegionPacket* const argPacket) { //replace existing regions regionPager.UnloadIf([&](Region const& region) -> bool { - return 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 << "\t" << region.GetSolid(1,1) << "\t" << argPacket->region->GetSolid(1,1) << std::endl; + return true; + } + else { + return false; + } }); regionPager.PushRegion(argPacket->region); diff --git a/common/map/region.cpp b/common/map/region.cpp index 1815d36..82bfacf 100644 --- a/common/map/region.cpp +++ b/common/map/region.cpp @@ -62,7 +62,7 @@ bool Region::SetSolid(int x, int y, bool b) { return solid[x * REGION_WIDTH + y] = b; } -bool Region::GetSolid(int x, int y) { +bool Region::GetSolid(int x, int y) const { if (x < 0 || y < 0 || x >= REGION_WIDTH || y >= REGION_HEIGHT) { throw(std::out_of_range("Region::GetSolid() argument out of range")); } diff --git a/common/map/region.hpp b/common/map/region.hpp index da919cb..c68b0c5 100644 --- a/common/map/region.hpp +++ b/common/map/region.hpp @@ -44,7 +44,7 @@ public: type_t GetTile(int x, int y, int z); bool SetSolid(int x, int y, bool b); - bool GetSolid(int x, int y); + bool GetSolid(int x, int y) const; //accessors int GetX() const; diff --git a/common/map/region_pager_base.cpp b/common/map/region_pager_base.cpp index 49b8118..1df6864 100644 --- a/common/map/region_pager_base.cpp +++ b/common/map/region_pager_base.cpp @@ -34,10 +34,7 @@ Region::type_t RegionPagerBase::SetTile(int x, int y, int z, Region::type_t v) { } Region::type_t RegionPagerBase::GetTile(int x, int y, int z) { - Region* ptr = FindRegion(x, y); - if (!ptr) { - return 0; - } + Region* ptr = GetRegion(x, y); return ptr->GetTile(x - ptr->GetX(), y - ptr->GetY(), z); } @@ -47,10 +44,7 @@ bool RegionPagerBase::SetSolid(int x, int y, int b) { } bool RegionPagerBase::GetSolid(int x, int y) { - Region* ptr = FindRegion(x, y); - if (!ptr) { - return 0; - } + Region* ptr = GetRegion(x, y); return ptr->GetSolid(x - ptr->GetX(), y - ptr->GetY()); } diff --git a/common/map/region_pager_base.hpp b/common/map/region_pager_base.hpp index a53083d..d2cc404 100644 --- a/common/map/region_pager_base.hpp +++ b/common/map/region_pager_base.hpp @@ -40,6 +40,7 @@ public: virtual bool GetSolid(int x, int y); //region manipulation + __attribute__ ((deprecated)) virtual Region* GetRegion(int x, int y); virtual Region* FindRegion(int x, int y); virtual Region* PushRegion(Region* const); diff --git a/server/server_application.cpp b/server/server_application.cpp index f689432..413b903 100644 --- a/server/server_application.cpp +++ b/server/server_application.cpp @@ -563,7 +563,14 @@ void ServerApplication::hRegionRequest(RegionPacket* const argPacket) { std::cerr << "Error message sent: " << newPacket.text << std::endl; return; } - Region* region = room->GetPager()->GetRegion(argPacket->x, argPacket->y); + + //A strange reoccurance of #45 caused this + Region* region = room->GetPager()->FindRegion(argPacket->x, argPacket->y); + //TODO: (0) load regions + if (region == nullptr) { + region = room->GetPager()->CreateRegion(argPacket->x, argPacket->y); + std::cout << "Summoned a room" << std::endl; + } //send the content RegionPacket newPacket;