savegame reorganization:
...synchronized turn_ and numTurns_ members of play_controller and gamestatus
This commit is contained in:
parent
61e8163c7a
commit
12939fc0ca
4 changed files with 16 additions and 1 deletions
|
@ -1016,6 +1016,8 @@ WML_HANDLER_FUNCTION(modify_turns, /*event_info*/, cfg)
|
|||
} else if(!value.empty()) {
|
||||
rsrc.status_ptr->add_turns(-rsrc.status_ptr->number_of_turns());
|
||||
rsrc.status_ptr->add_turns(lexical_cast_default<int>(value,-1));
|
||||
rsrc.controller->add_turns(-rsrc.controller->number_of_turns());
|
||||
rsrc.controller->add_turns(lexical_cast_default<int>(value,-1));
|
||||
}
|
||||
// change current turn only after applying mods
|
||||
if(!current.empty()) {
|
||||
|
@ -1026,6 +1028,7 @@ WML_HANDLER_FUNCTION(modify_turns, /*event_info*/, cfg)
|
|||
ERR_NG << "attempted to change current turn number to one out of range (" << new_turn_number << ") or less than current turn\n";
|
||||
} else if(new_turn_number_u != current_turn_number) {
|
||||
rsrc.status_ptr->set_turn(new_turn_number_u);
|
||||
rsrc.controller->set_turn(new_turn_number_u);
|
||||
rsrc.state_of_game->set_variable("turn_number", str_cast<size_t>(new_turn_number_u));
|
||||
rsrc.screen->new_turn();
|
||||
}
|
||||
|
|
|
@ -73,6 +73,8 @@ play_controller::play_controller(const config& level, game_state& state_of_game,
|
|||
skip_replay_(skip_replay),
|
||||
linger_(false),
|
||||
previous_turn_(0),
|
||||
turn_(status_.turn()),
|
||||
numTurns_(num_turns),
|
||||
savenames_(),
|
||||
wml_commands_(),
|
||||
victory_music_(),
|
||||
|
|
|
@ -858,7 +858,11 @@ void playsingle_controller::handle_generic_event(const std::string& name){
|
|||
}
|
||||
|
||||
void playsingle_controller::check_time_over(){
|
||||
if(!status_.next_turn()) {
|
||||
//FIXME: remove these assertions once turn functionality is removed from gamestatus
|
||||
assert (status_.turn() == turn_);
|
||||
assert (status_.number_of_turns() == number_of_turns());
|
||||
bool b = next_turn();
|
||||
if(!status_.next_turn() && b) {
|
||||
|
||||
if(non_interactive()) {
|
||||
std::cout << "time over (draw)\n";
|
||||
|
|
|
@ -163,6 +163,8 @@ void replay_controller::reset_replay(){
|
|||
is_playing_ = false;
|
||||
player_number_ = 1;
|
||||
current_turn_ = 1;
|
||||
turn_ = status_start_.turn();
|
||||
numTurns_ = status_start_.number_of_turns();
|
||||
recorder.start_replay();
|
||||
units_ = units_start_;
|
||||
status_ = status_start_;
|
||||
|
@ -359,6 +361,10 @@ void replay_controller::play_side(const unsigned int /*team_index*/, bool){
|
|||
player_number_++;
|
||||
|
||||
if (static_cast<size_t>(player_number_) > teams_.size()) {
|
||||
//FIXME: remove these assertions once turn functionality is removed from gamestatus
|
||||
assert (status_.turn() == turn_);
|
||||
assert (status_.number_of_turns() == number_of_turns());
|
||||
next_turn();
|
||||
status_.next_turn();
|
||||
try {
|
||||
finish_turn();
|
||||
|
|
Loading…
Add table
Reference in a new issue