summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map/itemdb.c4
-rw-r--r--src/map/mob.c2
-rw-r--r--src/map/script.c197
-rw-r--r--src/map/script.h4
-rw-r--r--src/map/skill.c2
5 files changed, 112 insertions, 97 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 6b888c23e..6428bade5 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -1188,7 +1188,7 @@ void itemdb_read_chains(void) {
int c = 0;
config_setting_t *entry = NULL;
- script->set_constant2(name,i-1,0);
+ script->set_constant2(name, i-1, false, false);
itemdb->chains[count].qty = (unsigned short)libconfig->setting_length(itc);
CREATE(itemdb->chains[count].items, struct item_chain_entry, libconfig->setting_length(itc));
@@ -2149,7 +2149,7 @@ void itemdb_name_constants(void) {
script->parser_current_file = "Item Database (Likely an invalid or conflicting AegisName)";
#endif // ENABLE_CASE_CHECK
for( data = dbi_first(iter); dbi_exists(iter); data = dbi_next(iter) )
- script->set_constant2(data->name,data->nameid,0);
+ script->set_constant2(data->name, data->nameid, false, false);
#ifdef ENABLE_CASE_CHECK
script->parser_current_file = NULL;
#endif // ENABLE_CASE_CHECK
diff --git a/src/map/mob.c b/src/map/mob.c
index 2d94d78e3..f93a7fef3 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -4316,7 +4316,7 @@ void mob_name_constants(void) {
#endif // ENABLE_CASE_CHECK
for (i = 0; i < MAX_MOB_DB; i++) {
if (mob->db_data[i] && !mob->is_clone(i))
- script->set_constant2(mob->db_data[i]->sprite, i, 0);
+ script->set_constant2(mob->db_data[i]->sprite, i, false, false);
}
#ifdef ENABLE_CASE_CHECK
script->parser_current_file = NULL;
diff --git a/src/map/script.c b/src/map/script.c
index 8ddfb0717..35a71868a 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -1379,6 +1379,10 @@ const char* parse_simpleexpr(const char *p)
return pv;
}
+ if (script->str_data[l].type == C_INT && script->str_data[l].deprecated) {
+ disp_warning_message("This constant is deprecated and it will be removed in a future version. Please see the script documentation and constants.conf for an alternative.\n", p);
+ }
+
p=script->skip_word(p);
if( *p == '[' ) {
// array(name[i] => getelementofarray(name,i) )
@@ -2231,25 +2235,31 @@ bool script_get_constant(const char* name, int* value)
return false;
}
value[0] = script->str_data[n].val;
+ if (script->str_data[n].deprecated) {
+ ShowWarning("The constant '%s' is deprecated and it will be removed in a future version. Please see the script documentation and constants.conf for an alternative.\n", name);
+ }
return true;
}
/// Creates new constant or parameter with given value.
-void script_set_constant(const char* name, int value, bool isparameter) {
+void script_set_constant(const char *name, int value, bool is_parameter, bool is_deprecated)
+{
int n = script->add_str(name);
if( script->str_data[n].type == C_NOP ) {// new
- script->str_data[n].type = isparameter ? C_PARAM : C_INT;
+ script->str_data[n].type = is_parameter ? C_PARAM : C_INT;
script->str_data[n].val = value;
+ script->str_data[n].deprecated = is_deprecated ? 1 : 0;
} else if( script->str_data[n].type == C_PARAM || script->str_data[n].type == C_INT ) {// existing parameter or constant
ShowError("script_set_constant: Attempted to overwrite existing %s '%s' (old value=%d, new value=%d).\n", ( script->str_data[n].type == C_PARAM ) ? "parameter" : "constant", name, script->str_data[n].val, value);
} else {// existing name
- ShowError("script_set_constant: Invalid name for %s '%s' (already defined as %s).\n", isparameter ? "parameter" : "constant", name, script->op2name(script->str_data[n].type));
+ ShowError("script_set_constant: Invalid name for %s '%s' (already defined as %s).\n", is_parameter ? "parameter" : "constant", name, script->op2name(script->str_data[n].type));
}
}
/* adds data to a existent constant in the database, inserted normally via parse */
-void script_set_constant2(const char *name, int value, bool isparameter) {
+void script_set_constant2(const char *name, int value, bool is_parameter, bool is_deprecated)
+{
int n = script->add_str(name);
if( script->str_data[n].type == C_PARAM ) {
@@ -2273,9 +2283,9 @@ void script_set_constant2(const char *name, int value, bool isparameter) {
script->str_data[n].label = -1;
}
- script->str_data[n].type = isparameter ? C_PARAM : C_INT;
+ script->str_data[n].type = is_parameter ? C_PARAM : C_INT;
script->str_data[n].val = value;
-
+ script->str_data[n].deprecated = is_deprecated ? 1 : 0;
}
/**
@@ -2298,6 +2308,7 @@ void read_constdb(void)
while ((t = libconfig->setting_get_elem(cdb, i++))) {
bool is_parameter = false;
+ bool is_deprecated = false;
int value = 0;
const char *name = config_setting_name(t);
const char *p = name;
@@ -2322,10 +2333,14 @@ void read_constdb(void)
if (i32 != 0)
is_parameter = true;
}
+ if (libconfig->setting_lookup_bool(t, "Deprecated", &i32)) {
+ if (i32 != 0)
+ is_deprecated = true;
+ }
} else {
value = libconfig->setting_get_int(t);
}
- script->set_constant(name, value, is_parameter);
+ script->set_constant(name, value, is_parameter, is_deprecated);
}
libconfig->destroy(&constants_conf);
}
@@ -20805,119 +20820,119 @@ void script_label_add(int key, int pos) {
**/
void script_hardcoded_constants(void)
{
- script->set_constant("true", 1, false);
- script->set_constant("false", 0, false);
+ script->set_constant("true", 1, false, false);
+ script->set_constant("false", 0, false, false);
/* server defines */
- script->set_constant("PACKETVER",PACKETVER,false);
- script->set_constant("MAX_LEVEL",MAX_LEVEL,false);
- script->set_constant("MAX_STORAGE",MAX_STORAGE,false);
- script->set_constant("MAX_GUILD_STORAGE",MAX_GUILD_STORAGE,false);
- script->set_constant("MAX_CART",MAX_INVENTORY,false);
- script->set_constant("MAX_INVENTORY",MAX_INVENTORY,false);
- script->set_constant("MAX_ZENY",MAX_ZENY,false);
- script->set_constant("MAX_BG_MEMBERS",MAX_BG_MEMBERS,false);
- script->set_constant("MAX_CHAT_USERS",MAX_CHAT_USERS,false);
- script->set_constant("MAX_REFINE",MAX_REFINE,false);
+ script->set_constant("PACKETVER",PACKETVER,false, false);
+ script->set_constant("MAX_LEVEL",MAX_LEVEL,false, false);
+ script->set_constant("MAX_STORAGE",MAX_STORAGE,false, false);
+ script->set_constant("MAX_GUILD_STORAGE",MAX_GUILD_STORAGE,false, false);
+ script->set_constant("MAX_CART",MAX_INVENTORY,false, false);
+ script->set_constant("MAX_INVENTORY",MAX_INVENTORY,false, false);
+ script->set_constant("MAX_ZENY",MAX_ZENY,false, false);
+ script->set_constant("MAX_BG_MEMBERS",MAX_BG_MEMBERS,false, false);
+ script->set_constant("MAX_CHAT_USERS",MAX_CHAT_USERS,false, false);
+ script->set_constant("MAX_REFINE",MAX_REFINE,false, false);
/* status options */
- script->set_constant("Option_Nothing",OPTION_NOTHING,false);
- script->set_constant("Option_Sight",OPTION_SIGHT,false);
- script->set_constant("Option_Hide",OPTION_HIDE,false);
- script->set_constant("Option_Cloak",OPTION_CLOAK,false);
- script->set_constant("Option_Falcon",OPTION_FALCON,false);
- script->set_constant("Option_Riding",OPTION_RIDING,false);
- script->set_constant("Option_Invisible",OPTION_INVISIBLE,false);
- script->set_constant("Option_Orcish",OPTION_ORCISH,false);
- script->set_constant("Option_Wedding",OPTION_WEDDING,false);
- script->set_constant("Option_Chasewalk",OPTION_CHASEWALK,false);
- script->set_constant("Option_Flying",OPTION_FLYING,false);
- script->set_constant("Option_Xmas",OPTION_XMAS,false);
- script->set_constant("Option_Transform",OPTION_TRANSFORM,false);
- script->set_constant("Option_Summer",OPTION_SUMMER,false);
- script->set_constant("Option_Dragon1",OPTION_DRAGON1,false);
- script->set_constant("Option_Wug",OPTION_WUG,false);
- script->set_constant("Option_Wugrider",OPTION_WUGRIDER,false);
- script->set_constant("Option_Madogear",OPTION_MADOGEAR,false);
- script->set_constant("Option_Dragon2",OPTION_DRAGON2,false);
- script->set_constant("Option_Dragon3",OPTION_DRAGON3,false);
- script->set_constant("Option_Dragon4",OPTION_DRAGON4,false);
- script->set_constant("Option_Dragon5",OPTION_DRAGON5,false);
- script->set_constant("Option_Hanbok",OPTION_HANBOK,false);
- script->set_constant("Option_Oktoberfest",OPTION_OKTOBERFEST,false);
+ script->set_constant("Option_Nothing",OPTION_NOTHING,false, false);
+ script->set_constant("Option_Sight",OPTION_SIGHT,false, false);
+ script->set_constant("Option_Hide",OPTION_HIDE,false, false);
+ script->set_constant("Option_Cloak",OPTION_CLOAK,false, false);
+ script->set_constant("Option_Falcon",OPTION_FALCON,false, false);
+ script->set_constant("Option_Riding",OPTION_RIDING,false, false);
+ script->set_constant("Option_Invisible",OPTION_INVISIBLE,false, false);
+ script->set_constant("Option_Orcish",OPTION_ORCISH,false, false);
+ script->set_constant("Option_Wedding",OPTION_WEDDING,false, false);
+ script->set_constant("Option_Chasewalk",OPTION_CHASEWALK,false, false);
+ script->set_constant("Option_Flying",OPTION_FLYING,false, false);
+ script->set_constant("Option_Xmas",OPTION_XMAS,false, false);
+ script->set_constant("Option_Transform",OPTION_TRANSFORM,false, false);
+ script->set_constant("Option_Summer",OPTION_SUMMER,false, false);
+ script->set_constant("Option_Dragon1",OPTION_DRAGON1,false, false);
+ script->set_constant("Option_Wug",OPTION_WUG,false, false);
+ script->set_constant("Option_Wugrider",OPTION_WUGRIDER,false, false);
+ script->set_constant("Option_Madogear",OPTION_MADOGEAR,false, false);
+ script->set_constant("Option_Dragon2",OPTION_DRAGON2,false, false);
+ script->set_constant("Option_Dragon3",OPTION_DRAGON3,false, false);
+ script->set_constant("Option_Dragon4",OPTION_DRAGON4,false, false);
+ script->set_constant("Option_Dragon5",OPTION_DRAGON5,false, false);
+ script->set_constant("Option_Hanbok",OPTION_HANBOK,false, false);
+ script->set_constant("Option_Oktoberfest",OPTION_OKTOBERFEST,false, false);
/* status option compounds */
- script->set_constant("Option_Dragon",OPTION_DRAGON,false);
- script->set_constant("Option_Costume",OPTION_COSTUME,false);
+ script->set_constant("Option_Dragon",OPTION_DRAGON,false, false);
+ script->set_constant("Option_Costume",OPTION_COSTUME,false, false);
/* send_target */
- script->set_constant("ALL_CLIENT",ALL_CLIENT,false);
- script->set_constant("ALL_SAMEMAP",ALL_SAMEMAP,false);
- script->set_constant("AREA",AREA,false);
- script->set_constant("AREA_WOS",AREA_WOS,false);
- script->set_constant("AREA_WOC",AREA_WOC,false);
- script->set_constant("AREA_WOSC",AREA_WOSC,false);
- script->set_constant("AREA_CHAT_WOC",AREA_CHAT_WOC,false);
- script->set_constant("CHAT",CHAT,false);
- script->set_constant("CHAT_WOS",CHAT_WOS,false);
- script->set_constant("PARTY",PARTY,false);
- script->set_constant("PARTY_WOS",PARTY_WOS,false);
- script->set_constant("PARTY_SAMEMAP",PARTY_SAMEMAP,false);
- script->set_constant("PARTY_SAMEMAP_WOS",PARTY_SAMEMAP_WOS,false);
- script->set_constant("PARTY_AREA",PARTY_AREA,false);
- script->set_constant("PARTY_AREA_WOS",PARTY_AREA_WOS,false);
- script->set_constant("GUILD",GUILD,false);
- script->set_constant("GUILD_WOS",GUILD_WOS,false);
- script->set_constant("GUILD_SAMEMAP",GUILD_SAMEMAP,false);
- script->set_constant("GUILD_SAMEMAP_WOS",GUILD_SAMEMAP_WOS,false);
- script->set_constant("GUILD_AREA",GUILD_AREA,false);
- script->set_constant("GUILD_AREA_WOS",GUILD_AREA_WOS,false);
- script->set_constant("GUILD_NOBG",GUILD_NOBG,false);
- script->set_constant("DUEL",DUEL,false);
- script->set_constant("DUEL_WOS",DUEL_WOS,false);
- script->set_constant("SELF",SELF,false);
- script->set_constant("BG",BG,false);
- script->set_constant("BG_WOS",BG_WOS,false);
- script->set_constant("BG_SAMEMAP",BG_SAMEMAP,false);
- script->set_constant("BG_SAMEMAP_WOS",BG_SAMEMAP_WOS,false);
- script->set_constant("BG_AREA",BG_AREA,false);
- script->set_constant("BG_AREA_WOS",BG_AREA_WOS,false);
- script->set_constant("BG_QUEUE",BG_QUEUE,false);
+ script->set_constant("ALL_CLIENT",ALL_CLIENT,false, false);
+ script->set_constant("ALL_SAMEMAP",ALL_SAMEMAP,false, false);
+ script->set_constant("AREA",AREA,false, false);
+ script->set_constant("AREA_WOS",AREA_WOS,false, false);
+ script->set_constant("AREA_WOC",AREA_WOC,false, false);
+ script->set_constant("AREA_WOSC",AREA_WOSC,false, false);
+ script->set_constant("AREA_CHAT_WOC",AREA_CHAT_WOC,false, false);
+ script->set_constant("CHAT",CHAT,false, false);
+ script->set_constant("CHAT_WOS",CHAT_WOS,false, false);
+ script->set_constant("PARTY",PARTY,false, false);
+ script->set_constant("PARTY_WOS",PARTY_WOS,false, false);
+ script->set_constant("PARTY_SAMEMAP",PARTY_SAMEMAP,false, false);
+ script->set_constant("PARTY_SAMEMAP_WOS",PARTY_SAMEMAP_WOS,false, false);
+ script->set_constant("PARTY_AREA",PARTY_AREA,false, false);
+ script->set_constant("PARTY_AREA_WOS",PARTY_AREA_WOS,false, false);
+ script->set_constant("GUILD",GUILD,false, false);
+ script->set_constant("GUILD_WOS",GUILD_WOS,false, false);
+ script->set_constant("GUILD_SAMEMAP",GUILD_SAMEMAP,false, false);
+ script->set_constant("GUILD_SAMEMAP_WOS",GUILD_SAMEMAP_WOS,false, false);
+ script->set_constant("GUILD_AREA",GUILD_AREA,false, false);
+ script->set_constant("GUILD_AREA_WOS",GUILD_AREA_WOS,false, false);
+ script->set_constant("GUILD_NOBG",GUILD_NOBG,false, false);
+ script->set_constant("DUEL",DUEL,false, false);
+ script->set_constant("DUEL_WOS",DUEL_WOS,false, false);
+ script->set_constant("SELF",SELF,false, false);
+ script->set_constant("BG",BG,false, false);
+ script->set_constant("BG_WOS",BG_WOS,false, false);
+ script->set_constant("BG_SAMEMAP",BG_SAMEMAP,false, false);
+ script->set_constant("BG_SAMEMAP_WOS",BG_SAMEMAP_WOS,false, false);
+ script->set_constant("BG_AREA",BG_AREA,false, false);
+ script->set_constant("BG_AREA_WOS",BG_AREA_WOS,false, false);
+ script->set_constant("BG_QUEUE",BG_QUEUE,false, false);
/* Renewal */
#ifdef RENEWAL
- script->set_constant("RENEWAL", 1, false);
+ script->set_constant("RENEWAL", 1, false, false);
#else
- script->set_constant("RENEWAL", 0, false);
+ script->set_constant("RENEWAL", 0, false, false);
#endif
#ifdef RENEWAL_CAST
- script->set_constant("RENEWAL_CAST", 1, false);
+ script->set_constant("RENEWAL_CAST", 1, false, false);
#else
- script->set_constant("RENEWAL_CAST", 0, false);
+ script->set_constant("RENEWAL_CAST", 0, false, false);
#endif
#ifdef RENEWAL_DROP
- script->set_constant("RENEWAL_DROP", 1, false);
+ script->set_constant("RENEWAL_DROP", 1, false, false);
#else
- script->set_constant("RENEWAL_DROP", 0, false);
+ script->set_constant("RENEWAL_DROP", 0, false, false);
#endif
#ifdef RENEWAL_EXP
- script->set_constant("RENEWAL_EXP", 1, false);
+ script->set_constant("RENEWAL_EXP", 1, false, false);
#else
- script->set_constant("RENEWAL_EXP", 0, false);
+ script->set_constant("RENEWAL_EXP", 0, false, false);
#endif
#ifdef RENEWAL_LVDMG
- script->set_constant("RENEWAL_LVDMG", 1, false);
+ script->set_constant("RENEWAL_LVDMG", 1, false, false);
#else
- script->set_constant("RENEWAL_LVDMG", 0, false);
+ script->set_constant("RENEWAL_LVDMG", 0, false, false);
#endif
#ifdef RENEWAL_EDP
- script->set_constant("RENEWAL_EDP", 1, false);
+ script->set_constant("RENEWAL_EDP", 1, false, false);
#else
- script->set_constant("RENEWAL_EDP", 0, false);
+ script->set_constant("RENEWAL_EDP", 0, false, false);
#endif
#ifdef RENEWAL_ASPD
- script->set_constant("RENEWAL_ASPD", 1, false);
+ script->set_constant("RENEWAL_ASPD", 1, false, false);
#else
- script->set_constant("RENEWAL_ASPD", 0, false);
+ script->set_constant("RENEWAL_ASPD", 0, false, false);
#endif
}
diff --git a/src/map/script.h b/src/map/script.h
index 5f71662c6..dbb0f8a03 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -666,8 +666,8 @@ struct script_interface {
struct script_data* (*push_str) (struct script_stack* stack, enum c_op type, char* str);
struct script_data* (*push_copy) (struct script_stack* stack, int pos);
void (*pop_stack) (struct script_state* st, int start, int end);
- void (*set_constant) (const char* name, int value, bool isparameter);
- void (*set_constant2) (const char *name, int value, bool isparameter);
+ void (*set_constant) (const char *name, int value, bool is_parameter, bool is_deprecated);
+ void (*set_constant2) (const char *name, int value, bool is_parameter, bool is_deprecated);
bool (*get_constant) (const char* name, int* value);
void (*label_add)(int key, int pos);
void (*run) (struct script_code *rootscript, int pos, int rid, int oid);
diff --git a/src/map/skill.c b/src/map/skill.c
index a14f7a6c5..be899d0dc 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -18795,7 +18795,7 @@ bool skill_parse_row_skilldb(char* split[], int columns, int current) {
safestrncpy(skill->dbs->db[idx].name, trim(split[15]), sizeof(skill->dbs->db[idx].name));
safestrncpy(skill->dbs->db[idx].desc, trim(split[16]), sizeof(skill->dbs->db[idx].desc));
strdb_iput(skill->name2id_db, skill->dbs->db[idx].name, skill_id);
- script->set_constant2(skill->dbs->db[idx].name,(int)skill_id,0);
+ script->set_constant2(skill->dbs->db[idx].name, (int)skill_id, false, false);
return true;
}