#248: support enabling AI module at run-time
Also adapt MP and traffic module to enable the AI module when required. This makes /sim/ai/enabled an internal property: it can default to false (in future), and can be enabled as soon as any user-level feature (traffic, MP, local weather, ...) requires it.
This commit is contained in:
parent
10d2d94778
commit
9b51c5e87e
4 changed files with 12 additions and 10 deletions
|
@ -69,10 +69,7 @@ void
|
|||
FGAIManager::init() {
|
||||
root = fgGetNode("sim/ai", true);
|
||||
|
||||
enabled = root->getNode("enabled", true)->getBoolValue();
|
||||
|
||||
if (!enabled)
|
||||
return;
|
||||
enabled = root->getNode("enabled", true);
|
||||
|
||||
thermal_lift_node = fgGetNode("/environment/thermal-lift-fps", true);
|
||||
wind_from_east_node = fgGetNode("/environment/wind-from-east-fps",true);
|
||||
|
@ -143,7 +140,7 @@ FGAIManager::update(double dt) {
|
|||
range_nearest = 10000.0;
|
||||
strength = 0.0;
|
||||
|
||||
if (!enabled)
|
||||
if (!enabled->getBoolValue())
|
||||
return;
|
||||
|
||||
FGTrafficManager *tmgr = (FGTrafficManager*) globals->get_subsystem("traffic-manager");
|
||||
|
|
|
@ -96,13 +96,13 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
bool enabled;
|
||||
int mNumAiTypeModels[FGAIBase::MAX_OBJECTS];
|
||||
int mNumAiModels;
|
||||
|
||||
double calcRange(double lat, double lon, double lat2, double lon2)const;
|
||||
|
||||
SGPropertyNode_ptr root;
|
||||
SGPropertyNode_ptr enabled;
|
||||
SGPropertyNode_ptr thermal_lift_node;
|
||||
SGPropertyNode_ptr user_latitude_node;
|
||||
SGPropertyNode_ptr user_longitude_node;
|
||||
|
|
|
@ -408,9 +408,8 @@ FGMultiplayMgr::init (void)
|
|||
|
||||
if (!fgGetBool("/sim/ai/enabled"))
|
||||
{
|
||||
SG_LOG(SG_NETWORK, SG_ALERT,
|
||||
"Cannot enable multiplayer mode: AI subsystem is disabled (to enable start with '--enable-ai-models').");
|
||||
return;
|
||||
// multiplayer depends on AI module
|
||||
fgSetBool("/sim/ai/enabled", true);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
|
|
|
@ -134,10 +134,16 @@ FGTrafficManager::~FGTrafficManager()
|
|||
|
||||
void FGTrafficManager::init()
|
||||
{
|
||||
if (!enabled || !aiEnabled) {
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!aiEnabled)
|
||||
{
|
||||
// traffic depends on AI module
|
||||
aiEnabled = true;
|
||||
}
|
||||
|
||||
assert(!doingInit);
|
||||
doingInit = true;
|
||||
if (string(fgGetString("/sim/traffic-manager/datafile")) == string("")) {
|
||||
|
|
Loading…
Add table
Reference in a new issue