From 2d190e40c84f99b23db6d0c9880819f4cbcecb66 Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Mon, 15 Mar 2021 19:14:34 +0100 Subject: [PATCH] Lua API: can't enter and frighten at once. Ban setting both enter_hut and frighten_hut to true at once. That will at the moment always lead to frighten hut. Forbid it now to reserve it for when one hut can be entered and another one frightened at the same tile. See osdn #41791 --- server/scripting/api_server_edit.c | 8 ++++++++ server/unittools.c | 1 + 2 files changed, 9 insertions(+) diff --git a/server/scripting/api_server_edit.c b/server/scripting/api_server_edit.c index 4bcb69de2a..96785ee97f 100644 --- a/server/scripting/api_server_edit.c +++ b/server/scripting/api_server_edit.c @@ -184,6 +184,10 @@ bool api_edit_unit_teleport(lua_State *L, Unit *punit, Tile *dest, LUASCRIPT_CHECK_ARG_NIL(L, punit, 2, Unit, FALSE); LUASCRIPT_CHECK_ARG_NIL(L, dest, 3, Tile, FALSE); + LUASCRIPT_CHECK(L, !(enter_hut && frighten_hut), + "Can't both enter and frighten a hut at the same time", + TRUE); + if (!allow_disembark && unit_transported(punit)) { /* Can't leave the transport. */ return TRUE; @@ -893,6 +897,10 @@ bool api_edit_unit_move(lua_State *L, Unit *punit, Tile *ptile, LUASCRIPT_CHECK_ARG_NIL(L, ptile, 3, Tile, FALSE); LUASCRIPT_CHECK_ARG(L, movecost >= 0, 4, "Negative move cost!", FALSE); + LUASCRIPT_CHECK(L, !(enter_hut && frighten_hut), + "Can't both enter and frighten a hut at the same time", + TRUE); + if (!disembark && unit_transported(punit)) { /* Can't leave the transport. */ return TRUE; diff --git a/server/unittools.c b/server/unittools.c index 91071d4fdf..36a4801cf5 100644 --- a/server/unittools.c +++ b/server/unittools.c @@ -4006,6 +4006,7 @@ bool unit_move(struct unit *punit, struct tile *pdesttile, int move_cost, if (unit_lives && (enter_hut || frighten_hut)) { /* Is there a hut? */ unit_enter_hut(punit, frighten_hut); + fc_assert(!(enter_hut && frighten_hut)); unit_lives = unit_is_alive(saved_id); } -- 2.20.1