TwinFan / LiveTraffic

LiveTraffic is an X-Plane multiplayer plugin, which fills your sky with live air traffic based on public flight tracking data.
https://twinfan.gitbook.io/livetraffic/
Other
101 stars 24 forks source link

xplanemp: Enhance multiplayer datarefs #117

Closed TwinFan closed 5 years ago

TwinFan commented 5 years ago

Current Situation / Problem The multiplayer uses just 3 dataRefs to control AI planes for TCAS blibs. While this is apparently OK for that purpose (TCAS is reported to work very good, so let's be careful with any change in this area) it is a bit few for other applications:

Suggested Solution

  1. I don’t see a need for users to pre-configure AI planes and Limit the number of TCAS blibs to those. xplanemp should be able to just use all technically available slots, 19 in XP11, at bit less in XP10. There is no technical connection between what xplanemp calls "drawing of Austin's planes" and filling of multiplayer dataRefs for AI control.
  2. xplanemp currently always returns a constant number of "active" aircraft. That's simply a bug...it should set the number of active planes correctly to the number of controlled AI planes.
  3. Keeping one plane at a fixed index as long as it is TCAS relevant should be doable and ease your job of following the a/c. Then, however, the number of active aircraft would need to be reported as the max used index, some indexes inbetween might be unused. I would set those unused positions to invalid values (latitude of -89) so they would not show up anywhere.
  4. Provide more multiplayer dataRefs. At the moment only the following are populated:
    sim/multiplayer/position/plane%d_x
    sim/multiplayer/position/plane%d_y
    sim/multiplayer/position/plane%d_z

    i.e. the position. xplanemp doesn't have all information for which there are sim/multiplayer dataRefs, especially the lib does not have any info on the movement of the plane (speeds) as it just asks current position with every frame. But things like heading, roll, pitch should be no problem.

Alternatives Also see #86 for an API on LiveTraffic's dataRefs. That will be the ultimate solution. So effort we put into this issue will be limited to a reasonable amount.

Benefits AI planes should be better handled in other apps like map, Little NavMap, ABC.

Additional context Ad 2. XPMPDefaultPlaneRenderer could easily count actual TCAS planes and was probably meant like that in the int tcas variable (there is, bad coding, a bool tcas variable in an included loop, too, fix that double-name also along the way), but this one gets set only once in the very beginning and thereafter stays constant:

    int modelCount, active, plugin, tcas;
    XPLMCountAircraft(&modelCount, &active, &plugin);
    tcas = modelCount - 1;  // This is how many tcas blips we can have!
TwinFan commented 5 years ago

Number 1. didn't fully work out...X-Plane limits the number of aircraft as returned by XPLMCountAircraft to the number of configured AI planes. I can (and do now) set more than that with XPLMSetActiveAircraftCount...but X-Plane simply doesn't accept more than there are AI planes.

So plugins could read all multiplayer dataRefs and just try...(like apparently X-TCAS does)...but if they rely on XPLMCountAircraft (Little Xpconnect of Little Navmap does, e.g., as does the internal X-Plane map and internal TCAS implementations in the Garmin instruments) they stop at the number of configured AI planes despite LT offering more planes.

The other implementations worked:

Also, LT/xplanemp now