From 670ea7c881b3e6cecc64d38eaf503a8e1a8a9972 Mon Sep 17 00:00:00 2001 From: ehofman Date: Thu, 28 Oct 2004 08:33:55 +0000 Subject: [PATCH] David Culp: Here's code to support a new AICarrier class, which I think will be sufficiently different from a basic AIShip that it should have its own class. --- src/AIModel/AICarrier.cxx | 39 +++++++++++++++++++++++++++++++++++++++ src/AIModel/AICarrier.hxx | 39 +++++++++++++++++++++++++++++++++++++++ src/AIModel/AIManager.cxx | 28 ++++++++++++++++++++++++++++ src/AIModel/AIManager.hxx | 1 + src/AIModel/Makefile.am | 3 ++- 5 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 src/AIModel/AICarrier.cxx create mode 100644 src/AIModel/AICarrier.hxx diff --git a/src/AIModel/AICarrier.cxx b/src/AIModel/AICarrier.cxx new file mode 100644 index 000000000..bb5212818 --- /dev/null +++ b/src/AIModel/AICarrier.cxx @@ -0,0 +1,39 @@ +// FGAICarrier - FGAIShip-derived class creates an AI aircraft carrier +// +// Written by David Culp, started October 2004. +// - davidculp2@comcast.net +// +// 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. + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "AICarrier.hxx" + + +FGAICarrier::FGAICarrier(FGAIManager* mgr) : FGAIShip(mgr) { +} + +FGAICarrier::~FGAICarrier() { +} + + +void FGAICarrier::update(double dt) { + FGAIShip::update(dt); +} + + + diff --git a/src/AIModel/AICarrier.hxx b/src/AIModel/AICarrier.hxx new file mode 100644 index 000000000..c536c457e --- /dev/null +++ b/src/AIModel/AICarrier.hxx @@ -0,0 +1,39 @@ +// FGAICarrier - AIShip-derived class creates an AI aircraft carrier +// +// Written by David Culp, started October 2004. +// +// Copyright (C) 2004 David P. Culp - davidculp2@comcast.net +// +// 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. + +#ifndef _FG_AICARRIER_HXX +#define _FG_AICARRIER_HXX + +#include "AIShip.hxx" +class FGAIManager; + +class FGAICarrier : public FGAIShip { + +public: + + FGAICarrier(FGAIManager* mgr); + ~FGAICarrier(); + +private: + + void update(double dt); +}; + +#endif // _FG_AICARRIER_HXX diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index a3d670e33..c925deaa8 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -30,6 +30,7 @@ #include "AIBallistic.hxx" #include "AIStorm.hxx" #include "AIThermal.hxx" +#include "AICarrier.hxx" SG_USING_STD(list); @@ -184,6 +185,30 @@ FGAIManager::createShip( FGAIModelEntity *entity ) { return ai_ship; } +void* +FGAIManager::createCarrier( FGAIModelEntity *entity ) { + + FGAIShip* ai_carrier = new FGAICarrier(this); + ai_list.push_back(ai_carrier); + ++numObjects[0]; + ++numObjects[FGAIBase::otShip]; + ai_carrier->setHeading(entity->heading); + ai_carrier->setSpeed(entity->speed); + ai_carrier->setPath(entity->path.c_str()); + ai_carrier->setAltitude(entity->altitude); + ai_carrier->setLongitude(entity->longitude); + ai_carrier->setLatitude(entity->latitude); + ai_carrier->setBank(entity->rudder); + + if ( entity->fp ) { + ai_carrier->setFlightPlan(entity->fp); + } + + ai_carrier->init(); + ai_carrier->bind(); + return ai_carrier; +} + void* FGAIManager::createBallistic( FGAIModelEntity *entity ) { @@ -301,6 +326,9 @@ void FGAIManager::processScenario( string &filename ) { } else if ( en->m_type == "ship") { createShip( en ); + } else if ( en->m_type == "carrier") { + createCarrier( en ); + } else if ( en->m_type == "thunderstorm") { createStorm( en ); diff --git a/src/AIModel/AIManager.hxx b/src/AIModel/AIManager.hxx index 619d91961..59b879b1f 100644 --- a/src/AIModel/AIManager.hxx +++ b/src/AIModel/AIManager.hxx @@ -67,6 +67,7 @@ public: void* createThermal( FGAIModelEntity *entity ); void* createStorm( FGAIModelEntity *entity ); void* createShip( FGAIModelEntity *entity ); + void* createCarrier( FGAIModelEntity *entity ); void destroyObject( void* ID ); diff --git a/src/AIModel/Makefile.am b/src/AIModel/Makefile.am index d3429a8ca..a44c13f90 100644 --- a/src/AIModel/Makefile.am +++ b/src/AIModel/Makefile.am @@ -10,6 +10,7 @@ libAIModel_a_SOURCES = \ AIStorm.hxx AIStorm.cxx \ AIThermal.hxx AIThermal.cxx \ AIFlightPlan.hxx AIFlightPlan.cxx \ - AIScenario.hxx AIScenario.cxx + AIScenario.hxx AIScenario.cxx \ + AICarrier.hxx AICarrier.cxx INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src -- 2.39.5