Skip to content

Commit

Permalink
remove field replay::skip_
Browse files Browse the repository at this point in the history
We have the information already in play_controller_skip_replay_
  • Loading branch information
gfgtdf committed Mar 1, 2015
1 parent 9d096be commit 8b83504
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 62 deletions.
4 changes: 2 additions & 2 deletions src/actions/heal.cpp
Expand Up @@ -24,7 +24,7 @@
#include "../gettext.hpp"
#include "../log.hpp"
#include "../map.hpp"
#include "../replay.hpp"
#include "../play_controller.hpp"
#include "../resources.hpp"
#include "../team.hpp"
#include "../unit.hpp"
Expand Down Expand Up @@ -352,7 +352,7 @@ void calculate_healing(int side, bool update_display)

const team & viewing_team =
(*resources::teams)[resources::screen->viewing_team()];
if (!recorder.is_skipping() && update_display &&
if (!resources::controller->is_skipping_replay() && update_display &&
patient.is_visible_to_team(viewing_team, resources::gameboard->map(), false) )
{
unit_list.push_front(heal_unit(patient, healers, healing, curing == POISON_CURE));
Expand Down
2 changes: 1 addition & 1 deletion src/game_events/action_wml.cpp
Expand Up @@ -635,7 +635,7 @@ WML_HANDLER_FUNCTION(message, event_info, cfg)
}

has_input = !options.empty() || has_text_input;
if (!has_input && get_replay_source().is_skipping()) {
if (!has_input && resources::controller->is_skipping_replay()) {
// No input to get and the user is not interested either.
return;
}
Expand Down
7 changes: 3 additions & 4 deletions src/play_controller.cpp
Expand Up @@ -195,7 +195,6 @@ void play_controller::init(CVideo& video){
}

loadscreen::start_stage("load level");
recorder.set_skip(false);

LOG_NG << "initializing game_state..." << (SDL_GetTicks() - ticks_) << std::endl;
gamestate_.init(ticks_, *this);
Expand Down Expand Up @@ -424,7 +423,7 @@ void play_controller::do_init_side()
current_team().spend_gold(expense);
}

calculate_healing(player_number_, !skip_replay_);
calculate_healing(player_number_, !is_skipping_replay());
}

// Prepare the undo stack.
Expand All @@ -448,11 +447,11 @@ void play_controller::init_side_end()
if (player_number_ == first_player_)
sound::play_sound(tod.sounds, sound::SOUND_SOURCES);

