diff options
author | Haru <haru@dotalux.com> | 2014-10-18 21:34:29 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2014-10-27 00:38:45 +0100 |
commit | ce85609f42d6f0f2fd1db6e76bce9744e231074e (patch) | |
tree | 5972802a7c25dae8b1845967ee82479d7ecfde2e /src/map | |
parent | c151e8714304dc4f95d9ce91b98fc84bf0958d94 (diff) | |
download | hercules-ce85609f42d6f0f2fd1db6e76bce9744e231074e.tar.gz hercules-ce85609f42d6f0f2fd1db6e76bce9744e231074e.tar.bz2 hercules-ce85609f42d6f0f2fd1db6e76bce9744e231074e.tar.xz hercules-ce85609f42d6f0f2fd1db6e76bce9744e231074e.zip |
Added source support to mark script commands as deprecated
- Commands marked as deprecated will trigger a warning when the script
is loaded. (there are currently no commands marked as such, but some
will come soon)
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/script.c | 10 | ||||
-rw-r--r-- | src/map/script.h | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/map/script.c b/src/map/script.c index b8e161e10..9429d66d4 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -772,6 +772,8 @@ const char* parse_callfunc(const char* p, int require_paren, int is_custom) script->addl(func); script->addc(C_ARG); arg = script->buildin[script->str_data[func].val]; + if (script->str_data[func].deprecated) + DeprecationWarning(p); if( !arg ) arg = &null_arg; // Use a dummy, null string } else if( script->str_data[func].type == C_USERFUNC || script->str_data[func].type == C_USERFUNC_POS ) { // script defined function @@ -18977,6 +18979,7 @@ bool script_add_builtin(const struct script_function *buildin, bool override) { } script->str_data[n].func = buildin->func; + script->str_data[n].deprecated = (buildin->deprecated ? 1 : 0); /* we only store the arguments, its the only thing used out of this */ if( slen ) { @@ -18994,11 +18997,14 @@ bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st) buildin.name = name; buildin.arg = args; buildin.func = func; + buildin.deprecated = false; return script->add_builtin(&buildin, true); } -#define BUILDIN_DEF(x,args) { buildin_ ## x , #x , args } -#define BUILDIN_DEF2(x,x2,args) { buildin_ ## x , x2 , args } +#define BUILDIN_DEF(x,args) { buildin_ ## x , #x , args, false } +#define BUILDIN_DEF2(x,x2,args) { buildin_ ## x , x2 , args, false } +#define BUILDIN_DEF_DEPRECATED(x,args) { buildin_ ## x , #x , args, true } +#define BUILDIN_DEF2_DEPRECATED(x,x2,args) { buildin_ ## x , x2 , args, true } void script_parse_builtin(void) { struct script_function BUILDIN[] = { // NPC interaction diff --git a/src/map/script.h b/src/map/script.h index 54b3835a7..75ba8d5ce 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -30,6 +30,8 @@ struct eri; #define DeprecationCaseWarning2(func, bad, good, where) ShowError("%s: detected possible use of wrong case in a script. Found '%s', probably meant to be '%s' (in '%s').\n", (func), (bad), (good), get_script_source(where)) #define disp_deprecation_message(func, good, p) disp_warning_message(func": use of deprecated keyword (use '"good"' instead).", (p)) +#define DeprecationWarning(p) disp_warning_message("This command is deprecated and it will be removed in a future update. Please see the script documentation for an alternative.\n", (p)) + #define NUM_WHISPER_VAR 10 /// Maximum amount of elements in script arrays @@ -433,6 +435,7 @@ struct script_function { bool (*func)(struct script_state *st); char *name; char *arg; + bool deprecated; }; // String buffer structures. @@ -445,6 +448,7 @@ struct str_data_struct { bool (*func)(struct script_state *st); int val; int next; + uint8 deprecated : 1; }; struct script_label_entry { |