Author: shadowmaster
Date: Sun Nov  6 06:39:28 2011
New Revision: 51883

URL: http://svn.gna.org/viewcvs/wesnoth?rev=51883&view=rev
Log:
Add wesnoth.unit_image_mods() function and make [move_unit] use it to respect 
mods applied via EffectWML

Modified:
    trunk/changelog
    trunk/data/lua/wml-tags.lua
    trunk/src/scripting/lua.cpp
    trunk/src/unit.cpp
    trunk/src/unit.hpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=51883&r1=51882&r2=51883&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sun Nov  6 06:39:28 2011
@@ -40,6 +40,9 @@
    * The side metatable provides also the side number
      (like wesnoth.sides[i].side, which would be i)
    * add function wesnoth.debug
+   * Added function wesnoth.unit_image_mods, which takes a unit object and
+     retrieves a image path function string depending on image mods applied via
+     EffectWML
    * Added: Support for clickables (button and repeating button) to
      wesnoth.set_dialog_callback (patch #2763)
    * Allowed function debug.traceback()
@@ -116,6 +119,7 @@
      in capture events (FR bug #13567)
    * Introduce [capture_village]fire_event=yes|no (def no) whether to fire
      any capture events (was previously always yes)
+   * Made [move_unit] respect image modifications applied by EffectWML to 
single units
  * Miscellaneous and bug fixes:
    * Add --language/-L commandline option to set the language for that session
    * Fixed: Avoid copying of singular iterators in the whiteboard code

Modified: trunk/data/lua/wml-tags.lua
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/lua/wml-tags.lua?rev=51883&r1=51882&r2=51883&view=diff
==============================================================================
--- trunk/data/lua/wml-tags.lua (original)
+++ trunk/data/lua/wml-tags.lua Sun Nov  6 06:39:28 2011
@@ -614,6 +614,7 @@
        local pattern = "[^%s,]+"
        for current_unit_index, current_unit in ipairs(units) do
                if not fire_event or current_unit.valid then
+                       local effect_mods = 
wesnoth.unit_image_mods(current_unit)
                        local xs, ys = string.gmatch(to_x, pattern), 
string.gmatch(to_y, pattern)
                        local move_string_x = current_unit.x
                        local move_string_y = current_unit.y
@@ -643,6 +644,7 @@
                                type = current_unit_cfg.type,
                                gender = current_unit_cfg.gender,
                                variation = current_unit_cfg.variation,
+                               image_mods = effect_mods,
                                side = current_unit_cfg.side,
                                x = move_string_x,
                                y = move_string_y

Modified: trunk/src/scripting/lua.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/scripting/lua.cpp?rev=51883&r1=51882&r2=51883&view=diff
==============================================================================
--- trunk/src/scripting/lua.cpp (original)
+++ trunk/src/scripting/lua.cpp Sun Nov  6 06:39:28 2011
@@ -2527,6 +2527,18 @@
        unit const *u = luaW_checkunit(L, 1);
        char const *m = luaL_checkstring(L, 2);
        lua_pushboolean(L, u->get_ability_bool(m));
+       return 1;
+}
+
+/**
+ * Returns the EffectWML image modifications affecting the given unit, if any.
+ * - Arg 1: unit userdata.
+ * - Ret 1: string of image path functions, or an empty string.
+ */
+static int intf_unit_image_mods(lua_State *L)
+{
+       unit const *u = luaW_checkunit(L, 1);
+       lua_pushstring(L, u->effect_image_mods().c_str());
        return 1;
 }
 
@@ -3502,6 +3514,7 @@
                { "transform_unit",           &intf_transform_unit           },
                { "unit_ability",             &intf_unit_ability             },
                { "unit_defense",             &intf_unit_defense             },
+               { "unit_image_mods",          &intf_unit_image_mods          },
                { "unit_movement_cost",       &intf_unit_movement_cost       },
                { "unit_resistance",          &intf_unit_resistance          },
                { NULL, NULL }

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=51883&r1=51882&r2=51883&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Sun Nov  6 06:39:28 2011
@@ -3009,6 +3009,10 @@
        return modifier.str();
 }
 
+std::string unit::effect_image_mods() const{
+       return image_mods_;
+}
+
 const tportrait* unit::portrait(
                const unsigned size, const tportrait::tside side) const
 {

Modified: trunk/src/unit.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.hpp?rev=51883&r1=51882&r2=51883&view=diff
==============================================================================
--- trunk/src/unit.hpp (original)
+++ trunk/src/unit.hpp Sun Nov  6 06:39:28 2011
@@ -332,6 +332,7 @@
        unit& clone(bool is_temporary=true);
 
        std::string TC_image_mods() const;
+       std::string effect_image_mods() const;
        std::string image_mods() const;
 
        /**


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to