diff options
author | ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2010-11-29 19:55:47 +0000 |
---|---|---|
committer | ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2010-11-29 19:55:47 +0000 |
commit | 166cb92fc2767eb8bb77b96062281d07df630561 (patch) | |
tree | 7d5d681e7527d254ad3da7f9e450b4fef1066924 /src/map/itemdb.c | |
parent | 49a385c135d3012abb08e1ddc6a301c89f0e3a54 (diff) | |
download | hercules-166cb92fc2767eb8bb77b96062281d07df630561.tar.gz hercules-166cb92fc2767eb8bb77b96062281d07df630561.tar.bz2 hercules-166cb92fc2767eb8bb77b96062281d07df630561.tar.xz hercules-166cb92fc2767eb8bb77b96062281d07df630561.zip |
* Resolved issues with item delay system.
- Fixed random crashes caused by map_session_data corruption due to out-of-bounds access to item_delay array (bugreport:4568, since r14455).
- Fixed item delay database not being compatible with @reloaditemdb. Item delays are now reset upon reloading, much like a restart would do (bugreport:4589).
- Fixed trailing commented lines in db/item_delay.txt could cause 'too many entries' error to be displayed.
- Fixed last entity of a cash food item not being recognized as cash food, thus not receiving use delay, due to access to deleted inventory slot (since r14426).
- These changes also fix a warning regarding variable 'i' in pc_useitem being potentionally uninitialized (bugreport:4559).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14521 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/itemdb.c')
-rw-r--r-- | src/map/itemdb.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c index d1eed4b27..8eb173a85 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -27,8 +27,6 @@ static struct item_group itemgroup_db[MAX_ITEMGROUP]; struct item_data dummy_item; //This is the default dummy item used for non-existant items. [Skotlex] -int item_delays = 0; - /*========================================== * 名前で検索用 *------------------------------------------*/ @@ -667,7 +665,7 @@ static int itemdb_read_itemtrade(void) static int itemdb_read_itemdelay(void) { FILE *fp; - int nameid, j; + int nameid, j, item_delays = 0; char line[1024], *str[10], *p; struct item_data *id; @@ -679,12 +677,12 @@ static int itemdb_read_itemdelay(void) while(fgets(line, sizeof(line), fp)) { + if (line[0] == '/' && line[1] == '/') + continue; if (item_delays == MAX_ITEMDELAYS) { ShowError("itemdb_read_itemdelay: Too many entries specified in %s/item_delay.txt! Increase MAX_ITEMDELAYS in itemdb.h!\n", db_path); break; } - if (line[0] == '/' && line[1] == '/') - continue; memset(str, 0, sizeof(str)); for (j = 0, p = line; j < 2 && p; j++) { str[j] = p; @@ -1075,7 +1073,10 @@ void itemdb_reload(void) // readjust itemdb pointer cache for each player iter = mapit_geteachpc(); for( sd = (struct map_session_data*)mapit_first(iter); mapit_exists(iter); sd = (struct map_session_data*)mapit_next(iter) ) + { + memset(sd->item_delay, 0, sizeof(sd->item_delay)); // reset item delays pc_setinventorydata(sd); + } mapit_free(iter); } |