summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
authorFilip Gawin <filip.gawin@zoho.com>2019-08-30 00:44:57 +0200
committerFilip Gawin <filip.gawin@zoho.com>2019-10-26 13:05:00 +0200
commit12ee71e4f732c883b33b9165c448302ea726186b (patch)
tree4c30f36d72de05fc3a2621dad08c363b75879821 /src/control
parentMerge pull request #253 from erorcun/erorcun (diff)
downloadre3-12ee71e4f732c883b33b9165c448302ea726186b.tar
re3-12ee71e4f732c883b33b9165c448302ea726186b.tar.gz
re3-12ee71e4f732c883b33b9165c448302ea726186b.tar.bz2
re3-12ee71e4f732c883b33b9165c448302ea726186b.tar.lz
re3-12ee71e4f732c883b33b9165c448302ea726186b.tar.xz
re3-12ee71e4f732c883b33b9165c448302ea726186b.tar.zst
re3-12ee71e4f732c883b33b9165c448302ea726186b.zip
Diffstat (limited to 'src/control')
-rw-r--r--src/control/PathFind.cpp51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp
index 3c16202b..700a89f1 100644
--- a/src/control/PathFind.cpp
+++ b/src/control/PathFind.cpp
@@ -1278,39 +1278,51 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta
targetNode = FindNodeClosestToCoors(target, type, distLimit);
else
targetNode = forcedTargetNode;
- if(targetNode < 0)
- goto fail;
+ if(targetNode < 0) {
+ *pNumNodes = 0;
+ if(pDist) *pDist = 100000.0f;
+ return;
+ }
// 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)
- goto fail;
+ if(numPathsToTry == 0) {
+ *pNumNodes = 0;
+ if(pDist) *pDist = 100000.0f;
+ return;
+ }
- if(startNodeId < 0){
+ if(startNodeId < 0) {
// why only check node 0?
- 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;
+ 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;
+ }
}
-
for(i = 0; i < 512; i++)
m_searchNodes[i].next = nil;
AddNodeToList(&m_pathNodes[targetNode], 0);
@@ -1388,11 +1400,6 @@ 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];