The Battle for Wesnoth  1.15.1+dev
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
replay Class Reference

#include <replay.hpp>

Public Types

enum  DATA_TYPE { ALL_DATA, NON_UNDO_DATA }
 
enum  MARK_SENT { MARK_AS_UNSENT, MARK_AS_SENT }
 

Public Member Functions

 replay (replay_recorder_base &base)
 
void add_start ()
 
void add_surrender (int side_number)
 
void add_countdown_update (int value, int team)
 
void add_synced_command (const std::string &name, const config &command)
 
void init_side ()
 
configget_last_real_command ()
 
void user_input (const std::string &, const config &, int from_side)
 adds a user_input to the replay More...
 
void add_label (const terrain_label *)
 
void clear_labels (const std::string &, bool)
 
void add_rename (const std::string &name, const map_location &loc)
 
void end_turn (int next_player_number)
 
void add_unit_checksum (const map_location &loc, config &cfg)
 
void add_log_data (const std::string &key, const std::string &var)
 
void add_log_data (const std::string &category, const std::string &key, const std::string &var)
 
void add_log_data (const std::string &category, const std::string &key, const config &c)
 
bool add_chat_message_location ()
 adds a chat message if it wasn't added yet. More...
 
bool add_chat_message_location (int pos)
 
void speak (const config &cfg)
 
const std::vector< chat_msg > & build_chat_log () const
 
config get_data_range (int cmd_start, int cmd_end, DATA_TYPE data_type=ALL_DATA) const
 
void undo ()
 
void undo_cut (config &dst)
 
void redo (const config &dst, bool set_to_end=false)
 
void start_replay ()
 
void revert_action ()
 
configget_next_action ()
 
bool at_end () const
 
void set_to_end ()
 
bool empty () const
 
void add_config (const config &cfg, MARK_SENT mark=MARK_AS_UNSENT)
 
int ncommands () const
 
bool add_start_if_not_there_yet ()
 
void delete_upcoming_commands ()
 

Static Public Member Functions

static void process_error (const std::string &msg)
 

Private Member Functions

void add_chat_log_entry (const config &speak, std::back_insert_iterator< std::vector< chat_msg >> &i) const
 
configcommand (int) const
 
void remove_command (int)
 
configadd_command ()
 Adds a new empty command to the command list at the end. More...
 
configadd_nonundoable_command ()
 adds a new command to the command list at the current position. More...
 

Private Attributes

replay_recorder_basebase_
 
std::vector< int > message_locations
 

Detailed Description

Definition at line 49 of file replay.hpp.

Member Enumeration Documentation

◆ DATA_TYPE

Enumerator
ALL_DATA 
NON_UNDO_DATA 

Definition at line 96 of file replay.hpp.

◆ MARK_SENT

Enumerator
MARK_AS_UNSENT 
MARK_AS_SENT 

Definition at line 120 of file replay.hpp.

Constructor & Destructor Documentation

◆ replay()

replay::replay ( replay_recorder_base base)
explicit

Definition at line 178 of file replay.cpp.

Member Function Documentation

◆ add_chat_log_entry()

void replay::add_chat_log_entry ( const config speak,
std::back_insert_iterator< std::vector< chat_msg >> &  i 
) const
private

Definition at line 353 of file replay.cpp.

References i, preferences::is_ignored(), and preferences::parse_should_show_lobby_join().

Referenced by build_chat_log().

◆ add_chat_message_location() [1/2]

bool replay::add_chat_message_location ( )

adds a chat message if it wasn't added yet.

Returns
true if a message location was added

Definition at line 329 of file replay.cpp.

References base_, and replay_recorder_base::get_pos().

Referenced by do_replay_handle(), and speak().

◆ add_chat_message_location() [2/2]

bool replay::add_chat_message_location ( int  pos)

◆ add_command()

config & replay::add_command ( )
private

Adds a new empty command to the command list at the end.

Returns
a reference to the added command

Definition at line 579 of file replay.cpp.

References replay_recorder_base::add_child(), at_end(), base_, and set_to_end().

Referenced by add_countdown_update(), add_rename(), add_start(), add_synced_command(), end_turn(), init_side(), and user_input().

◆ add_config()

void replay::add_config ( const config cfg,
MARK_SENT  mark = MARK_AS_UNSENT 
)

◆ add_countdown_update()

void replay::add_countdown_update ( int  value,
int  team 
)

Definition at line 235 of file replay.cpp.

References config::add_child(), and add_command().

Referenced by playmp_controller::after_human_turn().

◆ add_label()

void replay::add_label ( const terrain_label label)

◆ add_log_data() [1/3]

