From 73cd6f58928d29bb98b76fd893f06623307698e5 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 26 Aug 2024 00:28:31 +0300 Subject: [PATCH 23/23] Lua: Add edit.change_city_size() method See osdn #44230 Signed-off-by: Marko Lindqvist --- server/scripting/api_server_edit.c | 16 ++++++++++++++++ server/scripting/api_server_edit.h | 1 + server/scripting/tolua_server.pkg | 3 +++ 3 files changed, 20 insertions(+) diff --git a/server/scripting/api_server_edit.c b/server/scripting/api_server_edit.c index 50bdfb93ec..4e5e53e64c 100644 --- a/server/scripting/api_server_edit.c +++ b/server/scripting/api_server_edit.c @@ -1302,3 +1302,19 @@ bool api_edit_create_trade_route(lua_State *L, City *from, City *to) return TRUE; } + +/**********************************************************************//** + Change city size. +**************************************************************************/ +void api_edit_change_city_size(lua_State *L, City *pcity, int change, + Player *nationality) +{ + LUASCRIPT_CHECK_STATE(L); + LUASCRIPT_CHECK_ARG_NIL(L, pcity, 2, City); + + if (nationality == nullptr) { + nationality = city_owner(pcity); + } + + city_change_size(pcity, city_size_get(pcity) + change, nationality, "script"); +} diff --git a/server/scripting/api_server_edit.h b/server/scripting/api_server_edit.h index 9925b52537..299f47596c 100644 --- a/server/scripting/api_server_edit.h +++ b/server/scripting/api_server_edit.h @@ -121,5 +121,6 @@ void api_edit_player_give_bulbs(lua_State *L, Player *pplayer, int amount, Tech_Type *tech); bool api_edit_create_trade_route(lua_State *L, City *from, City *to); +void api_edit_change_city_size(lua_State *L, City *pcity, int change, Player *nationality); #endif /* API_SERVER_EDIT_H */ diff --git a/server/scripting/tolua_server.pkg b/server/scripting/tolua_server.pkg index 4c0e1ffa7f..4f8a981b10 100644 --- a/server/scripting/tolua_server.pkg +++ b/server/scripting/tolua_server.pkg @@ -248,6 +248,9 @@ module edit { bool api_edit_create_trade_route @ create_trade_route(lua_State *L, City *from, City *to); + + void api_edit_change_city_size + @ change_city_size(lua_State *L, City *pcity, int change, Player *nationality); } /* Luadata module. */ -- 2.45.2