From 3278e4c9eca364002ae32571f260782a564c4f8f Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 13 Feb 2023 05:32:23 +0200 Subject: [PATCH 19/19] 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 | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/server/edithand.c b/server/edithand.c index ab348afcc7..7f0a5bdf8a 100644 --- a/server/edithand.c +++ b/server/edithand.c @@ -144,6 +144,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 b5163cc03e..d95fb91e22 100644 --- a/server/scripting/api_server_edit.c +++ b/server/scripting/api_server_edit.c @@ -256,19 +256,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; } @@ -431,23 +437,24 @@ 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) +void api_edit_create_owned_extra(lua_State *L, Tile *ptile, + 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); } } @@ -486,7 +493,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; } @@ -495,6 +502,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