/* Motor - Decompiled by JODE
* Visit
http://jode.sourceforge.net/ */
package com.maddox.il2.fm;
import java.io.IOException;
import com.maddox.JGP.Point3d;
import com.maddox.JGP.Point3f;
import com.maddox.JGP.Vector3d;
import com.maddox.JGP.Vector3f;
import com.maddox.il2.ai.Airport;
import com.maddox.il2.ai.World;
import com.maddox.il2.engine.Actor;
import com.maddox.il2.engine.Eff3DActor;
import com.maddox.il2.engine.Hook;
import com.maddox.il2.game.AircraftHotKeys;
import com.maddox.il2.game.HUD;
import com.maddox.il2.game.Main3D;
import com.maddox.il2.objects.air.Aircraft;
import com.maddox.il2.objects.air.BI_1;
import com.maddox.il2.objects.air.BI_6;
import com.maddox.il2.objects.air.GLADIATOR;
import com.maddox.il2.objects.air.MXY_7;
import com.maddox.il2.objects.air.P_38;
import com.maddox.il2.objects.air.P_51;
import com.maddox.il2.objects.air.P_63C;
import com.maddox.il2.objects.air.SM79;
import com.maddox.il2.objects.air.SPITFIRE5B;
import com.maddox.il2.objects.air.SPITFIRE8;
import com.maddox.il2.objects.air.SPITFIRE8CLP;
import com.maddox.il2.objects.air.SPITFIRE9;
import com.maddox.il2.objects.air.YAK_3;
import com.maddox.il2.objects.air.YAK_3P;
import com.maddox.il2.objects.air.YAK_9M;
import com.maddox.il2.objects.air.YAK_9U;
import com.maddox.il2.objects.air.YAK_9UT;
import com.maddox.rts.NetMsgGuaranted;
import com.maddox.rts.NetMsgInput;
import com.maddox.rts.SectFile;
import com.maddox.rts.Time;
public class Motor extends FMMath
{
private static final boolean ___debug___ = false;
public static final int _E_TYPE_INLINE = 0;
public static final int _E_TYPE_RADIAL = 1;
public static final int _E_TYPE_JET = 2;
public static final int _E_TYPE_ROCKET = 3;
public static final int _E_TYPE_ROCKETBOOST = 4;
public static final int _E_TYPE_TOW = 5;
public static final int _E_TYPE_PVRD = 6;
public static final int _E_TYPE_HELO_INLINE = 7;
public static final int _E_TYPE_UNIDENTIFIED = 8;
public static final int _E_PROP_DIR_LEFT = 0;
public static final int _E_PROP_DIR_RIGHT = 1;
public static final int _E_STAGE_NULL = 0;
public static final int _E_STAGE_WAKE_UP = 1;
public static final int _E_STAGE_STARTER_ROLL = 2;
public static final int _E_STAGE_CATCH_UP = 3;
public static final int _E_STAGE_CATCH_ROLL = 4;
public static final int _E_STAGE_CATCH_FIRE = 5;
public static final int _E_STAGE_NOMINAL = 6;
public static final int _E_STAGE_DEAD = 7;
public static final int _E_STAGE_STUCK = 8;
public static final int _E_PROP_FIXED = 0;
public static final int _E_PROP_RETAIN_RPM_1 = 1;
public static final int _E_PROP_RETAIN_RPM_2 = 2;
public static final int _E_PROP_RETAIN_AOA_1 = 3;
public static final int _E_PROP_RETAIN_AOA_2 = 4;
public static final int _E_PROP_FRICTION = 5;
public static final int _E_PROP_MANUALDRIVEN = 6;
public static final int _E_PROP_WM_KOMANDGERAT = 7;
public static final int _E_PROP_FW_KOMANDGERAT = 8;
public static final int _E_PROP_CSP_EL = 9;
public static final int _E_CARB_SUCTION = 0;
public static final int _E_CARB_CARBURETOR = 1;
public static final int _E_CARB_INJECTOR = 2;
public static final int _E_CARB_FLOAT = 3;
public static final int _E_CARB_SHILLING = 4;
public static final int _E_COMPRESSOR_NONE = 0;
public static final int _E_COMPRESSOR_MANUALSTEP = 1;
public static final int _E_COMPRESSOR_WM_KOMANDGERAT = 2;
public static final int _E_COMPRESSOR_TURBO = 3;
public static final int _E_MIXER_GENERIC = 0;
public static final int _E_MIXER_BRIT_FULLAUTO = 1;
public static final int _E_MIXER_LIMITED_PRESSURE = 2;
public static final int _E_AFTERBURNER_GENERIC = 0;
public static final int _E_AFTERBURNER_MW50 = 1;
public static final int _E_AFTERBURNER_GM1 = 2;
public static final int _E_AFTERBURNER_FIRECHAMBER = 3;
public static final int _E_AFTERBURNER_WATER = 4;
public static final int _E_AFTERBURNER_NO2 = 5;
public static final int _E_AFTERBURNER_FUEL_INJECTION = 6;
public static final int _E_AFTERBURNER_FUEL_ILA5 = 7;
public static final int _E_AFTERBURNER_FUEL_ILA5AUTO = 8;
public static final int _E_AFTERBURNER_WATERMETHANOL = 9;
public static final int _E_AFTERBURNER_P51 = 10;
public static final int _E_AFTERBURNER_SPIT = 11;
private static int heatStringID = -1;
public FmSounds isnd = null;
private FlightModel reference = null;
private static boolean bTFirst;
public String soundName = null;
public String startStopName = null;
public String propName = null;
private int number = 0;
private int type = 0;
private int cylinders = 12;
private float engineMass = 900.0F;
private float wMin = 20.0F;
private float wNom = 180.0F;
private float wMax = 200.0F;
private float wWEP = 220.0F;
private float wMaxAllowed = 250.0F;
public int wNetPrev = 0;
public float engineMoment = 0.0F;
private float engineMomentMax = 0.0F;
private float engineBoostFactor = 1.0F;
private float engineAfterburnerBoostFactor = 1.0F;
private float engineDistAM = 0.0F;
private float engineDistBM = 0.0F;
private float engineDistCM = 0.0F;
private float producedDistabilisation;
private boolean bRan = false;
private Point3f enginePos = new Point3f();
private Vector3f engineVector = new Vector3f();
private Vector3f engineForce = new Vector3f();
private Vector3f engineTorque = new Vector3f();
private float engineDamageAccum = 0.0F;
private float _1_wMaxAllowed = 1.0F / wMaxAllowed;
private float _1_wMax = 1.0F / wMax;
private float RPMMin = 200.0F;
private float RPMNom = 2000.0F;
private float RPMMax = 2200.0F;
private float Vopt = 90.0F;
private float pressureExtBar;
private double momForFuel = 0.0;
public double addVflow = 0.0;
public double addVside = 0.0;
private Point3f propPos = new Point3f();
private float propReductor = 1.0F;
private int propAngleDeviceType = 0;
private float propAngleDeviceMinParam = 0.0F;
private float propAngleDeviceMaxParam = 0.0F;
private float propAngleDeviceAfterburnerParam = -999.9F;
private int propDirection = 0;
private float propDiameter = 3.0F;
private float propMass = 30.0F;
private float propI = 1.0F;
public Vector3d propIW = new Vector3d();
private float propSEquivalent = 1.0F;
private float propr = 1.125F;
private float propPhiMin = (float) Math.toRadians(10.0);
private float propPhiMax = (float) Math.toRadians(29.0);
private float propPhi = (float) Math.toRadians(11.0);
private float propPhiW;
private float propAoA;
private float propAoA0 = (float) Math.toRadians(11.0);
private float propAoACrit = (float) Math.toRadians(16.0);
private float propAngleChangeSpeed = 0.1F;
private float propForce = 0.0F;
public float propMoment = 0.0F;
private float propTarget = 0.0F;
private int mixerType = 0;
private float mixerLowPressureBar = 0.0F;
private float horsePowers = 1200.0F;
private float thrustMax = 10.7F;
private int cylindersOperable = 12;
private float engineI = 1.0F;
private float engineAcceleration = 1.0F;
private boolean[] bMagnetos = { true, true };
private boolean bIsAutonomous = true;
private boolean bIsMaster = true;
private boolean bIsStuck = false;
private boolean bIsInoperable = false;
private boolean bIsAngleDeviceOperational = true;
private boolean isPropAngleDeviceHydroOperable = true;
private int engineCarburetorType = 0;
private float FuelConsumptionP0 = 0.4F;
private float FuelConsumptionP05 = 0.24F;
private float FuelConsumptionP1 = 0.28F;
private float FuelConsumptionPMAX = 0.3F;
private int compressorType = 0;
public int compressorMaxStep = 0;
private float compressorPMax = 1.0F;
private float compressorManifoldPressure = 1.0F;
public float[] compressorAltitudes = null;
private float[] compressorPressure = null;
private float[] compressorAltMultipliers = null;
private float compressorRPMtoP0 = 1500.0F;
private float compressorRPMtoCurvature = -30.0F;
private float compressorRPMtoPMax = 2600.0F;
private float compressorRPMtoWMaxATA = 1.45F;
private float compressorSpeedManifold = 0.2F;
private float[] compressorRPM = new float[16];
private float[] compressorATA = new float[16];
private int nOfCompPoints = 0;
private boolean compressorStepFound = false;
private float compressorManifoldThreshold = 1.0F;
private float afterburnerCompressorFactor = 1.0F;
private float _1_P0 = 1.0F / Atmosphere.P0();
private float compressor1stThrottle = 1.0F;
private float compressor2ndThrottle = 1.0F;
private float compressorPAt0 = 0.3F;
private int afterburnerType = 0;
private boolean afterburnerChangeW = false;
private int stage = 0;
private int oldStage = 0;
private long timer = 0L;
private long given = 4611686018427387903L;
private float rpm = 0.0F;
public float w = 0.0F;
private float aw = 0.0F;
private float oldW = 0.0F;
private float readyness = 1.0F;
private float oldReadyness = 1.0F;
private float radiatorReadyness = 1.0F;
private float rearRush;
public float tOilIn = 0.0F;
public float tOilOut = 0.0F;
public float tWaterOut = 0.0F;
public float tCylinders = 0.0F;
private float tWaterCritMin;
public float tWaterCritMax;
private float tOilCritMin;
public float tOilCritMax;
private float tWaterMaxRPM;
public float tOilOutMaxRPM;
private float tOilInMaxRPM;
private float tChangeSpeed;
private float timeOverheat;
private float timeUnderheat;
private float timeCounter;
private float oilMass = 90.0F;
private float waterMass = 90.0F;
private float Ptermo;
private float R_air;
private float R_oil;
private float R_water;
private float R_cyl_oil;
private float R_cyl_water;
private float C_eng;
private float C_oil;
private float C_water;
private boolean bHasThrottleControl = true;
private boolean bHasAfterburnerControl = true;
private boolean bHasPropControl = true;
private boolean bHasRadiatorControl = true;
private boolean bHasMixControl = true;
private boolean bHasMagnetoControl = true;
private boolean bHasExtinguisherControl = false;
private boolean bHasCompressorControl = false;
private boolean bHasFeatherControl = false;
private int extinguishers = 0;
private float controlThrottle = 0.0F;
public float controlRadiator = 0.0F;
private boolean controlAfterburner = false;
private float controlProp = 1.0F;
private boolean bControlPropAuto = true;
private float controlMix = 1.0F;
private int controlMagneto = 0;
private int controlCompressor = 0;
private int controlFeather = 0;
public double zatizeni;
public float coolMult;
private int controlPropDirection;
private float neg_G_Counter = 0.0F;
private boolean bFullT = false;
private boolean bFloodCarb = false;
private boolean bWepRpmInLowGear;
public boolean fastATA = false;
private Vector3f old_engineForce = new Vector3f();
private Vector3f old_engineTorque = new Vector3f();
private float updateStep = 0.12F;
private float updateLast = 0.0F;
private float fricCoeffT = 1.0F;
private static Vector3f tmpV3f = new Vector3f();
private static Vector3d tmpV3d1 = new Vector3d();
private static Vector3d tmpV3d2 = new Vector3d();
private static Point3f safeloc = new Point3f();
private static Point3d safeLoc = new Point3d();
private static Vector3f safeVwld = new Vector3f();
private static Vector3f safeVflow = new Vector3f();
private static boolean tmpB;
private static float tmpF;
private int engineNoFuelHUDLogId = -1;
public void load(FlightModel flightmodel, String string, String string_0_,
int i) {
reference = flightmodel;
number = i;
SectFile sectfile = FlightModelMain.sectFile(string);
resolveFromFile(sectfile, "Generic");
resolveFromFile(sectfile, string_0_);
calcAfterburnerCompressorFactor();
if (type == 0 || type == 1 || type == 7)
initializeInline(flightmodel.Vmax);
if (type == 2)
initializeJet(flightmodel.Vmax);
}
private void resolveFromFile(SectFile sectfile, String string) {
soundName = sectfile.get(string, "SoundName", soundName);
propName = sectfile.get(string, "PropName", propName);
startStopName = sectfile.get(string, "StartStopName", startStopName);
Aircraft.debugprintln(reference.actor,
("Resolving submodel " + string + " from file '"
+ sectfile.toString() + "'...."));
String string_1_ = sectfile.get(string, "Type");
if (string_1_ != null) {
if (string_1_.endsWith("Inline"))
type = 0;
else if (string_1_.endsWith("Radial"))
type = 1;
else if (string_1_.endsWith("Jet"))
type = 2;
else if (string_1_.endsWith("RocketBoost"))
type = 4;
else if (string_1_.endsWith("Rocket"))
type = 3;
else if (string_1_.endsWith("Tow"))
type = 5;
else if (string_1_.endsWith("PVRD"))
type = 6;
else if (string_1_.endsWith("Unknown"))
type = 8;
else if (string_1_.endsWith("Azure"))
type = 8;
else if (string_1_.endsWith("HeloI"))
type = 7;
}
if (type == 0 || type == 1 || type == 7) {
int i = sectfile.get(string, "Cylinders", -99999);
if (i != -99999) {
cylinders = i;
cylindersOperable = cylinders;
}
}
string_1_ = sectfile.get(string, "Direction");
if (string_1_ != null) {
if (string_1_.endsWith("Left"))
propDirection = 0;
else if (string_1_.endsWith("Right"))
propDirection = 1;
}
float f = sectfile.get(string, "RPMMin", -99999.0F);
if (f != -99999.0F) {
RPMMin = f;
wMin = toRadianPerSecond(RPMMin);
}
f = sectfile.get(string, "RPMNom", -99999.0F);
if (f != -99999.0F) {
RPMNom = f;
wNom = toRadianPerSecond(RPMNom);
}
f = sectfile.get(string, "RPMMax", -99999.0F);
if (f != -99999.0F) {
RPMMax = f;
wMax = toRadianPerSecond(RPMMax);
_1_wMax = 1.0F / wMax;
}
f = sectfile.get(string, "RPMMaxAllowed", -99999.0F);
if (f != -99999.0F) {
wMaxAllowed = toRadianPerSecond(f);
_1_wMaxAllowed = 1.0F / wMaxAllowed;
}
f = sectfile.get(string, "Reductor", -99999.0F);
if (f != -99999.0F)
propReductor = f;
if (type == 0 || type == 1 || type == 7) {
f = sectfile.get(string, "HorsePowers", -99999.0F);
if (f != -99999.0F)
horsePowers = f;
int i = sectfile.get(string, "Carburetor", -99999);
if (i != -99999)
engineCarburetorType = i;
f = sectfile.get(string, "Mass", -99999.0F);
if (f != -99999.0F)
engineMass = f;
else
engineMass = horsePowers * 0.6F;
} else {
f = sectfile.get(string, "Thrust", -99999.0F);
if (f != -99999.0F)
thrustMax = f * 9.81F;
}
f = sectfile.get(string, "BoostFactor", -99999.0F);
if (f != -99999.0F)
engineBoostFactor = f;
f = sectfile.get(string, "WEPBoostFactor", -99999.0F);
if (f != -99999.0F)
engineAfterburnerBoostFactor = f;
if (type == 2) {
FuelConsumptionP0 = 0.075F;
FuelConsumptionP05 = 0.075F;
FuelConsumptionP1 = 0.1F;
FuelConsumptionPMAX = 0.11F;
}
if (type == 6) {
FuelConsumptionP0 = 0.835F;
FuelConsumptionP05 = 0.835F;
FuelConsumptionP1 = 0.835F;
FuelConsumptionPMAX = 0.835F;
}
f = sectfile.get(string, "FuelConsumptionP0", -99999.0F);
if (f != -99999.0F)
FuelConsumptionP0 = f;
f = sectfile.get(string, "FuelConsumptionP05", -99999.0F);
if (f != -99999.0F)
FuelConsumptionP05 = f;
f = sectfile.get(string, "FuelConsumptionP1", -99999.0F);
if (f != -99999.0F)
FuelConsumptionP1 = f;
f = sectfile.get(string, "FuelConsumptionPMAX", -99999.0F);
if (f != -99999.0F)
FuelConsumptionPMAX = f;
int i = sectfile.get(string, "Autonomous", -99999);
if (i != -99999) {
if (i == 0)
bIsAutonomous = false;
else if (i == 1)
bIsAutonomous = true;
}
i = sectfile.get(string, "cThrottle", -99999);
if (i != -99999) {
if (i == 0)
bHasThrottleControl = false;
else if (i == 1)
bHasThrottleControl = true;
}
i = sectfile.get(string, "cAfterburner", -99999);
if (i != -99999) {
if (i == 0)
bHasAfterburnerControl = false;
else if (i == 1)
bHasAfterburnerControl = true;
}
i = sectfile.get(string, "cProp", -99999);
if (i != -99999) {
if (i == 0)
bHasPropControl = false;
else if (i == 1)
bHasPropControl = true;
}
i = sectfile.get(string, "cMix", -99999);
if (i != -99999) {
if (i == 0)
bHasMixControl = false;
else if (i == 1)
bHasMixControl = true;
}
i = sectfile.get(string, "cMagneto", -99999);
if (i != -99999) {
if (i == 0)
bHasMagnetoControl = false;
else if (i == 1)
bHasMagnetoControl = true;
}
i = sectfile.get(string, "cCompressor", -99999);
if (i != -99999) {
if (i == 0)
bHasCompressorControl = false;
else if (i == 1)
bHasCompressorControl = true;
}
i = sectfile.get(string, "cFeather", -99999);
if (i != -99999) {
if (i == 0)
bHasFeatherControl = false;
else if (i == 1)
bHasFeatherControl = true;
}
i = sectfile.get(string, "cRadiator", -99999);
if (i != -99999) {
if (i == 0)
bHasRadiatorControl = false;
else if (i == 1)
bHasRadiatorControl = true;
}
i = sectfile.get(string, "Extinguishers", -99999);
if (i != -99999) {
extinguishers = i;
if (i != 0)
bHasExtinguisherControl = true;
else
bHasExtinguisherControl = false;
}
f = sectfile.get(string, "PropDiameter", -99999.0F);
if (f != -99999.0F)
propDiameter = f;
propr = 0.5F * propDiameter * 0.75F;
f = sectfile.get(string, "PropMass", -99999.0F);
if (f != -99999.0F)
propMass = f;
propI = propMass * propDiameter * propDiameter * 0.083F;
bWepRpmInLowGear = false;
i = sectfile.get(string, "PropAnglerType", -99999);
if (i != -99999) {
if (i > 255) {
bWepRpmInLowGear = (i & 0x100) > 1;
i -= 256;
}
propAngleDeviceType = i;
}
f = sectfile.get(string, "PropAnglerSpeed", -99999.0F);
if (f != -99999.0F)
propAngleChangeSpeed = f;
f = sectfile.get(string, "PropAnglerMinParam", -99999.0F);
if (f != -99999.0F) {
propAngleDeviceMinParam = f;
if (propAngleDeviceType == 6 || propAngleDeviceType == 5)
propAngleDeviceMinParam
= (float) Math.toRadians((double) propAngleDeviceMinParam);
if (propAngleDeviceType == 1 || propAngleDeviceType == 2
|| propAngleDeviceType == 7 || propAngleDeviceType == 8
|| propAngleDeviceType == 9)
propAngleDeviceMinParam
= toRadianPerSecond(propAngleDeviceMinParam);
}
f = sectfile.get(string, "PropAnglerMaxParam", -99999.0F);
if (f != -99999.0F) {
propAngleDeviceMaxParam = f;
if (propAngleDeviceType == 6 || propAngleDeviceType == 5)
propAngleDeviceMaxParam
= (float) Math.toRadians((double) propAngleDeviceMaxParam);
if (propAngleDeviceType == 1 || propAngleDeviceType == 2
|| propAngleDeviceType == 7 || propAngleDeviceType == 8
|| propAngleDeviceType == 9)
propAngleDeviceMaxParam
= toRadianPerSecond(propAngleDeviceMaxParam);
if (propAngleDeviceAfterburnerParam == -999.9F)
propAngleDeviceAfterburnerParam = propAngleDeviceMaxParam;
}
f = sectfile.get(string, "PropAnglerAfterburnerParam", -99999.0F);
if (f != -99999.0F) {
propAngleDeviceAfterburnerParam = f;
wWEP = toRadianPerSecond(propAngleDeviceAfterburnerParam);
if (wWEP != wMax)
afterburnerChangeW = true;
if (propAngleDeviceType == 6 || propAngleDeviceType == 5)
propAngleDeviceAfterburnerParam
= (float) (Math.toRadians
((double) propAngleDeviceAfterburnerParam));
if (propAngleDeviceType == 1 || propAngleDeviceType == 2
|| propAngleDeviceType == 7 || propAngleDeviceType == 8
|| propAngleDeviceType == 9)
propAngleDeviceAfterburnerParam
= toRadianPerSecond(propAngleDeviceAfterburnerParam);
} else
wWEP = wMax;
f = sectfile.get(string, "PropPhiMin", -99999.0F);
if (f != -99999.0F) {
propPhiMin = (float) Math.toRadians((double) f);
if (propPhi < propPhiMin)
propPhi = propPhiMin;
if (propTarget < propPhiMin)
propTarget = propPhiMin;
}
f = sectfile.get(string, "PropPhiMax", -99999.0F);
if (f != -99999.0F) {
propPhiMax = (float) Math.toRadians((double) f);
if (propPhi > propPhiMax)
propPhi = propPhiMax;
if (propTarget > propPhiMax)
propTarget = propPhiMax;
}
f = sectfile.get(string, "PropAoA0", -99999.0F);
if (f != -99999.0F)
propAoA0 = (float) Math.toRadians((double) f);
i = sectfile.get(string, "CompressorType", -99999);
if (i != -99999)
compressorType = i;
f = sectfile.get(string, "CompressorPMax", -99999.0F);
if (f != -99999.0F)
compressorPMax = f;
i = sectfile.get(string, "CompressorSteps", -99999);
if (i != -99999) {
compressorMaxStep = i - 1;
if (compressorMaxStep < 0)
compressorMaxStep = 0;
}
if (compressorAltitudes != null
&& compressorAltitudes.length == compressorMaxStep + 1) {
/* empty */
}
compressorAltitudes = new float[compressorMaxStep + 1];
compressorPressure = new float[compressorMaxStep + 1];
compressorAltMultipliers = new float[compressorMaxStep + 1];
if (compressorAltitudes.length > 0) {
for (int i_2_ = 0; i_2_ < compressorAltitudes.length; i_2_++) {
f = sectfile.get(string, "CompressorAltitude" + i_2_,
-99999.0F);
if (f != -99999.0F) {
compressorAltitudes[i_2_] = f;
compressorPressure[i_2_]
= (Atmosphere.pressure(compressorAltitudes[i_2_])
* _1_P0);
}
f = sectfile.get(string, "CompressorMultiplier" + i_2_,
-99999.0F);
if (f != -99999.0F)
compressorAltMultipliers[i_2_] = f;
}
}
f = sectfile.get(string, "CompressorRPMP0", -99999.0F);
if (f != -99999.0F) {
compressorRPMtoP0 = f;
insetrPoiInCompressorPoly(compressorRPMtoP0, 1.0F);
}
f = sectfile.get(string, "CompressorRPMCurvature", -99999.0F);
if (f != -99999.0F)
compressorRPMtoCurvature = f;
f = sectfile.get(string, "CompressorMaxATARPM", -99999.0F);
if (f != -99999.0F) {
compressorRPMtoWMaxATA = f;
insetrPoiInCompressorPoly(RPMMax, compressorRPMtoWMaxATA);
}
f = sectfile.get(string, "CompressorRPMPMax", -99999.0F);
if (f != -99999.0F) {
compressorRPMtoPMax = f;
insetrPoiInCompressorPoly(compressorRPMtoPMax, compressorPMax);
}
f = sectfile.get(string, "CompressorSpeedManifold", -99999.0F);
if (f != -99999.0F)
compressorSpeedManifold = f;
f = sectfile.get(string, "CompressorPAt0", -99999.0F);
if (f != -99999.0F)
compressorPAt0 = f;
f = sectfile.get(string, "Voptimal", -99999.0F);
if (f != -99999.0F)
Vopt = f * 0.277778F;
boolean bool = true;
float f_3_ = 2000.0F;
float f_4_ = 1.0F;
int i_5_ = 0;
while (bool) {
f = sectfile.get(string, "CompressorRPM" + i_5_, -99999.0F);
if (f != -99999.0F)
f_3_ = f;
else
bool = false;
f = sectfile.get(string, "CompressorATA" + i_5_, -99999.0F);
if (f != -99999.0F)
f_4_ = f;
else
bool = false;
if (bool)
insetrPoiInCompressorPoly(f_3_, f_4_);
i_5_++;
if (nOfCompPoints > 15 || i_5_ > 15)
bool = false;
}
i = sectfile.get(string, "AfterburnerType", -99999);
if (i != -99999)
afterburnerType = i;
i = sectfile.get(string, "MixerType", -99999);
if (i != -99999)
mixerType = i;
f = sectfile.get(string, "MixerAltitude", -99999.0F);
if (f != -99999.0F)
mixerLowPressureBar = Atmosphere.pressure(f) / Atmosphere.P0();
f = sectfile.get(string, "EngineI", -99999.0F);
if (f != -99999.0F)
engineI = f;
f = sectfile.get(string, "EngineAcceleration", -99999.0F);
if (f != -99999.0F)
engineAcceleration = f;
f = sectfile.get(string, "DisP0x", -99999.0F);
if (f != -99999.0F) {
float f_6_ = sectfile.get(string, "DisP0x", -99999.0F);
f_6_ = toRadianPerSecond(f_6_);
float f_7_ = sectfile.get(string, "DisP0y", -99999.0F);
f_7_ *= 0.01F;
float f_8_ = sectfile.get(string, "DisP1x", -99999.0F);
f_8_ = toRadianPerSecond(f_8_);
float f_9_ = sectfile.get(string, "DisP1y", -99999.0F);
f_9_ *= 0.01F;
float f_10_ = f_6_;
float f_11_ = f_7_;
float f_12_ = (f_8_ - f_6_) * (f_8_ - f_6_);
float f_13_ = f_9_ - f_7_;
engineDistAM = f_13_ / f_12_;
engineDistBM = -2.0F * f_13_ * f_10_ / f_12_;
engineDistCM = f_11_ + f_13_ * f_10_ * f_10_ / f_12_;
}
timeCounter = 0.0F;
f = sectfile.get(string, "TESPEED", -99999.0F);
if (f != -99999.0F)
tChangeSpeed = f;
f = sectfile.get(string, "TWATERMAXRPM", -99999.0F);
if (f != -99999.0F)
tWaterMaxRPM = f;
f = sectfile.get(string, "TOILINMAXRPM", -99999.0F);
if (f != -99999.0F)
tOilInMaxRPM = f;
f = sectfile.get(string, "TOILOUTMAXRPM", -99999.0F);
if (f != -99999.0F)
tOilOutMaxRPM = f;
f = sectfile.get(string, "MAXRPMTIME", -99999.0F);
if (f != -99999.0F)
timeOverheat = f;
f = sectfile.get(string, "MINRPMTIME", -99999.0F);
if (f != -99999.0F)
timeUnderheat = f;
f = sectfile.get(string, "TWATERMAX", -99999.0F);
if (f != -99999.0F)
tWaterCritMax = f;
f = sectfile.get(string, "TWATERMIN", -99999.0F);
if (f != -99999.0F)
tWaterCritMin = f;
f = sectfile.get(string, "TOILMAX", -99999.0F);
if (f != -99999.0F)
tOilCritMax = f;
f = sectfile.get(string, "TOILMIN", -99999.0F);
if (f != -99999.0F)
tOilCritMin = f;
coolMult = 1.0F;
}
private void initializeInline(float f) {
propSEquivalent = 0.26F * propr * propr;
engineMomentMax = horsePowers * 746.0F * 1.2F / wMax;
}
private void initializeJet(float f) {
propSEquivalent = ((float) (cylinders * cylinders) * (2.0F * thrustMax)
/ (getFanCy(propAoA0) * Atmosphere.ro0() * wMax
* wMax * propr * propr));
computePropForces(wMax, 0.0F, 0.0F, propAoA0, 0.0F);
engineMomentMax = propMoment;
}
public void initializeTowString(float f) {
propForce = f;
}
public void setMaster(boolean bool) {
bIsMaster = bool;
}
private void insetrPoiInCompressorPoly(float f, float f_14_) {
int i;
for (i = 0; i < nOfCompPoints; i++) {
if (!(compressorRPM[i] < f)) {
if (compressorRPM[i] != f)
break;
return;
}
}
for (int i_15_ = nOfCompPoints - 1; i_15_ >= i; i_15_--) {
compressorRPM[i_15_ + 1] = compressorRPM[i_15_];
compressorATA[i_15_ + 1] = compressorATA[i_15_];
}
nOfCompPoints++;
compressorRPM[i] = f;
compressorATA[i] = f_14_;
}
private void calcAfterburnerCompressorFactor() {
if (afterburnerType == 1 || afterburnerType == 7
|| afterburnerType == 8 || afterburnerType == 10
|| afterburnerType == 11 || afterburnerType == 6
|| afterburnerType == 5 || afterburnerType == 9
|| afterburnerType == 4) {
float f = compressorRPM[nOfCompPoints - 1];
float f_16_ = compressorATA[nOfCompPoints - 1];
nOfCompPoints--;
int i = 0;
int i_17_ = 1;
float f_18_ = 1.0F;
float f_19_ = f;
if (nOfCompPoints < 2)
afterburnerCompressorFactor = 1.0F;
else {
if ((double) f_19_ < 0.1)
f_18_
= Atmosphere.pressure((float) reference.Loc.z) * _1_P0;
else if (f_19_ >= compressorRPM[nOfCompPoints - 1])
f_18_ = compressorATA[nOfCompPoints - 1];
else {
if (f_19_ < compressorRPM[0]) {
i = 0;
i_17_ = 1;
} else {
for (int i_20_ = 0; i_20_ < nOfCompPoints - 1;
i_20_++) {
if (compressorRPM[i_20_] <= f_19_
&& f_19_ < compressorRPM[i_20_ + 1]) {
i = i_20_;
i_17_ = i_20_ + 1;
break;
}
}
}
float f_21_ = compressorRPM[i_17_] - compressorRPM[i];
if (f_21_ < 0.001F)
f_21_ = 0.001F;
f_18_ = compressorATA[i] + ((f_19_ - compressorRPM[i])
* (compressorATA[i_17_]
- compressorATA[i])
/ f_21_);
}
afterburnerCompressorFactor = f_16_ / f_18_;
}
} else
afterburnerCompressorFactor = 1.0F;
}
public float getATA(float f) {
int i = 0;
int i_22_ = 1;
float f_23_ = 1.0F;
if (nOfCompPoints < 2)
return 1.0F;
if ((double) f < 0.1)
f_23_ = Atmosphere.pressure((float) reference.Loc.z) * _1_P0;
else if (f >= compressorRPM[nOfCompPoints - 1])
f_23_ = compressorATA[nOfCompPoints - 1];
else {
if (f < compressorRPM[0]) {
i = 0;
i_22_ = 1;
} else {
for (int i_24_ = 0; i_24_ < nOfCompPoints - 1; i_24_++) {
if (compressorRPM[i_24_] <= f
&& f < compressorRPM[i_24_ + 1]) {
i = i_24_;
i_22_ = i_24_ + 1;
break;
}
}
}
float f_25_ = compressorRPM[i_22_] - compressorRPM[i];
if (f_25_ < 0.001F)
f_25_ = 0.001F;
f_23_ = (compressorATA[i]
+ ((f - compressorRPM[i])
* (compressorATA[i_22_] - compressorATA[i]) / f_25_));
}
return f_23_;
}
public void update(float f) {
if (!(reference instanceof RealFlightModel)
&& Time.tickCounter() > 200) {
updateLast += f;
if (updateLast >= updateStep)
f = updateStep;
else {
engineForce.set(old_engineForce);
engineTorque.set(old_engineTorque);
return;
}
}
producedDistabilisation = 0.0F;
pressureExtBar = (Atmosphere.pressure(reference.getAltitude())
+ (compressorSpeedManifold * 0.5F
* Atmosphere.density(reference.getAltitude())
* reference.getSpeed() * reference.getSpeed()));
pressureExtBar /= Atmosphere.P0();
if (controlThrottle > 1.0F && engineBoostFactor == 1.0F) {
reference.CT.setPowerControl(1.0F);
if (reference.isPlayers() && reference instanceof RealFlightModel
&& ((RealFlightModel) reference).isRealMode())
HUD.log(AircraftHotKeys.hudLogPowerId, "Power",
new Object[] { new Integer(100) });
}
computeForces(f);
computeStage(f);
if (stage > 0 && stage < 6)
engineForce.set(0.0F, 0.0F, 0.0F);
else if (stage ==
rpm = w = 0.0F;
if (reference.isPlayers()) {
if (bIsMaster && reference instanceof RealFlightModel
&& ((RealFlightModel) reference).isRealMode()) {
computeTemperature(f);
if (World.cur().diffCur.Reliability)
computeReliability(f);
}
if (World.cur().diffCur.Limited_Fuel)
computeFuel(f);
} else
computeFuel(f);
old_engineForce.set(engineForce);
old_engineTorque.set(engineTorque);
updateLast = 0.0F;
float f_26_ = 0.5F / (Math.abs(aw) + 1.0F) - 0.1F;
if (f_26_ < 0.025F)
f_26_ = 0.025F;
if (f_26_ > 0.4F)
f_26_ = 0.4F;
if (f_26_ < updateStep)
updateStep = 0.9F * updateStep + 0.1F * f_26_;
else
updateStep = 0.99F * updateStep + 0.01F * f_26_;
}
public void netupdate(float f, boolean bool) {
computeStage(f);
if ((double) Math.abs(w) < 1.0E-5)
propPhiW = 1.5707964F;
else
propPhiW
= (float) Math.atan(reference.Vflow.x
/ (double) (w * propReductor * propr));
propAoA = propPhi - propPhiW;
computePropForces(w * propReductor, (float) reference.Vflow.x, propPhi,
propAoA, reference.getAltitude());
float f_27_ = w;
float f_28_ = propPhi;
float f_29_ = compressorManifoldPressure;
computeForces(f);
if (bool)
compressorManifoldPressure = f_29_;
w = f_27_;
propPhi = f_28_;
rpm = toRPM(w);
}
public void setReadyness(Actor actor, float f) {
if (f > 1.0F)
f = 1.0F;
if (f < 0.0F)
f = 0.0F;
if (Actor.isAlive(actor)) {
if (bIsMaster) {
if (readyness > 0.0F && f == 0.0F) {
readyness = 0.0F;
setEngineDies(actor);
return;
}
doSetReadyness(f);
}
if (Math.abs(oldReadyness - readyness) > 0.1F) {
reference.AS.setEngineReadyness(actor, number,
(int) (f * 100.0F));
oldReadyness = readyness;
}
}
}
private void setReadyness(float f) {
setReadyness(reference.actor, f);
}
public void doSetReadyness(float f) {
readyness = f;
}
public void setStage(Actor actor, int i) {
if (Actor.isAlive(actor)) {
if (bIsMaster)
doSetStage(i);
reference.AS.setEngineStage(actor, number, i);
}
}
public void doSetStage(int i) {
stage = i;
}
public void setEngineStarts(Actor actor) {
if (bIsMaster && Actor.isAlive(actor)
&& (!isHasControlMagnetos() || !(getMagnetoMultiplier() < 0.1F)))
reference.AS.setEngineStarts(number);
}
public void doSetEngineStarts() {
if (Airport.distToNearestAirport(reference.Loc) < 1200.0
&& reference.isStationedOnGround()) {
reference.CT.setMagnetoControl(3);
setControlMagneto(3);
stage = 1;
bRan = false;
timer = Time.current();
} else if (stage == 0) {
reference.CT.setMagnetoControl(3);
setControlMagneto(3);
stage = 1;
timer = Time.current();
}
}
public void setEngineStops(Actor actor) {
if (Actor.isAlive(actor) && (stage >= 1 && stage <= 6))
reference.AS.setEngineStops(number);
}
public void doSetEngineStops() {
if (stage != 0) {
stage = 0;
setControlMagneto(0);
timer = Time.current();
}
}
public void setEngineDies(Actor actor) {
if (stage <= 6)
reference.AS.setEngineDies(reference.actor, number);
}
public void doSetEngineDies() {
if (stage < 7) {
bIsInoperable = true;
reference.setCapableOfTaxiing(false);
reference.setCapableOfACM(false);
doSetReadyness(0.0F);
float f = 0.0F;
int i = reference.EI.getNum();
if (i != 0) {
for (int i_30_ = 0; i_30_ < i; i_30_++)
f += (reference.EI.engines[i_30_].getReadyness()
/ (float) i);
if (f < 0.7F)
reference.setReadyToReturn(true);
if (f < 0.3F)
reference.setReadyToDie(true);
}
stage = 7;
if (reference.isPlayers())
HUD.log("FailedEngine");
timer = Time.current();
}
}
public void setEngineRunning(Actor actor) {
if (bIsMaster && Actor.isAlive(actor))
reference.AS.setEngineRunning(number);
}
public void doSetEngineRunning() {
if (stage < 6) {
stage = 6;
reference.CT.setMagnetoControl(3);
setControlMagneto(3);
if (reference.isPlayers())
HUD.log("EngineI1");
w = wMax * 0.75F;
tWaterOut = 0.5F * (tWaterCritMin + tWaterMaxRPM);
tOilOut = 0.5F * (tOilCritMin + tOilOutMaxRPM);
tOilIn = 0.5F * (tOilCritMin + tOilInMaxRPM);
propPhi = 0.5F * (propPhiMin + propPhiMax);
propTarget = propPhi;
if (isnd != null)
isnd.onEngineState(stage);
}
}
public void setKillCompressor(Actor actor) {
reference.AS.setEngineSpecificDamage(actor, number, 0);
}
public void doSetKillCompressor() {
switch (compressorType) {
case 2:
compressorAltitudes[0] = 50.0F;
compressorAltMultipliers[0] = 1.0F;
break;
case 1:
for (int i = 0; i < compressorMaxStep; i++) {
compressorAltitudes[i] = 50.0F;
compressorAltMultipliers[i] = 1.0F;
}
break;
}
}
public void setKillPropAngleDevice(Actor actor) {
reference.AS.setEngineSpecificDamage(actor, number, 3);
}
public void doSetKillPropAngleDevice() {
bIsAngleDeviceOperational = false;
}
public void setKillPropAngleDeviceSpeeds(Actor actor) {
reference.AS.setEngineSpecificDamage(actor, number, 4);
}
public void doSetKillPropAngleDeviceSpeeds() {
isPropAngleDeviceHydroOperable = false;
}
public void setCyliderKnockOut(Actor actor, int i) {
reference.AS.setEngineCylinderKnockOut(actor, number, i);
}
public void doSetCyliderKnockOut(int i) {
cylindersOperable -= i;
if (cylindersOperable < 0)
cylindersOperable = 0;
if (bIsMaster) {
if (getCylindersRatio() < 0.12F)
setEngineDies(reference.actor);
else if (getCylindersRatio() < getReadyness())
setReadyness(reference.actor, getCylindersRatio());
}
}
public void setMagnetoKnockOut(Actor actor, int i) {
reference.AS.setEngineMagnetoKnockOut(reference.actor, number, i);
}
public void doSetMagnetoKnockOut(int i) {
bMagnetos[i] = false;
if (i == controlMagneto)
setEngineStops(reference.actor);
}
public void setEngineStuck(Actor actor) {
reference.AS.setEngineStuck(actor, number);
}
public void doSetEngineStuck() {
bIsInoperable = true;
reference.setCapableOfTaxiing(false);
reference.setCapableOfACM(false);
if (stage !=
{
setReadyness(0.0F);
if (reference.isPlayers() && stage != 7)
HUD.log("FailedEngine");
stage = 8;
timer = Time.current();
}
}
public void setw(float f) {
w = f;
rpm = toRPM(w);
}
public void setPropPhi(float f) {
propPhi = f;
}
public void setEngineMomentMax(float f) {
engineMomentMax = f;
}
public void setPos(Point3d point3d) {
enginePos.set(point3d);
}
public void setPropPos(Point3d point3d) {
propPos.set(point3d);
}
public void setVector(Vector3f vector3f) {
engineVector.set(vector3f);
engineVector.normalize();
}
public void setControlThrottle(float f) {
if (bHasThrottleControl) {
if (afterburnerType == 4) {
if (f > 1.0F && controlThrottle <= 1.0F
&& reference.M.requestNitro(1.0E-4F)) {
reference.CT.setAfterburnerControl(true);
setControlAfterburner(true);
if (reference.isPlayers()) {
Main3D.cur3D().aircraftHotKeys
.setAfterburnerForAutoActivation(true);
HUD.logRightBottom("BoostWepTP4");
}
}
if (f < 1.0F && controlThrottle >= 1.0F) {
reference.CT.setAfterburnerControl(false);
setControlAfterburner(false);
if (reference.isPlayers()) {
Main3D.cur3D().aircraftHotKeys
.setAfterburnerForAutoActivation(false);
HUD.logRightBottom(null);
}
}
} else if (afterburnerType ==
{
if (f > 1.0F && controlThrottle <= 1.0F) {
reference.CT.setAfterburnerControl(true);
setControlAfterburner(true);
if (reference.isPlayers()) {
Main3D.cur3D().aircraftHotKeys
.setAfterburnerForAutoActivation(true);
HUD.logRightBottom("BoostWepTP7");
}
}
if (f < 1.0F && controlThrottle >= 1.0F) {
reference.CT.setAfterburnerControl(false);
setControlAfterburner(false);
if (reference.isPlayers()) {
Main3D.cur3D().aircraftHotKeys
.setAfterburnerForAutoActivation(false);
HUD.logRightBottom(null);
}
}
} else if (afterburnerType == 10) {
if (f > 1.0F && controlThrottle <= 1.0F) {
reference.CT.setAfterburnerControl(true);
setControlAfterburner(true);
if (reference.isPlayers()) {
Main3D.cur3D().aircraftHotKeys
.setAfterburnerForAutoActivation(true);
HUD.logRightBottom("BoostWepTP0");
}
}
if (f < 1.0F && controlThrottle >= 1.0F) {
reference.CT.setAfterburnerControl(false);
setControlAfterburner(false);
if (reference.isPlayers()) {
Main3D.cur3D().aircraftHotKeys
.setAfterburnerForAutoActivation(false);
HUD.logRightBottom(null);
}
}
}
controlThrottle = f;
}
}
public void setControlAfterburner(boolean bool) {
if (bHasAfterburnerControl) {
if (afterburnerType == 1 && !controlAfterburner && bool
&& controlThrottle > 1.0F && World.Rnd().nextFloat() < 0.5F
&& reference.isPlayers()
&& reference instanceof RealFlightModel
&& ((RealFlightModel) reference).isRealMode()
&& World.cur().diffCur.Vulnerability)
setCyliderKnockOut(reference.actor, World.Rnd().nextInt(0, 3));
controlAfterburner = bool;
}
if (afterburnerType == 4 || afterburnerType == 8
|| afterburnerType == 10)
controlAfterburner = bool;
}
public void doSetKillControlThrottle() {
bHasThrottleControl = false;
}
public void setControlPropDelta(int i) {
controlPropDirection = i;
}
public int getControlPropDelta() {
return controlPropDirection;
}
public void doSetKillControlAfterburner() {
bHasAfterburnerControl = false;
}
public void setControlProp(float f) {
if (bHasPropControl)
controlProp = f;
}
public void setControlPropAuto(boolean bool) {
if (bHasPropControl)
bControlPropAuto = bool && isAllowsAutoProp();
}
public void doSetKillControlProp() {
bHasPropControl = false;
}
public void setControlMix(float f) {
if (bHasMixControl) {
switch (mixerType) {
case 0:
controlMix = f;
break;
case 1:
controlMix = f;
if (controlMix < 1.0F)
controlMix = 1.0F;
break;
default:
controlMix = f;
}
}
}
public void doSetKillControlMix() {
bHasMixControl = false;
}
public void setControlMagneto(int i) {
if (bHasMagnetoControl) {
controlMagneto = i;
if (i == 0)
setEngineStops(reference.actor);
}
}
public void setControlCompressor(int i) {
if (bHasCompressorControl)
controlCompressor = i;
}
public void setControlFeather(int i) {
if (bHasFeatherControl) {
controlFeather = i;
if (reference.isPlayers())
HUD.log("EngineFeather" + controlFeather);
}
}
public void setControlRadiator(float f) {
if (bHasRadiatorControl)
controlRadiator = f;
}
public void setExtinguisherFire() {
if (bIsMaster) {
if (bHasExtinguisherControl) {
reference.AS.setEngineSpecificDamage(reference.actor, number,
5);
if (reference.AS.astateEngineStates[number] > 2)
reference.AS.setEngineState(reference.actor, number,
World.Rnd().nextInt(1, 2));
else if (reference.AS.astateEngineStates[number] > 0)
reference.AS.setEngineState(reference.actor, number, 0);
}
}
}
public void doSetExtinguisherFire() {
if (bHasExtinguisherControl) {
extinguishers--;
if (extinguishers == 0)
bHasExtinguisherControl = false;
reference.AS.doSetEngineExtinguisherVisuals(number);
if (bIsMaster) {
if (reference.AS.astateEngineStates[number] > 1
&& World.Rnd().nextFloat() < 0.56F)
reference.AS.repairEngine(number);
if (reference.AS.astateEngineStates[number] > 3
&& World.Rnd().nextFloat() < 0.21F) {
reference.AS.repairEngine(number);
reference.AS.repairEngine(number);
}
tWaterOut -= 4.0F;
tOilIn -= 4.0F;
tOilOut -= 4.0F;
}
if (reference.isPlayers())
HUD.log("ExtinguishersFired");
}
}
private void computeStage(float f) {
if (stage != 6) {
bTFirst = false;
float f_31_ = 20.0F;
long l = Time.current() - timer;
if (stage > 0 && stage < 6 && l > given) {
stage++;
timer = Time.current();
l = 0L;
}
if (oldStage != stage) {
bTFirst = true;
oldStage = stage;
}
if (stage > 0 && stage < 6)
setControlThrottle(0.2F);
switch (stage) {
case 0:
if (bTFirst) {
given = 4611686018427387903L;
timer = Time.current();
}
if (isnd != null)
isnd.onEngineState(stage);
break;
case 1:
if (bTFirst) {
if (bIsStuck) {
stage = 8;
break;
}
if (type == 3 || type == 4 || type == 6) {
stage = 5;
if (reference.isPlayers())
HUD.log("Starting_Engine");
break;
}
if (type == 0 || type == 1 || type == 7) {
if (w > wMin) {
stage = 3;
if (reference.isPlayers())
HUD.log("Starting_Engine");
break;
}
if (!bIsAutonomous) {
if ((Airport.distToNearestAirport(reference.Loc)
< 1200.0)
&& reference.isStationedOnGround()) {
setControlMagneto(3);
if (reference.isPlayers())
HUD.log("Starting_Engine");
} else {
doSetEngineStops();
if (reference.isPlayers())
HUD.log("EngineI0");
break;
}
} else if (reference.isPlayers())
HUD.log("Starting_Engine");
} else if (!bIsAutonomous) {
if ((Airport.distToNearestAirport(reference.Loc)
< 1200.0)
&& reference.isStationedOnGround()) {
setControlMagneto(3);
if (reference.isPlayers())
HUD.log("Starting_Engine");
} else {
if (reference.getSpeedKMH() < 350.0F) {
doSetEngineStops();
if (reference.isPlayers())
HUD.log("EngineI0");
break;
}
if (reference.isPlayers())
HUD.log("Starting_Engine");
}
} else if (reference.isPlayers())
HUD.log("Starting_Engine");
given
= (long) (500.0F * World.Rnd().nextFloat(1.0F, 2.0F));
}
if (isnd != null)
isnd.onEngineState(stage);
reference.CT.setMagnetoControl(3);
setControlMagneto(3);
w = 0.1047F * (20.0F * (float) l / (float) given);
setControlThrottle(0.0F);
break;
case 2:
if (bTFirst) {
given
= (long) (4000.0F * World.Rnd().nextFloat(1.0F, 2.0F));
if (bRan) {
given
= (long) (100.0F
+ ((tOilOutMaxRPM - tOilOut)
/ (tOilOutMaxRPM - f_31_) * 7900.0F
* World.Rnd().nextFloat(2.0F, 4.2F)));
if (given > 9000L)
given = World.Rnd().nextLong(7800L, 9600L);
if (bIsMaster && World.Rnd().nextFloat() < 0.5F) {
stage = 0;
reference.AS.setEngineStops(number);
}
}
}
w = 0.1047F * (20.0F + 15.0F * (float) l / (float) given);
setControlThrottle(0.0F);
if (isnd != null)
isnd.onEngineState(stage);
break;
case 3:
if (bTFirst) {
if (isnd != null)
isnd.onEngineState(stage);
if (bIsInoperable) {
stage = 0;
doSetEngineDies();
break;
}
given = (long) (50.0F * World.Rnd().nextFloat(1.0F, 2.0F));
if (bIsMaster && World.Rnd().nextFloat() < 0.12F
&& ((tOilOutMaxRPM - tOilOut) / (tOilOutMaxRPM - f_31_)
< 0.75F))
reference.AS.setEngineStops(number);
}
w = 0.1047F * (60.0F + 60.0F * (float) l / (float) given);
setControlThrottle(0.0F);
if (reference != null && type != 2 && type != 3 && type != 4
&& type != 6 && type != 5) {
for (int i = 1; i < 32; i++) {
try {
Hook hook
= reference.actor.findHook("_Engine"
+ (number + 1)
+ "EF_"
+ (i < 10 ? "0" + i
: "" + i));
if (hook != null)
Eff3DActor.New
(reference.actor, hook, null, 1.0F,
("3DO/Effects/Aircraft/EngineStart"
+ World.Rnd().nextInt(1, 3) + ".eff"),
-1.0F);
} catch (Exception exception) {
/* empty */
}
}
}
break;
case 4:
if (bTFirst)
given
= (long) (500.0F * World.Rnd().nextFloat(1.0F, 2.0F));
w = 12.564F;
setControlThrottle(0.0F);
if (isnd != null)
isnd.onEngineState(stage);
break;
case 5:
if (bTFirst) {
given
= (long) (500.0F * World.Rnd().nextFloat(1.0F, 2.0F));
if (bRan && (type == 0 || type == 1 || type == 7)) {
if ((tOilOutMaxRPM - tOilOut) / (tOilOutMaxRPM - f_31_)
> 0.75F) {
if (type == 0 || type == 7) {
if (bIsMaster && getReadyness() > 0.75F
&& World.Rnd().nextFloat() < 0.25F)
setReadyness(getReadyness() - 0.05F);
} else if (type == 1 && bIsMaster
&& World.Rnd().nextFloat() < 0.1F)
reference.AS.setEngineDies(reference.actor,
number);
}
if (bIsMaster && World.Rnd().nextFloat() < 0.1F)
reference.AS.setEngineStops(number);
}
bRan = true;
}
w = 0.1047F * (120.0F + 120.0F * (float) l / (float) given);
setControlThrottle(0.2F);
if (isnd != null)
isnd.onEngineState(stage);
break;
case 6:
if (bTFirst) {
given = -1L;
reference.AS.setEngineRunning(number);
}
if (isnd != null)
isnd.onEngineState(stage);
break;
case 7:
case 8:
if (bTFirst)
given = -1L;
setReadyness(0.0F);
setControlMagneto(0);
if (isnd != null)
isnd.onEngineState(stage);
break;
}
}
}
private void computeFuel(float f) {
tmpF = 0.0F;
float f_32_ = w * _1_wMax;
if (stage == 6) {
double d;
float f_33_;
switch (type) {
case 0:
case 1:
case 7:
d = momForFuel * (double) w * 0.00105;
f_33_ = (float) d / horsePowers;
if (d < (double) horsePowers * 0.05)
d = (double) horsePowers * 0.05;
break;
default:
d = (double) (thrustMax * (f_33_ = getPowerOutput()));
if (d < (double) thrustMax * 0.05)
d = (double) thrustMax * 0.05;
}
if (f_33_ < 0.0F)
f_33_ = 0.0F;
double d_34_;
if (f_33_ <= 0.5F)
d_34_ = ((double) FuelConsumptionP0
+ ((double) (FuelConsumptionP05 - FuelConsumptionP0)
* (2.0 * (double) f_33_)));
else if ((double) f_33_ <= 1.0)
d_34_ = ((double) FuelConsumptionP05
+ ((double) (FuelConsumptionP1 - FuelConsumptionP05)
* (2.0 * ((double) f_33_ - 0.5))));
else {
float f_35_ = f_33_ - 1.0F;
if (f_35_ > 0.1F)
f_35_ = 0.1F;
f_35_ *= 10.0F;
d_34_ = (double) (FuelConsumptionP1
+ ((FuelConsumptionPMAX - FuelConsumptionP1)
* f_35_));
}
d_34_ /= 3600.0;
switch (type) {
case 0:
case 1:
case 7: {
float f_36_ = (float) (d_34_ * d);
tmpF = f_36_ * f;
double d_37_ = (double) (f_36_ * 4.4E7F);
double d_38_ = (double) (f_36_ * 15.7F);
double d_39_ = 1010.0 * d_38_ * 700.0;
d *= 746.0;
Ptermo = (float) (d_37_ - d - d_39_);
break;
}
case 2:
tmpF = (float) (d_34_ * d * (double) f);
break;
case 3:
if (reference.actor instanceof BI_1
|| reference.actor instanceof BI_6)
tmpF = 1.8F * getPowerOutput() * f;
else if (reference.actor instanceof MXY_7)
tmpF = 0.5F * getPowerOutput() * f;
else
tmpF = 2.5777F * getPowerOutput() * f;
break;
case 4:
tmpF = 1.4320556F * getPowerOutput() * f;
tmpB = reference.M.requestNitro(tmpF);
tmpF = 0.0F;
if (!tmpB && bIsMaster) {
setEngineStops(reference.actor);
if (reference.isPlayers() && engineNoFuelHUDLogId == -1) {
engineNoFuelHUDLogId = HUD.makeIdLog();
HUD.log(engineNoFuelHUDLogId, "EngineNoFuel");
}
} else
break;
return;
case 6:
tmpF = (float) (d_34_ * d * (double) f);
tmpB = reference.M.requestNitro(tmpF);
tmpF = 0.0F;
if (!tmpB && bIsMaster) {
setEngineStops(reference.actor);
if (reference.isPlayers() && engineNoFuelHUDLogId == -1) {
engineNoFuelHUDLogId = HUD.makeIdLog();
HUD.log(engineNoFuelHUDLogId, "EngineNoFuel");
}
} else
break;
return;
}
}
tmpB = reference.M.requestFuel(tmpF);
if (!tmpB && bIsMaster) {
setEngineStops(reference.actor);
reference.setCapableOfACM(false);
reference.setCapableOfTaxiing(false);
if (reference.isPlayers() && engineNoFuelHUDLogId == -1) {
engineNoFuelHUDLogId = HUD.makeIdLog();
HUD.log(engineNoFuelHUDLogId, "EngineNoFuel");
}
}
if (controlAfterburner) {
switch (afterburnerType) {
case 1:
if (controlThrottle > 1.0F
&& !reference.M.requestNitro(0.044872F * f)
&& reference.isPlayers()
&& reference instanceof RealFlightModel
&& ((RealFlightModel) reference).isRealMode()
&& World.cur().diffCur.Vulnerability)
setReadyness(reference.actor, getReadyness() - 0.01F * f);
break;
case 2:
if (!reference.M.requestNitro(0.044872F * f)) {
/* empty */
}
break;
case 5:
if (!reference.M.requestNitro(0.044872F * f)) {
/* empty */
}
break;
case 9:
if (!reference.M.requestNitro(0.044872F * f)) {
/* empty */
}
break;
case 4:
if (!reference.M.requestNitro(0.044872F * f)) {
reference.CT.setAfterburnerControl(false);
if (reference.isPlayers()) {
Main3D.cur3D().aircraftHotKeys
.setAfterburnerForAutoActivation(false);
HUD.logRightBottom(null);
}
}
break;
}
}
}
private void computeReliability(float f) {
if (stage == 6) {
float f_40_ = controlThrottle;
if (engineBoostFactor > 1.0F)
f_40_ *= 0.9090909F;
switch (type) {
default:
zatizeni = (double) f_40_;
zatizeni = zatizeni * zatizeni;
zatizeni = zatizeni * zatizeni;
zatizeni *= (double) f * 6.19842621786999E-5;
if (zatizeni > World.Rnd().nextDouble(0.0, 1.0)) {
int i = World.Rnd().nextInt(0, 9);
if (i < 2) {
reference.AS.hitEngine(reference.actor, number, 3);
Aircraft.debugprintln(reference.actor,
("Malfunction #" + number
+ " - smoke"));
} else {
setCyliderKnockOut(reference.actor,
World.Rnd().nextInt(0, 3));
Aircraft.debugprintln(reference.actor,
("Malfunction #" + number
+ " - power loss"));
}
}
break;
case 0:
case 1:
case 7: {
zatizeni = (double) (coolMult * f_40_);
zatizeni *= (double) (w / wWEP);
zatizeni = zatizeni * zatizeni;
zatizeni = zatizeni * zatizeni;
double d = zatizeni * (double) f * 1.4248134284734321E-5;
if (d > World.Rnd().nextDouble(0.0, 1.0)) {
int i = World.Rnd().nextInt(0, 19);
if (i < 10) {
reference.AS.setEngineCylinderKnockOut(reference.actor,
number, 1);
Aircraft.debugprintln(reference.actor,
("Malfunction #" + number
+ " - cylinder"));
} else if (i < 12) {
if (i < 11) {
reference.AS.setEngineMagnetoKnockOut((reference
.actor),
number, 0);
Aircraft.debugprintln(reference.actor,
("Malfunction #" + number
+ " - mag1"));
} else {
reference.AS.setEngineMagnetoKnockOut((reference
.actor),
number, 1);
Aircraft.debugprintln(reference.actor,
("Malfunction #" + number
+ " - mag2"));
}
} else if (i < 14) {
reference.AS.setEngineDies(reference.actor, number);
Aircraft.debugprintln(reference.actor,
("Malfunction #" + number
+ " - dead"));
} else if (i < 15) {
reference.AS.setEngineStuck(reference.actor, number);
Aircraft.debugprintln(reference.actor,
("Malfunction #" + number
+ " - stuck"));
} else if (i < 17) {
setKillPropAngleDevice(reference.actor);
Aircraft.debugprintln(reference.actor,
("Malfunction #" + number
+ " - propAngler"));
} else {
reference.AS.hitOil(reference.actor, number);
Aircraft.debugprintln(reference.actor,
("Malfunction #" + number
+ " - oil"));
}
}
}
}
}
}