2002-04-03 23:54:44 +00:00
|
|
|
// AIMgr.cxx - implementation of FGAIMgr
|
|
|
|
// - a global management class for FlightGear generated AI traffic
|
|
|
|
//
|
|
|
|
// Written by David Luff, started March 2002.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2002 David C Luff - david.luff@nottingham.ac.uk
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
*
|
|
|
|
* WARNING - Curt has some ideas about AI traffic so anything in here
|
|
|
|
* may get rewritten or scrapped. Contact Curt curt@flightgear.org
|
|
|
|
* before spending any time or effort on this code!!!
|
|
|
|
*
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <Main/fgfs.hxx>
|
|
|
|
#include <Main/fg_props.hxx>
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
|
|
|
|
#include "AIMgr.hxx"
|
|
|
|
#include "AILocalTraffic.hxx"
|
|
|
|
|
|
|
|
SG_USING_STD(list);
|
|
|
|
|
|
|
|
|
|
|
|
FGAIMgr::FGAIMgr() {
|
|
|
|
}
|
|
|
|
|
|
|
|
FGAIMgr::~FGAIMgr() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void FGAIMgr::init() {
|
2002-12-04 20:03:18 +00:00
|
|
|
// Hard wire some local traffic for now.
|
|
|
|
// This is regardless of location and hence *very* ugly but it is a start.
|
|
|
|
FGAILocalTraffic* local_traffic = new FGAILocalTraffic;
|
|
|
|
local_traffic->Init();
|
|
|
|
local_traffic->FlyCircuits(1, true); // Fly 2 circuits with touch & go in between
|
|
|
|
ai_list.push_back(local_traffic);
|
2002-04-03 23:54:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FGAIMgr::bind() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void FGAIMgr::unbind() {
|
|
|
|
}
|
|
|
|
|
2002-10-02 15:27:49 +00:00
|
|
|
void FGAIMgr::update(double dt) {
|
2002-12-04 20:03:18 +00:00
|
|
|
// Don't update any planes for first 50 runs through - this avoids some possible initialisation anomalies
|
|
|
|
static int i = 0;
|
|
|
|
i++;
|
|
|
|
if(i < 50) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Traverse the list of active planes and run all their update methods
|
|
|
|
ai_list_itr = ai_list.begin();
|
|
|
|
while(ai_list_itr != ai_list.end()) {
|
|
|
|
(*ai_list_itr)->Update(dt);
|
|
|
|
++ai_list_itr;
|
|
|
|
}
|
2002-04-04 01:32:00 +00:00
|
|
|
}
|