]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIManager.cxx
Make the vertical acceleration rate scale with vertical performance. The
[flightgear.git] / src / AIModel / AIManager.cxx
index cfe7276b7e9e919cf4b5b47f6bf30008d89239b6..207913bb1ff5aae959e33dc829126c7c8c79ddb2 100644 (file)
@@ -16,7 +16,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #include <Main/globals.hxx>
 
@@ -36,6 +36,8 @@
 FGAIManager::FGAIManager() {
   _dt = 0.0;
   mNumAiModels = 0;
+  for (unsigned i = 0; i < FGAIBase::MAX_OBJECTS; ++i)
+    mNumAiTypeModels[i] = 0;
 }
 
 FGAIManager::~FGAIManager() {
@@ -97,7 +99,6 @@ void FGAIManager::unbind() {
 
 
 void FGAIManager::update(double dt) {
-
   // initialize these for finding nearest thermals
   range_nearest = 10000.0;
   strength = 0.0;
@@ -112,6 +113,7 @@ void FGAIManager::update(double dt) {
     if ((*ai_list_itr)->getDie()) {      
       tmgr->release((*ai_list_itr)->getID());
       --mNumAiModels;
+      --(mNumAiTypeModels[(*ai_list_itr)->getType()]);
       (*ai_list_itr)->unbind();
       ai_list_itr = ai_list.erase(ai_list_itr);
     } else {
@@ -131,9 +133,14 @@ void FGAIManager::update(double dt) {
 void
 FGAIManager::attach(SGSharedPtr<FGAIBase> model)
 {
-  model->setManager(this);
+  unsigned idx = mNumAiTypeModels[model->getType()];
+  const char* typeString = model->getTypeString();
+  SGPropertyNode* root = globals->get_props()->getNode("ai/models", true);
+  SGPropertyNode* p = root->getNode(typeString, idx, true);
+  model->setManager(this, p);
   ai_list.push_back(model);
   ++mNumAiModels;
+  ++(mNumAiTypeModels[model->getType()]);
   model->init();
   model->bind();
 }
@@ -144,6 +151,7 @@ void FGAIManager::destroyObject( int ID ) {
   while(ai_list_itr != ai_list.end()) {
     if ((*ai_list_itr)->getID() == ID) {
       --mNumAiModels;
+      --(mNumAiTypeModels[(*ai_list_itr)->getType()]);
       (*ai_list_itr)->unbind();
       ai_list_itr = ai_list.erase(ai_list_itr);
     } else