Changed @reloaditemdb again to only unload items from item_db2. Also byte aligned the item_data struct a bit.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12643 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
Kevin 2008-04-23 20:54:07 +00:00
parent 2599064a46
commit 75cd3c3acb
2 changed files with 31 additions and 14 deletions

View File

@ -689,7 +689,7 @@ static int itemdb_gendercheck(struct item_data *id)
/*========================================== /*==========================================
* processes one itemdb entry * 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->name, str[1], sizeof(id->name));
safestrncpy(id->jname, str[2], sizeof(id->jname)); safestrncpy(id->jname, str[2], sizeof(id->jname));
if(db == 1)
id->flag.db2 = 1;
id->type = atoi(str[3]); id->type = atoi(str[3]);
if (id->type == IT_DELAYCONSUME) if (id->type == IT_DELAYCONSUME)
{ //Items that are consumed only after target confirmation { //Items that are consumed only after target confirmation
@ -900,8 +903,7 @@ static int itemdb_readdb(void)
} }
str[21] = p; str[21] = p;
if (!itemdb_parse_dbrow(str, path, lines, 0, fi))
if (!itemdb_parse_dbrow(str, path, lines, 0))
continue; continue;
count++; count++;
@ -948,7 +950,7 @@ static int itemdb_read_sqldb(void)
if( str[i] == NULL ) str[i] = dummy; // get rid of NULL columns 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; continue;
++count; ++count;
} }
@ -1016,6 +1018,16 @@ static int itemdb_final_sub(DBKey key,void *data,va_list ap)
return 0; 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) void itemdb_reload(void)
{ {
@ -1023,11 +1035,13 @@ void itemdb_reload(void)
for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i )
if( itemdb_array[i] ) if( itemdb_array[i] )
destroy_item_data(itemdb_array[i], 1); if( itemdb_array[i]->flag.db2 )
{
destroy_item_data(itemdb_array[i], 1);
memset(itemdb_array[i], 0, sizeof(struct item_data));
}
itemdb_other->clear(itemdb_other, itemdb_final_sub); itemdb_other->clear(itemdb_other, itemdb_reload_sub);
memset(itemdb_array, 0, sizeof(itemdb_array));
itemdb_read(); itemdb_read();
} }

View File

@ -34,8 +34,8 @@
#define UNKNOWN_ITEM_ID 512 #define UNKNOWN_ITEM_ID 512
struct item_data { struct item_data {
int nameid;
char name[ITEM_NAME_LENGTH],jname[ITEM_NAME_LENGTH]; char name[ITEM_NAME_LENGTH],jname[ITEM_NAME_LENGTH];
int nameid;
//Do not add stuff between value_buy and wlv (see how getiteminfo works) //Do not add stuff between value_buy and wlv (see how getiteminfo works)
int value_buy; int value_buy;
int value_sell; int value_sell;
@ -56,24 +56,27 @@ struct item_data {
// some script commands should be revised as well... // 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 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 class_upper : 3; //Specifies if the upper-type can equip it (bitfield, 1: normal, 2: upper, 3: baby)
unsigned unused : 5;
struct { struct {
unsigned short chance; unsigned short chance;
int id; int id;
} mob[MAX_SEARCH]; //Holds the mobs that have the highest drop rate for this item. [Skotlex] } 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 { struct {
unsigned available : 1; unsigned available : 1;
unsigned value_notdc : 1; unsigned value_notdc : 1;
unsigned value_notoc : 1; unsigned value_notoc : 1;
short no_equip;
unsigned no_refine : 1; // [celest] unsigned no_refine : 1; // [celest]
unsigned delay_consume : 1; // Signifies items that are not consumed immediately upon double-click [Skotlex] 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 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; } flag;
short gm_lv_trade_override; //GM-level to override trade_restriction 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 { struct item_group {