From 5a36d466929ac9ba5612d577904773e3bd58bfe5 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Tue, 27 Aug 2019 22:46:41 +0200 Subject: Audio fixes --- src/control/PathFind.cpp | 57 +++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 32 deletions(-) (limited to 'src/control/PathFind.cpp') diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp index eb63b0b0..e9b33395 100644 --- a/src/control/PathFind.cpp +++ b/src/control/PathFind.cpp @@ -1263,9 +1263,7 @@ CPathFind::FindNextNodeWandering(uint8 type, CVector coors, CPathNode **lastNode static CPathNode *apNodesToBeCleared[4995]; void -CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector target, - CPathNode **nodes, int16 *pNumNodes, int16 maxNumNodes, CVehicle *vehicle, - float *pDist, float distLimit, int32 forcedTargetNode) +CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector target, CPathNode **nodes, int16 *pNumNodes, int16 maxNumNodes, CVehicle *vehicle, float *pDist, float distLimit, int32 forcedTargetNode) { int i, j; @@ -1275,51 +1273,41 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta targetNode = FindNodeClosestToCoors(target, type, distLimit); else targetNode = forcedTargetNode; - if(targetNode < 0) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } + if(targetNode < 0) + goto fail; // Find start int numPathsToTry; CTreadable *startObj; - if(startNodeId < 0) { + if(startNodeId < 0){ if(vehicle == nil || (startObj = vehicle->m_treadable[type]) == nil) startObj = FindRoadObjectClosestToCoors(start, type); numPathsToTry = 0; - for(i = 0; i < 12; i++) { - if(startObj->m_nodeIndices[type][i] < 0) break; - if(m_pathNodes[startObj->m_nodeIndices[type][i]].group == - m_pathNodes[targetNode].group) + for(i = 0; i < 12; i++){ + if(startObj->m_nodeIndices[type][i] < 0) + break; + if(m_pathNodes[startObj->m_nodeIndices[type][i]].group == m_pathNodes[targetNode].group) numPathsToTry++; } - } else { + }else{ numPathsToTry = 1; startObj = m_mapObjects[m_pathNodes[startNodeId].objectIndex]; } - if(numPathsToTry == 0) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - } + if(numPathsToTry == 0) + goto fail; - if(startNodeId < 0) { + if(startNodeId < 0){ // why only check node 0? - if(m_pathNodes[startObj->m_nodeIndices[type][0]].group != - m_pathNodes[targetNode].group) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } - } else { - if(m_pathNodes[startNodeId].group != m_pathNodes[targetNode].group) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } + if(m_pathNodes[startObj->m_nodeIndices[type][0]].group != m_pathNodes[targetNode].group) + goto fail; + }else{ + if(m_pathNodes[startNodeId].group != m_pathNodes[targetNode].group) + goto fail; } - for(i = 0; i < 512; i++) m_searchNodes[i].next = nil; + + for(i = 0; i < 512; i++) + m_searchNodes[i].next = nil; AddNodeToList(&m_pathNodes[targetNode], 0); int numNodesToBeCleared = 0; apNodesToBeCleared[numNodesToBeCleared++] = &m_pathNodes[targetNode]; @@ -1395,6 +1383,11 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta for(i = 0; i < numNodesToBeCleared; i++) apNodesToBeCleared[i]->distance = MAX_DIST; return; + +fail: + *pNumNodes = 0; + if(pDist) + *pDist = 100000.0f; } static CPathNode *pNodeList[32]; -- cgit v1.2.3