[wesnoth-commits] [wesnoth/wesnoth] ec5dd9: Upgrade the existing scope exit utility

Celtic Minstrel noreply at github.com
Sun Apr 11 22:54:07 UTC 2021


  Branch: refs/heads/lua_events
  Home:   https://github.com/wesnoth/wesnoth
  Commit: ec5dd9e20168d320eb6d2a94c54940705482c041
      https://github.com/wesnoth/wesnoth/commit/ec5dd9e20168d320eb6d2a94c54940705482c041
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-10 (Sat, 10 Apr 2021)

  Changed paths:
    M src/gui/dialogs/multiplayer/mp_join_game.cpp
    M src/units/udisplay.cpp
    M src/utils/scope_exit.hpp

  Log Message:
  -----------
  Upgrade the existing scope exit utility


  Commit: 5ceef0a7822003e3e20b542ef2e2d7b41e59fe35
      https://github.com/wesnoth/wesnoth/commit/5ceef0a7822003e3e20b542ef2e2d7b41e59fe35
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-10 (Sat, 10 Apr 2021)

  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.hpp
    M src/game_events/manager_impl.cpp
    M src/game_events/manager_impl.hpp
    M src/game_events/menu_item.cpp
    M src/game_events/menu_item.hpp
    M src/game_events/wmi_manager.cpp
    M src/game_events/wmi_manager.hpp
    M src/game_state.cpp
    M src/scripting/game_lua_kernel.cpp
    M src/scripting/game_lua_kernel.hpp
    M src/scripting/lua_kernel_base.cpp
    M src/units/unit.cpp

  Log Message:
  -----------
  Events are now a Lua function instead of WML

The function is specified by [event]code= and will be passed the entire contents of the [event] tag (including the code itself).

If code= is omitted, a default is supplied which runs ActionWML; however, internally it is still a function rather than a list of ActionWML commands.


  Commit: 0562b9a2e3bba01dc64b646a6c2e2c72af2403ed
      https://github.com/wesnoth/wesnoth/commit/0562b9a2e3bba01dc64b646a6c2e2c72af2403ed
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-10 (Sat, 10 Apr 2021)

  Changed paths:
    M data/lua/core/interface.lua
    M data/lua/on_event.lua
    M data/lua/wml-tags.lua
    M src/game_events/entity_location.cpp
    M src/game_events/entity_location.hpp
    M src/game_events/handlers.cpp
    M src/game_events/handlers.hpp
    M src/game_events/manager.cpp
    M src/game_events/manager.hpp
    M src/game_events/manager_impl.cpp
    M src/game_events/manager_impl.hpp
    M src/game_events/menu_item.cpp
    M src/game_events/pump.cpp
    M src/game_events/pump.hpp
    M src/scripting/game_lua_kernel.cpp
    M src/scripting/game_lua_kernel.hpp
    M src/scripting/push_check.hpp
    M src/side_filter.hpp

  Log Message:
  -----------
  Enable setting an arbitrary Lua function as an event handler.

Unlike the old wesnoth.game_events.on_event hook and the "convenient" on_event() wrapper for it, this new functionality supports all of the features of WML events, with the sole exception of serialization, since it's not possible to reliably serialize a Lua function.

This commit also divorces menu items from the event that they trigger. The undocumented wesnoth.interface.set_menu_item function no longer adds an event for the menu item; the caller needs to separately register an event using the new functionality.


  Commit: 2044c578f7db320d2df82d596ee176b071da241d
      https://github.com/wesnoth/wesnoth/commit/2044c578f7db320d2df82d596ee176b071da241d
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-10 (Sat, 10 Apr 2021)

  Changed paths:
    M src/ai/formula/ai.cpp
    M src/formula/callable_objects.cpp
    M src/formula/callable_objects.hpp
    M src/game_events/handlers.cpp
    M src/game_events/manager.cpp

  Log Message:
  -----------
  Add [event]filter_formula= for WFL event filtering


  Commit: 8a6dff91148ce6c421e80cb4d1a844d697fe24ae
      https://github.com/wesnoth/wesnoth/commit/8a6dff91148ce6c421e80cb4d1a844d697fe24ae
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-10 (Sat, 10 Apr 2021)

  Changed paths:
    M src/formula/callable_objects.cpp

  Log Message:
  -----------
  WFL: Add recall list to the side object


  Commit: 677078a0adcafb02b86a1edef01fa11de4ab78d0
      https://github.com/wesnoth/wesnoth/commit/677078a0adcafb02b86a1edef01fa11de4ab78d0
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-10 (Sat, 10 Apr 2021)

  Changed paths:
    M src/formula/callable_objects.cpp
    M src/formula/callable_objects.hpp
    M src/game_events/handlers.cpp

  Log Message:
  -----------
  Make the event context available to WFL event filters


  Commit: e561f742777c360fa385edb291bcb6cbc96862f3
      https://github.com/wesnoth/wesnoth/commit/e561f742777c360fa385edb291bcb6cbc96862f3
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-10 (Sat, 10 Apr 2021)

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

  Log Message:
  -----------
  Support Lua event filters as [event]filter= with [filter_args]

