[Commits] [wesnoth/wesnoth] 88b0fe: Further reworking of event iteration interface

GitHub noreply at github.com
Thu Jan 11 18:12:31 UTC 2018


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 88b0fe59536b3976ea2894cee17ca3773d0f8300
      https://github.com/wesnoth/wesnoth/commit/88b0fe59536b3976ea2894cee17ca3773d0f8300
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2018-01-11 (Thu, 11 Jan 2018)

  Changed paths:
    M src/game_events/handlers.cpp
    M src/game_events/handlers.hpp
    M src/game_events/manager.cpp
    M src/game_events/manager_impl.cpp
    M src/game_events/manager_impl.hpp

  Log Message:
  -----------
  Further reworking of event iteration interface

Fixes #2312. Turns out constructing a list of matching handlers breaks some undocumented
behavior, namely events being executed in the order they're added (usually the order in
which they appear in the WML). It also broke certain variable substitution by moving variable
interpolation wholly before any event execution, as opposed to between each event.

This commit implements an even simpler method: simply iterating through every registered
handler in order, checking for a name match on each one, and if it passes, immediately
executing the provided function. Cleanup will only occur once the toplevel call to
execute_on_events is completed.

This commit also removes the immediately cleanup upon removing a handler. This should
ensure (I didn't test explicitly, but from other incidental issues I'm sure this is the
case) the size of the main vector doesn't change during iteration.

I also changed the pre-add standardization code to only affect event names without variables.
Variable names are standardized later after variable substitution.


  Commit: 8ae99bc86abf0d4ef1b0a8e9dbe313452cee6a9f
      https://github.com/wesnoth/wesnoth/commit/8ae99bc86abf0d4ef1b0a8e9dbe313452cee6a9f
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2018-01-11 (Thu, 11 Jan 2018)

  Changed paths:
    A data/test/scenarios/test_event_names_and_order.cfg
    M wml_test_schedule

  Log Message:
  -----------
  Added some event unit tests by @Pentarctagon

Tests event execution order and events with variable names.


Compare: https://github.com/wesnoth/wesnoth/compare/395f8fac789f...8ae99bc86abf


More information about the Commits mailing list