- Timestamp:
- Oct 30, 2015, 12:08:30 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AI_HS15/src/orxonox/controllers/SectionController.cc
r10719 r10722 48 48 if (this->isInitialized()) 49 49 { 50 50 if (this->myDivisionLeader_) 51 this->myDivisionLeader_->myFollower_ = 0; 52 if(this->myWingman_) 53 this->myWingman_->myLeader_ = 0; 51 54 } 52 55 } 53 LeaderController* SectionController::findNewDivisionLeader() 56 57 LeaderController* SectionController::findNewDivisionLeader() 54 58 { 55 59 56 60 if (!this->getControllableEntity()) 57 return NULL;61 return 0; 58 62 59 63 LeaderController* closestLeader = 0; 64 float minDistance = std::numeric_limits<float>::infinity(); 60 65 //go through all pawns 61 66 for (ObjectList<LeaderController>::iterator it = ObjectList<LeaderController>::begin(); it; ++it) 62 67 { 63 68 //0ptr or not DivisionController? 69 if (!(it) || !(it)->bIsDivisionLeader_ || !(it->getControllableEntity())) 70 continue; 64 71 //same team? 65 72 if ((this->getControllableEntity()->getTeam() != (it)->getControllableEntity()->getTeam())) … … 72 79 73 80 74 //nullptr or not DivisionController? 75 if (!(it) || !(it)->bIsDivisionLeader_) 76 continue; 81 77 82 78 83 float distance = ((it)->getControllableEntity()->getPosition() - this->getControllableEntity()->getPosition()).length(); 79 80 // is pawn in range? 84 85 if (distance < minDistance && !(it->hasFollower())) 86 { 87 closestLeader = *it; 88 minDistance = distance; 89 } 90 /* // is pawn in range? 81 91 if (distance < RADIUS_TO_SEARCH_FOR_LEADER) 82 92 { … … 84 94 if ((it)->setFollower(this)) 85 95 return (*it); 86 } 96 }*/ 87 97 } 88 return NULL; 98 if (closestLeader) 99 { 100 if (closestLeader->setFollower(this)) 101 return closestLeader; 102 } 103 return 0; 89 104 90 105 } … … 96 111 { 97 112 LeaderController* newDivisionLeader = findNewDivisionLeader(); 98 myDivisionLeader_ = newDivisionLeader;99 /*if (newDivisionLeader)113 this->myDivisionLeader_ = newDivisionLeader; 114 /*if (newDivisionLeader) 100 115 orxout(internal_error) << "new DivisionLeader set" << endl; 101 116 else 102 orxout(internal_error) << " nulldivision leader" << endl;*/117 orxout(internal_error) << "0 division leader" << endl;*/ 103 118 } 104 119 }
Note: See TracChangeset
for help on using the changeset viewer.