The Battle for Wesnoth  1.19.4+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 &name, const config &input, 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_unsent_commands (DATA_TYPE data_type)
 
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 ()
 
configpeek_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_
 
int sent_upto_
 
std::vector< int > message_locations
 

Detailed Description

Definition at line 58 of file replay.hpp.

Member Enumeration Documentation

◆ DATA_TYPE

Enumerator
ALL_DATA 
NON_UNDO_DATA 

Definition at line 107 of file replay.hpp.

◆ MARK_SENT

Enumerator
MARK_AS_UNSENT 
MARK_AS_SENT 

Definition at line 132 of file replay.hpp.

Constructor & Destructor Documentation

◆ replay()

replay::replay ( replay_recorder_base base)
explicit

Definition at line 182 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 358 of file replay.cpp.

References prefs::get(), and i.

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 334 of file replay.cpp.

References base_, and replay_recorder_base::get_pos().

Referenced by 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 587 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 240 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)

Definition at line 273 of file replay.cpp.

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

Referenced by events::menu_handler::label_terrain().

◆ add_log_data() [1/3]

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

◆ 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 320 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 &  key,
const std::string &  var 
)

◆ 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 597 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 
)

Definition at line 294 of file replay.cpp.

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

Referenced by events::menu_handler::rename_unit().

◆ add_start()

void replay::add_start ( )

Definition at line 227 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 234 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 
)

Definition at line 284 of file replay.cpp.

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

Referenced by events::menu_handler::clear_labels().

◆ command()

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

◆ delete_upcoming_commands()

void replay::delete_upcoming_commands ( )

◆ empty()

bool replay::empty ( ) const

Definition at line 656 of file replay.cpp.

References ncommands().

Referenced by savegame::convert_old_saves_1_11_0().

◆ end_turn()

void replay::end_turn ( int  next_player_number)

Definition at line 305 of file replay.cpp.

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

Referenced by playsingle_controller::sync_end_turn().

◆ get_last_real_command()

config & replay::get_last_real_command ( )

Definition at line 438 of file replay.cpp.

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

◆ get_next_action()

config * replay::get_next_action ( )

◆ get_unsent_commands()

config replay::get_unsent_commands ( DATA_TYPE  data_type)

Definition at line 397 of file replay.cpp.

References config::add_child(), ALL_DATA, c, command(), ncommands(), and sent_upto_.

Referenced by playmp_controller::send_actions().

◆ init_side()

void replay::init_side ( )

◆ ncommands()

int replay::ncommands ( ) const

◆ peek_next_action()

config * replay::peek_next_action ( )

Definition at line 633 of file replay.cpp.

References at_end(), base_, command(), replay_recorder_base::get_pos(), LOG_REPLAY, and ncommands().

◆ 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 366 of file replay.cpp.

References base_, utf8::index(), 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 651 of file replay.cpp.

References base_, and replay_recorder_base::set_to_end().

Referenced by add_command(), redo(), and undo_cut().

◆ speak()

void replay::speak ( const config cfg)

◆ start_replay()

void replay::start_replay ( )

Definition at line 609 of file replay.cpp.

References base_, and replay_recorder_base::set_pos().

◆ undo()

void replay::undo ( )

Definition at line 570 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
nameThe tag name of the config to add
inputthe contents of the config to add
from_sidethe side that had to make the decision, -1 for 'server'

Definition at line 258 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 163 of file replay.hpp.

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

◆ sent_upto_

int replay::sent_upto_
private

Definition at line 162 of file replay.hpp.

Referenced by get_unsent_commands().


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