Apparently it was the #45 fix that broke collisions
This commit is contained in:
@@ -573,7 +573,14 @@ void World::hRegionContent(RegionPacket* const argPacket) {
|
|||||||
|
|
||||||
//replace existing regions
|
//replace existing regions
|
||||||
regionPager.UnloadIf([&](Region const& region) -> bool {
|
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);
|
regionPager.PushRegion(argPacket->region);
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ bool Region::SetSolid(int x, int y, bool b) {
|
|||||||
return solid[x * REGION_WIDTH + y] = 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) {
|
if (x < 0 || y < 0 || x >= REGION_WIDTH || y >= REGION_HEIGHT) {
|
||||||
throw(std::out_of_range("Region::GetSolid() argument out of range"));
|
throw(std::out_of_range("Region::GetSolid() argument out of range"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
type_t GetTile(int x, int y, int z);
|
type_t GetTile(int x, int y, int z);
|
||||||
|
|
||||||
bool SetSolid(int x, int y, bool b);
|
bool SetSolid(int x, int y, bool b);
|
||||||
bool GetSolid(int x, int y);
|
bool GetSolid(int x, int y) const;
|
||||||
|
|
||||||
//accessors
|
//accessors
|
||||||
int GetX() const;
|
int GetX() const;
|
||||||
|
|||||||
@@ -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::type_t RegionPagerBase::GetTile(int x, int y, int z) {
|
||||||
Region* ptr = FindRegion(x, y);
|
Region* ptr = GetRegion(x, y);
|
||||||
if (!ptr) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return ptr->GetTile(x - ptr->GetX(), y - ptr->GetY(), z);
|
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) {
|
bool RegionPagerBase::GetSolid(int x, int y) {
|
||||||
Region* ptr = FindRegion(x, y);
|
Region* ptr = GetRegion(x, y);
|
||||||
if (!ptr) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return ptr->GetSolid(x - ptr->GetX(), y - ptr->GetY());
|
return ptr->GetSolid(x - ptr->GetX(), y - ptr->GetY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public:
|
|||||||
virtual bool GetSolid(int x, int y);
|
virtual bool GetSolid(int x, int y);
|
||||||
|
|
||||||
//region manipulation
|
//region manipulation
|
||||||
|
__attribute__ ((deprecated))
|
||||||
virtual Region* GetRegion(int x, int y);
|
virtual Region* GetRegion(int x, int y);
|
||||||
virtual Region* FindRegion(int x, int y);
|
virtual Region* FindRegion(int x, int y);
|
||||||
virtual Region* PushRegion(Region* const);
|
virtual Region* PushRegion(Region* const);
|
||||||
|
|||||||
@@ -563,7 +563,14 @@ void ServerApplication::hRegionRequest(RegionPacket* const argPacket) {
|
|||||||
std::cerr << "Error message sent: " << newPacket.text << std::endl;
|
std::cerr << "Error message sent: " << newPacket.text << std::endl;
|
||||||
return;
|
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
|
//send the content
|
||||||
RegionPacket newPacket;
|
RegionPacket newPacket;
|
||||||
|
|||||||
Reference in New Issue
Block a user