1
0
Fork 0

Add a net_byte_order flag so that the calling code can specify if network

byte order conversion is desired (defaults to true.)
This commit is contained in:
curt 2003-03-03 04:35:09 +00:00
parent 000e86756c
commit 2b534ebf6d
4 changed files with 175 additions and 166 deletions

View file

@ -98,7 +98,7 @@ static void htond (double &x)
// Populate the FGNetCtrls structure from the property tree.
void FGProps2NetCtrls( FGNetCtrls *net ) {
void FGProps2NetCtrls( FGNetCtrls *net, bool net_byte_order ) {
int i;
SGPropertyNode * node = fgGetNode("/controls", true);
@ -183,6 +183,7 @@ void FGProps2NetCtrls( FGNetCtrls *net ) {
net->freeze |= 0x04;
}
if ( net_byte_order ) {
// convert to network byte order
net->version = htonl(net->version);
htond(net->aileron);
@ -218,15 +219,17 @@ void FGProps2NetCtrls( FGNetCtrls *net ) {
htond(net->magvar);
net->speedup = htonl(net->speedup);
net->freeze = htonl(net->freeze);
}
}
// Update the property tree from the FGNetCtrls structure.
void FGNetCtrls2Props( FGNetCtrls *net ) {
void FGNetCtrls2Props( FGNetCtrls *net, bool net_byte_order ) {
int i;
SGPropertyNode * node = fgGetNode("/controls", true);
if ( net_byte_order ) {
// convert from network byte order
net->version = htonl(net->version);
htond(net->aileron);
@ -262,6 +265,7 @@ void FGNetCtrls2Props( FGNetCtrls *net ) {
htond(net->magvar);
net->speedup = htonl(net->speedup);
net->freeze = htonl(net->freeze);
}
if ( net->version != FG_NET_CTRLS_VERSION ) {
SG_LOG( SG_IO, SG_ALERT,

View file

@ -63,10 +63,10 @@ public:
// Helper functions which may be useful outside this class
// Populate the FGNetCtrls structure from the property tree.
void FGProps2NetCtrls( FGNetCtrls *net );
void FGProps2NetCtrls( FGNetCtrls *net, bool net_byte_order = true );
// Update the property tree from the FGNetCtrls structure.
void FGNetCtrls2Props( FGNetCtrls *net );
void FGNetCtrls2Props( FGNetCtrls *net, bool net_byte_order = true );
#endif // _FG_NATIVE_CTRLS_HXX

View file

@ -100,7 +100,7 @@ bool FGNativeFDM::open() {
}
void FGProps2NetFDM( FGNetFDM *net ) {
void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order ) {
int i;
// Version sanity checking
@ -174,6 +174,7 @@ void FGProps2NetFDM( FGNetFDM *net ) {
net->warp = globals->get_warp();
net->visibility = fgGetDouble("/environment/visibility-m");
if ( net_byte_order ) {
// Convert the net buffer to network format
net->version = htonl(net->version);
@ -225,12 +226,14 @@ void FGProps2NetFDM( FGNetFDM *net ) {
net->cur_time = htonl( net->cur_time );
net->warp = htonl( net->warp );
htond(net->visibility);
}
}
void FGNetFDM2Props( FGNetFDM *net ) {
void FGNetFDM2Props( FGNetFDM *net, bool net_byte_order ) {
int i;
if ( net_byte_order ) {
// Convert to the net buffer from network format
net->version = ntohl(net->version);
@ -274,12 +277,14 @@ void FGNetFDM2Props( FGNetFDM *net ) {
}
net->num_wheels = htonl(net->num_wheels);
// I don't need to convert the Wow flags, since they are one byte in size
// I don't need to convert the Wow flags, since they are one
// byte in size
htond(net->flap_deflection);
net->cur_time = ntohl(net->cur_time);
net->warp = ntohl(net->warp);
htond(net->visibility);
}
if ( net->version == FG_NET_FDM_VERSION ) {
// cout << "pos = " << net->longitude << " " << net->latitude << endl;

View file

@ -57,10 +57,10 @@ public:
// Helper functions which may be useful outside this class
// Populate the FGNetFDM structure from the property tree.
void FGProps2NetFDM( FGNetFDM *net );
void FGProps2NetFDM( FGNetFDM *net, bool net_byte_order = true );
// Update the property tree from the FGNetFDM structure.
void FGNetFDM2Props( FGNetFDM *net );
void FGNetFDM2Props( FGNetFDM *net, bool net_byte_order = true );
#endif // _FG_NATIVE_FDM_HXX