Skip to content

Commit

Permalink
Inline out variable declaration
Browse files Browse the repository at this point in the history
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
  • Loading branch information
lamont-granquist committed Nov 1, 2023
1 parent dad84bf commit 088be36
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 41 deletions.
4 changes: 1 addition & 3 deletions MechJeb2/MechJebModuleAttitudeController.cs
Expand Up @@ -373,9 +373,7 @@ public override void Drive(FlightCtrlState s)
}
else
{
Vector3d act;
Vector3d deltaEuler;
Controller.DrivePre(s, out act, out deltaEuler);
Controller.DrivePre(s, out Vector3d act, out Vector3d deltaEuler);

act.Scale(ActuationControl);

Expand Down
9 changes: 3 additions & 6 deletions MechJeb2/MechJebModuleCustomInfoWindow.cs
Expand Up @@ -251,8 +251,7 @@ public override void OnLoad(ConfigNode local, ConfigNode type, ConfigNode global
bool useOldConfig = true;
if (windowNode.HasValue("enabledEditor"))
{
bool loadedEnabled;
if (bool.TryParse(windowNode.GetValue("enabledEditor"), out loadedEnabled))
if (bool.TryParse(windowNode.GetValue("enabledEditor"), out bool loadedEnabled))
{
window.EnabledEditor = loadedEnabled;
useOldConfig = false;
Expand All @@ -263,8 +262,7 @@ public override void OnLoad(ConfigNode local, ConfigNode type, ConfigNode global

if (windowNode.HasValue("enabledFlight"))
{
bool loadedEnabled;
if (bool.TryParse(windowNode.GetValue("enabledFlight"), out loadedEnabled))
if (bool.TryParse(windowNode.GetValue("enabledFlight"), out bool loadedEnabled))
{
window.EnabledFlight = loadedEnabled;
useOldConfig = false;
Expand All @@ -277,8 +275,7 @@ public override void OnLoad(ConfigNode local, ConfigNode type, ConfigNode global
{
if (windowNode.HasValue("enabled"))
{
bool loadedEnabled;
if (bool.TryParse(windowNode.GetValue("enabled"), out loadedEnabled))
if (bool.TryParse(windowNode.GetValue("enabled"), out bool loadedEnabled))
{
window.Enabled = loadedEnabled;
window.EnabledEditor = window.Enabled;
Expand Down
3 changes: 1 addition & 2 deletions MechJeb2/MechJebModuleDebugArrows.cs
Expand Up @@ -743,8 +743,7 @@ private static int getMiddlePoint(int p1, int p2, ref List<Vector3> vertices, re
long greaterIndex = firstIsSmaller ? p2 : p1;
long key = (smallerIndex << 32) + greaterIndex;

int ret;
if (cache.TryGetValue(key, out ret))
if (cache.TryGetValue(key, out int ret))
{
return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions MechJeb2/MechJebModuleRoverController.cs
Expand Up @@ -371,8 +371,8 @@ public override void

if (StabilityControl)
{
RaycastHit hit;
Physics.Raycast(Vessel.CoM + VesselState.surfaceVelocity * terrainLookAhead + VesselState.up * 100, -VesselState.up, out hit, 500,
Physics.Raycast(Vessel.CoM + VesselState.surfaceVelocity * terrainLookAhead + VesselState.up * 100, -VesselState.up,
out RaycastHit hit, 500,
1 << 15, QueryTriggerInteraction.Ignore);
Vector3 norm = hit.normal;

Expand Down
17 changes: 7 additions & 10 deletions MechJeb2/MechJebModuleSpaceplaneAutopilot.cs
Expand Up @@ -665,8 +665,7 @@ private void InitRunwaysList()
string runwayName = site.GetValue("name");
ConfigNode start = site.GetNode("start");
ConfigNode end = site.GetNode("end");
double touchdown = 0.0;
double.TryParse(site.GetValue("touchdown"), out touchdown);
double.TryParse(site.GetValue("touchdown"), out double touchdown);

if (runwayName == null || start == null || end == null)
continue;
Expand All @@ -678,10 +677,9 @@ private void InitRunwaysList()
if (lat == null || lon == null || alt == null)
continue;

double startLatitude, startLongitude, startAltitude;
double.TryParse(lat, out startLatitude);
double.TryParse(lon, out startLongitude);
double.TryParse(alt, out startAltitude);
double.TryParse(lat, out double startLatitude);
double.TryParse(lon, out double startLongitude);
double.TryParse(alt, out double startAltitude);

lat = end.GetValue("latitude");
lon = end.GetValue("longitude");
Expand All @@ -690,10 +688,9 @@ private void InitRunwaysList()
if (lat == null || lon == null || alt == null)
continue;

double endLatitude, endLongitude, endAltitude;
double.TryParse(lat, out endLatitude);
double.TryParse(lon, out endLongitude);
double.TryParse(alt, out endAltitude);
double.TryParse(lat, out double endLatitude);
double.TryParse(lon, out double endLongitude);
double.TryParse(alt, out double endAltitude);

string bodyName = site.GetValue("body");
CelestialBody body = bodyName != null ? FlightGlobals.Bodies.Find(b => b.bodyName == bodyName) : Planetarium.fetch.Home;
Expand Down
24 changes: 6 additions & 18 deletions MechJeb2/VesselState.cs
Expand Up @@ -874,9 +874,7 @@ private void UpdateRCSThrustAndTorque(Vessel vessel)
{
Vector6.Direction dir6 = Vector6.Values[i];
Vector3d dir = Vector6.Directions[(int)dir6];
double[] throttles;
List<RCSSolver.Thruster> thrusters;
rcsbal.GetThrottles(dir, out throttles, out thrusters);
rcsbal.GetThrottles(dir, out double[] throttles, out List<RCSSolver.Thruster> thrusters);
if (throttles != null)
{
for (int j = 0; j < throttles.Length; j++)
Expand Down Expand Up @@ -1127,9 +1125,7 @@ private void AnalyzeParts(Vessel vessel, EngineInfo einfo, IntakeInfo iinfo)
var rw = pm as ModuleReactionWheel;
if (rw != null)
{
Vector3 pos;
Vector3 neg;
rw.GetPotentialTorque(out pos, out neg);
rw.GetPotentialTorque(out Vector3 pos, out Vector3 neg);

// GetPotentialTorque reports the same value for pos & neg on ModuleReactionWheel
torqueReactionWheel.Add(pos);
Expand Down Expand Up @@ -1163,10 +1159,7 @@ private void AnalyzeParts(Vessel vessel, EngineInfo einfo, IntakeInfo iinfo)
//if (p.ShieldedFromAirstream || cs.deploy)
// continue;

Vector3 ctrlTorquePos;
Vector3 ctrlTorqueNeg;

cs.GetPotentialTorque(out ctrlTorquePos, out ctrlTorqueNeg);
cs.GetPotentialTorque(out Vector3 ctrlTorquePos, out Vector3 ctrlTorqueNeg);

torqueControlSurface.Add(ctrlTorquePos);
torqueControlSurface.Add(ctrlTorqueNeg);
Expand All @@ -1190,9 +1183,7 @@ private void AnalyzeParts(Vessel vessel, EngineInfo einfo, IntakeInfo iinfo)
}
}

Vector3 pos;
Vector3 neg;
g.GetPotentialTorque(out pos, out neg);
g.GetPotentialTorque(out Vector3 pos, out Vector3 neg);

// GetPotentialTorque reports the same value for pos & neg on ModuleGimbal

Expand All @@ -1210,9 +1201,7 @@ private void AnalyzeParts(Vessel vessel, EngineInfo einfo, IntakeInfo iinfo)
{
var tp = pm as ITorqueProvider;

Vector3 pos;
Vector3 neg;
tp.GetPotentialTorque(out pos, out neg);
tp.GetPotentialTorque(out Vector3 pos, out Vector3 neg);

torqueOthers.Add(pos);
torqueOthers.Add(neg);
Expand Down Expand Up @@ -1295,9 +1284,8 @@ private void AnalyzeParts(Vessel vessel, EngineInfo einfo, IntakeInfo iinfo)

if (isLoadedFAR && !vessel.packed && surfaceVelocity != Vector3d.zero)
{
Vector3 farForce = Vector3.zero;
Vector3 farTorque = Vector3.zero;
CalculateVesselAeroForcesWithCache(vessel, out farForce, out farTorque, surfaceVelocity, altitudeASL);
CalculateVesselAeroForcesWithCache(vessel, out Vector3 farForce, out farTorque, surfaceVelocity, altitudeASL);

Vector3d farDragVector = Vector3d.Dot(farForce, -surfaceVelocity.normalized) * -surfaceVelocity.normalized;
drag = farDragVector.magnitude / mass;
Expand Down

0 comments on commit 088be36

Please sign in to comment.