mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
Style, typos
This commit is contained in:
@@ -32,4 +32,5 @@ namespace BlackGui
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -41,4 +41,5 @@ namespace BlackGui
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace BlackMisc
|
||||
* Split the range [in,end) into n equal chunks and use the random number generator rng to choose one element from each.
|
||||
*/
|
||||
template <typename ForwardIt, typename OutputIt, typename Generator>
|
||||
void copySampleElements(ForwardIt in, ForwardIt end, OutputIt out, const int n, Generator &&rng)
|
||||
void copySampleElements(ForwardIt in, ForwardIt end, OutputIt out, int n, Generator &&rng)
|
||||
{
|
||||
const auto size = static_cast<int>(std::distance(in, end));
|
||||
for (int i = 0; i < std::min(n, size); ++i)
|
||||
|
||||
@@ -30,20 +30,20 @@ namespace BlackMisc
|
||||
|
||||
void CSimpleCommandParser::parse(const QString &commandLine)
|
||||
{
|
||||
this->m_knownCommand = false;
|
||||
this->m_originalLine = commandLine;
|
||||
this->m_cleanedLine = commandLine.trimmed().simplified();
|
||||
if (!this->m_cleanedLine.isEmpty())
|
||||
m_knownCommand = false;
|
||||
m_originalLine = commandLine;
|
||||
m_cleanedLine = commandLine.trimmed().simplified();
|
||||
if (!m_cleanedLine.isEmpty())
|
||||
{
|
||||
this->m_splitParts = m_cleanedLine.split(' ');
|
||||
if (!this->m_splitParts.isEmpty())
|
||||
m_splitParts = m_cleanedLine.split(' ');
|
||||
if (!m_splitParts.isEmpty())
|
||||
{
|
||||
const QString &first = this->m_splitParts.constFirst();
|
||||
const QString &first = m_splitParts.constFirst();
|
||||
const QString formatted = formatCommand(first);
|
||||
if (isCommand(first))
|
||||
{
|
||||
this->m_commandPart = formatted;
|
||||
this->m_knownCommand = this->m_knownCommands.contains(formatted);
|
||||
m_commandPart = formatted;
|
||||
m_knownCommand = m_knownCommands.contains(formatted);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,22 +52,22 @@ namespace BlackMisc
|
||||
const QString &CSimpleCommandParser::part(int index) const
|
||||
{
|
||||
static const QString empty("");
|
||||
if (index < 0 || index >= this->m_splitParts.size()) return empty;
|
||||
return this->m_splitParts.at(index);
|
||||
if (index < 0 || index >= m_splitParts.size()) return empty;
|
||||
return m_splitParts.at(index);
|
||||
}
|
||||
|
||||
QString CSimpleCommandParser::remainingStringAfter(int index) const
|
||||
{
|
||||
if (index < 0) { return this->m_originalLine.trimmed(); }
|
||||
if (index < 0) { return m_originalLine.trimmed(); }
|
||||
const QString p = this->part(index);
|
||||
int fi = this->m_originalLine.indexOf(p, 0, Qt::CaseInsensitive);
|
||||
int fi = m_originalLine.indexOf(p, 0, Qt::CaseInsensitive);
|
||||
if (fi < 0) { return ""; }
|
||||
return this->m_originalLine.mid(fi).trimmed();
|
||||
return m_originalLine.mid(fi).trimmed();
|
||||
}
|
||||
|
||||
int CSimpleCommandParser::countParts() const
|
||||
{
|
||||
return this->m_splitParts.count();
|
||||
return m_splitParts.count();
|
||||
}
|
||||
|
||||
bool CSimpleCommandParser::hasPart(int index) const
|
||||
@@ -206,30 +206,30 @@ namespace BlackMisc
|
||||
|
||||
bool CSimpleCommandParser::matchesCommand(const QString &checkCommand, const QString &alias1, const QString &alias2)
|
||||
{
|
||||
if (this->m_commandPart.isEmpty()) { return false; }
|
||||
if (!checkCommand.isEmpty() && formatCommand(checkCommand) == this->m_commandPart) { return true; }
|
||||
if (!alias1.isEmpty() && formatCommand(alias1) == this->m_commandPart) { return true; }
|
||||
if (!alias2.isEmpty() && formatCommand(alias2) == this->m_commandPart) { return true; }
|
||||
if (m_commandPart.isEmpty()) { return false; }
|
||||
if (!checkCommand.isEmpty() && formatCommand(checkCommand) == m_commandPart) { return true; }
|
||||
if (!alias1.isEmpty() && formatCommand(alias1) == m_commandPart) { return true; }
|
||||
if (!alias2.isEmpty() && formatCommand(alias2) == m_commandPart) { return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSimpleCommandParser::commandStartsWith(const QString &startPattern) const
|
||||
{
|
||||
if (this->m_commandPart.isEmpty()) { return false; }
|
||||
return this->m_commandPart.startsWith(formatCommand(startPattern));
|
||||
if (m_commandPart.isEmpty()) { return false; }
|
||||
return m_commandPart.startsWith(formatCommand(startPattern));
|
||||
}
|
||||
|
||||
bool CSimpleCommandParser::commandEndsWith(const QString &endPattern) const
|
||||
{
|
||||
if (this->m_commandPart.isEmpty()) { return false; }
|
||||
return this->m_commandPart.endsWith(endPattern);
|
||||
if (m_commandPart.isEmpty()) { return false; }
|
||||
return m_commandPart.endsWith(endPattern);
|
||||
}
|
||||
|
||||
void CSimpleCommandParser::setCheckedCommandList(const QStringList &commands)
|
||||
{
|
||||
for (const QString &c : commands)
|
||||
{
|
||||
this->m_knownCommands.append(formatCommand(c));
|
||||
m_knownCommands.append(formatCommand(c));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -107,10 +107,10 @@ namespace BlackMisc
|
||||
QString CSimConnectUtilities::resolveEnumToString(const DWORD id, const char *enumName)
|
||||
{
|
||||
const int i = CSimConnectUtilities::staticMetaObject.indexOfEnumerator(enumName);
|
||||
if (i < 0) return QString("No enumerator for %1").arg(enumName);
|
||||
if (i < 0) { return QString("No enumerator for %1").arg(enumName); }
|
||||
const QMetaEnum m = CSimConnectUtilities::staticMetaObject.enumerator(i);
|
||||
const char *k = m.valueToKey(id);
|
||||
return (k) ? QLatin1String(k) : QString("Id %1 not found for %2").arg(id).arg(enumName);
|
||||
return (k) ? QLatin1String(k) : QString("Id '%1' not found for %2").arg(id).arg(enumName);
|
||||
}
|
||||
|
||||
const QString &CSimConnectUtilities::simConnectIniFilename()
|
||||
|
||||
@@ -20,10 +20,11 @@ namespace BlackMisc
|
||||
bool ISimulationEnvironmentProvider::rememberGroundElevation(const ICoordinateGeodetic &elevationCoordinate, const CLength &epsilon)
|
||||
{
|
||||
{
|
||||
// no 2nd elevation nearby
|
||||
// no 2nd elevation nearby?
|
||||
QReadLocker l(&m_lockElvCoordinates);
|
||||
if (m_elvCoordinates.containsObjectInRange(elevationCoordinate, minRange(epsilon))) { return false; }
|
||||
}
|
||||
|
||||
{
|
||||
// we keep latest at front
|
||||
// * we assume we find them faster
|
||||
|
||||
@@ -71,9 +71,13 @@ namespace BlackSimPlugin
|
||||
//! \@{
|
||||
virtual bool isConnected() const override;
|
||||
virtual bool isSimulating() const override { return isConnected(); }
|
||||
virtual void timerEvent(QTimerEvent *event) override;
|
||||
//! \@}
|
||||
|
||||
//! Timer event dispatching
|
||||
//! \sa m_timerId
|
||||
//! \sa CSimulatorFsxCommon::dispatch
|
||||
virtual void timerEvent(QTimerEvent *event) override;
|
||||
|
||||
//! \name Base class overrides
|
||||
//! @{
|
||||
virtual void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid) override;
|
||||
|
||||
@@ -157,6 +157,7 @@ namespace BlackSimPlugin
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataRemoteAircraftGetPosition, "PLANE ALTITUDE", "Feet");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataRemoteAircraftGetPosition, "GROUND ALTITUDE", "Feet");
|
||||
hr += SimConnect_AddToDataDefinition(hSimConnect, CSimConnectDefinitions::DataRemoteAircraftGetPosition, "STATIC CG TO GROUND", "Feet");
|
||||
|
||||
if (hr != S_OK)
|
||||
{
|
||||
CLogMessage(static_cast<CSimConnectDefinitions *>(nullptr)).error("SimConnect error: initRemoteAircraftSimData %1") << hr;
|
||||
|
||||
@@ -601,7 +601,7 @@ namespace BlackSimPlugin
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorFsxCommon::updatProbeFromSimulator(const CCallsign &callsign, const DataDefinitionRemoteAircraftSimData &remoteAircraftData)
|
||||
void CSimulatorFsxCommon::updateProbeFromSimulator(const CCallsign &callsign, const DataDefinitionRemoteAircraftSimData &remoteAircraftData)
|
||||
{
|
||||
CElevationPlane elevation(remoteAircraftData.latitudeDeg, remoteAircraftData.longitudeDeg, remoteAircraftData.elevationFt);
|
||||
elevation.setSinglePointRadius();
|
||||
|
||||
@@ -305,7 +305,7 @@ namespace BlackSimPlugin
|
||||
void updateRemoteAircraftFromSimulator(const CSimConnectObject &simObject, const DataDefinitionRemoteAircraftSimData &remoteAircraftData);
|
||||
|
||||
//! Probe data sent from simulator
|
||||
void updatProbeFromSimulator(const BlackMisc::Aviation::CCallsign &callsign, const DataDefinitionRemoteAircraftSimData &remoteAircraftData);
|
||||
void updateProbeFromSimulator(const BlackMisc::Aviation::CCallsign &callsign, const DataDefinitionRemoteAircraftSimData &remoteAircraftData);
|
||||
|
||||
//! Update from SB client area
|
||||
void updateOwnAircraftFromSimulator(const DataDefinitionClientAreaSb &sbDataArea);
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace BlackSimPlugin
|
||||
simulatorFsxP3D->m_simulatorDetails = QString("Name: '%1' Version: %2 SimConnect: %3").arg(simulatorFsxP3D->m_simulatorName, simulatorFsxP3D->m_simulatorVersion, simulatorFsxP3D->m_simConnectVersion);
|
||||
CLogMessage(static_cast<CSimulatorFsxCommon *>(nullptr)).info("Connected to %1: '%2'") << simulatorFsxP3D->getSimulatorPluginInfo().getIdentifier() << simulatorFsxP3D->m_simulatorDetails;
|
||||
simulatorFsxP3D->setSimConnected();
|
||||
break;
|
||||
break; // SIMCONNECT_RECV_ID_OPEN
|
||||
}
|
||||
case SIMCONNECT_RECV_ID_EXCEPTION:
|
||||
{
|
||||
@@ -75,7 +75,7 @@ namespace BlackSimPlugin
|
||||
<< exceptionString << ex
|
||||
<< (sendIdDetails.isEmpty() ? "N/A" : sendIdDetails);
|
||||
simulatorFsxP3D->triggerAutoTraceSendId();
|
||||
break;
|
||||
break; // SIMCONNECT_RECV_ID_EXCEPTION
|
||||
}
|
||||
case SIMCONNECT_RECV_ID_QUIT:
|
||||
{
|
||||
@@ -113,7 +113,7 @@ namespace BlackSimPlugin
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
break; // SIMCONNECT_RECV_ID_EVENT
|
||||
}
|
||||
case SIMCONNECT_RECV_ID_EVENT_OBJECT_ADDREMOVE:
|
||||
{
|
||||
@@ -122,7 +122,7 @@ namespace BlackSimPlugin
|
||||
const SIMCONNECT_SIMOBJECT_TYPE objectType = event->eObjType;
|
||||
if (objectType != SIMCONNECT_SIMOBJECT_TYPE_AIRCRAFT && objectType != SIMCONNECT_SIMOBJECT_TYPE_HELICOPTER)
|
||||
{
|
||||
break;
|
||||
break; // SIMCONNECT_RECV_ID_EVENT_OBJECT_ADDREMOVE
|
||||
}
|
||||
|
||||
// such an object is not necessarily one of ours
|
||||
@@ -152,7 +152,7 @@ namespace BlackSimPlugin
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break; // SIMCONNECT_RECV_ID_EVENT_OBJECT_ADDREMOVE
|
||||
}
|
||||
case SIMCONNECT_RECV_ID_EVENT_FRAME:
|
||||
{
|
||||
@@ -166,7 +166,7 @@ namespace BlackSimPlugin
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
break; // SIMCONNECT_RECV_ID_EVENT_FRAME
|
||||
}
|
||||
case SIMCONNECT_RECV_ID_ASSIGNED_OBJECT_ID:
|
||||
{
|
||||
@@ -204,7 +204,7 @@ namespace BlackSimPlugin
|
||||
emit simulatorFsxP3D->physicallyAddingRemoteModelFailed(remoteAircraft, msg);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break; // SIMCONNECT_RECV_ID_ASSIGNED_OBJECT_ID
|
||||
}
|
||||
case SIMCONNECT_RECV_ID_SIMOBJECT_DATA_BYTYPE:
|
||||
{
|
||||
@@ -257,11 +257,11 @@ namespace BlackSimPlugin
|
||||
{
|
||||
static_assert(sizeof(DataDefinitionRemoteAircraftSimData) == 5 * sizeof(double), "DataDefinitionRemoteAircraftSimData has an incorrect size.");
|
||||
simulatorFsxP3D->m_dispatchLastRequest = CSimConnectDefinitions::RequestRangeForSimData;
|
||||
const CSimConnectObject simObj = simulatorFsxP3D->getSimObjectForObjectId(objectId);
|
||||
if (!simObj.hasValidRequestAndObjectId()) { break; }
|
||||
const CSimConnectObject simObject = simulatorFsxP3D->getSimObjectForObjectId(objectId);
|
||||
if (!simObject.hasValidRequestAndObjectId()) { break; }
|
||||
const DataDefinitionRemoteAircraftSimData *remoteAircraftSimData = (DataDefinitionRemoteAircraftSimData *)&pObjData->dwData;
|
||||
// extra check, but ids should be the same
|
||||
if (objectId == simObj.getObjectId())
|
||||
if (objectId == simObject.getObjectId())
|
||||
{
|
||||
simulatorFsxP3D->updateRemoteAircraftFromSimulator(simObj, *remoteAircraftSimData);
|
||||
}
|
||||
@@ -278,7 +278,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
const CCallsign cs = simulatorFsxP3D->m_pendingProbeRequests.value(requestId);
|
||||
if (cs.isEmpty()) { break; }
|
||||
simulatorFsxP3D->updatProbeFromSimulator(cs, *probeSimData);
|
||||
simulatorFsxP3D->updateProbeFromSimulator(cs, *probeSimData);
|
||||
}
|
||||
}
|
||||
else if (CSimulatorFsxCommon::isRequestForLights(requestId))
|
||||
|
||||
Reference in New Issue
Block a user