1
0
Fork 0

Csaba "Jester" HALASZ: radar fix & extension

- fix breakage due to former commit (AIManager.cxx, r1.72)
- make AI properties available in AIBase
- add <valid> property for animations/nasal scripts
- support more MP and AI targets
- add target select and altitude display
This commit is contained in:
mfranz 2007-04-04 09:51:41 +00:00
parent b5ab955877
commit 2621ba7a47
3 changed files with 23 additions and 13 deletions

View file

@ -83,15 +83,8 @@ FGAIBase::~FGAIBase() {
if (props) { if (props) {
SGPropertyNode* parent = props->getParent(); SGPropertyNode* parent = props->getParent();
if (parent) { if (parent)
model_removed->setStringValue(props->getPath()); model_removed->setStringValue(props->getPath());
parent->removeChild(props->getName(), props->getIndex(), false);
}
// so that radar does not have to do extra checks
props->setBoolValue("radar/in-range", false);
props->removeChild("id", 0);
} }
delete fp; delete fp;
fp = 0; fp = 0;
@ -507,6 +500,10 @@ bool FGAIBase::_getServiceable() const {
return serviceable; return serviceable;
} }
SGPropertyNode* FGAIBase::_getProps() const {
return props;
}
void FGAIBase::_setAltitude( double _alt ) { void FGAIBase::_setAltitude( double _alt ) {
setAltitude( _alt ); setAltitude( _alt );
} }

View file

@ -184,6 +184,7 @@ public:
double _get_speed_north_fps() const; double _get_speed_north_fps() const;
bool _getServiceable() const; bool _getServiceable() const;
SGPropertyNode* _getProps() const;
const char* _getPath(); const char* _getPath();
const char* _getCallsign(); const char* _getCallsign();

View file

@ -122,7 +122,19 @@ void FGAIManager::update(double dt) {
tmgr->release((*ai_list_itr)->getID()); tmgr->release((*ai_list_itr)->getID());
--mNumAiModels; --mNumAiModels;
--(mNumAiTypeModels[(*ai_list_itr)->getType()]); --(mNumAiTypeModels[(*ai_list_itr)->getType()]);
(*ai_list_itr)->unbind(); FGAIBase *base = *ai_list_itr;
SGPropertyNode *props = base->_getProps();
props->setBoolValue("valid", false);
base->unbind();
// for backward compatibility reset properties, so that aircraft,
// which don't know the <valid> property, keep working
// TODO: remove after a while
props->setIntValue("id", -1);
props->setBoolValue("radar/in-range", false);
props->setIntValue("refuel/tanker", false);
ai_list_itr = ai_list.erase(ai_list_itr); ai_list_itr = ai_list.erase(ai_list_itr);
} else { } else {
fetchUserState(); fetchUserState();
@ -150,11 +162,10 @@ FGAIManager::attach(SGSharedPtr<FGAIBase> model)
//more than 10000 mp-aircrafts in the property tree we should optimize the mp-server //more than 10000 mp-aircrafts in the property tree we should optimize the mp-server
{ {
p = root->getNode(typeString, i, false); p = root->getNode(typeString, i, false);
if (!p) break; if (!p || !p->getBoolValue("valid", false))
if (p->getIntValue("id",-1)==model->getID()) break;
{ if (p->getIntValue("id",-1)==model->getID()) {
p->setStringValue("callsign","***invalid node***"); //debug only, should never set! p->setStringValue("callsign","***invalid node***"); //debug only, should never set!
} }
} }
p = root->getNode(typeString, i, true); p = root->getNode(typeString, i, true);
@ -166,6 +177,7 @@ FGAIManager::attach(SGSharedPtr<FGAIBase> model)
|| model->getType()==FGAIBase::otMultiplayer || model->getType()==FGAIBase::otMultiplayer
|| model->getType()==FGAIBase::otStatic); || model->getType()==FGAIBase::otStatic);
model->bind(); model->bind();
p->setBoolValue("valid", true);
} }