diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 8ba013896..9467c7539 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ D2X-Rebirth Changelog +20110515 +-------- +main/multi.c: Solved possible issue when setting new Bounty_target via host messing up scores or new target itself - only set if player decided why to unset Bounty_target, keeping code flow and game logic in order; Fixed two compiler warnings regarding set but unused variables + 20110513 -------- main/multi.c: Send player position also when multi_send_player_explode() is called so powerups drop at the right spot in case the respawn packet arrives first diff --git a/main/multi.c b/main/multi.c index 3433d7600..b5db5833d 100644 --- a/main/multi.c +++ b/main/multi.c @@ -131,7 +131,8 @@ fix Show_kill_list_timer = 0; char Multi_is_guided=0; char PKilledFlags[MAX_NUM_NET_PLAYERS]; -int Bounty_target = 0; // Target for bounty mode netgame +int Bounty_target = 0, new_Bounty_target = -1; // Target for bounty mode netgame. NOTE: new_Bounty_target is a helper variable solving issues in case multi_do_bounty and multi_do_kill/multi_disconnect_player are processed in wrong order in case Bounty_target suicide/left game + int multi_sending_message[MAX_NUM_NET_PLAYERS] = { 0,0,0,0,0,0,0,0 }; int multi_defining_message = 0; @@ -763,21 +764,32 @@ void multi_compute_kill(int killer, int killed) HUD_init_message(HM_MULTI, "%s %s", killed_name, TXT_SUICIDE); /* Bounty mode needs some lovin' */ - if( Game_mode & GM_BOUNTY && killed_pnum == Bounty_target && multi_i_am_master() ) + if( Game_mode & GM_BOUNTY && killed_pnum == Bounty_target ) { - /* Select a random number */ - int new_bounty_target = d_rand() % MAX_NUM_NET_PLAYERS; - - /* Make sure they're valid: Don't check against kill flags, - * just in case everyone's dead! */ - while( !Players[new_bounty_target].connected ) - new_bounty_target = d_rand() % MAX_NUM_NET_PLAYERS; - - /* Select new target */ - multi_new_bounty_target( new_bounty_target ); - - /* Send this new data */ - multi_send_bounty(); + if ( multi_i_am_master() ) + { + /* Select a random number */ + int new = d_rand() % MAX_NUM_NET_PLAYERS; + + /* Make sure they're valid: Don't check against kill flags, + * just in case everyone's dead! */ + while( !Players[new].connected ) + new = d_rand() % MAX_NUM_NET_PLAYERS; + + /* Select new target */ + multi_new_bounty_target( new ); + + /* Send this new data */ + multi_send_bounty(); + } + else + { + /* check if we already got a new target from host. if yes set it, if not just unset the current one. */ + if ( new_Bounty_target != -1 ) + Bounty_target = new_Bounty_target; + else + Bounty_target = -1; + } } } @@ -2025,21 +2037,32 @@ void multi_disconnect_player(int pnum) } // Bounty target left - select a new one - if( Game_mode & GM_BOUNTY && pnum == Bounty_target && multi_i_am_master() ) + if( Game_mode & GM_BOUNTY && pnum == Bounty_target ) { - /* Select a random number */ - int new_bounty_target = d_rand() % MAX_NUM_NET_PLAYERS; - - /* Make sure they're valid: Don't check against kill flags, - * just in case everyone's dead! */ - while( !Players[new_bounty_target].connected ) - new_bounty_target = d_rand() % MAX_NUM_NET_PLAYERS; - - /* Select new target */ - multi_new_bounty_target( new_bounty_target ); - - /* Send this new data */ - multi_send_bounty(); + if ( multi_i_am_master() ) + { + /* Select a random number */ + int new = d_rand() % MAX_NUM_NET_PLAYERS; + + /* Make sure they're valid: Don't check against kill flags, + * just in case everyone's dead! */ + while( !Players[new].connected ) + new = d_rand() % MAX_NUM_NET_PLAYERS; + + /* Select new target */ + multi_new_bounty_target( new ); + + /* Send this new data */ + multi_send_bounty(); + } + else + { + /* check if we already got a new target from host. if yes set it, if not just unset the current one. */ + if ( new_Bounty_target != -1 ) + Bounty_target = new_Bounty_target; + else + Bounty_target = -1; + } } multi_sending_message[pnum] = 0; } @@ -3308,6 +3331,7 @@ void multi_prep_level(void) PhallicMan=-1; Drop_afterburner_blob_flag=0; Bounty_target = 0; + new_Bounty_target = -1; multi_consistency_error(1); for (i=0;i