Refactored the map system (read more)
The region's width, height and depth are all defined by preprocessor macros. The rest of the map system has been updated to match. The programs proper need to be updated as well. It would be a good idea to include the macros' values as part of the initial communication protocols, so that the clients don't connect to a server that is using the wrong sized regions.
This commit is contained in:
@@ -23,18 +23,6 @@
|
||||
|
||||
#include "utility.hpp"
|
||||
|
||||
RegionPagerBase::RegionPagerBase(int argWidth, int argHeight, int argDepth):
|
||||
regionWidth(argWidth),
|
||||
regionHeight(argHeight),
|
||||
regionDepth(argDepth)
|
||||
{
|
||||
//EMPTY
|
||||
}
|
||||
|
||||
RegionPagerBase::~RegionPagerBase() {
|
||||
//EMPTY
|
||||
}
|
||||
|
||||
Region::type_t RegionPagerBase::SetTile(int x, int y, int z, Region::type_t v) {
|
||||
Region* ptr = GetRegion(x, y);
|
||||
return ptr->SetTile(x - ptr->GetX(), y - ptr->GetY(), z, v);
|
||||
@@ -47,8 +35,8 @@ Region::type_t RegionPagerBase::GetTile(int x, int y, int z) {
|
||||
|
||||
Region* RegionPagerBase::GetRegion(int x, int y) {
|
||||
//snap the coords
|
||||
x = snapToBase(regionWidth, x);
|
||||
y = snapToBase(regionHeight, y);
|
||||
x = snapToBase(REGION_WIDTH, x);
|
||||
y = snapToBase(REGION_HEIGHT, y);
|
||||
|
||||
//get the region by various means
|
||||
Region* ptr = nullptr;
|
||||
@@ -60,6 +48,10 @@ Region* RegionPagerBase::GetRegion(int x, int y) {
|
||||
}
|
||||
|
||||
Region* RegionPagerBase::FindRegion(int x, int y) {
|
||||
//snap the coords
|
||||
x = snapToBase(REGION_WIDTH, x);
|
||||
y = snapToBase(REGION_HEIGHT, y);
|
||||
|
||||
//find the region
|
||||
for (std::list<Region*>::iterator it = regionList.begin(); it != regionList.end(); it++) {
|
||||
if ((*it)->GetX() == x && (*it)->GetY() == y) {
|
||||
|
||||
Reference in New Issue
Block a user