summaryrefslogtreecommitdiff
path: root/src/map/itemdb.c
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-10-10 21:51:56 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-10-10 21:51:56 +0000
commita4bb0c3ad6d6ba04cfe3f142da460bcf836e069f (patch)
tree0072a5eb971520d234780328481300fb9c84b359 /src/map/itemdb.c
parent69ebeeb417756359eee461ea9db90d96564d8536 (diff)
downloadhercules-a4bb0c3ad6d6ba04cfe3f142da460bcf836e069f.tar.gz
hercules-a4bb0c3ad6d6ba04cfe3f142da460bcf836e069f.tar.bz2
hercules-a4bb0c3ad6d6ba04cfe3f142da460bcf836e069f.tar.xz
hercules-a4bb0c3ad6d6ba04cfe3f142da460bcf836e069f.zip
* Fixed itemdb_read_sqldb blowing up the server with segmentation faults.
* Added an option for parse_script to ignore the checks for the set of brackets around the script. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11398 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/itemdb.c')
-rw-r--r--src/map/itemdb.c50
1 files changed, 16 insertions, 34 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index e110bf488..70a056292 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -696,7 +696,7 @@ static int itemdb_gendercheck(struct item_data *id)
/*==========================================
* processes one itemdb entry
*------------------------------------------*/
-static bool itemdb_parse_dbrow(const char** str, const char* source, int line)
+static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt)
{
/*
+----+--------------+---------------+------+-----------+------------+--------+--------+---------+-------+-------+------------+-------------+---------------+-----------------+--------------+-------------+------------+------+--------+--------------+----------------+
@@ -785,11 +785,11 @@ static bool itemdb_parse_dbrow(const char** str, const char* source, int line)
}
if (*str[19])
- id->script = parse_script(str[19], source, line, 0);
+ id->script = parse_script(str[19], source, line, scriptopt);
if (*str[20])
- id->equip_script = parse_script(str[20], source, line, 0);
+ id->equip_script = parse_script(str[20], source, line, scriptopt);
if (*str[21])
- id->unequip_script = parse_script(str[21], source, line, 0);
+ id->unequip_script = parse_script(str[21], source, line, scriptopt);
return true;
}
@@ -891,7 +891,7 @@ static int itemdb_readdb(void)
str[21] = p;
- if (!itemdb_parse_dbrow(str, path, lines))
+ if (!itemdb_parse_dbrow(str, path, lines, 0))
continue;
count++;
@@ -917,49 +917,31 @@ static int itemdb_read_sqldb(void)
for( fi = 0; fi < ARRAYLENGTH(item_db_name); ++fi )
{
uint32 lines = 0, count = 0;
-
+
// retrieve all rows from the item database
if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT * FROM `%s`", item_db_name[fi]) )
{
Sql_ShowDebug(mmysql_handle);
continue;
}
-
+
// process rows one by one
while( SQL_SUCCESS == Sql_NextRow(mmysql_handle) )
- {
- // wrap the result into a TXT-compatible format
- char line[1024];
+ {// wrap the result into a TXT-compatible format
char* str[22];
- char* p;
int i;
-
- lines++;
- for (i = 0, p = line; i < 22; i++)
- {
- char* data;
- size_t len;
- Sql_GetData(mmysql_handle, i, &data, &len);
-
- if (data == NULL)
- p[0] = '\0';
- else if (i >= 19 && data[0] != '{') {
- sprintf(p, "{ %s }", data); len+= 4;
- } else
- strcpy(p, data);
- str[i] = p;
- p+= len + 1;
- }
-
- if (!itemdb_parse_dbrow(str, item_db_name[fi], lines))
+ ++lines;
+ for( i = 0; i < 22; ++i )
+ Sql_GetData(mmysql_handle, i, &str[i], NULL);
+
+ if (!itemdb_parse_dbrow(str, item_db_name[fi], lines, 0))
continue;
-
- count++;
+ ++count;
}
-
+
// free the query result
Sql_FreeResult(mmysql_handle);
-
+
ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, item_db_name[fi]);
}