if (!recorder.is_skipping()){
if (!is_skipping_replay()){
gui_->invalidate_all();
}

if (!recorder.is_skipping() && !skip_replay_ && current_team().get_scroll_to_leader()){
if (!is_skipping_replay() && current_team().get_scroll_to_leader()){
gui_->scroll_to_leader(player_number_,game_display::ONSCREEN,false);
}
whiteboard_manager_->on_init_side();
Expand Down
15 changes: 5 additions & 10 deletions src/playmp_controller.cpp
Expand Up @@ -140,7 +140,7 @@ possible_end_play_signal playmp_controller::play_human_turn()

if(network_reader_.read(cfg)) {
turn_info::PROCESS_DATA_RESULT res;
HANDLE_END_PLAY_SIGNAL( res = turn_data_.process_network_data(cfg, skip_replay_) );
HANDLE_END_PLAY_SIGNAL( res = turn_data_.process_network_data(cfg) );
if (res == turn_info::PROCESS_RESTART_TURN)
{
// Clean undo stack if turn has to be restarted (losing control)
Expand Down Expand Up @@ -212,7 +212,7 @@ possible_end_play_signal playmp_controller::play_idle_loop()
config cfg;
if(network_reader_.read(cfg)) {
turn_info::PROCESS_DATA_RESULT res;
HANDLE_END_PLAY_SIGNAL( res = turn_data_.process_network_data(cfg, skip_replay_) );
HANDLE_END_PLAY_SIGNAL( res = turn_data_.process_network_data(cfg) );

if (res == turn_info::PROCESS_RESTART_TURN)
{
Expand Down Expand Up @@ -332,7 +332,7 @@ void playmp_controller::wait_for_upload()
*gui_, _("Waiting for next scenario..."), cfg);

if(res != network::null_connection) {
if (turn_data_.process_network_data_from_reader(skip_replay_) == turn_info::PROCESS_END_LINGER) {
if (turn_data_.process_network_data_from_reader() == turn_info::PROCESS_END_LINGER) {
break;
}
}
Expand Down Expand Up @@ -388,12 +388,10 @@ possible_end_play_signal playmp_controller::play_network_turn(){
config cfg;
if(network_reader_.read(cfg)) {
if (replay_last_turn_ <= turn()){
if (skip_replay_) {
skip_replay_ = false;
}
skip_replay_ = false;
}
turn_info::PROCESS_DATA_RESULT result;
HANDLE_END_PLAY_SIGNAL ( result = turn_data_.process_network_data(cfg, skip_replay_) );
HANDLE_END_PLAY_SIGNAL ( result = turn_data_.process_network_data(cfg) );
if(player_type_changed_ == true)
{
//we received a player change/quit during waiting in get_user_choice/synced_context::pull_remote_user_input
Expand All @@ -411,13 +409,10 @@ possible_end_play_signal playmp_controller::play_network_turn(){
*/
else if(!recorder.at_end())
{
bool was_skipping = recorder.is_skipping();
recorder.set_skip(skip_replay_);
if(do_replay() == REPLAY_FOUND_END_TURN)
{
break;
}
recorder.set_skip(was_skipping);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/playsingle_controller.cpp
Expand Up @@ -117,7 +117,7 @@ void playsingle_controller::init_gui(){
}
gui_->scroll_to_tile(gamestate_.board_.map().starting_position(1), game_display::WARP);

update_locker lock_display(gui_->video(),recorder.is_skipping());
update_locker lock_display(gui_->video(), is_skipping_replay());
get_hotkey_command_executor()->set_button_state(*gui_);
events::raise_draw_event();
gui_->draw();
Expand Down Expand Up @@ -239,7 +239,7 @@ boost::optional<LEVEL_RESULT> playsingle_controller::play_scenario_init(end_leve

init_gui();
past_prestart = true;
LOG_NG << "first_time..." << (recorder.is_skipping() ? "skipping" : "no skip") << "\n";
LOG_NG << "first_time..." << (is_skipping_replay() ? "skipping" : "no skip") << "\n";

events::raise_draw_event();
try {
Expand Down
17 changes: 6 additions & 11 deletions src/playturn.cpp
Expand Up @@ -75,7 +75,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::sync_network()
//could get data back pertaining to the next turn.
config cfg;
while( (retv == turn_info::PROCESS_CONTINUE) && network_reader_.read(cfg)) {
retv = process_network_data(cfg,false);
retv = process_network_data(cfg);
cfg.clear();
}
send_data();
Expand All @@ -92,20 +92,15 @@ void turn_info::send_data()
}
}

turn_info::PROCESS_DATA_RESULT turn_info::handle_turn(
const config& t,
const bool skip_replay)
turn_info::PROCESS_DATA_RESULT turn_info::handle_turn(const config& t)
{
//t can contain a [command] or a [upload_log]
assert(t.all_children_count() == 1);
/** @todo FIXME: Check what commands we execute when it's our turn! */

bool was_skipping = recorder.is_skipping();
recorder.set_skip(skip_replay);
//note, that this function might call itself recursively: do_replay -> ... -> persist_var -> ... -> handle_generic_event -> sync_network -> handle_turn
recorder.add_config(t, replay::MARK_AS_SENT);
PROCESS_DATA_RESULT retv = replay_to_process_data_result(do_replay());
recorder.set_skip(was_skipping);
return retv;
}

Expand All @@ -116,12 +111,12 @@ void turn_info::do_save()
}
}

turn_info::PROCESS_DATA_RESULT turn_info::process_network_data_from_reader(bool skip_replay)
turn_info::PROCESS_DATA_RESULT turn_info::process_network_data_from_reader()
{
config cfg;
while(this->network_reader_.read(cfg))
{
PROCESS_DATA_RESULT res = process_network_data(cfg, skip_replay);
PROCESS_DATA_RESULT res = process_network_data(cfg);
if(res != PROCESS_CONTINUE)
{
return res;
Expand All @@ -130,7 +125,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data_from_reader(bool
return PROCESS_CONTINUE;
}

turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg, bool skip_replay)
turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg)
{
// we cannot be connected to multiple peers anymore because
// the simple wesnothserver implementation in wesnoth was removed years ago.
Expand Down Expand Up @@ -167,7 +162,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
}
else if (const config &turn = cfg.child("turn"))
{
return handle_turn(turn, skip_replay);
return handle_turn(turn);
}
else if (cfg.has_child("whiteboard"))
{
Expand Down
8 changes: 3 additions & 5 deletions src/playturn.hpp
Expand Up @@ -50,10 +50,10 @@ class turn_info
void send_data();

//function which will process incoming network data received with playturn_network_adapter, and act on it.
PROCESS_DATA_RESULT process_network_data(const config& cfg, bool skip_replay);
PROCESS_DATA_RESULT process_network_data(const config& cfg);

//reads as much data from network_reader_ as possible and processed it.
PROCESS_DATA_RESULT process_network_data_from_reader(bool skip_replay);
PROCESS_DATA_RESULT process_network_data_from_reader();

events::generic_event& host_transfer() { return host_transfer_; }

Expand All @@ -64,9 +64,7 @@ class turn_info
static void change_controller(int side, const std::string& controller);
static void change_side_controller(int side, const std::string& player);
static PROCESS_DATA_RESULT replay_to_process_data_result(REPLAY_RETURN replayreturn);
PROCESS_DATA_RESULT handle_turn(
const config& t,
const bool skip_replay);
PROCESS_DATA_RESULT handle_turn(const config& t);

void do_save();

Expand Down
21 changes: 4 additions & 17 deletions src/replay.cpp
Expand Up @@ -186,14 +186,12 @@ chat_msg::~chat_msg()
replay::replay() :
cfg_(),
pos_(0),
skip_(false),
message_locations()
{}

replay::replay(const config& cfg) :
cfg_(cfg),
pos_(0),
skip_(false),
message_locations()
{}

Expand All @@ -215,16 +213,6 @@ void replay::process_error(const std::string& msg)
resources::controller->process_oos(msg); // might throw end_level_exception(QUIT)
}

void replay::set_skip(bool skip)
{
skip_ = skip;
}

bool replay::is_skipping() const
{
return skip_;
}

void replay::add_unit_checksum(const map_location& loc,config& cfg)
{
if(! game_config::mp_debug) {
Expand Down Expand Up @@ -648,7 +636,6 @@ void replay::clear()
message_log.clear();
cfg_ = config();
pos_ = 0;
skip_ = false;
}

bool replay::empty()
Expand Down Expand Up @@ -721,11 +708,11 @@ REPLAY_RETURN do_replay(bool one_move)
{
log_scope("do replay");

if (!get_replay_source().is_skipping()){
if (!resources::controller->is_skipping_replay()) {
resources::screen->recalculate_minimap();
}

update_locker lock_update(resources::screen->video(),get_replay_source().is_skipping());
update_locker lock_update(resources::screen->video(), resources::controller->is_skipping_replay());
return do_replay_handle(one_move);
}

Expand Down Expand Up @@ -769,7 +756,7 @@ REPLAY_RETURN do_replay_handle(bool one_move)
//if (!preferences::parse_should_show_lobby_join(speaker_name, message)) return;
bool is_whisper = (speaker_name.find("whisper: ") == 0);
get_replay_source().add_chat_message_location();
if (!get_replay_source().is_skipping() || is_whisper) {
if (!resources::controller->is_skipping_replay() || is_whisper) {
int side = child["side"];
resources::screen->get_chat_manager().add_chat_message(get_time(child), speaker_name, side, message,
(team_name.empty() ? events::chat_handler::MESSAGE_PUBLIC
Expand Down Expand Up @@ -905,7 +892,7 @@ REPLAY_RETURN do_replay_handle(bool one_move)
/*
we need to use the undo stack during replays in order to make delayed shroud updated work.
*/
synced_context::run_in_synced_context(commandname, data, true, !get_replay_source().is_skipping(), false,show_oos_error_error_function);
synced_context::run_in_synced_context(commandname, data, true, !resources::controller->is_skipping_replay(), false,show_oos_error_error_function);
if (one_move) {
return REPLAY_FOUND_END_MOVE;
}
Expand Down
5 changes: 0 additions & 5 deletions src/replay.hpp
Expand Up @@ -55,9 +55,6 @@ class replay

void append(const config& cfg);

void set_skip(bool skip);
bool is_skipping() const;

void add_start();
void add_countdown_update(int value,int team);

Expand Down Expand Up @@ -152,8 +149,6 @@ class replay
config cfg_;
int pos_;

bool skip_;

std::vector<int> message_locations;
};

Expand Down
8 changes: 3 additions & 5 deletions src/replay_controller.cpp
Expand Up @@ -324,7 +324,6 @@ void replay_controller::reset_replay()
skip_replay_ = false;
gamestate_.tod_manager_= tod_manager_start_;
recorder.start_replay();
recorder.set_skip(false);
saved_game_ = saved_game_start_;
gamestate_.board_ = gameboard_start_;
gui_->change_display_context(&gamestate_.board_); //this doesn't change the pointer value, but it triggers the gui to update the internal terrain builder object,
Expand Down Expand Up @@ -400,7 +399,7 @@ possible_end_play_signal replay_controller::replay_next_turn(){

PROPOGATE_END_PLAY_SIGNAL( play_turn() );

if (!skip_replay_ || !is_playing_){
if (!is_skipping_replay() || !is_playing_){
gui_->scroll_to_leader(player_number_,game_display::ONSCREEN,false);
}

Expand All @@ -417,7 +416,7 @@ possible_end_play_signal replay_controller::replay_next_move_or_side(bool one_mo
HANDLE_END_PLAY_SIGNAL( play_move_or_side(one_move) );
}

if ( (!skip_replay_ || !is_playing_) && (last_replay_action == REPLAY_FOUND_END_TURN) ){
if ( (!is_skipping_replay() || !is_playing_) && (last_replay_action == REPLAY_FOUND_END_TURN) ){
gui_->scroll_to_leader(player_number_,game_display::ONSCREEN,false);
}

Expand Down Expand Up @@ -476,7 +475,6 @@ void replay_controller::replay_show_team1(){

void replay_controller::replay_skip_animation(){
skip_replay_ = !skip_replay_;
recorder.set_skip(skip_replay_);
}

//move all sides till stop/end
Expand Down Expand Up @@ -644,7 +642,7 @@ void replay_controller::handle_generic_event(const std::string& name){

gui::button* skip_animation_button = gui_->find_action_button("skip-animation");
if(skip_animation_button) {
skip_animation_button->set_check(skip_replay_);
skip_animation_button->set_check(is_skipping_replay());
}
} else {
rebuild_replay_theme();
Expand Down

0 comments on commit 8b83504

Please sign in to comment.