From 925636da8c86712f7fbbc5074f89855dc21243a5 Mon Sep 17 00:00:00 2001 From: tigital Date: Fri, 11 Jun 2004 01:38:28 +0000 Subject: [PATCH] byte-swapping changes for bigendian systems --- src/network/multi_obj.cpp | 18 +++++++-------- src/network/multi_oo.cpp | 30 ++++++++++++------------ src/network/multi_options.cpp | 43 +++++++++++++++++++++++++---------- src/network/multi_pmsg.cpp | 15 +++++++----- 4 files changed, 64 insertions(+), 42 deletions(-) diff --git a/src/network/multi_obj.cpp b/src/network/multi_obj.cpp index 863b1d3..7a5a1cc 100644 --- a/src/network/multi_obj.cpp +++ b/src/network/multi_obj.cpp @@ -559,7 +559,7 @@ int multi_oo_pack_data(net_player *pl, object *objp, ubyte oo_flags, ubyte *data // don't add for clients if(Net_player->flags & NETINFO_FLAG_AM_MASTER){ multi_rate_add(NET_PLAYER_NUM(pl), "sig", 2); - ADD_DATA( objp->net_signature ); + ADD_DATA_U16( objp->net_signature ); multi_rate_add(NET_PLAYER_NUM(pl), "flg", 1); ADD_DATA( oo_flags ); @@ -652,7 +652,7 @@ int multi_oo_unpack_client_data(net_player *pl, ubyte *data) object *tobj; // get the data - GET_DATA(tnet_sig); + GET_DATA_U16(tnet_sig); GET_DATA(t_subsys); GET_DATA(l_subsys); @@ -704,7 +704,7 @@ int multi_oo_unpack_data(net_player *pl, ubyte *data) // add the object's net signature, type and oo_flags if(!(Net_player->flags & NETINFO_FLAG_AM_MASTER)){ - GET_DATA( net_sig ); + GET_DATA_U16( net_sig ); GET_DATA( oo_flags ); } // clients always pos and orient stuff only @@ -910,8 +910,8 @@ int multi_oo_unpack_data(net_player *pl, ubyte *data) object *target_objp; GET_DATA( umode ); - GET_DATA( submode ); - GET_DATA( target_signature ); + GET_DATA_S16( submode ); + GET_DATA_U16( target_signature ); if(shipp->ai_index >= 0){ Ai_info[shipp->ai_index].mode = umode; @@ -940,10 +940,10 @@ int multi_oo_unpack_data(net_player *pl, ubyte *data) int ai_flags, ai_mode, ai_submode; // flag - GET_DATA(ai_flags); - GET_DATA(ai_mode); - GET_DATA(ai_submode); - GET_DATA(dock_sig); + GET_DATA_S32(ai_flags); + GET_DATA_S32(ai_mode); + GET_DATA_S32(ai_submode); + GET_DATA_U16(dock_sig); // valid ship? if((shipp != NULL) && (shipp->ai_index >= 0) && (shipp->ai_index < MAX_AI_INFO)){ diff --git a/src/network/multi_oo.cpp b/src/network/multi_oo.cpp index 14d532b..facbcb0 100644 --- a/src/network/multi_oo.cpp +++ b/src/network/multi_oo.cpp @@ -884,7 +884,7 @@ int multi_oo_pack_data(net_player *pl, object *objp, ubyte oo_flags, ubyte *data packet_size = 0; // don't add for clients if(Net_player->flags & NETINFO_FLAG_AM_MASTER){ - ADD_DATA( objp->net_signature ); + ADD_DATA_U16( objp->net_signature ); } ADD_DATA( oo_flags ); ADD_DATA( data_size ); @@ -975,7 +975,7 @@ int multi_oo_unpack_client_data(net_player *pl, ubyte *data) object *tobj; // get the data - GET_DATA(tnet_sig); + GET_DATA_U16(tnet_sig); GET_DATA(t_subsys); GET_DATA(l_subsys); @@ -1025,7 +1025,7 @@ int multi_oo_unpack_data(net_player *pl, ubyte *data, ushort packet_sequence_num // add the object's net signature, type and oo_flags if(!(Net_player->flags & NETINFO_FLAG_AM_MASTER)){ - GET_DATA( net_sig ); + GET_DATA_U16( net_sig ); } GET_DATA( oo_flags ); GET_DATA( data_size ); @@ -1204,8 +1204,8 @@ int multi_oo_unpack_data(net_player *pl, ubyte *data, ushort packet_sequence_num object *target_objp; GET_DATA(umode); - GET_DATA(submode); - GET_DATA( target_signature ); + GET_DATA_S16(submode); + GET_DATA_U16( target_signature ); if(shipp->ai_index > 0){ Ai_info[shipp->ai_index].mode = umode; @@ -1450,8 +1450,8 @@ void multi_oo_process_all(net_player *pl) BUILD_HEADER(OBJECT_UPDATE); // add the sequencing # - ADD_DATA(Netgame.server_update_seq); - ADD_DATA(OO_global_time); + ADD_DATA_U16(Netgame.server_update_seq); + ADD_DATA_S32(OO_global_time); // get a pointer to the object targ_obj = &Objects[pl->s_info.target_objnum]; @@ -1472,8 +1472,8 @@ void multi_oo_process_all(net_player *pl) BUILD_HEADER(OBJECT_UPDATE); // add the sequencing # - ADD_DATA(Netgame.server_update_seq); - ADD_DATA(OO_global_time); + ADD_DATA_U16(Netgame.server_update_seq); + ADD_DATA_S32(OO_global_time); } idx = 0; @@ -1504,8 +1504,8 @@ void multi_oo_process_all(net_player *pl) BUILD_HEADER(OBJECT_UPDATE); // add the sequencing # - ADD_DATA(Netgame.server_update_seq); - ADD_DATA(OO_global_time); + ADD_DATA_U16(Netgame.server_update_seq); + ADD_DATA_S32(OO_global_time); } if(add_size){ @@ -1559,8 +1559,8 @@ void multi_oo_process_update(ubyte *data, header *hinfo) net_player *pl = NULL; // process sequencing info here - GET_DATA(packet_seq); - GET_DATA(server_stamp); + GET_DATA_U16(packet_seq); + GET_DATA_S32(server_stamp); // if this is processed on the server, its a client object update packet player_index = -1; @@ -1731,8 +1731,8 @@ void multi_oo_send_control_info() BUILD_HEADER(OBJECT_UPDATE); // add the sequencing # - ADD_DATA(Netgame.server_update_seq); - ADD_DATA(OO_global_time); + ADD_DATA_U16(Netgame.server_update_seq); + ADD_DATA_S32(OO_global_time); oo_flags = (OO_POS_NEW | OO_ORIENT_NEW | OO_EXTRA_PHYSICS); diff --git a/src/network/multi_options.cpp b/src/network/multi_options.cpp index fa28b36..2646971 100644 --- a/src/network/multi_options.cpp +++ b/src/network/multi_options.cpp @@ -13,6 +13,9 @@ * $Author$ * * $Log$ + * Revision 1.5 2004/06/11 01:34:41 tigital + * byte-swapping changes for bigendian systems + * * Revision 1.4 2003/05/25 02:30:43 taylor * Freespace 1 support * @@ -527,6 +530,12 @@ void multi_options_update_netgame() ADD_DATA(code); // add the netgame options + Netgame.options.flags = INTEL_INT( Netgame.options.flags ); + Netgame.options.respawn = INTEL_INT( Netgame.options.respawn ); + Netgame.options.voice_token_wait = INTEL_INT( Netgame.options.voice_token_wait ); + Netgame.options.voice_record_time = INTEL_INT( Netgame.options.voice_record_time ); + Netgame.options.kill_limit= INTEL_INT( Netgame.options.kill_limit ); + Netgame.options.mission_time_limit = (fix)INTEL_INT( Netgame.options.mission_time_limit ); ADD_DATA(Netgame.options); // send the packet @@ -554,6 +563,8 @@ void multi_options_update_local() ADD_DATA(code); // add the netgame options + Net_player->p_info.options.flags = INTEL_INT( Net_player->p_info.options.flags ); + Net_players->p_info.options.obj_update_level = INTEL_INT( Net_player->p_info.options.obj_update_level ); ADD_DATA(Net_player->p_info.options); // send the packet @@ -576,8 +587,8 @@ void multi_options_update_start_game(netgame_info *ng) // add the start game options ADD_STRING(ng->name); - ADD_DATA(ng->mode); - ADD_DATA(ng->security); + ADD_DATA_S32(ng->mode); + ADD_DATA_S32(ng->security); // add mode-specific data switch(ng->mode){ @@ -586,7 +597,7 @@ void multi_options_update_start_game(netgame_info *ng) break; case NG_MODE_RANK_ABOVE: case NG_MODE_RANK_BELOW: - ADD_DATA(ng->rank_base); + ADD_DATA_S32(ng->rank_base); break; } @@ -609,10 +620,10 @@ void multi_options_update_mission(netgame_info *ng, int campaign_mode) ADD_DATA(code); // type (coop or team vs. team) - ADD_DATA(ng->type_flags); + ADD_DATA_S32(ng->type_flags); // respawns - ADD_DATA(ng->respawn); + ADD_DATA_U32(ng->respawn); // add the mission/campaign filename code = (ubyte)campaign_mode; @@ -655,10 +666,10 @@ void multi_options_process_packet(unsigned char *data, header *hinfo) GET_STRING(Netgame.name); // get the netgame mode - GET_DATA(Netgame.mode); + GET_DATA_S32(Netgame.mode); // get the security # - GET_DATA(Netgame.security); + GET_DATA_S32(Netgame.security); // get mode specific data switch(Netgame.mode){ @@ -667,7 +678,7 @@ void multi_options_process_packet(unsigned char *data, header *hinfo) break; case NG_MODE_RANK_ABOVE: case NG_MODE_RANK_BELOW: - GET_DATA(Netgame.rank_base); + GET_DATA_S32(Netgame.rank_base); break; } @@ -687,7 +698,7 @@ void multi_options_process_packet(unsigned char *data, header *hinfo) Assert(Game_mode & GM_STANDALONE_SERVER); // coop or team vs. team mode - GET_DATA(ng.type_flags); + GET_DATA_S32(ng.type_flags); if((ng.type_flags & NG_TYPE_TEAM) && !(Netgame.type_flags & NG_TYPE_TEAM)){ multi_team_reset(); } @@ -698,7 +709,7 @@ void multi_options_process_packet(unsigned char *data, header *hinfo) Netgame.type_flags = ng.type_flags; // new respawn count - GET_DATA(Netgame.respawn); + GET_DATA_U32(Netgame.respawn); // name string memset(str,255,0); @@ -759,6 +770,12 @@ void multi_options_process_packet(unsigned char *data, header *hinfo) // get the netgame options case MULTI_OPTION_SERVER: GET_DATA(Netgame.options); + Netgame.options.flags = INTEL_INT( Netgame.options.flags ); + Netgame.options.respawn = INTEL_INT( Netgame.options.respawn ); + Netgame.options.voice_token_wait = INTEL_INT( Netgame.options.voice_token_wait ); + Netgame.options.voice_record_time = INTEL_INT( Netgame.options.voice_record_time ); + Netgame.options.kill_limit = INTEL_INT( Netgame.options.kill_limit ); + Netgame.options.mission_time_limit = (fix)INTEL_INT( Netgame.options.mission_time_limit ); // if we're a standalone set for no sound, do so here if((Game_mode & GM_STANDALONE_SERVER) && !Multi_options_g.std_voice){ @@ -796,9 +813,11 @@ void multi_options_process_packet(unsigned char *data, header *hinfo) // local netplayer options case MULTI_OPTION_LOCAL: if(player_index == -1){ - GET_DATA(bogus); - } else { + GET_DATA(bogus); //data not used, so don't swap! + } else { GET_DATA(Net_players[player_index].p_info.options); + Net_players[player_index].p_info.options.flags = INTEL_INT( Net_players[player_index].p_info.options.flags ); + Net_players[player_index].p_info.options.obj_update_level = INTEL_INT( Net_players[player_index].p_info.options.obj_update_level ); } break; } diff --git a/src/network/multi_pmsg.cpp b/src/network/multi_pmsg.cpp index aab962e..3793aa2 100644 --- a/src/network/multi_pmsg.cpp +++ b/src/network/multi_pmsg.cpp @@ -13,6 +13,9 @@ * $Author$ * * $Log$ + * Revision 1.5 2004/06/11 01:38:28 tigital + * byte-swapping changes for bigendian systems + * * Revision 1.4 2002/06/09 04:41:23 relnev * added copyright header * @@ -727,13 +730,13 @@ void multi_msg_send_squadmsg_packet(net_player *target,net_player *source,int co BUILD_HEADER(SQUADMSG_PLAYER); // add the command and targeting data - ADD_DATA(command); + ADD_DATA_S32(command); // add the id of the guy sending the order - ADD_DATA(source->player_id); + ADD_DATA_S16(source->player_id); // net signature - ADD_DATA(net_sig); + ADD_DATA_U16(net_sig); // targeted subsytem (or -1 if none) s_val = (char)subsys_type; @@ -859,9 +862,9 @@ void multi_msg_process_squadmsg_packet(unsigned char *data, header *hinfo) int offset = HEADER_LENGTH; // get all packet data - GET_DATA(command); - GET_DATA(source_id); - GET_DATA(net_sig); + GET_DATA_S32(command); + GET_DATA_S16(source_id); + GET_DATA_U16(net_sig); GET_DATA(s_val); PACKET_SET_SIZE(); -- 2.39.2