Centralized UDP Broadcast function for IPv4 and IPv6 calls - patch by Kp

This commit is contained in:
zicodxx 2013-01-03 16:08:39 +01:00
parent f3cad7ce27
commit b68e3f430c
2 changed files with 20 additions and 24 deletions

View file

@ -1,5 +1,9 @@
D2X-Rebirth Changelog
20130103
--------
main/net_udp.c: Centralized UDP Broadcast function for IPv4 and IPv6 calls - patch by Kp
20121102
--------
arch/include/key.h, arch/sdl/key.c, main/kconfig.c: Made key_properties readable in other files; Eliminated key_text variable; Marked unicode_frame_buffer as extern in header - patches by Kp

View file

@ -101,6 +101,8 @@ extern void multi_send_wall_status_specific (int pnum,int wallnum,ubyte type,uby
extern void multi_send_light_specific (int pnum,int segnum,ubyte val);
extern void multi_send_trigger_specific (char pnum,char trig);
static void net_udp_broadcast_game_info(ubyte info_upid);
// Variables
int UDP_num_sendto = 0, UDP_len_sendto = 0, UDP_num_recvfrom = 0, UDP_len_recvfrom = 0;
UDP_mdata_info UDP_MData;
@ -2290,6 +2292,14 @@ void net_udp_send_game_info(struct _sockaddr sender_addr, ubyte info_upid)
}
}
static void net_udp_broadcast_game_info(ubyte info_upid)
{
net_udp_send_game_info(GBcast, info_upid);
#ifdef IPv6
net_udp_send_game_info(GMcast_v6, info_upid);
#endif
}
/* Send game info to all players in this game. Also send lite_info for people watching the netlist */
void net_udp_send_netgame_update()
{
@ -2301,10 +2311,7 @@ void net_udp_send_netgame_update()
continue;
net_udp_send_game_info(Netgame.players[i].protocol.udp.addr, UPID_GAME_INFO);
}
net_udp_send_game_info(GBcast, UPID_GAME_INFO_LITE);
#ifdef IPv6
net_udp_send_game_info(GMcast_v6, UPID_GAME_INFO_LITE);
#endif
net_udp_broadcast_game_info(UPID_GAME_INFO_LITE);
}
int net_udp_send_request(void)
@ -3475,10 +3482,7 @@ int net_udp_send_sync(void)
net_udp_dump_player(Netgame.players[i].protocol.udp.addr, DUMP_ABORTED);
net_udp_send_game_info(Netgame.players[i].protocol.udp.addr, UPID_GAME_INFO);
}
net_udp_send_game_info(GBcast, UPID_GAME_INFO_LITE);
#ifdef IPv6
net_udp_send_game_info(GMcast_v6, UPID_GAME_INFO_LITE);
#endif
net_udp_broadcast_game_info(UPID_GAME_INFO_LITE);
return -1;
}
@ -3656,10 +3660,7 @@ abort:
net_udp_dump_player(Netgame.players[i].protocol.udp.addr, DUMP_ABORTED);
net_udp_send_game_info(Netgame.players[i].protocol.udp.addr, UPID_GAME_INFO);
}
net_udp_send_game_info(GBcast, UPID_GAME_INFO_LITE);
#ifdef IPv6
net_udp_send_game_info(GMcast_v6, UPID_GAME_INFO_LITE);
#endif
net_udp_broadcast_game_info(UPID_GAME_INFO_LITE);
Netgame.numplayers = save_nplayers;
Network_status = NETSTAT_MENU;
@ -3777,10 +3778,7 @@ int net_udp_start_game(void)
Game_mode = GM_GAME_OVER;
return 0; // see if we want to tweak the game we setup
}
net_udp_send_game_info(GBcast, UPID_GAME_INFO_LITE); // game started. broadcast our current status to everyone who wants to know
#ifdef IPv6
net_udp_send_game_info(GMcast_v6, UPID_GAME_INFO_LITE); // game started. broadcast our current status to everyone who wants to know
#endif
net_udp_broadcast_game_info(UPID_GAME_INFO_LITE); // game started. broadcast our current status to everyone who wants to know
return 1; // don't keep params menu or mission listbox (may want to join a game next time)
}
@ -4021,10 +4019,7 @@ void net_udp_leave_game()
continue;
net_udp_send_game_info(Netgame.players[i].protocol.udp.addr, UPID_GAME_INFO);
}
net_udp_send_game_info(GBcast, UPID_GAME_INFO_LITE);
#ifdef IPv6
net_udp_send_game_info(GMcast_v6, UPID_GAME_INFO_LITE);
#endif
net_udp_broadcast_game_info(UPID_GAME_INFO_LITE);
N_players=nsave;
#ifdef USE_TRACKER
if( Netgame.Tracker )
@ -4185,10 +4180,7 @@ void net_udp_do_frame(int force, int listen)
if (multi_i_am_master() && time>=last_bcast_time+(F1_0*10))
{
last_bcast_time = time;
net_udp_send_game_info(GBcast, UPID_GAME_INFO_LITE);
#ifdef IPv6
net_udp_send_game_info(GMcast_v6, UPID_GAME_INFO_LITE);
#endif
net_udp_broadcast_game_info(UPID_GAME_INFO_LITE);
}
#ifdef USE_TRACKER