mail[Wesnoth-commits] r41564 - /trunk/src/scripting/lua.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by guillaume . melquiond on March 14, 2010 - 12:58:
Author: silene
Date: Sun Mar 14 12:58:54 2010
New Revision: 41564

URL: http://svn.gna.org/viewcvs/wesnoth?rev=41564&view=rev
Log:
Allowed modifying locations of units outside the map.

Modified:
    trunk/src/scripting/lua.cpp

Modified: trunk/src/scripting/lua.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/scripting/lua.cpp?rev=41564&r1=41563&r2=41564&view=diff
==============================================================================
--- trunk/src/scripting/lua.cpp (original)
+++ trunk/src/scripting/lua.cpp Sun Mar 14 12:58:54 2010
@@ -792,9 +792,10 @@
                return luaL_typerror(L, 3, error_buffer.c_str());
        }
 
-       unit *pu = static_cast<lua_unit *>(lua_touserdata(L, 1))->get();
+       lua_unit *lu = static_cast<lua_unit *>(lua_touserdata(L, 1));
        char const *m = luaL_checkstring(L, 2);
        lua_settop(L, 3);
+       unit *pu = lu->get();
        if (!pu) return luaL_argerror(L, 1, "unknown unit");
        unit &u = *pu;
 
@@ -805,6 +806,11 @@
        modify_tstring_attrib("name", u.set_name(value));
        modify_string_attrib("role", u.set_role(value));
        modify_string_attrib("facing", 
u.set_facing(map_location::parse_direction(value)));
+       if (!lu->on_map()) {
+               map_location loc = u.get_location();
+               modify_int_attrib("x", loc.x = value - 1; 
u.set_location(loc));
+               modify_int_attrib("y", loc.y = value - 1; 
u.set_location(loc));
+       }
        goto error_call_destructors_2;
 }
 




Related Messages


Powered by MHonArc, Updated Sun Mar 14 13:00:18 2010