various bugfixes

This commit is contained in:
Jörg Hinrichs 2006-04-02 22:03:12 +00:00
parent c0aaa42bf1
commit c9882f7085
7 changed files with 26 additions and 12 deletions

View File

@ -508,7 +508,7 @@ void mouse_handler::left_click(const SDL_MouseButtonEvent& event, const bool bro
}
}
if(clear_shroud(*gui_, status_, map_, gameinfo_, units_, teams_, team_num_)) {
if(clear_shroud(*gui_, status_, map_, gameinfo_, units_, teams_, team_num_ - 1)) {
clear_undo_stack();
}
@ -530,7 +530,7 @@ void mouse_handler::left_click(const SDL_MouseButtonEvent& event, const bool bro
enemy == units_.end() && !current_route_.steps.empty() &&
current_route_.steps.front() == selected_hex_) {
move_unit_along_current_route();
if(clear_shroud(*gui_, status_, map_, gameinfo_, units_, teams_, team_num_)) {
if(clear_shroud(*gui_, status_, map_, gameinfo_, units_, teams_, team_num_ - 1)) {
clear_undo_stack();
}
} else {

View File

@ -150,14 +150,20 @@ void playmp_controller::after_human_turn(){
//send one more time to make sure network is up-to-date.
turn_data_->send_data();
if (turn_data_ != NULL){
delete turn_data_;
turn_data_ = NULL;
}
playsingle_controller::after_human_turn();
}
void playmp_controller::finish_side_turn(){
play_controller::finish_side_turn();
//just in case due to an exception turn_data_ has not been deleted in after_human_turn
if (turn_data_ != NULL){
delete turn_data_;
turn_data_ = NULL;
}
}

View File

@ -44,6 +44,7 @@ playsingle_controller::playsingle_controller(const config& level, const game_dat
generator_setter(&recorder), cursor_setter(cursor::NORMAL), replay_sender_(recorder)
{
end_turn_ = false;
replaying_ = false;
}
void playsingle_controller::init_gui(){
@ -148,6 +149,8 @@ LEVEL_RESULT playsingle_controller::play_scenario(const std::vector<config*>& st
fire_start(!loading_game_);
gui_->recalculate_minimap();
bool replaying_ = (recorder.at_end() == false);
LOG_NG << "starting main loop\n" << (SDL_GetTicks() - ticks_) << "\n";
for(; ; first_player_ = 0) {
play_turn();
@ -308,29 +311,28 @@ void playsingle_controller::play_turn(){
gui_->invalidate_game_status();
events::raise_draw_event();
LOG_NG << "turn: " << current_turn_++ << "\n";
LOG_NG << "turn: " << current_turn_ << "\n";
current_turn_++;
bool replaying = (recorder.at_end() == false);
for(player_number_ = first_player_ + 1; player_number_ <= teams_.size(); player_number_++) {
init_side(player_number_ - 1);
if (replaying){
if (replaying_){
const hotkey::basic_handler key_events_handler(gui_);
LOG_NG << "doing replay " << player_number_ << "\n";
try {
replaying = ::do_replay(*gui_,map_,gameinfo_,units_,teams_,
replaying_ = ::do_replay(*gui_,map_,gameinfo_,units_,teams_,
player_number_,status_,gamestate_);
} catch(replay::error&) {
gui::show_dialog(*gui_,NULL,"",_("The file you have tried to load is corrupt"),gui::OK_ONLY);
replaying = false;
replaying_ = false;
}
LOG_NG << "result of replay: " << (replaying?"true":"false") << "\n";
LOG_NG << "result of replay: " << (replaying_?"true":"false") << "\n";
}
check_music(replaying);
check_music(replaying_);
if (!replaying){
if (!replaying_){
play_side(player_number_);
}

View File

@ -68,6 +68,7 @@ protected:
bool end_turn_;
bool player_type_changed_;
bool replaying_;
private:
};

View File

@ -30,6 +30,10 @@ turn_info::turn_info(const game_data& gameinfo, game_state& state_of_game,
gui_.enable_menu("endturn", mode == PLAY_TURN);
}
turn_info::~turn_info(){
undo_stack_.clear();
}
void turn_info::turn_slice()
{
events::pump();

View File

@ -44,6 +44,8 @@ public:
std::vector<team>& teams, unsigned int team_num, unit_map& units,
TURN_MODE mode, replay_network_sender& network_sender);
~turn_info();
void turn_slice();
void sync_network();

View File

@ -138,7 +138,6 @@ const bool replay_controller::is_loading_game(){
void replay_controller::reset_replay(){
is_playing_ = false;
current_turn_ = 1;
player_number_ = 1;
recorder.start_replay();
units_ = *(new unit_map(units_start_));