Author: cazfi
Date: Tue May 23 00:09:15 2017
New Revision: 35697

URL: http://svn.gna.org/viewcvs/freeciv?rev=35697&view=rev
Log:
Add scripting API control over unit 'stay'

See hrm Feature #661580

Modified:
    branches/S3_0/server/scripting/api_server_edit.c
    branches/S3_0/server/scripting/api_server_edit.h
    branches/S3_0/server/scripting/tolua_server.pkg

Modified: branches/S3_0/server/scripting/api_server_edit.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/server/scripting/api_server_edit.c?rev=35697&r1=35696&r2=35697&view=diff
==============================================================================
--- branches/S3_0/server/scripting/api_server_edit.c    (original)
+++ branches/S3_0/server/scripting/api_server_edit.c    Tue May 23 00:09:15 2017
@@ -591,6 +591,32 @@
 }
 
 /*****************************************************************************
+  Prohibit unit from moving
+*****************************************************************************/
+void api_edit_unit_moving_disallow(lua_State *L, Unit *punit)
+{
+  LUASCRIPT_CHECK_STATE(L);
+  LUASCRIPT_CHECK_SELF(L, punit);
+
+  if (punit != NULL) {
+    punit->stay = TRUE;
+  }
+}
+
+/*****************************************************************************
+  Allow unit to move
+*****************************************************************************/
+void api_edit_unit_moving_allow(lua_State *L, Unit *punit)
+{
+  LUASCRIPT_CHECK_STATE(L);
+  LUASCRIPT_CHECK_SELF(L, punit);
+
+  if (punit != NULL) {
+    punit->stay = FALSE;
+  }
+}
+
+/*****************************************************************************
   Add history to a city
 *****************************************************************************/
 void api_edit_city_add_history(lua_State *L, City *pcity, int amount)

Modified: branches/S3_0/server/scripting/api_server_edit.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/server/scripting/api_server_edit.h?rev=35697&r1=35696&r2=35697&view=diff
==============================================================================
--- branches/S3_0/server/scripting/api_server_edit.h    (original)
+++ branches/S3_0/server/scripting/api_server_edit.h    Tue May 23 00:09:15 2017
@@ -73,6 +73,8 @@
 void api_edit_player_victory(lua_State *L, Player *pplayer);
 bool api_edit_unit_move(lua_State *L, Unit *punit, Tile *ptile,
                         int movecost);
+void api_edit_unit_moving_disallow(lua_State *L, Unit *punit);
+void api_edit_unit_moving_allow(lua_State *L, Unit *punit);
 
 void api_edit_city_add_history(lua_State *L, City *pcity, int amount);
 void api_edit_player_add_history(lua_State *L, Player *pplayer, int amount);

Modified: branches/S3_0/server/scripting/tolua_server.pkg
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/server/scripting/tolua_server.pkg?rev=35697&r1=35696&r2=35697&view=diff
==============================================================================
--- branches/S3_0/server/scripting/tolua_server.pkg     (original)
+++ branches/S3_0/server/scripting/tolua_server.pkg     Tue May 23 00:09:15 2017
@@ -177,6 +177,10 @@
     @ player_victory (lua_State *L, Player *self);
   bool api_edit_unit_move
     @ unit_move(lua_State *L, Unit *self, Tile *moveto, int movecost);
+  void api_edit_unit_moving_disallow
+    @ movement_disallow(lua_State *L, Unit *self);
+  void api_edit_unit_moving_allow
+    @ movement_allow(lua_State *L, Unit *self);
 
   void api_edit_city_add_history
     @ add_city_history(lua_State *L, City *self, int amount);
@@ -333,6 +337,14 @@
 
 function Unit:move(moveto, movecost)
   return edit.unit_move(self, moveto, movecost)
+end
+
+function Unit:movement_disallow()
+  edit.movement_disallow(self)
+end
+
+function Unit:movement_allow()
+  edit.movement_allow(self)
 end
 
 -- Server functions for Tile module


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

Reply via email to