]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/AIEntity.cxx
This innocuous looking typo was crashing the sim whenever an AI plane was asked to...
[flightgear.git] / src / ATC / AIEntity.cxx
index d87b86dbfcc76225ad7695a8654096d272f186da..f4d58cd1d657f73ff79b024c2827b8599d6b62a3 100644 (file)
 //
 // 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.
 
 /*****************************************************************
 *
 * WARNING - Curt has some ideas about AI traffic so anything in here
-* may get rewritten or scrapped.  Contact Curt curt@flightgear.org 
+* may get rewritten or scrapped.  Contact Curt http://www.flightgear.org/~curt 
 * before spending any time or effort on this code!!!
 *
 ******************************************************************/
@@ -45,25 +45,30 @@ FGAIEntity::FGAIEntity() {
 
 FGAIEntity::~FGAIEntity() {
        //cout << "FGAIEntity dtor called..." << endl;
-       _model->deRef();        // Ought to check valid?
        //cout << "Removing model from scene graph..." << endl;
        globals->get_scenery()->get_scene_graph()->removeKid(_aip.getSceneGraph());
+        // Unregister that one at the scenery manager
+        globals->get_scenery()->unregister_placement_transform(_aip.getTransform());
+
        //cout << "Done!" << endl;
 }
 
 void FGAIEntity::SetModel(ssgBranch* model) {
        _model = model;
-       _model->ref();
        _aip.init(_model);
        _aip.setVisible(false);
        globals->get_scenery()->get_scene_graph()->addKid(_aip.getSceneGraph());
+        // Register that one at the scenery manager
+        globals->get_scenery()->register_placement_transform(_aip.getTransform());
+
 }
 
 void FGAIEntity::Update(double dt) {
 }
 
-string FGAIEntity::GetCallsign() {
-       return("");
+const string &FGAIEntity::GetCallsign() {
+       static string s = "";
+       return(s);
 }
 
 void FGAIEntity::RegisterTransmission(int code) {
@@ -74,5 +79,5 @@ void FGAIEntity::RegisterTransmission(int code) {
 void FGAIEntity::Transform() {
     _aip.setPosition(_pos.lon(), _pos.lat(), _pos.elev() * SG_METER_TO_FEET);
     _aip.setOrientation(_roll, _pitch, _hdg);
-    _aip.update( globals->get_scenery()->get_center() );    
+    _aip.update();    
 }