From 728442ff96700321547965de98d07274261a013b Mon Sep 17 00:00:00 2001 From: zicodxx Date: Wed, 2 Feb 2011 23:51:29 +0100 Subject: [PATCH] Little more smoothness for Multiplayer: Before dropping Powerups in random segment, make sure it's accessible by the player who drops it; Got rid of goto in InitPlayerPositions() and made code more D2-ish; Allow host to send 50 object/extra packets per second which does not overload network stack, yet but speeds up joining --- CHANGELOG.txt | 1 + main/fireball.c | 8 ++++---- main/gameseq.c | 25 ++++++++++++------------- main/net_ipx.c | 2 +- main/net_udp.c | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 2a510db1c..692914e83 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,7 @@ D1X-Rebirth Changelog -------- arch/include/event.h, arch/include/joy.h, arch/include/key.h, arch/include/mouse.h, arch/sdl/event.c, arch/sdl/joy.c, arch/sdl/key.c, arch/sdl/mouse.c, main/automap.c, main/endlevel.c, main/game.c, main/gamecntl.c, main/inferno.c, main/kconfig.c, main/kconfig.h, main/multi.c, main/newmenu.c, main/slew.c: Added event types for all input actions; Rewrote kconfig code to work with events; static defined inputs will not trigger kconfig-mapped inputs anymore; Simplified keyboard, mouse and joystick code a lot due to event-based handling; Added function to toggle SDL key repeats on and off; Put timer_update() to event_process; Removed return when event_poll() is idle to get cursor hiding to work again; Added a small delay between cursoe hiding and re-enabling to cursor will not accidentially enable by SDL event centering cursor while hiding arch/ogl/ogl.c: After rendering Reboot reticle, reset glLineWidth to default value again +main/fireball.c, main/gameseq.c, main/net_ipx.c, main/net_udp.c: Little more smoothness for Multiplayer: Before dropping Powerups in random segment, make sure it's accessible by the player who drops it; Got rid of goto in InitPlayerPositions() and made code more D2-ish; Allow host to send 50 object/extra packets per second which does not overload network stack, yet but speeds up joining 20110126 -------- diff --git a/main/fireball.c b/main/fireball.c index 998ae461c..e66c3622e 100644 --- a/main/fireball.c +++ b/main/fireball.c @@ -393,9 +393,8 @@ int pick_connected_segment(object *objp, int max_depth) return -1; } -#define BASE_NET_DROP_DEPTH 10 +#define BASE_NET_DROP_DEPTH 10 -#ifdef NETWORK // ------------------------------------------------------------------------------------------------------ // Choose segment to drop a powerup in. // For all active net players, try to create a N segment path from the player. If possible, return that @@ -430,7 +429,9 @@ int choose_drop_segment(void) } if (segnum == -1) { - return (d_rand() * Highest_segment_index) >> 15; + while (cur_drop_depth > 0 && segnum == -1) // before dropping in random segment, try to find ANY segment which is connected to the player responsible for the drop so object will not spawn in inaccessible areas + segnum = pick_connected_segment(&Objects[Players[Player_num].objnum], --cur_drop_depth); + return ((segnum == -1)?((d_rand() * Highest_segment_index) >> 15):segnum); // basically it should be impossible segnum == -1 now... but oh well... } else return segnum; @@ -483,7 +484,6 @@ void maybe_drop_net_powerup(int powerup_type) object_create_explosion(segnum, &new_pos, i2f(5), VCLIP_POWERUP_DISAPPEARANCE ); } } -#endif // ------------------------------------------------------------------------------------------------------ // Return true if current segment contains some object. diff --git a/main/gameseq.c b/main/gameseq.c index 1b1d829ba..fbce9b3e1 100644 --- a/main/gameseq.c +++ b/main/gameseq.c @@ -1331,15 +1331,14 @@ void InitPlayerPosition(int random) if (! ((Game_mode & GM_MULTI) && !(Game_mode&GM_MULTI_COOP)) ) // If not deathmatch NewPlayer = Player_num; -#ifdef NETWORK else if (random == 1) { int i, closest = -1, trys=0; fix closest_dist = 0x7ffffff, dist; + timer_update(); + d_srand((fix)timer_query()); do { - timer_update(); - d_srand((fix)timer_query()); trys++; NewPlayer = d_rand() % NumNetPlayerPositions; @@ -1348,28 +1347,28 @@ void InitPlayerPosition(int random) for (i=0; i= 0) ) { closest_dist = dist; closest = i; } } } - } while ( (closest_dist= 0); Assert(NewPlayer < NumNetPlayerPositions); - ConsoleObject->pos = Player_init[NewPlayer].pos; ConsoleObject->orient = Player_init[NewPlayer].orient; - - obj_relink(ConsoleObject-Objects,Player_init[NewPlayer].segnum); - -done: + obj_relink(ConsoleObject-Objects,Player_init[NewPlayer].segnum); reset_player_object(); reset_cruise(); } diff --git a/main/net_ipx.c b/main/net_ipx.c index 097e4a60a..37b5fd75f 100644 --- a/main/net_ipx.c +++ b/main/net_ipx.c @@ -1310,7 +1310,7 @@ void net_ipx_send_objects(void) int player_num = IPX_sync_player.player.connected; static fix64 last_send_time = 0; - if (last_send_time + (F1_0/10) > timer_query()) + if (last_send_time + (F1_0/50) > timer_query()) return; last_send_time = timer_query(); diff --git a/main/net_udp.c b/main/net_udp.c index ae5576519..839d8649e 100644 --- a/main/net_udp.c +++ b/main/net_udp.c @@ -1354,7 +1354,7 @@ void net_udp_send_objects(void) 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()) + if (last_send_time + (F1_0/50) > timer_query()) return; last_send_time = timer_query(); @@ -4567,7 +4567,7 @@ void net_udp_send_extras () { static fix64 last_send_time = 0; - if (last_send_time + (F1_0/10) > timer_query()) + if (last_send_time + (F1_0/50) > timer_query()) return; last_send_time = timer_query();