The Battle for Wesnoth  1.17.12+dev
Namespaces | Classes | Typedefs | Functions
game_events Namespace Reference

Domain specific events. More...

Namespaces

 builtin_conditions
 
 context
 

Classes

struct  entity_location
 
struct  event_filter
 Represents a single filter condition on an event. More...
 
class  event_handler
 
class  event_handlers
 
struct  filter_attack
 
struct  filter_condition
 
struct  filter_dynamic
 This is a dynamic wrapper for any filter type, specified via [insert_tag]. More...
 
struct  filter_formula
 
struct  filter_side
 
struct  filter_unit
 
class  manager
 The game event manager loads the scenario configuration object, and ensures that events are handled according to the scenario configuration for its lifetime. More...
 
class  pending_event_handler
 Represents a handler that is about to be added to the events manager but is still waiting for some data. More...
 
struct  pump_impl
 
struct  queued_event
 
class  wmi_manager
 
class  wml_action
 
class  wml_event_pump
 
class  wml_menu_item
 

Typedefs

using handler_ptr = std::shared_ptr< event_handler >
 
using weak_handler_ptr = std::weak_ptr< event_handler >
 
using handler_list = std::list< weak_handler_ptr >
 
using pump_result_t = std::tuple< bool, bool >
 

Functions

 WML_HANDLER_FUNCTION (clear_global_variable,, pcfg)
 Experimental data persistence. More...
 
static void on_replay_error (const std::string &message)
 
 WML_HANDLER_FUNCTION (do_command,, cfg)
 
 WML_HANDLER_FUNCTION (get_global_variable,, pcfg)
 Experimental data persistence. More...
 
 WML_HANDLER_FUNCTION (modify_turns,, cfg)
 
 WML_HANDLER_FUNCTION (move_unit_fake,, cfg)
 Moving a 'unit' - i.e. More...
 
 WML_HANDLER_FUNCTION (move_units_fake,, cfg)
 
 WML_HANDLER_FUNCTION (recall,, cfg)
 If we should recall units that match a certain description. More...
 
 WML_HANDLER_FUNCTION (replace_map,, cfg)
 Experimental map replace. More...
 
 WML_HANDLER_FUNCTION (set_global_variable,, pcfg)
 Experimental data persistence. More...
 
 WML_HANDLER_FUNCTION (set_variables,, cfg)
 
 WML_HANDLER_FUNCTION (store_relative_direction,, cfg)
 Store the relative direction from one hex to another in a WML variable. More...
 
 WML_HANDLER_FUNCTION (store_rotate_map_location,, cfg)
 Store the rotation of one hex around another in a WML variable. More...
 
 WML_HANDLER_FUNCTION (tunnel,, cfg)
 
 WML_HANDLER_FUNCTION (unit,, cfg)
 If we should spawn a new unit on the map somewhere. More...
 
 WML_HANDLER_FUNCTION (on_undo, event_info, cfg)
 
bool conditional_passed (const vconfig &cond)
 
bool matches_special_filter (const config &cfg, const vconfig &filter)
 
static std::unique_ptr< event_filtermake_filter (const std::string &key, const vconfig &contents)
 

Detailed Description

Domain specific events.

This module defines the game's event mechanism. Events might be units moving or fighting, or when victory or defeat occurs. A scenario's configuration file will define actions to take when certain events occur. This module is responsible for making sure that when the events occur, the actions take place.

Game events have nothing to do with mouse movement, keyboard events, etc. These kinds of system events can be handled using namespace events

Typedef Documentation

◆ handler_list

using game_events::handler_list = typedef std::list<weak_handler_ptr>

Definition at line 27 of file fwd.hpp.

◆ handler_ptr

using game_events::handler_ptr = typedef std::shared_ptr<event_handler>

Definition at line 25 of file fwd.hpp.

◆ pump_result_t

using game_events::pump_result_t = typedef std::tuple<bool , bool >

Definition at line 29 of file fwd.hpp.

◆ weak_handler_ptr

using game_events::weak_handler_ptr = typedef std::weak_ptr<event_handler>

Definition at line 26 of file fwd.hpp.

Function Documentation

◆ conditional_passed()

bool game_events::conditional_passed ( const vconfig cond)

◆ make_filter()

static std::unique_ptr<event_filter> game_events::make_filter ( const std::string &  key,
const vconfig contents 
)
static

◆ matches_special_filter()

bool game_events::matches_special_filter ( const config cfg,
const vconfig filter 
)

Definition at line 215 of file conditional_wml.cpp.

References vconfig::get_parsed_config(), and WRN_NG.

Referenced by game_events::filter_attack::operator()().

◆ on_replay_error()

static void game_events::on_replay_error ( const std::string &  message)
static

Definition at line 267 of file action_wml.cpp.

References ERR_NG.

Referenced by WML_HANDLER_FUNCTION().

