]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/AIEntity.cxx
The most important part is that it fixes possible
[flightgear.git] / src / ATC / AIEntity.cxx
index 9dccebea01911ec734d2d84c3c6fa884eb23634f..efcaaee1cc56ce05be481d4185e32cf26939baf8 100644 (file)
@@ -45,9 +45,12 @@ FGAIEntity::FGAIEntity() {
 
 FGAIEntity::~FGAIEntity() {
        //cout << "FGAIEntity dtor called..." << endl;
-       _model->deRef();        // Ought to check valid?
+        ssgDeRefDelete(_model);        // 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;
 }
 
@@ -57,13 +60,17 @@ void FGAIEntity::SetModel(ssgBranch* model) {
        _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 +81,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();    
 }