diff options
-rw-r--r-- | sql-files/item_db2.sql | 2 | ||||
-rw-r--r-- | sql-files/item_db_re.sql | 2 | ||||
-rw-r--r-- | src/map/itemdb.c | 19 | ||||
-rw-r--r-- | src/plugins/db2sql.c | 115 |
4 files changed, 125 insertions, 13 deletions
diff --git a/sql-files/item_db2.sql b/sql-files/item_db2.sql index 3819d0fdf..de2c541e3 100644 --- a/sql-files/item_db2.sql +++ b/sql-files/item_db2.sql @@ -39,7 +39,7 @@ CREATE TABLE `item_db2` ( `defence` smallint(5) UNSIGNED DEFAULT NULL, `range` tinyint(2) UNSIGNED DEFAULT NULL, `slots` tinyint(2) UNSIGNED DEFAULT NULL, - `equip_jobs` int(12) UNSIGNED DEFAULT NULL, + `equip_jobs` bigint(20) UNSIGNED DEFAULT NULL, `equip_upper` tinyint(8) UNSIGNED DEFAULT NULL, `equip_genders` tinyint(2) UNSIGNED DEFAULT NULL, `equip_locations` smallint(4) UNSIGNED DEFAULT NULL, diff --git a/sql-files/item_db_re.sql b/sql-files/item_db_re.sql index c0cb02f8b..2e2929c69 100644 --- a/sql-files/item_db_re.sql +++ b/sql-files/item_db_re.sql @@ -39,7 +39,7 @@ CREATE TABLE `item_db` ( `defence` smallint(5) UNSIGNED DEFAULT NULL, `range` tinyint(2) UNSIGNED DEFAULT NULL, `slots` tinyint(2) UNSIGNED DEFAULT NULL, - `equip_jobs` int(12) UNSIGNED DEFAULT NULL, + `equip_jobs` bigint(20) UNSIGNED DEFAULT NULL, `equip_upper` tinyint(8) UNSIGNED DEFAULT NULL, `equip_genders` tinyint(2) UNSIGNED DEFAULT NULL, `equip_locations` smallint(4) UNSIGNED DEFAULT NULL, diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 27adc387b..20efb5e9e 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1666,14 +1666,21 @@ void itemdb_readdb_job_sub(struct item_data *id, struct config_setting_t *t) { int idx = 0; struct config_setting_t *it = NULL; + bool enable_all = false; + id->class_base[0] = id->class_base[1] = id->class_base[2] = 0; + + if (libconfig->setting_lookup_bool_real(t, "All", &enable_all) && enable_all) { + itemdb->jobmask2mapid(id->class_base, UINT64_MAX); + } while ((it = libconfig->setting_get_elem(t, idx++)) != NULL) { const char *job_name = config_setting_name(it); int job_id; - if (strcmp(job_name, "All") == 0) { - itemdb->jobmask2mapid(id->class_base, UINT64_MAX); - } else if ((job_id = pc->check_job_name(job_name)) == -1) { + if (strcmp(job_name, "All") == 0) + continue; + + if ((job_id = pc->check_job_name(job_name)) == -1) { ShowWarning("itemdb_readdb_job_sub: unknown job name '%s'!\n", job_name); } else { itemdb->jobid2mapid(id->class_base, job_id, libconfig->setting_get_bool(it)); @@ -1825,8 +1832,10 @@ int itemdb_readdb_libconfig_sub(struct config_setting_t *it, int n, const char * if ((t = libconfig->setting_get_member(it, "Job")) != NULL) { if (config_setting_is_group(t)) { itemdb->readdb_job_sub(&id, t); - } else if (itemdb->lookup_const(it, "Job", &i32) && i32 >= 0) { - itemdb->jobmask2mapid(id.class_base, i32); + } else if (itemdb->lookup_const(it, "Job", &i32)) { // This is an unsigned value, do not check for >= 0 + itemdb->jobmask2mapid(id.class_base, (uint64)i32); + } else if (!inherit) { + itemdb->jobmask2mapid(id.class_base, UINT64_MAX); } } else if (!inherit) { itemdb->jobmask2mapid(id.class_base, UINT64_MAX); diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c index 34e1c2053..86708ebbc 100644 --- a/src/plugins/db2sql.c +++ b/src/plugins/db2sql.c @@ -30,6 +30,7 @@ #include "map/itemdb.h" #include "map/mob.h" #include "map/map.h" +#include "map/pc.h" #include "common/HPMDataCheck.h" @@ -120,6 +121,100 @@ void db2sql_fileheader(void) } /** + * Converts the Job field of an Item DB entry to the numeric format used in the SQL table. + */ +uint64 itemdb2sql_readdb_job_sub(struct config_setting_t *t) +{ + uint64 jobmask = 0; + int idx = 0; + struct config_setting_t *it = NULL; + bool enable_all = false; + + if (libconfig->setting_lookup_bool_real(t, "All", &enable_all) && enable_all) { + jobmask |= UINT64_MAX; + } + while ((it = libconfig->setting_get_elem(t, idx++)) != NULL) { + const char *job_name = config_setting_name(it); + int job_id; + + if (strcmp(job_name, "All") == 0) + continue; + + if ((job_id = pc->check_job_name(job_name)) != -1) { + uint64 newmask = 0; + switch (job_id) { + // Base Classes + case JOB_NOVICE: + case JOB_SUPER_NOVICE: + newmask = 1ULL << JOB_NOVICE; + break; + case JOB_SWORDMAN: + case JOB_MAGE: + case JOB_ARCHER: + case JOB_ACOLYTE: + case JOB_MERCHANT: + case JOB_THIEF: + // 2-1 Classes + case JOB_KNIGHT: + case JOB_PRIEST: + case JOB_WIZARD: + case JOB_BLACKSMITH: + case JOB_HUNTER: + case JOB_ASSASSIN: + // 2-2 Classes + case JOB_CRUSADER: + case JOB_MONK: + case JOB_SAGE: + case JOB_ALCHEMIST: + case JOB_BARD: + case JOB_DANCER: + case JOB_ROGUE: + // Extended Classes + case JOB_GUNSLINGER: + case JOB_NINJA: + newmask = 1ULL << job_id; + break; + // Extended Classes (special handling) + case JOB_TAEKWON: + newmask = 1ULL << 21; + break; + case JOB_STAR_GLADIATOR: + newmask = 1ULL << 22; + break; + case JOB_SOUL_LINKER: + newmask = 1ULL << 23; + break; + // Other Classes + case JOB_GANGSI: //Bongun/Munak + newmask = 1ULL << 26; + break; + case JOB_DEATH_KNIGHT: + newmask = 1ULL << 27; + break; + case JOB_DARK_COLLECTOR: + newmask = 1ULL << 28; + break; + case JOB_KAGEROU: + case JOB_OBORO: + newmask = 1ULL << 29; + break; + case JOB_REBELLION: + newmask = 1ULL << 30; + break; + } + + if (libconfig->setting_get_bool(it)) { + jobmask |= newmask; + } else { + jobmask &= ~newmask; + } + } + } + + return jobmask; +} + +/** * Converts an Item DB entry to SQL. * * @see itemdb_readdb_libconfig_sub. @@ -134,6 +229,7 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) char *str; int i32; uint32 ui32; + uint64 ui64; struct config_setting_t *t = NULL; StringBuf buf; @@ -180,11 +276,18 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) StrBuf->Printf(&buf, "'%d',", it->slot); // equip_jobs - if (libconfig->setting_lookup_int(entry, "Job", &i32)) // This is an unsigned value, do not check for >= 0 - ui32 = (uint32)i32; - else - ui32 = UINT_MAX; - StrBuf->Printf(&buf, "'%u',", ui32); + if ((t = libconfig->setting_get_member(entry, "Job")) != NULL) { + if (config_setting_is_group(t)) { + ui64 = itemdb2sql_readdb_job_sub(t); + } else if (itemdb->lookup_const(entry, "Job", &i32)) { // This is an unsigned value, do not check for >= 0 + ui64 = (uint64)i32; + } else { + ui64 = UINT64_MAX; + } + } else { + ui64 = UINT64_MAX; + } + StrBuf->Printf(&buf, "'0x%"PRIX64"',", ui64); // equip_upper if (libconfig->setting_lookup_int(entry, "Upper", &i32) && i32 >= 0) @@ -344,7 +447,7 @@ void itemdb2sql_tableheader(void) " `defence` smallint(5) UNSIGNED DEFAULT NULL,\n" " `range` tinyint(2) UNSIGNED DEFAULT NULL,\n" " `slots` tinyint(2) UNSIGNED DEFAULT NULL,\n" - " `equip_jobs` int(12) UNSIGNED DEFAULT NULL,\n" + " `equip_jobs` bigint(20) UNSIGNED DEFAULT NULL,\n" " `equip_upper` tinyint(8) UNSIGNED DEFAULT NULL,\n" " `equip_genders` tinyint(2) UNSIGNED DEFAULT NULL,\n" " `equip_locations` smallint(4) UNSIGNED DEFAULT NULL,\n" |