Author: jtn
Date: Mon Jan 25 19:34:37 2016
New Revision: 31600

URL: http://svn.gna.org/viewcvs/freeciv?rev=31600&view=rev
Log:
Lua: add Unit:transporter(), Unit:cargo_iterate().

See gna patch #6845.

Modified:
    branches/S2_6/common/scriptcore/api_game_methods.c
    branches/S2_6/common/scriptcore/api_game_methods.h
    branches/S2_6/common/scriptcore/tolua_game.pkg

Modified: branches/S2_6/common/scriptcore/api_game_methods.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/scriptcore/api_game_methods.c?rev=31600&r1=31599&r2=31600&view=diff
==============================================================================
--- branches/S2_6/common/scriptcore/api_game_methods.c  (original)
+++ branches/S2_6/common/scriptcore/api_game_methods.c  Mon Jan 25 19:34:37 2016
@@ -880,6 +880,28 @@
 }
 
 /*****************************************************************************
+  Return Unit that transports punit, if any.
+*****************************************************************************/
+Unit *api_methods_unit_transporter(lua_State *L, Unit *punit)
+{
+  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_SELF(L, punit, NULL);
+
+  return punit->transporter;
+}
+
+/*****************************************************************************
+  Return list head for cargo list for Unit
+*****************************************************************************/
+Unit_List_Link *api_methods_private_unit_cargo_list_head(lua_State *L,
+                                                         Unit *punit)
+{
+  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_SELF(L, punit, NULL);
+  return unit_list_head(punit->transporting);
+}
+
+/*****************************************************************************
   Return TRUE if punit_type has flag.
 *****************************************************************************/
 bool api_methods_unit_type_has_flag(lua_State *L, Unit_Type *punit_type,

Modified: branches/S2_6/common/scriptcore/api_game_methods.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/scriptcore/api_game_methods.h?rev=31600&r1=31599&r2=31600&view=diff
==============================================================================
--- branches/S2_6/common/scriptcore/api_game_methods.h  (original)
+++ branches/S2_6/common/scriptcore/api_game_methods.h  Mon Jan 25 19:34:37 2016
@@ -138,6 +138,9 @@
 bool api_methods_unit_city_can_be_built_here(lua_State *L, Unit *punit);
 Tile *api_methods_unit_tile_get(lua_State *L, Unit * punit);
 Direction api_methods_unit_orientation_get(lua_State *L, Unit *punit);
+Unit *api_methods_unit_transporter(lua_State *L, Unit *punit);
+Unit_List_Link *api_methods_private_unit_cargo_list_head(lua_State *L,
+                                                         Unit *punit);
 
 /* Unit Type */
 bool api_methods_unit_type_has_flag(lua_State *L, Unit_Type *punit_type,

Modified: branches/S2_6/common/scriptcore/tolua_game.pkg
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/scriptcore/tolua_game.pkg?rev=31600&r1=31599&r2=31600&view=diff
==============================================================================
--- branches/S2_6/common/scriptcore/tolua_game.pkg      (original)
+++ branches/S2_6/common/scriptcore/tolua_game.pkg      Mon Jan 25 19:34:37 2016
@@ -214,10 +214,19 @@
       @ tile(lua_State *L, Unit *self);
   }
 
+  Unit *api_methods_unit_transporter
+    @ transporter (lua_State *L, Unit *self);
   bool api_methods_unit_city_can_be_built_here
     @ is_on_possible_city_tile (lua_State *L, Unit *self);
   Direction api_methods_unit_orientation_get
     @ facing(lua_State *L, Unit *self);
+}
+
+module methods_private {
+  module Unit {
+    Unit_List_Link *api_methods_private_unit_cargo_list_head
+      @ cargo_list_head (lua_State *L, Unit *self);
+  }
 }
 
 $[
@@ -534,6 +543,11 @@
   function Tile:units_iterate()
     return safe_iterate_list(private.Tile.unit_list_head(self))
   end
+
+  -- Safe iteration over the units transported by Unit
+  function Unit:cargo_iterate()
+    return safe_iterate_list(private.Unit.cargo_list_head(self))
+  end
 end
 
 -- ***************************************************************************


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to