* @brief update all path costs using depth-first search starting at pPath */
| 178 | * @brief update all path costs using depth-first search starting at pPath |
| 179 | */ |
| 180 | void SetCoords(uint16_t pPath) |
| 181 | { |
| 182 | PushActiveStep(pPath); |
| 183 | // while there are path nodes to check |
| 184 | while (gdwCurPathStep > 0) { |
| 185 | uint16_t pathOldIndex = PopActiveStep(); |
| 186 | const PathNode &pathOld = PathNodes[pathOldIndex]; |
| 187 | for (uint16_t childIndex : pathOld.childIndices) { |
| 188 | if (childIndex == PathNode::InvalidIndex) |
| 189 | break; |
| 190 | PathNode &pathAct = PathNodes[childIndex]; |
| 191 | |
| 192 | if (pathOld.g + CheckEqual(pathOld.position(), pathAct.position()) < pathAct.g) { |
| 193 | if (path_solid_pieces(pathOld.position(), pathAct.position())) { |
| 194 | pathAct.parentIndex = pathOldIndex; |
| 195 | pathAct.g = pathOld.g + CheckEqual(pathOld.position(), pathAct.position()); |
| 196 | pathAct.f = pathAct.g + pathAct.h; |
| 197 | PushActiveStep(childIndex); |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Returns a number representing the direction from a starting tile to a neighbouring tile. |
no test coverage detected