From 0177a6f2aebfc0768078553731d8300f2108c94a Mon Sep 17 00:00:00 2001 From: zicodxx Date: Wed, 19 Jan 2011 00:07:06 +0100 Subject: [PATCH] Instead of calling object/extras sending every frame, use a delay of 100ms between packet send to not overload the network stack --- CHANGELOG.txt | 1 + main/net_ipx.c | 5 +++++ main/net_udp.c | 17 ++++++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 0e0c284dd..40812f44e 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,7 @@ D1X-Rebirth Changelog -------- main/gamecntl.c, main/gameseq.c: Allowing loading a savestate while being in death sequence and resetting Dead_player_camera correctly in init_player_stats_level() so forther death sequences won't screw up main/net_udp.c: In net_udp_send_objects() player_num byte was not considered for mode 1 resulting on incorrect object count for this mode +main/net_ipx.c, main/net_udp.c: Instead of calling object/extras sending every frame, use a delay of 100ms between packet send to not overload the network stack 20110117 -------- diff --git a/main/net_ipx.c b/main/net_ipx.c index 7d2375365..67a95a732 100644 --- a/main/net_ipx.c +++ b/main/net_ipx.c @@ -1308,6 +1308,11 @@ void net_ipx_send_objects(void) int obj_count_frame = 0; int player_num = IPX_sync_player.player.connected; + static fix64 last_send_time = 0; + + if (last_send_time + (F1_0/10) > timer_query()) + return; + last_send_time = timer_query(); // Send clear objects array trigger and send player num diff --git a/main/net_udp.c b/main/net_udp.c index 24d5f90b9..5c00a8e74 100644 --- a/main/net_udp.c +++ b/main/net_udp.c @@ -1352,6 +1352,11 @@ void net_udp_send_objects(void) sbyte owner, player_num = UDP_sync_player.player.connected; static int obj_count = 0; int loc = 0, i = 0, remote_objnum = 0, obj_count_frame = 0; + static fix64 last_send_time = 0; + + if (last_send_time + (F1_0/10) > timer_query()) + return; + last_send_time = timer_query(); // Send clear objects array trigger and send player num @@ -1451,7 +1456,7 @@ void net_udp_send_objects(void) Network_send_objects = 0; obj_count = 0; - Network_sending_extras=25; // start to send extras + Network_sending_extras=2; // start to send extras VerifyPlayerJoined = Player_joining_extras = player_num; return; @@ -4555,11 +4560,17 @@ int net_udp_get_new_player_num (UDP_sequence_packet *their) void net_udp_send_extras () { + static fix64 last_send_time = 0; + + if (last_send_time + (F1_0/10) > timer_query()) + return; + last_send_time = timer_query(); + Assert (Player_joining_extras>-1); - if (Network_sending_extras==25 && (Netgame.PlayTimeAllowed || Netgame.KillGoal)) + if (Network_sending_extras==2 && (Netgame.PlayTimeAllowed || Netgame.KillGoal)) multi_send_kill_goal_counts(); - if (Network_sending_extras==10) + if (Network_sending_extras==1) multi_send_powcap_update(); Network_sending_extras--;