Hello, Im trying to understand how does the GetTile function works in C++ cause I would like to use the function in another way, so here is the code :
I don't understand what the Qtreenode does here, and I would like to know how the server can refer to a tile using a x-y-z position, Im only able to do a linear search with a foreach, that iterate trough all the node of the map....
Code:
Tile* Map::getTile(uint16_t x, uint16_t y, uint8_t z) const
78 {
79 if (z >= MAP_MAX_LAYERS) {
80 return nullptr;
81 }
82
83 const QTreeLeafNode* leaf = QTreeNode::getLeafStatic<const QTreeLeafNode*, const QTreeNode*>(&root, x, y);
84 if (!leaf) {
85 return nullptr;
86 }
87
88 const Floor* floor = leaf->getFloor(z);
89 if (!floor) {
90 return nullptr;
91 }
92 return floor->tiles[x & FLOOR_MASK][y & FLOOR_MASK];
93 }
I don't understand what the Qtreenode does here, and I would like to know how the server can refer to a tile using a x-y-z position, Im only able to do a linear search with a foreach, that iterate trough all the node of the map....