Author: anonymissimus
Date: Thu Sep 23 16:20:09 2010
New Revision: 46665
URL: http://svn.gna.org/viewcvs/wesnoth?rev=46665&view=rev
Log:
Allowed events to be fired conditionally via[event][condition] (see FutureWML).
Ment to be used when values of variables unrelated to filtered units shall be
queried, otherwise lua_function would need to be misused for this. Allows for
simplification/splitting up into events for events with structure
[event][if][variable][then][else].
Modified:
trunk/data/lua/wml-tags.lua
trunk/src/game_events.cpp
Modified: trunk/data/lua/wml-tags.lua
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/lua/wml-tags.lua?rev=46665&r1=46664&r2=46665&view=diff
==============================================================================
--- trunk/data/lua/wml-tags.lua (original)
+++ trunk/data/lua/wml-tags.lua Thu Sep 23 16:20:09 2010
@@ -208,7 +208,7 @@
for i = 1, #cfg do
local v = cfg[i]
local cmd = v[1]
- if not string.find(cmd, "^filter") then
+ if not string.find(cmd, "^filter") and cmd ~= "condition" then
cmd = wml_actions[cmd] or
helper.wml_error(string.format("[%s] not
supported", cmd))
cmd(v[2])
Modified: trunk/src/game_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=46665&r1=46664&r2=46665&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Thu Sep 23 16:20:09 2010
@@ -2864,6 +2864,14 @@
scoped_weapon_info second_weapon("second_weapon",
ev.data.child("second"));
vconfig filters(handler.get_config());
+
+ foreach (const vconfig &condition, filters.get_children("condition"))
+ {
+ if (!game_events::conditional_passed(condition)) {
+ return false;
+ }
+ }
+
foreach (const vconfig &f, filters.get_children("filter"))
{
if (unit1 == units->end() ||
!game_events::unit_matches_filter(*unit1, f)) {
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits