mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-30 11:04:50 +00:00
Rewrite some of my earlier changes to be less intrusive,
fixing some side-effect bugs.
This commit is contained in:
parent
fa16daecf7
commit
e493804a88
@ -389,13 +389,6 @@ void play_controller::init_gui(){
|
||||
}
|
||||
}
|
||||
|
||||
void play_controller::init_turn(){
|
||||
std::stringstream turn_stream;
|
||||
turn_stream << status_.turn();
|
||||
game_events::fire("turn " + turn_stream.str());
|
||||
game_events::fire("new turn");
|
||||
}
|
||||
|
||||
void play_controller::init_side(const unsigned int team_index, bool /*is_replay*/){
|
||||
log_scope("player turn");
|
||||
team& current_team = teams_[team_index];
|
||||
@ -509,6 +502,8 @@ void play_controller::finish_turn(){
|
||||
update_locker lock_display(gui_->video(),recorder.is_skipping());
|
||||
const std::string turn_num = event_stream.str();
|
||||
gamestate_.set_variable("turn_number",turn_num);
|
||||
game_events::fire("turn " + turn_num);
|
||||
game_events::fire("new turn");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,6 @@ protected:
|
||||
void fire_prestart(bool execute);
|
||||
void fire_start(bool execute);
|
||||
virtual void init_gui();
|
||||
void init_turn();
|
||||
virtual void init_side(const unsigned int team_index, bool is_replay = false);
|
||||
void place_sides_in_preferred_locations(gamemap& map, const config::child_list& sides);
|
||||
virtual void finish_side_turn();
|
||||
|
@ -47,6 +47,7 @@ playsingle_controller::playsingle_controller(const config& level,
|
||||
player_type_changed_(false),
|
||||
replaying_(false),
|
||||
turn_over_(false),
|
||||
skip_next_turn_(false),
|
||||
victory_music_(),
|
||||
defeat_music_()
|
||||
{
|
||||
@ -516,13 +517,13 @@ void playsingle_controller::play_turn(bool save)
|
||||
|
||||
|
||||
for(player_number_ = first_player_; player_number_ <= teams_.size(); player_number_++) {
|
||||
// If a side is empty skip over it.
|
||||
if (current_team().is_empty()) continue;
|
||||
try {
|
||||
if (player_number_ == first_player_) {
|
||||
init_turn();
|
||||
if (skip_next_turn_) {
|
||||
skip_next_turn_ = false;
|
||||
throw end_turn_exception();
|
||||
}
|
||||
// If a side is empty skip over it.
|
||||
if (current_team().is_empty()) continue;
|
||||
|
||||
init_side(player_number_ - 1);
|
||||
} catch (end_turn_exception) {
|
||||
if (current_team().is_network() == false) {
|
||||
@ -572,7 +573,12 @@ void playsingle_controller::play_turn(bool save)
|
||||
// Time has run out
|
||||
check_time_over();
|
||||
|
||||
finish_turn();
|
||||
try {
|
||||
finish_turn();
|
||||
} catch (end_turn_exception) {
|
||||
// If [end_turn] is encountered, skip the first existing side's turn.
|
||||
skip_next_turn_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void playsingle_controller::play_side(const unsigned int team_index, bool save)
|
||||
|
@ -84,6 +84,7 @@ protected:
|
||||
bool player_type_changed_;
|
||||
bool replaying_;
|
||||
bool turn_over_;
|
||||
bool skip_next_turn_;
|
||||
private:
|
||||
void report_victory(std::stringstream& report,
|
||||
end_level_exception& end_level,
|
||||
|
@ -63,7 +63,8 @@ replay_controller::replay_controller(const config& level,
|
||||
delay_(0),
|
||||
is_playing_(false),
|
||||
show_everything_(false),
|
||||
show_team_(1)
|
||||
show_team_(1),
|
||||
skip_next_turn_(false)
|
||||
{
|
||||
init();
|
||||
gamestate_start_ = gamestate_;
|
||||
@ -325,8 +326,9 @@ void replay_controller::play_side(const unsigned int /*team_index*/, bool){
|
||||
|
||||
try{
|
||||
try{
|
||||
if (player_number_ == 1) {
|
||||
play_controller::init_turn();
|
||||
if (skip_next_turn_) {
|
||||
skip_next_turn_ = false;
|
||||
throw end_turn_exception();
|
||||
}
|
||||
play_controller::init_side(player_number_ - 1, true);
|
||||
|
||||
@ -355,7 +357,11 @@ void replay_controller::play_side(const unsigned int /*team_index*/, bool){
|
||||
|
||||
if (static_cast<size_t>(player_number_) > teams_.size()){
|
||||
status_.next_turn();
|
||||
finish_turn();
|
||||
try {
|
||||
finish_turn();
|
||||
} catch (end_turn_exception) {
|
||||
skip_next_turn_ = true;
|
||||
}
|
||||
player_number_ = 1;
|
||||
current_turn_++;
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ private:
|
||||
|
||||
bool show_everything_;
|
||||
unsigned int show_team_;
|
||||
bool skip_next_turn_;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user