void foreach_tile_pos(std::function<void(const int3& pos)> foo) { for(int i = 0; i < cb->getMapSize().x; i++) for(int j = 0; j < cb->getMapSize().y; j++) for(int k = 0; k < cb->getMapSize().z; k++) foo(int3(i,j,k)); }
void SectorMap::write(crstring fname) { std::ofstream out(fname); for (int k = 0; k < cb->getMapSize().z; k++) { for (int j = 0; j < cb->getMapSize().y; j++) { for (int i = 0; i < cb->getMapSize().x; i++) { out << (int)sector[i][j][k] << '\t'; } out << std::endl; } out << std::endl; } }
void foreach_tile_pos(std::function<void(const int3& pos)> foo) { // some micro-optimizations since this function gets called a LOT // callback pointer is thread-specific and slow to retrieve -> read map size only once int3 mapSize = cb->getMapSize(); for(int i = 0; i < mapSize.x; i++) for(int j = 0; j < mapSize.y; j++) for(int k = 0; k < mapSize.z; k++) foo(int3(i,j,k)); }