From 1b5b9b66284f0178e8c4654ef94edf370c28ad93 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 30 Dec 2021 04:59:19 +0200 Subject: [PATCH 36/36] Add deprecation warning about use of old style parameters fcdb.option() See osdn #43463 Signed-off-by: Marko Lindqvist --- server/scripting/api_fcdb_base.c | 13 +++++++++++++ server/scripting/tolua_fcdb.pkg | 16 ++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/server/scripting/api_fcdb_base.c b/server/scripting/api_fcdb_base.c index a938f10369..76dc1f3d80 100644 --- a/server/scripting/api_fcdb_base.c +++ b/server/scripting/api_fcdb_base.c @@ -15,6 +15,9 @@ #include #endif +/* utility */ +#include "deprecations.h" + /* common/scriptcore */ #include "luascript.h" @@ -23,6 +26,8 @@ #include "api_fcdb_base.h" +#define OPTION_DEPR_PREFIX "#deprecated." + /**********************************************************************//** Return the value for the fcdb setting 'type'. **************************************************************************/ @@ -31,5 +36,13 @@ const char *api_fcdb_option(lua_State *L, const char *type) LUASCRIPT_CHECK_STATE(L, NULL); LUASCRIPT_CHECK_ARG_NIL(L, type, 2, string, NULL); + if (!fc_strncasecmp(OPTION_DEPR_PREFIX, type, + strlen(OPTION_DEPR_PREFIX))) { + type = type + strlen(OPTION_DEPR_PREFIX); + log_deprecation("Option name for fdb.option(\"%s\") given " + "in a way deprecated since 2.5. " + "Use literal string instead.", type); + } + return fcdb_option_get(type); } diff --git a/server/scripting/tolua_fcdb.pkg b/server/scripting/tolua_fcdb.pkg index e2e653f9b7..d76688ae30 100644 --- a/server/scripting/tolua_fcdb.pkg +++ b/server/scripting/tolua_fcdb.pkg @@ -50,13 +50,13 @@ $[ -- but it's deprecated in favour of literal strings, and the strings listed -- here are only conventional. fcdb["param"] = { - HOST = "host", - USER = "user", - PORT = "port", - PASSWORD = "password", - DATABASE = "database", - TABLE_USER = "table_user", - TABLE_LOG = "table_log", - BACKEND = "backend" + HOST = "#deprecated.host", + USER = "#deprecated.user", + PORT = "#deprecated.port", + PASSWORD = "#deprecated.password", + DATABASE = "#deprecated.database", + TABLE_USER = "#deprecated.table_user", + TABLE_LOG = "#deprecated.table_log", + BACKEND = "#deprecated.backend" } $] -- 2.34.1