From 926cff033bb9533ae3d8615f8b90e2e443d0525b Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 21 Aug 2017 20:58:36 +0200 Subject: Add support for bitmask arrays in the item_db Upper field Signed-off-by: Haru --- db/item_db2.conf | 2 +- db/pre-re/item_db.conf | 2 +- db/re/item_db.conf | 2 +- doc/item_db.txt | 20 ++++++++++---------- src/map/itemdb.c | 2 +- src/map/script.c | 10 ++++++++++ src/plugins/db2sql.c | 5 +++-- 7 files changed, 27 insertions(+), 16 deletions(-) diff --git a/db/item_db2.conf b/db/item_db2.conf index c4bc83837..8abe34a38 100644 --- a/db/item_db2.conf +++ b/db/item_db2.conf @@ -79,7 +79,7 @@ item_db: ( Rebellion: true/false (boolean, defaults to false) } Job: Job mask (alternate format, int, defaults to all jobs = 0xFFFFFFFF) - Upper: Upper mask (int, defaults to any = 0x3f) + Upper: Upper mask (bitmask array, string or int, defaults to "ITEMUPPER_ALL") Gender: Gender (int, defaults to both = 2) Loc: Equip location (int, required value for equipment) WeaponLv: Weapon Level (int, defaults to 0) diff --git a/db/pre-re/item_db.conf b/db/pre-re/item_db.conf index 055d3962c..7153451c2 100644 --- a/db/pre-re/item_db.conf +++ b/db/pre-re/item_db.conf @@ -79,7 +79,7 @@ item_db: ( Rebellion: true/false (boolean, defaults to false) } Job: Job mask (alternate format, int, defaults to all jobs = 0xFFFFFFFF) - Upper: Upper mask (int, defaults to any = 0x3f) + Upper: Upper mask (bitmask array, string or int, defaults to "ITEMUPPER_ALL") Gender: Gender (string, defaults to "SEX_ANY") Loc: Equip location (int, required value for equipment) WeaponLv: Weapon Level (int, defaults to 0) diff --git a/db/re/item_db.conf b/db/re/item_db.conf index bb4d87a77..e0830f876 100644 --- a/db/re/item_db.conf +++ b/db/re/item_db.conf @@ -79,7 +79,7 @@ item_db: ( Rebellion: true/false (boolean, defaults to false) } Job: Job mask (alternate format, int, defaults to all jobs = 0xFFFFFFFF) - Upper: Upper mask (int, defaults to any = 0x3f) + Upper: Upper mask (bitmask array, string or int, defaults to "ITEMUPPER_ALL") Gender: Gender (string, defaults to "SEX_ANY") Loc: Equip location (int, required value for equipment) WeaponLv: Weapon Level (int, defaults to 0) diff --git a/doc/item_db.txt b/doc/item_db.txt index 8a33f9c35..d9ec96fc1 100644 --- a/doc/item_db.txt +++ b/doc/item_db.txt @@ -58,7 +58,7 @@ item_db: ( Summoner: true/false (boolean, defaults to false) } Job: Job mask (alternate synxtax, int, defaults to all jobs = 0xFFFFFFFF) - Upper: Upper mask (int, defaults to any = 0x3f) + Upper: Upper mask (bitmask array, string or int, defaults to "ITEMUPPER_ALL") Gender: Gender (string, defaults to "SEX_ANY") Loc: Equip location (int, required value for equipment) WeaponLv: Weapon Level (int, defaults to 0) @@ -188,17 +188,17 @@ Job: Job restrictions. If this block is omitted, item can be equipped by all cl All (default value): 0xFFFFFFFF Upper: Equippable upper-types. Uses the following bitmasks: - Normal jobs: 0x01 (1) - Upper jobs: 0x02 (2) - Baby jobs: 0x04 (4) - Third jobs: 0x08 (8) - Upper Third jobs: 0x10 (16) - Baby Third jobs: 0x20 (32) + Normal jobs: ITEMUPPER_NORMAL (0x01) + Upper jobs: ITEMUPPER_UPPER (0x02) + Baby jobs: ITEMUPPER_BABY (0x04) + Third jobs: ITEMUPPER_THIRD (0x08) + Upper Third jobs: ITEMUPPER_THIRDUPPER (0x10) + Baby Third jobs: ITEMUPPER_THIRDBABY (0x20) Under pre-re mode third classes are considered upper, making use of - the 8 and above masks is therefore not necessary unless in renewal - mode. When no value is specified, all classes (mask 0x3f) are able to - equip the item. + the ITEMUPPER_THIRD and above masks is therefore not necessary unless + in renewal mode. When no value is specified, all classes (mask + ITEMUPPER_ALL = 0x3f) are able to equip the item. Gender: Gender restriction. Available genders: diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 7a2c967fb..0ace20984 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2037,7 +2037,7 @@ int itemdb_readdb_libconfig_sub(struct config_setting_t *it, int n, const char * itemdb->jobmask2mapid(id.class_base, UINT64_MAX); } - if( itemdb->lookup_const(it, "Upper", &i32) && i32 >= 0 ) + if (itemdb->lookup_const_mask(it, "Upper", &i32) && i32 >= 0) id.class_upper = (unsigned int)i32; else if( !inherit ) id.class_upper = ITEMUPPER_ALL; diff --git a/src/map/script.c b/src/map/script.c index 5ce581db6..f29ce4104 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -24572,6 +24572,16 @@ void script_hardcoded_constants(void) script->set_constant("A_CANNONBALL", A_CANNONBALL, false, false); script->set_constant("A_THROWWEAPON", A_THROWWEAPON, false, false); + script->constdb_comment("Item Upper Masks"); + script->set_constant("ITEMUPPER_NONE", ITEMUPPER_NONE, false, false); + script->set_constant("ITEMUPPER_NORMAL", ITEMUPPER_NORMAL, false, false); + script->set_constant("ITEMUPPER_UPPER", ITEMUPPER_UPPER, false, false); + script->set_constant("ITEMUPPER_BABY", ITEMUPPER_BABY, false, false); + script->set_constant("ITEMUPPER_THIRD", ITEMUPPER_THIRD, false, false); + script->set_constant("ITEMUPPER_THIRDUPPER", ITEMUPPER_THIRDUPPER, false, false); + script->set_constant("ITEMUPPER_THIRDBABY", ITEMUPPER_THIRDBABY, false, false); + script->set_constant("ITEMUPPER_ALL", ITEMUPPER_ALL, false, false); + script->constdb_comment("Renewal"); #ifdef RENEWAL script->set_constant("RENEWAL", 1, false, false); diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c index cb8660df9..38e5ead5d 100644 --- a/src/plugins/db2sql.c +++ b/src/plugins/db2sql.c @@ -297,10 +297,11 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) StrBuf->Printf(&buf, "'%"PRIu64"',", ui64); // equip_upper - if (libconfig->setting_lookup_int(entry, "Upper", &i32) && i32 >= 0) + if (itemdb->lookup_const_mask(entry, "Upper", &i32) && i32 >= 0) ui32 = (uint32)i32; else ui32 = ITEMUPPER_ALL; + StrBuf->Printf(&buf, "'%u',", ui32); // equip_genders @@ -323,7 +324,7 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) // refineable StrBuf->Printf(&buf, "'%d',", it->flag.no_refine?0:1); - + // disable_options StrBuf->Printf(&buf, "'%d',", it->flag.no_options?1:0); -- cgit v1.2.3-70-g09d2