Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool check_node(int x, int y, int z, char (*map)[MAP_X][MAP_Y][MAP_Z],
- bool destroy)
- {
- bool visited;
- list<Position> path;
- list<Position> nodes;
- char mark[MAP_X][MAP_Y][MAP_Z];
- //set it to 0 here
- memset(mark,0,MAP_X*MAP_Y*MAP_Z);
- Position new_pos;
- new_pos.x = x;
- new_pos.y = y;
- new_pos.z = z;
- nodes.push_back(new_pos);
- while (!nodes.empty()) {
- Position node = nodes.back();
- nodes.pop_back();
- if (node.z == 63) {
- return true;
- }
- // already visited?
- if (!mark[node.x][node.y][node.z])
- {
- path.push_back(node);
- mark[node.x][node.y][node.z]=1;
- x = node.x;
- y = node.y;
- z = node.z;
- add_node(x, y, z - 1, map, nodes);
- add_node(x, y - 1, z, map, nodes);
- add_node(x, y + 1, z, map, nodes);
- add_node(x - 1, y, z, map, nodes);
- add_node(x + 1, y, z, map, nodes);
- add_node(x, y, z + 1, map, nodes);
- }
- }
- // destroy the node's path!
- for (list<Position>::const_iterator iter = path.begin();
- iter != path.end(); ++iter)
- {
- (*map)[iter->x][iter->y][iter->z] = 0;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement