From 3d6b4e6c7169716a2bd3e56acb8c45750f662298 Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Fri, 12 Mar 2021 20:00:44 +0100 Subject: [PATCH 14/14] Lua API: deprecate not specifying side effects. Deprecate calling edit.unit_move() - aka Unit:move() - and edit.unit_teleport() - aka Unit:teleport() - without specifying the side effect parameters and then assuming that they will be filled in based on the old rules. See osdn #41752 --- server/scripting/api_server_edit.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/server/scripting/api_server_edit.c b/server/scripting/api_server_edit.c index 0da5de694b..4bcb69de2a 100644 --- a/server/scripting/api_server_edit.c +++ b/server/scripting/api_server_edit.c @@ -16,6 +16,7 @@ #endif /* utility */ +#include "deprecations.h" #include "rand.h" /* common */ @@ -51,6 +52,21 @@ #include "api_server_edit.h" +/**********************************************************************//** + Warn about use of a deprecated number of arguments. +**************************************************************************/ +static void deprecated_semantic_warning(const char *call, const char *aka, + const char *deprecated_since) +{ + if (are_deprecation_warnings_enabled()) { + log_deprecation_always( + "Deprecated: Lua call %s aka %s filling out the remaining" + " parameters based on the old rules is deprecated" + " since Freeciv %s.", + call, aka, deprecated_since); + } +} + /*************************************************************************//** Unleash barbarians on a tile, for example from a hut *****************************************************************************/ @@ -206,6 +222,9 @@ bool api_edit_unit_teleport_old(lua_State *L, Unit *punit, Tile *dest) bool alive; struct city *pcity; + deprecated_semantic_warning("edit.unit_teleport(unit, dest)", + "Unit:teleport(dest)", "3.1"); + LUASCRIPT_CHECK_STATE(L, FALSE); LUASCRIPT_CHECK_ARG_NIL(L, punit, 2, Unit, FALSE); LUASCRIPT_CHECK_ARG_NIL(L, dest, 3, Tile, FALSE); @@ -893,6 +912,9 @@ bool api_edit_unit_move_old(lua_State *L, Unit *punit, Tile *ptile, { struct city *pcity; + deprecated_semantic_warning("edit.unit_move(unit, moveto, movecost)", + "Unit:move(moveto, movecost)", "3.1"); + LUASCRIPT_CHECK_STATE(L, FALSE); LUASCRIPT_CHECK_SELF(L, punit, FALSE); LUASCRIPT_CHECK_ARG_NIL(L, ptile, 3, Tile, FALSE); -- 2.20.1