This also supports passing an arbitrary Lua function as the filter when the event is registered from Lua.


  Commit: a9eb0c8d496662de294e58666ec87639b70d3039
      https://github.com/wesnoth/wesnoth/commit/a9eb0c8d496662de294e58666ec87639b70d3039
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-10 (Sat, 10 Apr 2021)

  Changed paths:
    M data/lua/core/interface.lua
    M data/lua/wml-tags.lua
    M src/scripting/game_lua_kernel.cpp

  Log Message:
  -----------
  Move the event firing functons to wesnoth.game_events

* These functions take the full event data config as the final argument, rather than just the weapon info subconfigs.
* The [fire_event] tag now supports a [data] tag that can add additional data to the event, for example damage_inflicted. The [primary_attack]  and [secondary_attack] tags are still supported and are not deprecated.
* wesnoth.current.event_context now has a data child which holds the full event data. It still duplicates common info (weapons and damage inflicted) in the same way as before.


  Commit: 565464cdbf314af20363358aec42e00c9321f7b3
      https://github.com/wesnoth/wesnoth/commit/565464cdbf314af20363358aec42e00c9321f7b3
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-10 (Sat, 10 Apr 2021)

  Changed paths:
    M src/game_events/handlers.hpp

  Log Message:
  -----------
  Make event_filter non-copyable to ensure RAII integrity


  Commit: 4d237eaecc0bf44c1a0ccc88cbeea1a0ec9c6b03
      https://github.com/wesnoth/wesnoth/commit/4d237eaecc0bf44c1a0ccc88cbeea1a0ec9c6b03
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-10 (Sat, 10 Apr 2021)

  Changed paths:
    A data/lua/core/unit_test.lua
    M data/test/scenarios/test_menu_items.cfg
    M src/scripting/game_lua_kernel.cpp

  Log Message:
  -----------
  Add a unit_test module only available in [test] scenarios

It contains fire_wml_menu_item along with a set of new assert functions


  Commit: bb9ce5d3b567fbabc29bdd9167920c562083813d
      https://github.com/wesnoth/wesnoth/commit/bb9ce5d3b567fbabc29bdd9167920c562083813d
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-10 (Sat, 10 Apr 2021)

  Changed paths:
    M data/test/scenarios/test_assert.cfg
    M data/test/scenarios/test_return.cfg
    M wml_test_schedule

  Log Message:
  -----------
  Add Lua counterparts to the basic WML unit test system sanity test cases


  Commit: 13c22eaaa90e7805b733dfbb2a61c9b721274ec2
      https://github.com/wesnoth/wesnoth/commit/13c22eaaa90e7805b733dfbb2a61c9b721274ec2
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-10 (Sat, 10 Apr 2021)

  Changed paths:
    M src/game_events/handlers.cpp
    M src/game_events/handlers.hpp
    M src/play_controller.cpp
    M src/scripting/game_lua_kernel.cpp
    M src/scripting/game_lua_kernel.hpp

  Log Message:
  -----------
  Improve the handling of event serialization when Lua code is attached

- Don't try to serialize an event with a Lua filter (ie, add{filter = function() end})
- Write the serialization warning to in-game chat, but ONLY if the event was registered after preload


  Commit: 5d13fb5a9e1fc295c63c61ee411755f167d9b74e
      https://github.com/wesnoth/wesnoth/commit/5d13fb5a9e1fc295c63c61ee411755f167d9b74e
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-10 (Sat, 10 Apr 2021)

  Changed paths:
    M src/scripting/game_lua_kernel.cpp

  Log Message:
  -----------
  "repeat" is a Lua keyword so it makes a poor choice of argument name


  Commit: 797200ba654684c7343186629268ad79720d0871
      https://github.com/wesnoth/wesnoth/commit/797200ba654684c7343186629268ad79720d0871
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-10 (Sat, 10 Apr 2021)

  Changed paths:
    M src/scripting/game_lua_kernel.cpp

  Log Message:
  -----------
  Adding an event handler via the positional call style now defaults to a repeating event

This is a somewhat controversial change!

PROS:
- This makes wesnoth.game_events.add a drop-in replacement for the on_event function
- If you're registering events in preload, most of them WILL be repeating events

