From 722ae49d8945848bfc20f5a4c63625f3beb0de35 Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Wed, 10 Feb 2021 14:36:12 +0100 Subject: [PATCH] Fix Unit:move() and Unit:teleport() hut behavior. Fix the Lua api functions Unit:move() and Unit:teleport()'s hut behavior. They would pop a hut when hut_behavior is Normal and Nothing, but not when it is Frighten. Nothing is the one that is supposed to be unable to pop huts. See osdn #41544 --- server/scripting/api_server_edit.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/server/scripting/api_server_edit.c b/server/scripting/api_server_edit.c index c7f8a0dbd9..3ab8e656fc 100644 --- a/server/scripting/api_server_edit.c +++ b/server/scripting/api_server_edit.c @@ -189,7 +189,12 @@ bool api_edit_unit_teleport(lua_State *L, Unit *punit, Tile *dest) || pplayers_at_war(extra_owner(dest), unit_owner(punit))) && tile_has_claimable_base(dest, unit_type_get(punit)), - unit_class_get(punit)->hut_behavior != HUT_FRIGHTEN); + /* Backwards compatibility: unit_enter_hut() would + * return without doing anything if the unit was + * HUT_NOTHING. Setting this parameter to FALSE makes + * sure unit_enter_hut() isn't called. */ + unit_can_do_action_result(punit, ACTRES_HUT_FRIGHTEN) + || unit_can_do_action_result(punit, ACTRES_HUT_ENTER)); if (alive) { struct player *owner = unit_owner(punit); @@ -839,7 +844,12 @@ bool api_edit_unit_move(lua_State *L, Unit *punit, Tile *ptile, || pplayers_at_war(extra_owner(ptile), unit_owner(punit))) && tile_has_claimable_base(ptile, unit_type_get(punit)), - unit_class_get(punit)->hut_behavior != HUT_FRIGHTEN); + /* Backwards compatibility: unit_enter_hut() would + * return without doing anything if the unit was + * HUT_NOTHING. Setting this parameter to FALSE makes + * sure unit_enter_hut() isn't called. */ + unit_can_do_action_result(punit, ACTRES_HUT_FRIGHTEN) + || unit_can_do_action_result(punit, ACTRES_HUT_ENTER)); } /*************************************************************************//** -- 2.20.1