The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes
mp_sync Namespace Reference

Classes

struct  user_choice
 Interface for querying local choices. More...
 

Functions

replay commands as legal from

Performs a choice for WML events.

The choice is synchronized across all the multiplayer clients and stored into the replay. The function object is called if the local client is responsible for making the choice. otherwise this function waits for a remote choice and returns it when it is received. information about the choice made is saved in replay with dependent=true

Parameters
nameTag used for storing the choice into the replay.
sideThe number of the side responsible for making the choice. If zero, it defaults to the currently active side.
Note
In order to prevent issues with sync, crash, or infinite loop, a number of precautions must be taken when getting a choice from a specific side.
  • The server must recognize non-active players. Preferably the server should be notified about which player the data is expected from, and discard data from unexpected players.
config get_user_choice (const std::string &name, const user_choice &uch, int side=0)
 
std::map< int, configget_user_choice_multiple_sides (const std::string &name, const user_choice &uch, std::set< int > sides)
 Performs a choice for mutiple sides for WML events. More...
 

Function Documentation

config mp_sync::get_user_choice ( const std::string name,
const user_choice &  uch,
int  side = 0 
)
std::map< int, config > mp_sync::get_user_choice_multiple_sides ( const std::string name,
const user_choice &  uch,
std::set< int sides 
)

Performs a choice for mutiple sides for WML events.

uch is called on all sies specified in sides, this in done simulaniously on all those sides (or one after another if one client controlls mutiple sides) and after all calls are executed the results are returned.

Definition at line 102 of file synced_user_choice.cpp.

References user_choice_manager::get_user_choice_internal(), synced_context::is_synced(), replay::process_error(), mp_sync::user_choice::random_choice(), and resources::teams.

Referenced by intf_synchronize_choices().