From a72e167dd45389b0c6a984fd4fb5e95cf768b8c8 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 13 Feb 2023 05:26:35 +0200 Subject: [PATCH 37/37] Lua: Call tile_change_side_effects() after tile changes See osdn #46425 Signed-off-by: Marko Lindqvist --- server/edithand.c | 2 ++ server/scripting/api_server_edit.c | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/server/edithand.c b/server/edithand.c index 62c648265a..fb61400822 100644 --- a/server/edithand.c +++ b/server/edithand.c @@ -145,6 +145,8 @@ static void check_edited_tile_terrains(void) assign_continent_numbers(); send_all_known_tiles(NULL); need_continents_reassigned = FALSE; + + /* FIXME: adv / ai phase handling like in check_terrain_change() */ } #ifdef SANITY_CHECKING diff --git a/server/scripting/api_server_edit.c b/server/scripting/api_server_edit.c index 49dcff5a6f..86e47e34a5 100644 --- a/server/scripting/api_server_edit.c +++ b/server/scripting/api_server_edit.c @@ -577,19 +577,25 @@ bool api_edit_change_terrain(lua_State *L, Tile *ptile, Terrain *pterr) old_terrain = tile_terrain(ptile); if (old_terrain == pterr - || (terrain_has_flag(pterr, TER_NO_CITIES) && tile_city(ptile) != NULL)) { + || (terrain_has_flag(pterr, TER_NO_CITIES) + && tile_city(ptile) != NULL)) { return FALSE; } - + tile_change_terrain(ptile, pterr); fix_tile_on_terrain_change(ptile, old_terrain, FALSE); if (need_to_reassign_continents(old_terrain, pterr)) { assign_continent_numbers(); + + /* FIXME: adv / ai phase handling like in check_terrain_change() */ + send_all_known_tiles(NULL); } update_tile_knowledge(ptile); + tile_change_side_effects(ptile); + return TRUE; } @@ -831,23 +837,23 @@ bool api_edit_trait_mod_set(lua_State *L, Player *pplayer, Create a new owned extra. **************************************************************************/ void api_edit_create_owned_extra(lua_State *L, Tile *ptile, - const char *name, - Player *pplayer) + const char *name, Player *pplayer) { struct extra_type *pextra; LUASCRIPT_CHECK_STATE(L); LUASCRIPT_CHECK_ARG_NIL(L, ptile, 2, Tile); - if (!name) { + if (name == NULL) { return; } pextra = extra_type_by_rule_name(name); - if (pextra) { + if (pextra != NULL) { create_extra(ptile, pextra, pplayer); update_tile_knowledge(ptile); + tile_change_side_effects(ptile); } } @@ -886,7 +892,7 @@ void api_edit_remove_extra(lua_State *L, Tile *ptile, const char *name) LUASCRIPT_CHECK_STATE(L); LUASCRIPT_CHECK_ARG_NIL(L, ptile, 2, Tile); - if (!name) { + if (name == NULL) { return; } @@ -895,6 +901,7 @@ void api_edit_remove_extra(lua_State *L, Tile *ptile, const char *name) if (pextra != NULL && tile_has_extra(ptile, pextra)) { tile_extra_rm_apply(ptile, pextra); update_tile_knowledge(ptile); + tile_change_side_effects(ptile); } } -- 2.39.1