void replay::add_log_data ( const std::string &  key,
const std::string &  var 
)

◆ add_log_data() [2/3]

void replay::add_log_data ( const std::string &  category,
const std::string &  key,
const std::string &  var 
)

Definition at line 315 of file replay.cpp.

References base_, config::child_or_add(), and replay_recorder_base::get_upload_log().

◆ add_log_data() [3/3]

void replay::add_log_data ( const std::string &  category,
const std::string &  key,
const config c 
)

◆ add_nonundoable_command()

config & replay::add_nonundoable_command ( )
private

adds a new command to the command list at the current position.

Returns
a reference to the added command

Definition at line 589 of file replay.cpp.

References at_end(), base_, replay_recorder_base::get_pos(), replay_recorder_base::insert_command(), replay_recorder_base::set_pos(), and replay_recorder_base::size().

Referenced by add_label(), add_surrender(), clear_labels(), and speak().

◆ add_rename()

void replay::add_rename ( const std::string &  name,
const map_location loc 
)

◆ add_start()

void replay::add_start ( )

Definition at line 222 of file replay.cpp.

References config::add_child(), and add_command().

◆ add_start_if_not_there_yet()

bool replay::add_start_if_not_there_yet ( )

◆ add_surrender()

void replay::add_surrender ( int  side_number)

Definition at line 229 of file replay.cpp.

References config::add_child(), and add_nonundoable_command().

Referenced by playmp_controller::surrender().

◆ add_synced_command()

void replay::add_synced_command ( const std::string &  name,
const config command 
)

◆ add_unit_checksum()

void replay::add_unit_checksum ( const map_location loc,
config cfg 
)

◆ at_end()

bool replay::at_end ( ) const

◆ build_chat_log()

const std::vector< chat_msg > & replay::build_chat_log ( ) const

◆ clear_labels()

void replay::clear_labels ( const std::string &  team_name,
bool  force 
)

◆ command()

config & replay::command ( int  n) const
private

◆ delete_upcoming_commands()

void replay::delete_upcoming_commands ( )

◆ empty()

bool replay::empty ( ) const

Definition at line 637 of file replay.cpp.

References ncommands().

◆ end_turn()

void replay::end_turn ( int  next_player_number)

Definition at line 300 of file replay.cpp.

References config::add_child(), and add_command().

Referenced by do_replay_handle(), and playsingle_controller::sync_end_turn().

◆ get_data_range()

config replay::get_data_range ( int  cmd_start,
int  cmd_end,
DATA_TYPE  data_type = ALL_DATA 
) const

◆ get_last_real_command()

config & replay::get_last_real_command ( )

Definition at line 434 of file replay.cpp.

References base_, c, command(), ERR_REPLAY, and replay_recorder_base::get_pos().

◆ get_next_action()

config * replay::get_next_action ( )

◆ init_side()

void replay::init_side ( )

◆ ncommands()

int replay::ncommands ( ) const

◆ process_error()

void replay::process_error ( const std::string &  msg)
static

◆ redo()

void replay::redo ( const config dst,
bool  set_to_end = false 
)

◆ remove_command()

void replay::remove_command ( int  index)
private

Definition at line 362 of file replay.cpp.

References base_, message_locations, and replay_recorder_base::remove_command().

Referenced by undo_cut().

◆ revert_action()

void replay::revert_action ( )

◆ set_to_end()

void replay::set_to_end ( )

Definition at line 632 of file replay.cpp.

References base_, and replay_recorder_base::set_to_end().

Referenced by add_command(), and undo_cut().

◆ speak()

void replay::speak ( const config cfg)

◆ start_replay()

void replay::start_replay ( )

Definition at line 601 of file replay.cpp.

References base_, and replay_recorder_base::set_pos().

◆ undo()

void replay::undo ( )

Definition at line 561 of file replay.cpp.

References dummy, and undo_cut().

Referenced by synced_context::run_and_store().

◆ undo_cut()

void replay::undo_cut ( config dst)

◆ user_input()

void replay::user_input ( const std::string &  name,
const config input,
int  from_side 
)

adds a user_input to the replay

Parameters
from_sidethe side that had to make the decision, -1 for 'server'

Definition at line 253 of file replay.cpp.

References config::add_child(), and add_command().

Referenced by user_choice_manager::ask_local_choice(), and synced_context::ask_server_choice().

Member Data Documentation

◆ base_

replay_recorder_base* replay::base_
private

◆ message_locations

std::vector<int> replay::message_locations
private

Definition at line 150 of file replay.hpp.

Referenced by add_chat_message_location(), build_chat_log(), and remove_command().


The documentation for this class was generated from the following files: