Skip to content

Commit

Permalink
Fix gefs.aircraft.setup is not defined error
Browse files Browse the repository at this point in the history
  • Loading branch information
Qantas94Heavy committed Nov 7, 2016
1 parent 94c025c commit 15e123f
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions source/bugfixes/restrictions.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ define(function () {
}, 12000);
}

function matchesName() {
var aircraftName = gefs.aircraft.name;
return aircraftName === 'md11' || aircraftName === 'a380' || gefs.aircraft.setup.maxLimits;
}

function addRestrictions() {
if (matchesName()) speedTimer = setInterval(checkSpeedAndAltitude, 5000);
}

var oldReset = Aircraft.prototype.reset;
Aircraft.prototype.reset = function (bOnTheGround) {
clearTimeout(deleteTimeout);
Expand All @@ -97,15 +106,17 @@ define(function () {
activated = false;
}

if (matchesName()) speedTimer = setInterval(checkSpeedAndAltitude, 5000);
addRestrictions();
oldReset.call(this, bOnTheGround);
};

function matchesName() {
return /^(?:md11|a380|\d+)$/.test(gefs.aircraft.name) || gefs.aircraft.setup.maxLimits;
}

if (matchesName()) speedTimer = setInterval(checkSpeedAndAltitude, 5000);
// Aircraft setup object might not be loaded yet.
var setupLoadTimer = setInterval(function () {
if (gefs.aircraft.setup) {
clearInterval(setupLoadTimer);
addRestrictions();
}
}, 1000);
}

return restrictionsBugfix;
Expand Down

0 comments on commit 15e123f

Please sign in to comment.