From a493355af3c06c1104d7a2f892b3323b499a66da Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 22 Jun 2014 10:28:32 +0300 Subject: FULLPIPE: MovGraph::calcMovItems: renamed variables and added some comments --- engines/fullpipe/motion.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp index 66d587f134..1b7141f067 100644 --- a/engines/fullpipe/motion.cpp +++ b/engines/fullpipe/motion.cpp @@ -1470,12 +1470,12 @@ Common::Array *MovGraph::genMovArr(int x, int y, int *arrSize, int fla return arr; } -void MovGraph::shuffleTree(MovGraphLink *lnk, MovGraphLink *lnk2, Common::Array &tempObList1, Common::Array &tempObList2) { +void MovGraph::shuffleTree(MovGraphLink *lnk, MovGraphLink *lnk2, Common::Array &tempObList1, Common::Array &allPaths) { if (lnk == lnk2) { for (uint i = 0; i < tempObList1.size(); i++) - tempObList2.push_back(tempObList1[i]); + allPaths.push_back(tempObList1[i]); - tempObList2.push_back(lnk); + allPaths.push_back(lnk); } else { lnk->_flags |= 0x80000000; @@ -1492,39 +1492,42 @@ void MovGraph::shuffleTree(MovGraphLink *lnk, MovGraphLink *lnk2, Common::Array< } if (!(l->_flags & 0xA0000000)) - shuffleTree(l, lnk2, tempObList1, tempObList2); + shuffleTree(l, lnk2, tempObList1, allPaths); } lnk->_flags &= 0x7FFFFFFF; } } -Common::Array *MovGraph::calcMovItems(MovArr *movarr1, MovArr *movarr2, int *listCount) { +// Returns a list of possible paths two points in graph space +Common::Array *MovGraph::calcMovItems(MovArr *currPos, MovArr *destPos, int *pathCount) { Common::Array tempObList1; - Common::Array tempObList2; + Common::Array allPaths; - shuffleTree(movarr1->_link, movarr2->_link, tempObList1, tempObList2); + // Get all paths between two edges of the graph + shuffleTree(currPos->_link, destPos->_link, tempObList1, allPaths); - *listCount = 0; + *pathCount = 0; - if (!tempObList2.size()) + if (!allPaths.size()) return 0; - *listCount = tempObList2.size(); + *pathCount = allPaths.size(); Common::Array *res = new Common::Array; - for (int i = 0; i < *listCount; i++) { + for (int i = 0; i < *pathCount; i++) { MovItem *r = new MovItem; - genMovItem(r, tempObList2[i], movarr1, movarr2); + genMovItem(r, allPaths[i], currPos, destPos); res->push_back(r); - delete tempObList2[i]; + delete allPaths[i]; } - movarr2->_link = movarr1->_link; + // Start the resulting path from current position + destPos->_link = currPos->_link; return res; } -- cgit v1.2.3