attempt to fix replay 'play turn' and 'play side turn'

http://gna.org/bugs/?24447

This also replaces  broken 'new replay_stop_condition();' instruction
with 'stop_replay();'
This commit is contained in:
gfgtdf 2016-02-26 17:42:14 +01:00
parent 944f68b136
commit 39b61a081b
3 changed files with 23 additions and 31 deletions

View File

@ -772,6 +772,9 @@ REPLAY_RETURN do_replay_handle(bool one_move)
else
{
resources::controller->do_init_side();
if (one_move) {
return REPLAY_FOUND_INIT_TURN;
}
}
}

View File

@ -157,6 +157,7 @@ enum REPLAY_RETURN
REPLAY_RETURN_AT_END,
REPLAY_FOUND_DEPENDENT,
REPLAY_FOUND_END_TURN,
REPLAY_FOUND_INIT_TURN,
REPLAY_FOUND_END_MOVE,
REPLAY_FOUND_END_LEVEL
};

View File

@ -42,44 +42,29 @@ struct replay_play_nostop : public replay_controller::replay_stop_condition
virtual bool should_stop() { return false; }
};
struct replay_play_moves_base : public replay_controller::replay_stop_condition
struct replay_play_moves : public replay_controller::replay_stop_condition
{
int moves_todo_;
bool started_;
replay_play_moves_base(int moves_todo, bool started = true) : moves_todo_(moves_todo), started_(started) {}
virtual void move_done() { if(started_) { --moves_todo_; } }
replay_play_moves(int moves_todo) : moves_todo_(moves_todo) {}
virtual void move_done() { --moves_todo_; }
virtual bool should_stop() { return moves_todo_ == 0; }
void start() { started_ = true; }
};
struct replay_play_moves : public replay_play_moves_base
{
replay_play_moves(int moves_todo) : replay_play_moves_base(moves_todo, true) {}
};
struct replay_play_turn : public replay_play_moves_base
struct replay_play_turn : public replay_controller::replay_stop_condition
{
int turn_begin_;
replay_play_turn(int turn_begin) : replay_play_moves_base(1, false), turn_begin_(turn_begin) {}
virtual void new_side_turn(int , int turn)
{
if (turn != turn_begin_) {
start();
}
}
int turn_current_;
replay_play_turn(int turn_begin) : turn_begin_(turn_begin), turn_current_(turn_begin) {}
virtual void new_side_turn(int , int turn) { turn_current_ = turn; }
virtual bool should_stop() { return turn_begin_ != turn_current_; }
};
struct replay_play_side : public replay_play_moves_base
struct replay_play_side : public replay_controller::replay_stop_condition
{
int turn_begin_;
int side_begin_;
replay_play_side(int turn_begin, int side_begin) : replay_play_moves_base(1, false), turn_begin_(turn_begin), side_begin_(side_begin) {}
virtual void new_side_turn(int side , int turn)
{
if (turn != turn_begin_ || side != side_begin_) {
start();
}
}
bool next_side_;
replay_play_side() : next_side_(false) {}
virtual void new_side_turn(int , int) { next_side_ = true; }
virtual bool should_stop() { return next_side_; }
};
}
@ -265,7 +250,7 @@ void replay_controller::replay_next_turn()
void replay_controller::replay_next_side()
{
stop_condition_.reset(new replay_play_side(controller_.gamestate().tod_manager_.turn(), controller_.current_side()));
stop_condition_.reset(new replay_play_side());
}
void replay_controller::replay_next_move()
@ -308,7 +293,6 @@ bool replay_controller::recorder_at_end() const
REPLAY_RETURN replay_controller::play_side_impl()
{
stop_condition_->new_side_turn(controller_.current_side(), controller_.gamestate().tod_manager_.turn());
while(!return_to_play_side_ && !static_cast<playsingle_controller&>(controller_).get_player_type_changed())
{
if(!stop_condition_->should_stop())
@ -326,7 +310,11 @@ REPLAY_RETURN replay_controller::play_side_impl()
return res;
}
if(res == REPLAY_RETURN_AT_END) {
new replay_stop_condition();
stop_replay();
}
if(res == REPLAY_FOUND_INIT_TURN)
{
stop_condition_->new_side_turn(controller_.current_side(), controller_.gamestate().tod_manager_.turn());
}
}
controller_.play_slice(false);