Itutorial
Legendary OT User
- Joined
- Dec 23, 2014
- Messages
- 2,339
- Solutions
- 68
- Reaction score
- 1,024
This probably cant happen like this but im just trying to get something figured out. If I can get an answer for this I would be able to start the trial and error. I know why this isnt a good idea.
Pretty much I dont know how to add the tiles to a vector. There is Map::getTile(x, y) which works the same but returns one tile. Help please
I figured this problem out. I needed the vector to be a Tile* vector (could be a new problem though)
New problem
Figured this out too. This can be closed.
Pretty much I dont know how to add the tiles to a vector. There is Map::getTile(x, y) which works the same but returns one tile. Help please
C++:
Tile* Map::getAllTiles(uint8_t floorMin, uint8_t floorMax) const
{
if (floorMax >= MAP_MAX_LAYERS) {
floorMax = MAP_MAX_LAYERS;
}
if (floorMin < 0) {
floorMin = 0;
}
uint16_t maxX = 5000;
uint16_t maxY = 5000;
uint8_t currentZ = 0;
uint8_t cFloorMax = 0;
if (floorMin) {
currentZ = floorMin;
}
if (floorMax) {
cFloorMax = floorMax;
}
std::vector<Floor> floorArray;
for (currentZ; currentZ <= cFloorMax; currentZ++) {
for (uint16_t currentY = 0; currentY < maxY; currentY++) {
for (uint16_t currentX = 0; currentX < maxX; currentX++) {
if (currentX == maxX && currentY == maxY && currentZ == cFloorMax) {
break;
}
if (currentX > maxX) {
currentX = maxX;
}
if (currentY > maxY) {
currentY = maxY;
}
const QTreeLeafNode* leaf = QTreeNode::getLeafStatic<const QTreeLeafNode*, const QTreeNode*>(&root, currentX, currentY);
if (!leaf) {
return nullptr;
}
const Floor* floor = leaf->getFloor(currentZ);
if (!floor) {
return nullptr;
}
floorArray.push_back(floor->tiles[currentX & FLOOR_MASK][currentY & FLOOR_MASK]);
}
}
}
}
Post automatically merged:
I figured this problem out. I needed the vector to be a Tile* vector (could be a new problem though)
New problem
C++:
std::vector<Tile*> tileVector = map->getAllTiles(0, 15);
Figured this out too. This can be closed.
Last edited: