The Battle for Wesnoth  1.19.5+dev
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 multiple sides for WML events. More...
 

Function Documentation

◆ get_user_choice()

config mp_sync::get_user_choice ( const std::string &  name,
const user_choice uch,
int  side = 0 
)

◆ get_user_choice_multiple_sides()

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 multiple sides for WML events.

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

Definition at line 103 of file synced_user_choice.cpp.

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

Referenced by intf_synchronize_choices().