msfs-simconnect-api-wrapper
Advanced tools
Comparing version 2.0.0 to 2.0.2
@@ -0,1 +1,5 @@ | ||
v2.0.1 | ||
- fix exception on repeated airport:index calls. | ||
v2.0.0 | ||
@@ -2,0 +6,0 @@ |
{ | ||
"name": "msfs-simconnect-api-wrapper", | ||
"version": "2.0.0", | ||
"version": "2.0.2", | ||
"description": "A convenient SimConnect API for playing with Microsoft Flight Simulator 2020", | ||
@@ -5,0 +5,0 @@ "main": "msfs-api.js", |
@@ -134,26 +134,59 @@ /** | ||
const SIMCONNECT_FACILITY_AIRPORT = 1000; | ||
const AIRPORT_TYPE = SIMCONNECT_FACILITY_LIST_TYPE_AIRPORT; | ||
function addAirportHandling(api) { | ||
const { handle } = api; | ||
let facilityDefinitionRegistered = false; | ||
const TYPE = SIMCONNECT_FACILITY_LIST_TYPE_AIRPORT; | ||
const IN_RANGE = api.nextId(); | ||
const OUT_OF_RANGE = api.nextId(); | ||
function registerFacilityDefinition(handle) { | ||
if (facilityDefinitionRegistered) return; | ||
facilityDefinitionRegistered = true; | ||
handle.subscribeToFacilitiesEx1(TYPE, IN_RANGE, OUT_OF_RANGE); | ||
const FA = SIMCONNECT_FACILITY_AIRPORT; | ||
handle.on("airportList", (data) => { | ||
const { requestID: id } = data; | ||
// Airport | ||
handle.addToFacilityDefinition(FA, "OPEN AIRPORT"); // Open | ||
// work around the node-simconnect typo, if it still exists | ||
if (data.aiports) { | ||
data.airports ??= data.aiports; | ||
delete data.aiports; | ||
} | ||
[ | ||
`LATITUDE`, | ||
`LONGITUDE`, | ||
`ALTITUDE`, | ||
`MAGVAR`, | ||
`NAME`, | ||
`NAME64`, | ||
`REGION`, | ||
`N_RUNWAYS`, | ||
].forEach((thing) => handle.addToFacilityDefinition(FA, thing)); | ||
// Are there in/out of range airports? | ||
api.eventListeners[id]?.handlers.forEach((handle) => handle(data.airports)); | ||
}); | ||
// Runway | ||
handle.addToFacilityDefinition(FA, "OPEN RUNWAY"); // "start of data" marker | ||
[ | ||
`LATITUDE`, | ||
`LONGITUDE`, | ||
`ALTITUDE`, | ||
`HEADING`, | ||
`LENGTH`, | ||
`WIDTH`, | ||
`PATTERN_ALTITUDE`, | ||
`SLOPE`, | ||
`TRUE_SLOPE`, | ||
`SURFACE`, | ||
].forEach((thing) => handle.addToFacilityDefinition(FA, thing)); | ||
[ | ||
`PRIMARY_NUMBER`, | ||
`PRIMARY_DESIGNATOR`, | ||
`PRIMARY_ILS_TYPE`, | ||
`PRIMARY_ILS_ICAO`, | ||
`PRIMARY_ILS_REGION`, | ||
].forEach((thing) => handle.addToFacilityDefinition(FA, thing)); | ||
[ | ||
`SECONDARY_NUMBER`, | ||
`SECONDARY_DESIGNATOR`, | ||
`SECONDARY_ILS_TYPE`, | ||
`SECONDARY_ILS_ICAO`, | ||
`SECONDARY_ILS_REGION`, | ||
].forEach((thing) => handle.addToFacilityDefinition(FA, thing)); | ||
handle.addToFacilityDefinition(FA, "CLOSE RUNWAY"); // "end of data" marker | ||
} | ||
@@ -214,54 +247,6 @@ | ||
const FA = SIMCONNECT_FACILITY_AIRPORT; | ||
registerFacilityDefinition(handle); | ||
// Airport | ||
handle.addToFacilityDefinition(FA, "OPEN AIRPORT"); // Open | ||
const airportData = { ICAO: AIRPORT_ICAO, runways: [] }; | ||
[ | ||
`LATITUDE`, | ||
`LONGITUDE`, | ||
`ALTITUDE`, | ||
`MAGVAR`, | ||
`NAME`, | ||
`NAME64`, | ||
`REGION`, | ||
`N_RUNWAYS`, | ||
].forEach((thing) => handle.addToFacilityDefinition(FA, thing)); | ||
// Runway | ||
handle.addToFacilityDefinition(FA, "OPEN RUNWAY"); // "start of data" marker | ||
[ | ||
`LATITUDE`, | ||
`LONGITUDE`, | ||
`ALTITUDE`, | ||
`HEADING`, | ||
`LENGTH`, | ||
`WIDTH`, | ||
`PATTERN_ALTITUDE`, | ||
`SLOPE`, | ||
`TRUE_SLOPE`, | ||
`SURFACE`, | ||
].forEach((thing) => handle.addToFacilityDefinition(FA, thing)); | ||
[ | ||
`PRIMARY_NUMBER`, | ||
`PRIMARY_DESIGNATOR`, | ||
`PRIMARY_ILS_TYPE`, | ||
`PRIMARY_ILS_ICAO`, | ||
`PRIMARY_ILS_REGION`, | ||
].forEach((thing) => handle.addToFacilityDefinition(FA, thing)); | ||
[ | ||
`SECONDARY_NUMBER`, | ||
`SECONDARY_DESIGNATOR`, | ||
`SECONDARY_ILS_TYPE`, | ||
`SECONDARY_ILS_ICAO`, | ||
`SECONDARY_ILS_REGION`, | ||
].forEach((thing) => handle.addToFacilityDefinition(FA, thing)); | ||
handle.addToFacilityDefinition(FA, "CLOSE RUNWAY"); // "end of data" marker | ||
const airportData = { runways: [] }; | ||
const handler = ({ data, type }) => { | ||
@@ -276,3 +261,2 @@ // airport | ||
const name64 = data.readString64(); | ||
const ICAO = AIRPORT_ICAO; | ||
const region = data.readString8(); | ||
@@ -279,0 +263,0 @@ const runwayCount = data.readInt32(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
218598
6558