MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / SetCoords

Function SetCoords

Source/engine/path.cpp:180–202  ·  view source on GitHub ↗

* @brief update all path costs using depth-first search starting at pPath */

Source from the content-addressed store, hash-verified

178 * @brief update all path costs using depth-first search starting at pPath
179 */
180void 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.

Callers 1

ParentPathFunction · 0.85

Calls 5

PushActiveStepFunction · 0.85
PopActiveStepFunction · 0.85
CheckEqualFunction · 0.85
path_solid_piecesFunction · 0.85
positionMethod · 0.80

Tested by

no test coverage detected