mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-25 18:25:42 +08:00
[FSUIPC] Style, use const "lists" to iterate
This commit is contained in:
committed by
Mat Sutcliffe
parent
7b49f56695
commit
12613c9ed4
@@ -218,15 +218,14 @@ namespace BlackSimPlugin
|
|||||||
nw.nTempCtr = 0;
|
nw.nTempCtr = 0;
|
||||||
nw.nWindsCtr = 0;
|
nw.nWindsCtr = 0;
|
||||||
nw.nCloudsCtr = 0;
|
nw.nCloudsCtr = 0;
|
||||||
nw.nElevation = 0; // metres * 65536;
|
nw.nElevation = 0; // meters * 65536;
|
||||||
nw.nUpperVisCtr = 0;
|
nw.nUpperVisCtr = 0;
|
||||||
|
|
||||||
// todo: Take station from weather grid
|
// todo: Take station from weather grid
|
||||||
memcpy(nw.chICAO, "GLOB", 4);
|
memcpy(nw.chICAO, "GLOB", 4);
|
||||||
|
|
||||||
CVisibilityLayerList visibilityLayers = gridPoint.getVisibilityLayers();
|
const CVisibilityLayerList visibilityLayers = gridPoint.getVisibilityLayers().sortedBy(&CVisibilityLayer::getBase);
|
||||||
visibilityLayers.sortBy(&CVisibilityLayer::getBase);
|
const auto surfaceVisibility = visibilityLayers.frontOrDefault();
|
||||||
auto surfaceVisibility = visibilityLayers.frontOrDefault();
|
|
||||||
NewVis vis;
|
NewVis vis;
|
||||||
vis.LowerAlt = static_cast<short>(surfaceVisibility.getBase().valueInteger(CLengthUnit::m()));
|
vis.LowerAlt = static_cast<short>(surfaceVisibility.getBase().valueInteger(CLengthUnit::m()));
|
||||||
vis.UpperAlt = static_cast<ushort>(surfaceVisibility.getTop().valueInteger(CLengthUnit::m()));
|
vis.UpperAlt = static_cast<ushort>(surfaceVisibility.getTop().valueInteger(CLengthUnit::m()));
|
||||||
@@ -244,8 +243,7 @@ namespace BlackSimPlugin
|
|||||||
nw.UpperVis[nw.nUpperVisCtr++] = vis;
|
nw.UpperVis[nw.nUpperVisCtr++] = vis;
|
||||||
}
|
}
|
||||||
|
|
||||||
CTemperatureLayerList temperatureLayers = gridPoint.getTemperatureLayers();
|
const CTemperatureLayerList temperatureLayers = gridPoint.getTemperatureLayers().sortedBy(&CTemperatureLayer::getLevel);
|
||||||
temperatureLayers.sortBy(&CTemperatureLayer::getLevel);
|
|
||||||
for (const auto &temperatureLayer : temperatureLayers)
|
for (const auto &temperatureLayer : temperatureLayers)
|
||||||
{
|
{
|
||||||
NewTemp temp;
|
NewTemp temp;
|
||||||
@@ -256,8 +254,7 @@ namespace BlackSimPlugin
|
|||||||
nw.Temp[nw.nTempCtr++] = temp;
|
nw.Temp[nw.nTempCtr++] = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCloudLayerList cloudLayers = gridPoint.getCloudLayers();
|
const CCloudLayerList cloudLayers = gridPoint.getCloudLayers().sortedBy(&CCloudLayer::getBase);
|
||||||
cloudLayers.sortBy(&CCloudLayer::getBase);
|
|
||||||
for (const auto &cloudLayer : cloudLayers)
|
for (const auto &cloudLayer : cloudLayers)
|
||||||
{
|
{
|
||||||
NewCloud cloud;
|
NewCloud cloud;
|
||||||
@@ -300,9 +297,8 @@ namespace BlackSimPlugin
|
|||||||
nw.Cloud[nw.nCloudsCtr++] = cloud;
|
nw.Cloud[nw.nCloudsCtr++] = cloud;
|
||||||
}
|
}
|
||||||
|
|
||||||
CWindLayerList windLayers = gridPoint.getWindLayers();
|
const CWindLayerList windLayers = gridPoint.getWindLayers().sortedBy(&CWindLayer::getLevel);
|
||||||
windLayers.sortBy(&CWindLayer::getLevel);
|
for (const auto &windLayer : windLayers)
|
||||||
for (const auto &windLayer : as_const(windLayers))
|
|
||||||
{
|
{
|
||||||
NewWind wind;
|
NewWind wind;
|
||||||
wind.Direction = static_cast<ushort>(windLayer.getDirection().value(CAngleUnit::deg()) * 65536 / 360.0);
|
wind.Direction = static_cast<ushort>(windLayer.getDirection().value(CAngleUnit::deg()) * 65536 / 360.0);
|
||||||
@@ -522,7 +518,7 @@ namespace BlackSimPlugin
|
|||||||
situation.setAltitude(altitude);
|
situation.setAltitude(altitude);
|
||||||
situation.setPressureAltitude(pressureAltitude);
|
situation.setPressureAltitude(pressureAltitude);
|
||||||
aircraft.setSituation(situation);
|
aircraft.setSituation(situation);
|
||||||
aircraft.setCG(altitude-groundAltitude); // calculate the CG
|
aircraft.setCG(altitude - groundAltitude); // calculate the CG
|
||||||
} // situation
|
} // situation
|
||||||
|
|
||||||
// model
|
// model
|
||||||
@@ -586,14 +582,14 @@ namespace BlackSimPlugin
|
|||||||
nw.uDynamics = 0;
|
nw.uDynamics = 0;
|
||||||
for (std::size_t i = 0; i < sizeof(nw.uSpare) / sizeof(nw.uSpare[0]); i++) { nw.uSpare[i] = 0; }
|
for (std::size_t i = 0; i < sizeof(nw.uSpare) / sizeof(nw.uSpare[0]); i++) { nw.uSpare[i] = 0; }
|
||||||
|
|
||||||
nw.dLatitude = 0.;
|
nw.dLatitude = 0.0;
|
||||||
nw.dLongitude = 0.;
|
nw.dLongitude = 0.0;
|
||||||
nw.nElevation = 0;
|
nw.nElevation = 0;
|
||||||
nw.ulTimeStamp = 0;
|
nw.ulTimeStamp = 0;
|
||||||
nw.nTempCtr = 0;
|
nw.nTempCtr = 0;
|
||||||
nw.nWindsCtr = 0;
|
nw.nWindsCtr = 0;
|
||||||
nw.nCloudsCtr = 0;
|
nw.nCloudsCtr = 0;
|
||||||
QByteArray clearWeather(reinterpret_cast<const char *>(&nw), sizeof(NewWeather));
|
const QByteArray clearWeather(reinterpret_cast<const char *>(&nw), sizeof(NewWeather));
|
||||||
m_weatherMessageQueue.append(FsuipcWeatherMessage(0xC800, clearWeather, 1));
|
m_weatherMessageQueue.append(FsuipcWeatherMessage(0xC800, clearWeather, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -617,7 +613,7 @@ namespace BlackSimPlugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (weatherMessage.m_leftTrials == 0)
|
if (weatherMessage.m_leftTrials < 1)
|
||||||
{
|
{
|
||||||
CLogMessage(this).debug() << "Number of trials reached for weather message. Dropping it.";
|
CLogMessage(this).debug() << "Number of trials reached for weather message. Dropping it.";
|
||||||
m_weatherMessageQueue.removeFirst();
|
m_weatherMessageQueue.removeFirst();
|
||||||
@@ -626,8 +622,8 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
double CFsuipc::intToFractional(double fractional)
|
double CFsuipc::intToFractional(double fractional)
|
||||||
{
|
{
|
||||||
double f = fractional / 10.0;
|
const double f = fractional / 10.0;
|
||||||
if (f < 1.0) return f;
|
if (f < 1.0) { return f; }
|
||||||
return intToFractional(f);
|
return intToFractional(f);
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user