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

This commit is contained in:
zicodxx 2011-02-02 23:51:34 +01:00
parent 21836c5c6b
commit 3c9c7af995
5 changed files with 17 additions and 24 deletions

View file

@ -4,6 +4,7 @@ D2X-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/movie.c, 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
--------

View file

@ -506,8 +506,7 @@ int pick_connected_segment(object *objp, int max_depth)
return -1;
}
#ifdef NETWORK
#define BASE_NET_DROP_DEPTH 8
#define BASE_NET_DROP_DEPTH 8
// ------------------------------------------------------------------------------------------------------
// Choose segment to drop a powerup in.
@ -574,14 +573,14 @@ int choose_drop_segment()
}
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;
}
#endif // NETWORK
#ifdef NETWORK
// ------------------------------------------------------------------------------------------------------
// Drop cloak powerup if in a network game.
@ -628,7 +627,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.

View file

@ -1821,19 +1821,16 @@ void InitPlayerPosition(int random_flag)
{
int NewPlayer=0;
#ifdef NETWORK
if (! ((Game_mode & GM_MULTI) && !(Game_mode&GM_MULTI_COOP)) ) // If not deathmatch
#endif
NewPlayer = Player_num;
#ifdef NETWORK
else if (random_flag == 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;
@ -1842,7 +1839,7 @@ void InitPlayerPosition(int random_flag)
for (i=0; i<N_players; i++ ) {
if ( (i!=Player_num) && (Objects[Players[i].objnum].type == OBJ_PLAYER) ) {
dist = find_connected_distance(&Objects[Players[i].objnum].pos, Objects[Players[i].objnum].segnum, &Player_init[NewPlayer].pos, Player_init[NewPlayer].segnum, 10, WID_FLY_FLAG ); // Used to be 5, search up to 10 segments
dist = find_connected_distance(&Objects[Players[i].objnum].pos, Objects[Players[i].objnum].segnum, &Player_init[NewPlayer].pos, Player_init[NewPlayer].segnum, 15, WID_FLY_FLAG ); // Used to be 5, search up to 15 segments
if ( (dist < closest_dist) && (dist >= 0) ) {
closest_dist = dist;
closest = i;
@ -1850,22 +1847,19 @@ void InitPlayerPosition(int random_flag)
}
}
} while ( (closest_dist<i2f(10*20)) && (trys<MAX_NUM_NET_PLAYERS*2) );
} while ( (closest_dist<i2f(15*20)) && (trys<MAX_NUM_NET_PLAYERS*2) );
}
else {
goto done; // If deathmatch and not random, positions were already determined by sync packet
// If deathmatch and not random, positions were already determined by sync packet
reset_player_object();
reset_cruise();
return;
}
Assert(NewPlayer >= 0);
Assert(NewPlayer < NumNetPlayerPositions);
#endif
ConsoleObject->pos = Player_init[NewPlayer].pos;
ConsoleObject->orient = Player_init[NewPlayer].orient;
obj_relink(ConsoleObject-Objects,Player_init[NewPlayer].segnum);
#ifdef NETWORK
done:
#endif
reset_player_object();
reset_cruise();
}

View file

@ -1468,7 +1468,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();
@ -5205,7 +5205,7 @@ void net_ipx_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();

View file

@ -1451,7 +1451,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();
@ -4846,7 +4846,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();