◆ WML_HANDLER_FUNCTION() [1/15]

game_events::WML_HANDLER_FUNCTION ( clear_global_variable  ,
pcfg   
)

Experimental data persistence.

Todo:
Finish experimenting.

Definition at line 261 of file action_wml.cpp.

References resources::controller, and verify_and_clear_global_variable().

◆ WML_HANDLER_FUNCTION() [2/15]

game_events::WML_HANDLER_FUNCTION ( do_command  ,
cfg   
)

◆ WML_HANDLER_FUNCTION() [3/15]

game_events::WML_HANDLER_FUNCTION ( get_global_variable  ,
pcfg   
)

Experimental data persistence.

Todo:
Finish experimenting.

Definition at line 351 of file action_wml.cpp.

References verify_and_get_global_variable().

◆ WML_HANDLER_FUNCTION() [4/15]

game_events::WML_HANDLER_FUNCTION ( modify_turns  ,
cfg   
)

◆ WML_HANDLER_FUNCTION() [5/15]

game_events::WML_HANDLER_FUNCTION ( move_unit_fake  ,
cfg   
)

Moving a 'unit' - i.e.

a dummy unit that is just moving for the visual effect

Definition at line 385 of file action_wml.cpp.

References fake_unit_ptr::get(), fake_unit_ptr::get_unit_ptr(), unit_display::move_unit(), map_location::NDIRECTIONS, game_config::path, and utils::split().

◆ WML_HANDLER_FUNCTION() [6/15]

game_events::WML_HANDLER_FUNCTION ( move_units_fake  ,
cfg   
)

◆ WML_HANDLER_FUNCTION() [7/15]

game_events::WML_HANDLER_FUNCTION ( recall  ,
cfg   
)

If we should recall units that match a certain description.

If you change attributes specific to [recall] (that is, not a Standard Unit Filter) be sure to update data/lua/wml_tag, auto_recall feature for [role] to reflect your changes.

FIXME: we should design the WML to avoid these types of collisions; filters should be named consistently and always have a distinct scope.

Definition at line 468 of file action_wml.cpp.

References recall_list_manager::begin(), vconfig::child(), DBG_NG, recall_list_manager::end(), recall_list_manager::erase(), filename_, unit_map::find_leaders(), pathfind::find_vacant_tile(), resources::gameboard, utf8::index(), LOG_NG, LOG_WML, game_board::map(), unit_filter::matches(), map_location::null_location(), map_location::parse_direction(), actions::place_recruit(), config::remove_attribute(), utf8::size(), gamemap_base::special_locations(), game_board::teams(), game_board::units(), and pathfind::VACANT_ANY.

◆ WML_HANDLER_FUNCTION() [8/15]

game_events::WML_HANDLER_FUNCTION ( replace_map  ,
cfg   
)

◆ WML_HANDLER_FUNCTION() [9/15]

game_events::WML_HANDLER_FUNCTION ( set_global_variable  ,
pcfg   
)

Experimental data persistence.

Todo:
Finish experimenting.

Definition at line 660 of file action_wml.cpp.

References resources::controller, and verify_and_set_global_variable().

◆ WML_HANDLER_FUNCTION() [10/15]

game_events::WML_HANDLER_FUNCTION ( set_variables  ,
cfg   
)

◆ WML_HANDLER_FUNCTION() [11/15]

game_events::WML_HANDLER_FUNCTION ( store_relative_direction  ,
cfg   
)

Store the relative direction from one hex to another in a WML variable.

This is mainly useful as a diagnostic tool, but could be useful for some kind of scenario.

Definition at line 776 of file action_wml.cpp.

References variable_info< V >::as_scalar(), ERR_NG, resources::gamedata, map_location::get_relative_dir(), game_data::get_variable_access_write(), map_location::write_direction(), and WRN_NG.

◆ WML_HANDLER_FUNCTION() [12/15]

game_events::WML_HANDLER_FUNCTION ( store_rotate_map_location  ,
cfg   
)

Store the rotation of one hex around another in a WML variable.

In increments of 60 degrees, clockwise. This is mainly useful as a diagnostic tool, but could be useful for some kind of scenario.

Definition at line 814 of file action_wml.cpp.

References variable_info< V >::as_container(), ERR_NG, resources::gamedata, game_data::get_variable_access_write(), and WRN_NG.

◆ WML_HANDLER_FUNCTION() [13/15]

game_events::WML_HANDLER_FUNCTION ( tunnel  ,
cfg   
)

◆ WML_HANDLER_FUNCTION() [14/15]

game_events::WML_HANDLER_FUNCTION ( unit  ,
cfg   
)

◆ WML_HANDLER_FUNCTION() [15/15]

game_events::WML_HANDLER_FUNCTION ( on_undo  ,
event_info  ,
cfg   
)

Definition at line 923 of file action_wml.cpp.

References synced_context::add_undo_commands().