summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-10-10 15:59:58 -0300
committershennetsind <ind@henn.et>2013-10-10 15:59:58 -0300
commit1e7918769778b2be98daa754ce02dbe0eae53fd9 (patch)
tree66a1b654f030f708d18132d9a77d6b892e3dfd34 /src
parent80dfb11513812c7007f55c4b4b72c7f1cbee47f4 (diff)
downloadhercules-1e7918769778b2be98daa754ce02dbe0eae53fd9.tar.gz
hercules-1e7918769778b2be98daa754ce02dbe0eae53fd9.tar.bz2
hercules-1e7918769778b2be98daa754ce02dbe0eae53fd9.tar.xz
hercules-1e7918769778b2be98daa754ce02dbe0eae53fd9.zip
Fixed Bug #7570
Thanks to frenzmu06. Added code into the item db parser to throw a warning when there is more than one version of a item from within the same file, thanks to EvilPuncker. Closes #183 Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src')
-rw-r--r--src/map/itemdb.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index fe2c43fcc..09eec557d 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -1704,12 +1704,11 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt)
* Reading item from item db
* item_db2 overwriting item_db
*------------------------------------------*/
-int itemdb_readdb(void)
-{
+int itemdb_readdb(void) {
const char* filename[] = {
DBPATH"item_db.txt",
"item_db2.txt" };
-
+ bool duplicate[MAX_ITEMDB];
int fi;
for( fi = 0; fi < ARRAYLENGTH(filename); ++fi ) {
@@ -1726,11 +1725,13 @@ int itemdb_readdb(void)
continue;
}
+ memset(&duplicate,0,sizeof(duplicate));
+
// process rows one by one
while(fgets(line, sizeof(line), fp))
{
char *str[32], *p;
- int i;
+ int i, id = 0;
lines++;
if(line[0] == '/' && line[1] == '/')
continue;
@@ -1807,9 +1808,14 @@ int itemdb_readdb(void)
}
}
- if (!itemdb->parse_dbrow(str, filepath, lines, 0))
+ if (!(id = itemdb->parse_dbrow(str, filepath, lines, 0)))
continue;
+ if( duplicate[id] ) {
+ ShowWarning("itemdb_readdb:%s: duplicate entry of ID #%d (%s/%s)\n",filename[fi],id,itemdb_name(id),itemdb_jname(id));
+ } else
+ duplicate[id] = true;
+
count++;
}
@@ -1836,7 +1842,7 @@ int itemdb_read_sqldb(void) {
for( fi = 0; fi < ARRAYLENGTH(item_db_name); ++fi ) {
uint32 count = 0;
-
+
// retrieve all rows from the item database
if( SQL_ERROR == SQL->Query(map->mysql_handle, "SELECT * FROM `%s`", item_db_name[fi]) ) {
Sql_ShowDebug(map->mysql_handle);
@@ -1856,6 +1862,7 @@ int itemdb_read_sqldb(void) {
if (!itemdb->parse_dbrow(str, item_db_name[fi], -(atoi(str[0])), SCRIPT_IGNORE_EXTERNAL_BRACKETS))
continue;
+
++count;
}