1
0
Fork 0

MP2017.2 V2 protocol enhancements

1. Add support for scaled floats; most of the floats we transmit are small and thus can fit into a scaled short.
2. Change most properties to use scaled floats.
This commit is contained in:
Richard Harrison 2017-02-23 22:33:33 +01:00
parent 3fceba7a24
commit 80dc810d15
3 changed files with 501 additions and 406 deletions

File diff suppressed because it is too large Load diff

View file

@ -85,6 +85,7 @@ private:
void Send(); void Send();
void SendMyPosition(const FGExternalMotionData& motionInfo); void SendMyPosition(const FGExternalMotionData& motionInfo);
short get_scaled_short(double v, double scale);
union MsgBuf; union MsgBuf;
FGAIMultiplayer* addMultiplayer(const std::string& callsign, FGAIMultiplayer* addMultiplayer(const std::string& callsign,

View file

@ -73,7 +73,7 @@ XDR_encode_int32 ( const int32_t & n_Val )
return (SWAP32(static_cast<xdr_data_t> (n_Val))); return (SWAP32(static_cast<xdr_data_t> (n_Val)));
} }
static short convert_int_to_short(int v1) static short XDR_convert_int_to_short(int v1)
{ {
if (v1 < -32767) if (v1 < -32767)
v1 = -32767; v1 = -32767;
@ -89,7 +89,7 @@ static short convert_int_to_short(int v1)
*/ */
xdr_data_t XDR_encode_shortints32(const int v1, const int v2) xdr_data_t XDR_encode_shortints32(const int v1, const int v2)
{ {
return XDR_encode_uint32( (convert_int_to_short(v1) << 16) | (convert_int_to_short(v2))); return XDR_encode_uint32( ((XDR_convert_int_to_short(v1) << 16) & 0xffff0000) | ((XDR_convert_int_to_short(v2)) & 0xffff));
} }
/* Decode packed shorts into two ints. V1 in the highword ($V1..V2..)*/ /* Decode packed shorts into two ints. V1 in the highword ($V1..V2..)*/
void XDR_decode_shortints32(const xdr_data_t & n_Val, int &v1, int &v2) void XDR_decode_shortints32(const xdr_data_t & n_Val, int &v1, int &v2)