Author: cazfi
Date: Wed Dec 23 00:34:50 2015
New Revision: 31158

URL: http://svn.gna.org/viewcvs/freeciv?rev=31158&view=rev
Log:
Added edit.remove_extra() to lua interface

See patch #6614

Modified:
    trunk/server/scripting/api_server_edit.c
    trunk/server/scripting/api_server_edit.h
    trunk/server/scripting/tolua_server.pkg

Modified: trunk/server/scripting/api_server_edit.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/scripting/api_server_edit.c?rev=31158&r1=31157&r2=31158&view=diff
==============================================================================
--- trunk/server/scripting/api_server_edit.c    (original)
+++ trunk/server/scripting/api_server_edit.c    Wed Dec 23 00:34:50 2015
@@ -429,6 +429,28 @@
 }
 
 /*****************************************************************************
+  Remove extra from tile, if present
+*****************************************************************************/
+void api_edit_remove_extra(lua_State *L, Tile *ptile, const char *name)
+{
+  struct extra_type *pextra;
+
+  LUASCRIPT_CHECK_STATE(L);
+  LUASCRIPT_CHECK_ARG_NIL(L, ptile, 2, Tile);
+
+  if (!name) {
+    return;
+  }
+
+  pextra = extra_type_by_rule_name(name);
+
+  if (pextra != NULL && tile_has_extra(ptile, pextra)) {
+    tile_extra_rm_apply(ptile, pextra);
+    update_tile_knowledge(ptile);
+  }
+}
+
+/*****************************************************************************
   Set tile label text.
 *****************************************************************************/
 void api_edit_tile_set_label(lua_State *L, Tile *ptile, const char *label)

Modified: trunk/server/scripting/api_server_edit.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/scripting/api_server_edit.h?rev=31158&r1=31157&r2=31158&view=diff
==============================================================================
--- trunk/server/scripting/api_server_edit.h    (original)
+++ trunk/server/scripting/api_server_edit.h    Wed Dec 23 00:34:50 2015
@@ -57,6 +57,7 @@
 void api_edit_create_base(lua_State *L, Tile *ptile, const char *name,
                           struct player *pplayer);
 void api_edit_create_road(lua_State *L, Tile *ptile, const char *name);
+void api_edit_remove_extra(lua_State *L, Tile *ptile, const char *name);
 
 void api_edit_tile_set_label(lua_State *L, Tile *ptile, const char *label);
 

Modified: trunk/server/scripting/tolua_server.pkg
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/scripting/tolua_server.pkg?rev=31158&r1=31157&r2=31158&view=diff
==============================================================================
--- trunk/server/scripting/tolua_server.pkg     (original)
+++ trunk/server/scripting/tolua_server.pkg     Wed Dec 23 00:34:50 2015
@@ -130,6 +130,8 @@
   /* Deprecated; use edit.create_extra() */
   void api_edit_create_road
     @ create_road (lua_State *L, Tile *ptile, const char *name);
+  void api_edit_remove_extra
+    @ remove_extra (lua_State *L, Tile *ptile, const char *name);
   void api_edit_tile_set_label
     @ tile_set_label (lua_State *L, Tile *ptile, const char *label);
   Player *api_edit_create_player
@@ -315,6 +317,10 @@
   edit.create_road(self, name)
 end
 
+function Tile:remove_extra(name)
+  edit.remove_extra(self, name)
+end
+
 function Tile:unleash_barbarians()
   return edit.unleash_barbarians(self)
 end


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

Reply via email to