Fix incorrect gear read in HandlePosi

This commit is contained in:
Jason Watkins
2019-10-17 15:22:03 -07:00
parent fb8940583e
commit 2ff4497de5
2 changed files with 56 additions and 38 deletions

View File

@@ -141,11 +141,25 @@ namespace XPC
else if (head == "POSI")
{
char aircraft = buffer[5];
float gear = *((float*)(buffer + 30));
float pos[3];
float gear;
double pos[3];
float orient[3];
memcpy(pos, buffer + 6, 12);
memcpy(orient, buffer + 18, 12);
if (size == 34) /* lat/lon/h as 32-bit float */
{
float posd_32[3];
memcpy(posd_32, buffer + 6, 12);
pos[0] = posd_32[0];
pos[1] = posd_32[1];
pos[2] = posd_32[2];
memcpy(orient, buffer + 18, 12);
memcpy(&gear, buffer + 30, 4);
}
else if (size == 46) /* lat/lon/h as 64-bit double */
{
memcpy(pos, buffer + 6, 24);
memcpy(orient, buffer + 30, 12);
memcpy(&gear, buffer + 42, 4);
}
ss << " AC:" << (int)aircraft;
ss << " Pos:(" << pos[0] << ' ' << pos[1] << ' ' << pos[2] << ") Orient:(";
ss << orient[0] << ' ' << orient[1] << ' ' << orient[2] << ") Gear:";