X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAIModel%2Fsubmodel.cxx;h=a25212198584427cbcb3fa74c4013d6cce694153;hb=38226af24ec01e8f0a20d7fd73ef838a69f6ef25;hp=471b45dd1307b165800817c94412e7ec8a37fb2a;hpb=f2bca353addaabb703804ec9987f6533b12bdedd;p=flightgear.git diff --git a/src/AIModel/submodel.cxx b/src/AIModel/submodel.cxx index 471b45dd1..a25212198 100644 --- a/src/AIModel/submodel.cxx +++ b/src/AIModel/submodel.cxx @@ -43,6 +43,11 @@ FGSubmodelMgr::~FGSubmodelMgr() { } +FGAIManager* FGSubmodelMgr::aiManager() +{ + return (FGAIManager*)globals->get_subsystem("ai_model"); +} + void FGSubmodelMgr::init() { index = 0; @@ -74,13 +79,8 @@ void FGSubmodelMgr::init() _contrail_trigger = fgGetNode("ai/submodels/contrails", true); _contrail_trigger->setBoolValue(false); - ai = (FGAIManager*)globals->get_subsystem("ai_model"); - load(); - //_model_added_node = fgGetNode("ai/models/model-added", true); - //_model_added_node->addChangeListener(this, false); - } void FGSubmodelMgr::postinit() { @@ -119,9 +119,9 @@ void FGSubmodelMgr::update(double dt) _expiry = false; // check if the submodel hit an object or terrain - sm_list = ai->get_ai_list(); - sm_list_iterator sm_list_itr = sm_list.begin(); - sm_list_iterator end = sm_list.end(); + FGAIManager::ai_list_type sm_list(aiManager()->get_ai_list()); + FGAIManager::ai_list_iterator sm_list_itr = sm_list.begin(), + end = sm_list.end(); for (; sm_list_itr != end; ++sm_list_itr) { FGAIBase::object_type object_type =(*sm_list_itr)->getType(); @@ -207,7 +207,7 @@ void FGSubmodelMgr::update(double dt) if (trigger && (*submodel_iterator)->count != 0) { - int id = (*submodel_iterator)->id; + //int id = (*submodel_iterator)->id; string name = (*submodel_iterator)->name; SG_LOG(SG_GENERAL, SG_DEBUG, @@ -300,10 +300,11 @@ bool FGSubmodelMgr::release(submodel *sm, double dt) ballist->setZoffset(sm->z_offset); ballist->setPitchoffset(sm->pitch_offset); ballist->setYawoffset(sm->yaw_offset); - ballist->setParentNode(_selected_ac); + ballist->setParentNodes(_selected_ac); ballist->setContentsNode(sm->contents_node); ballist->setWeight(sm->weight); - ai->attach(ballist); + + aiManager()->attach(ballist); if (sm->count > 0) sm->count--; @@ -341,7 +342,7 @@ void FGSubmodelMgr::transform(submodel *sm) IC.mass = sm->weight * lbs_to_slugs; int id = sm->id; - int sub_id = sm->sub_id; + //int sub_id = sm->sub_id; string name = sm->name; @@ -386,8 +387,6 @@ void FGSubmodelMgr::transform(submodel *sm) } else { // set the data for a submodel tied to an AI Object //cout << " set the data for a submodel tied to an AI Object " << id << endl; - sm_list_iterator sm_list_itr = sm_list.begin(); - sm_list_iterator end = sm_list.end(); setParentNode(id); } @@ -480,15 +479,15 @@ void FGSubmodelMgr::loadAI() { SG_LOG(SG_GENERAL, SG_DEBUG, "Submodels: Loading AI submodels "); - sm_list = ai->get_ai_list(); + FGAIManager::ai_list_type sm_list(aiManager()->get_ai_list()); if (sm_list.empty()) { SG_LOG(SG_GENERAL, SG_ALERT, "Submodels: Unable to read AI submodel list"); return; } - sm_list_iterator sm_list_itr = sm_list.begin(); - sm_list_iterator end = sm_list.end(); + FGAIManager::ai_list_iterator sm_list_itr = sm_list.begin(), + end = sm_list.end(); while (sm_list_itr != end) { string path = (*sm_list_itr)->_getSMPath(); @@ -515,9 +514,7 @@ void FGSubmodelMgr::setData(int id, string& path, bool serviceable) { SGPropertyNode root; - SGPath config(globals->get_fg_root()); - config.append(path); - SG_LOG(SG_GENERAL, SG_DEBUG, "setData: path " << path); + SGPath config = globals->resolve_aircraft_path(path); try { SG_LOG(SG_GENERAL, SG_DEBUG, "Submodels: Trying to read AI submodels file: " << config.str()); @@ -620,10 +617,7 @@ void FGSubmodelMgr::setData(int id, string& path, bool serviceable) void FGSubmodelMgr::setSubData(int id, string& path, bool serviceable) { SGPropertyNode root; - - SGPath config(globals->get_fg_root()); - config.append(path); - SG_LOG(SG_GENERAL, SG_DEBUG, "setSubData: path " << path); + SGPath config = globals->resolve_aircraft_path(path); try { SG_LOG(SG_GENERAL, SG_DEBUG, @@ -826,48 +820,35 @@ void FGSubmodelMgr::setOffsetPos(){ void FGSubmodelMgr::valueChanged(SGPropertyNode *prop) { -// cout << "LISTENER: " << endl; + return; // this isn't working atm const char* _model_added = _model_added_node->getStringValue(); basic_string ::size_type indexCh2b; string str2 = _model_added; - const char *cstr2b = "ballistic"; + const char *cstr2b = "multiplayer"; indexCh2b = str2.find( cstr2b, 0 ); -// cout << "model added - " << str2 <<" now do something "<< endl; - if (indexCh2b != string::npos ){ // we will ignore Ballistic Objects - there are potentially too many - return; - } else { - - SGPropertyNode *a_node = fgGetNode(_model_added, true ); - SGPropertyNode *sub_node = a_node->getChild("submodels", 0, true); + + //cout << "Submodels: model added - " << str2 <<" read path "<< endl; + //return; + SGPropertyNode *a_node = fgGetNode(_model_added, true); + SGPropertyNode *sub_node = a_node->getChild("sim", 0, true); SGPropertyNode_ptr path_node = sub_node->getChild("path", 0, true); + SGPropertyNode_ptr callsign_node = a_node->getChild("callsign", 0, true); - string path = path_node->getStringValue(); + string callsign = callsign_node->getStringValue(); - if (path.empty()){ - // nothing to do - return - //cout << "subpath empty - return" << endl << endl; + //cout << "Submodels: model added - " << callsign <<" read callsign "<< endl; return; - } else { - //cout << "subpath found - loading" << endl << endl; - SGPropertyNode_ptr ident_node = a_node->getChild("id", 0, true); - int id = ident_node->getIntValue(); - - setData(id, path, true); - - _found_sub = true; - - while (_found_sub) - loadSubmodels(); + } else { + cout << "model added - " << str2 <<" returning "<< endl; + return; } - } - } void FGSubmodelMgr::setParentNode(int id) {