Fixed control change when giving own team (bug #6639)

This commit is contained in:
Pauli Nieminen 2008-01-30 15:35:18 +00:00
parent 45aa783438
commit b979c5b58d
5 changed files with 25 additions and 19 deletions

View file

@ -9,6 +9,7 @@ Version 1.3.15+svn:
* display reloaded games in yellow instead of green in the game list
as they are also a kind of already running games
* Made era not required while loading save game
* Fixed control change when giving own team (bug #6639)
* miscellaneous and bug fixes:
* Moved destruction of conditional object before the mutex. This should
fix random crash in network disconnect.

View file

@ -2199,14 +2199,7 @@ private:
if (player == preferences::login())
return;
change_side_controller(side,player,true);
teams_[side_num - 1].make_network();
textbox_info_.close(*gui_);
if(team_num == side_num) {
//if it is our turn at the moment, we have to indicate to the
//play_controller, that we are no longer in control
gui_->set_team(0);
throw end_turn_exception(side_num);
}
} else {
//it is not our side, the server will decide if we can change the
//controller (that is if we are host of the game)

View file

@ -346,7 +346,8 @@ void play_controller::init_side(const unsigned int team_index, bool /*is_replay*
&& !current_team.get_disallow_observers()) {
gui_->set_team(size_t(team_index));
}
gui_->set_playing_team(size_t(team_index));
gui_->set_playing_team(size_t(team_index));
std::stringstream player_number_str;
player_number_str << player_number_;

View file

@ -99,13 +99,15 @@ void playmp_controller::play_side(const unsigned int team_index, bool save){
// reset gui to prev human one
if (!teams_[team_index-1].is_human()) {
int t = find_human_team_before(team_index);
if (t > 0) {
gui_->set_team(t-1);
gui_->recalculate_minimap();
gui_->invalidate_all();
gui_->draw();
gui_->update_display();
}
if (t <= 0)
t = gui_->get_playing_team() + 1;
gui_->set_team(t-1);
gui_->recalculate_minimap();
gui_->invalidate_all();
gui_->draw();
gui_->update_display();
}
}
}
@ -174,7 +176,10 @@ void playmp_controller::play_human_turn(){
if(res != network::null_connection) {
try{
turn_data_->process_network_data(cfg,res,backlog,skip_replay_);
if (turn_data_->process_network_data(cfg,res,backlog,skip_replay_) == turn_info::PROCESS_RESTART_TURN)
{
throw end_turn_exception(gui_->get_playing_team() + 1);
}
}
catch (replay::error& e){
process_oos(e.message);

View file

@ -157,22 +157,28 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
if(index < teams_.size()) {
teams_[index].set_current_player(player);
const unit_map::iterator leader = find_leader(units_, side);
bool restart = gui_.get_playing_team() == index;
if(leader != units_.end())
leader->second.rename(player);
if ( (controller == "human") && (!teams_[index].is_human()) ) {
teams_[index].make_human();
if (!teams_[gui_.get_playing_team()].is_human())
{
gui_.set_team(index);
}
teams_[index].make_human();
} else if ( (controller == "network") && (!teams_[index].is_network()) ){
teams_[index].make_network();
} else if ( (controller == "ai") && (!teams_[index].is_ai()) ) {
teams_[index].make_ai();
}
return PROCESS_RESTART_TURN;
else
{
restart = false;
}
return restart ? PROCESS_RESTART_TURN : PROCESS_CONTINUE;
}
}