diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/itemdb.c | 30 | ||||
-rw-r--r-- | src/map/itemdb.h | 15 |
2 files changed, 31 insertions, 14 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 25b47eb64..442508775 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -689,7 +689,7 @@ static int itemdb_gendercheck(struct item_data *id) /*========================================== * processes one itemdb entry *------------------------------------------*/ -static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt) +static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt, int db) { /* +----+--------------+---------------+------+-----------+------------+--------+--------+---------+-------+-------+------------+-------------+---------------+-----------------+--------------+-------------+------------+------+--------+--------------+----------------+ @@ -713,6 +713,9 @@ static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scr safestrncpy(id->name, str[1], sizeof(id->name)); safestrncpy(id->jname, str[2], sizeof(id->jname)); + if(db == 1) + id->flag.db2 = 1; + id->type = atoi(str[3]); if (id->type == IT_DELAYCONSUME) { //Items that are consumed only after target confirmation @@ -900,8 +903,7 @@ static int itemdb_readdb(void) } str[21] = p; - - if (!itemdb_parse_dbrow(str, path, lines, 0)) + if (!itemdb_parse_dbrow(str, path, lines, 0, fi)) continue; count++; @@ -948,7 +950,7 @@ static int itemdb_read_sqldb(void) if( str[i] == NULL ) str[i] = dummy; // get rid of NULL columns } - if (!itemdb_parse_dbrow(str, item_db_name[fi], lines, SCRIPT_IGNORE_EXTERNAL_BRACKETS)) + if (!itemdb_parse_dbrow(str, item_db_name[fi], lines, SCRIPT_IGNORE_EXTERNAL_BRACKETS, fi)) continue; ++count; } @@ -1016,6 +1018,16 @@ static int itemdb_final_sub(DBKey key,void *data,va_list ap) return 0; } +static int itemdb_reload_sub(DBKey key,void *data,va_list ap) +{ + struct item_data *id = (struct item_data *)data; + + if( id != &dummy_item && id->flag.db2) + destroy_item_data(id, 1); + + return 0; +} + void itemdb_reload(void) { @@ -1023,11 +1035,13 @@ void itemdb_reload(void) for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) if( itemdb_array[i] ) - destroy_item_data(itemdb_array[i], 1); - - itemdb_other->clear(itemdb_other, itemdb_final_sub); + if( itemdb_array[i]->flag.db2 ) + { + destroy_item_data(itemdb_array[i], 1); + memset(itemdb_array[i], 0, sizeof(struct item_data)); + } - memset(itemdb_array, 0, sizeof(itemdb_array)); + itemdb_other->clear(itemdb_other, itemdb_reload_sub); itemdb_read(); } diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 6be49f3e9..cbbee0932 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -34,8 +34,8 @@ #define UNKNOWN_ITEM_ID 512 struct item_data { - int nameid; char name[ITEM_NAME_LENGTH],jname[ITEM_NAME_LENGTH]; + int nameid; //Do not add stuff between value_buy and wlv (see how getiteminfo works) int value_buy; int value_sell; @@ -56,24 +56,27 @@ struct item_data { // some script commands should be revised as well... unsigned int class_base[3]; //Specifies if the base can wear this item (split in 3 indexes per type: 1-1, 2-1, 2-2) unsigned class_upper : 3; //Specifies if the upper-type can equip it (bitfield, 1: normal, 2: upper, 3: baby) + unsigned unused : 5; struct { unsigned short chance; int id; } mob[MAX_SEARCH]; //Holds the mobs that have the highest drop rate for this item. [Skotlex] - struct script_code *script; //Default script for everything. - struct script_code *equip_script; //Script executed once when equipping. - struct script_code *unequip_script;//Script executed once when unequipping. struct { unsigned available : 1; unsigned value_notdc : 1; unsigned value_notoc : 1; - short no_equip; unsigned no_refine : 1; // [celest] unsigned delay_consume : 1; // Signifies items that are not consumed immediately upon double-click [Skotlex] - unsigned trade_restriction : 7; //Item restrictions mask [Skotlex] unsigned autoequip: 1; + unsigned unused:2; + unsigned db2: 1; //Items from the custom item database (item_db2) + unsigned trade_restriction : 7; //Item restrictions mask [Skotlex] + short no_equip; } flag; short gm_lv_trade_override; //GM-level to override trade_restriction + struct script_code *script; //Default script for everything. + struct script_code *equip_script; //Script executed once when equipping. + struct script_code *unequip_script;//Script executed once when unequipping. }; struct item_group { |