From 4051fb985dd299fd274238a955f234351da5fe77 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 1 Apr 2022 21:53:38 +0300 Subject: [PATCH 39/39] Lua: Add City:remove() Requested by Ihnatus See osdn #44229 Signed-off-by: Marko Lindqvist --- server/scripting/api_server_edit.c | 11 +++++++++++ server/scripting/api_server_edit.h | 1 + server/scripting/tolua_server.pkg | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/server/scripting/api_server_edit.c b/server/scripting/api_server_edit.c index 657dfbf17f..f1b54b8481 100644 --- a/server/scripting/api_server_edit.c +++ b/server/scripting/api_server_edit.c @@ -589,6 +589,17 @@ void api_edit_create_city(lua_State *L, Player *pplayer, Tile *ptile, create_city(pplayer, ptile, name, pplayer); } +/**********************************************************************//** + Destroy a city +**************************************************************************/ +void api_edit_remove_city(lua_State *L, City *pcity) +{ + LUASCRIPT_CHECK_STATE(L); + LUASCRIPT_CHECK_ARG_NIL(L, pcity, 2, City); + + remove_city(pcity); +} + /**********************************************************************//** Create a building to a city **************************************************************************/ diff --git a/server/scripting/api_server_edit.h b/server/scripting/api_server_edit.h index 2098cbce66..e52d00957b 100644 --- a/server/scripting/api_server_edit.h +++ b/server/scripting/api_server_edit.h @@ -71,6 +71,7 @@ bool api_edit_change_terrain(lua_State *L, Tile *ptile, Terrain *pterr); void api_edit_create_city(lua_State *L, Player *pplayer, Tile *ptile, const char *name); +void api_edit_remove_city(lua_State *L, City *pcity); void api_edit_create_building(lua_State *L, City *pcity, Building_Type *impr); void api_edit_remove_building(lua_State *L, City *pcity, Building_Type *impr); Player *api_edit_create_player(lua_State *L, const char *username, diff --git a/server/scripting/tolua_server.pkg b/server/scripting/tolua_server.pkg index fa17125598..3f393ebfde 100644 --- a/server/scripting/tolua_server.pkg +++ b/server/scripting/tolua_server.pkg @@ -129,6 +129,8 @@ module edit { void api_edit_create_city @ create_city (lua_State *L, Player *pplayer, Tile *ptile, const char *name); + void api_edit_remove_city + @ remove_city (lua_State *L, City *pcity); void api_edit_create_building @ create_building (lua_State *L, City *pcity, Building_Type *impr); void api_edit_remove_building @@ -367,6 +369,10 @@ function Player:give_bulbs(amount) end -- Server functions for City module +function City:remove() + edit.remove_city(self) +end + function City:add_history(amount) edit.add_city_history(self, amount) end -- 2.35.1