From a7fb91818b2d12e4992c7ce9a6da6c82b846bc66 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 6 Sep 2024 21:33:15 +0300 Subject: [PATCH 17/17] Lua: Add nationality parameter to edit.create_city() See osdn #44627 Signed-off-by: Marko Lindqvist --- server/citytools.c | 8 ++++++-- server/citytools.h | 2 +- server/edithand.c | 2 +- server/scripting/api_server_edit.c | 5 ++--- server/scripting/api_server_edit.h | 2 +- server/scripting/tolua_server.pkg | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/server/citytools.c b/server/citytools.c index d89768d254..f7eb1b688a 100644 --- a/server/citytools.c +++ b/server/citytools.c @@ -1677,7 +1677,7 @@ void create_city(struct player *pplayer, struct tile *ptile, created. ****************************************************************************/ bool create_city_for_player(struct player *pplayer, struct tile *ptile, - const char *name) + const char *name, struct player *nationality) { const struct civ_map *nmap = &(wld.map); @@ -1695,8 +1695,12 @@ bool create_city_for_player(struct player *pplayer, struct tile *ptile, name = city_name_suggestion(pplayer, ptile); } + if (nationality == nullptr) { + nationality = pplayer; + } + map_show_tile(pplayer, ptile); - create_city(pplayer, ptile, name, pplayer); + create_city(pplayer, ptile, name, nationality); return TRUE; } diff --git a/server/citytools.h b/server/citytools.h index d2d90596f9..b202bb82e3 100644 --- a/server/citytools.h +++ b/server/citytools.h @@ -69,7 +69,7 @@ void city_build_free_buildings(struct city *pcity); void create_city(struct player *pplayer, struct tile *ptile, const char *name, struct player *nationality); bool create_city_for_player(struct player *pplayer, struct tile *ptile, - const char *name); + const char *name, struct player *nationality); void remove_city(struct city *pcity); struct trade_route *remove_trade_route(struct city *pc1, diff --git a/server/edithand.c b/server/edithand.c index 0ec1648c7f..3edee4c618 100644 --- a/server/edithand.c +++ b/server/edithand.c @@ -712,7 +712,7 @@ void handle_edit_city_create(struct connection *pc, int owner, int tile, conn_list_do_buffer(game.est_connections); - if (!create_city_for_player(pplayer, ptile, NULL)) { + if (!create_city_for_player(pplayer, ptile, nullptr, nullptr)) { notify_conn(pc->self, ptile, E_BAD_COMMAND, ftc_editor, /* TRANS: ..." at ." */ _("A city may not be built at %s."), tile_link(ptile)); diff --git a/server/scripting/api_server_edit.c b/server/scripting/api_server_edit.c index 4e5e53e64c..03616a2104 100644 --- a/server/scripting/api_server_edit.c +++ b/server/scripting/api_server_edit.c @@ -674,14 +674,13 @@ bool api_edit_change_terrain(lua_State *L, Tile *ptile, Terrain *pterr) Create a new city. **************************************************************************/ bool api_edit_create_city(lua_State *L, Player *pplayer, Tile *ptile, - const char *name) + const char *name, Player *nationality) { LUASCRIPT_CHECK_STATE(L, FALSE); LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player, FALSE); LUASCRIPT_CHECK_ARG_NIL(L, ptile, 3, Tile, FALSE); - /* TODO: Allow initial citizen to be of nationality other than owner */ - return create_city_for_player(pplayer, ptile, name); + return create_city_for_player(pplayer, ptile, name, nationality); } /**********************************************************************//** diff --git a/server/scripting/api_server_edit.h b/server/scripting/api_server_edit.h index 299f47596c..51672bea49 100644 --- a/server/scripting/api_server_edit.h +++ b/server/scripting/api_server_edit.h @@ -73,7 +73,7 @@ void api_edit_unit_movepoints(lua_State *L, Unit *self, int change); bool api_edit_change_terrain(lua_State *L, Tile *ptile, Terrain *pterr); bool api_edit_create_city(lua_State *L, Player *pplayer, Tile *ptile, - const char *name); + const char *name, Player *nationality); void api_edit_remove_city(lua_State *L, City *pcity); bool api_edit_transfer_city(lua_State *L, City *pcity, Player *new_owner); void api_edit_create_building(lua_State *L, City *pcity, Building_Type *impr); diff --git a/server/scripting/tolua_server.pkg b/server/scripting/tolua_server.pkg index 4f8a981b10..b14a9b7323 100644 --- a/server/scripting/tolua_server.pkg +++ b/server/scripting/tolua_server.pkg @@ -141,7 +141,7 @@ module edit { @ change_terrain(lua_State *L, Tile *ptile, Terrain *pterr); bool api_edit_create_city @ create_city (lua_State *L, Player *pplayer, Tile *ptile, - const char *name); + const char *name, Player *nationality); bool api_edit_transfer_city @ transfer_city (lua_State *L, City *pcity, Player *new_owner); void api_edit_remove_city -- 2.45.2