diff options
author | Kenpachi Developer <Kenpachi.Developer@gmx.de> | 2020-05-09 20:44:00 +0200 |
---|---|---|
committer | Kenpachi Developer <Kenpachi.Developer@gmx.de> | 2020-05-09 20:44:00 +0200 |
commit | 8226a31d9c46950df20afaad08c2f22745f74088 (patch) | |
tree | 81140b940f2f813a8bd76ba9b3d9e1b1b53c33d3 /src/map/script.c | |
parent | 29d40c5a52ab4bb1ef08e03b763bfa47f6cad0fe (diff) | |
download | hercules-8226a31d9c46950df20afaad08c2f22745f74088.tar.gz hercules-8226a31d9c46950df20afaad08c2f22745f74088.tar.bz2 hercules-8226a31d9c46950df20afaad08c2f22745f74088.tar.xz hercules-8226a31d9c46950df20afaad08c2f22745f74088.zip |
Add script_is_permanent_variable() function
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c index c08f5e829..e5c407cc7 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -3395,6 +3395,32 @@ static void set_reg_instance_num(struct script_state *st, int64 num, const char } /** + * Validates if a variable is permanent (stored in database) by passed variable name. + * + * @param name The variable name to validate. + * @return True if variable is permanent, otherwise false. + * + **/ +static bool script_is_permanent_variable(const char *name) +{ + nullpo_retr(false, name); + + if (strlen(name) == 0) + return false; + + if (ISALNUM(name[0]) != 0) + return true; // Permanent characater variable. + + if (name[0] == '#') + return true; // Permanent (global) account variable. + + if (strlen(name) > 1 && name[0] == '$' && ISALNUM(name[1]) != 0) + return true; // Permanent server variable. + + return false; +} + +/** * Stores the value of a script variable * * @param st current script state. @@ -28250,6 +28276,7 @@ void script_defaults(void) script->load_parameters = script_load_parameters; script->print_line = script_print_line; script->errorwarning_sub = script_errorwarning_sub; + script->is_permanent_variable = script_is_permanent_variable; script->set_reg = set_reg; script->set_reg_ref_str = set_reg_npcscope_str; script->set_reg_pc_ref_str = set_reg_pc_ref_str; |