CONS:
- This makes the default depend on the call style; in positional style, it defaults to repeating, and in named-argument style, it defaults to non-repeating
- This makes the default different from the WML default of non-repeating events


  Commit: 998af2c148f3b46af5a607bfb38d3dd9f729d42d
      https://github.com/wesnoth/wesnoth/commit/998af2c148f3b46af5a607bfb38d3dd9f729d42d
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-10 (Sat, 10 Apr 2021)

  Changed paths:
    M src/game_events/handlers.cpp

  Log Message:
  -----------
  fixup the serialization warning


  Commit: a2abac304b49bec3d3a52e9acb415e83369371b2
      https://github.com/wesnoth/wesnoth/commit/a2abac304b49bec3d3a52e9acb415e83369371b2
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-11 (Sun, 11 Apr 2021)

  Changed paths:
    M src/game_events/handlers.cpp

  Log Message:
  -----------
  fix missing newlines in event serialization warning


  Commit: 98d5ca919f00d69b29575079350bc5f55dffc49d
      https://github.com/wesnoth/wesnoth/commit/98d5ca919f00d69b29575079350bc5f55dffc49d
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-11 (Sun, 11 Apr 2021)

  Changed paths:
    A data/test/scenarios/events-test_actions.cfg
    M wml_test_schedule

  Log Message:
  -----------
  Unit tests for each way of assigning an action to an event handler


  Commit: 66373cffdc7df79b1bddddfdffe9b908f16b59e1
      https://github.com/wesnoth/wesnoth/commit/66373cffdc7df79b1bddddfdffe9b908f16b59e1
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-11 (Sun, 11 Apr 2021)

  Changed paths:
    M data/test/scenarios/events-test_actions.cfg
    M src/scripting/game_lua_kernel.cpp

  Log Message:
  -----------
  Use first_time_only instead of repeating in the Lua Event API


  Commit: bfcc30e53bd495fd1c3f17053c33cd3099d01a27
      https://github.com/wesnoth/wesnoth/commit/bfcc30e53bd495fd1c3f17053c33cd3099d01a27
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-11 (Sun, 11 Apr 2021)

  Changed paths:
    M run_wml_tests

  Log Message:
  -----------
  run_wml_tests: Don't crash if a test crashes


  Commit: 4f36363259de91b40fa8b31cbe6e5dc309aa2415
      https://github.com/wesnoth/wesnoth/commit/4f36363259de91b40fa8b31cbe6e5dc309aa2415
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-11 (Sun, 11 Apr 2021)

  Changed paths:
    M run_wml_tests

  Log Message:
  -----------
  run_wml_tests: Fix inaccurate test summary with tests not expected to pass


  Commit: a071adc601fa68252713a87c53ff44e0d7bf9512
      https://github.com/wesnoth/wesnoth/commit/a071adc601fa68252713a87c53ff44e0d7bf9512
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-11 (Sun, 11 Apr 2021)

  Changed paths:
    M projectfiles/VC16/wesnoth.vcxproj
    M projectfiles/VC16/wesnoth.vcxproj.filters
    M projectfiles/Xcode/The Battle for Wesnoth.xcodeproj/project.pbxproj
    M src/play_controller.cpp
    M src/scripting/game_lua_kernel.cpp
    M src/scripting/game_lua_kernel.hpp
    A src/utils/guard_value.hpp

  Log Message:
  -----------
  Fix crash when destroying a Lua filter


  Commit: b8c478d9345702acaabf2ade846bccb790428beb
      https://github.com/wesnoth/wesnoth/commit/b8c478d9345702acaabf2ade846bccb790428beb
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-11 (Sun, 11 Apr 2021)

  Changed paths:
    M src/scripting/game_lua_kernel.cpp

  Log Message:
  -----------
  Fix dynamic Lua filters not working at all


  Commit: a6443684f70e91abc740e21ff3e41c9d172bd4ca
      https://github.com/wesnoth/wesnoth/commit/a6443684f70e91abc740e21ff3e41c9d172bd4ca
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-11 (Sun, 11 Apr 2021)

  Changed paths:
    M data/test/scenarios/events-test_filters.cfg
    M wml_test_schedule

  Log Message:
  -----------
  Unit tests for the new filter options


  Commit: fb38604349ff618c9157037a85e7030af6b42d34
      https://github.com/wesnoth/wesnoth/commit/fb38604349ff618c9157037a85e7030af6b42d34
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-11 (Sun, 11 Apr 2021)

  Changed paths:
    M data/lua/wml-tags.lua
    M src/game_events/handlers.cpp
    M src/game_events/manager_impl.cpp

  Log Message:
  -----------
  Address minor pull request comments


  Commit: 0805dfa7fc3964c4e6922792f195009286a21c8d
      https://github.com/wesnoth/wesnoth/commit/0805dfa7fc3964c4e6922792f195009286a21c8d
  Author: Celtic Minstrel <celtic.minstrel.ca at some.place>
  Date:   2021-04-11 (Sun, 11 Apr 2021)

  Changed paths:
    M data/lua/wml-tags.lua

  Log Message:
  -----------
  Fix [fire_event]


Compare: https://github.com/wesnoth/wesnoth/compare/227269ad9be3...0805dfa7fc39



More information about the Commits mailing list