summaryrefslogtreecommitdiff
path: root/src/map/itemdb.c
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-09-27 11:18:58 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-09-27 11:18:58 +0000
commita46c1fbcb1b7df32c678af8f0bbfda801d6142dc (patch)
tree7911e6f38e2e13b8d1b31b34e61f46ffe35b459c /src/map/itemdb.c
parent7df1201fe4659ecaea754e101ebd5bcd4051e4f2 (diff)
downloadhercules-a46c1fbcb1b7df32c678af8f0bbfda801d6142dc.tar.gz
hercules-a46c1fbcb1b7df32c678af8f0bbfda801d6142dc.tar.bz2
hercules-a46c1fbcb1b7df32c678af8f0bbfda801d6142dc.tar.xz
hercules-a46c1fbcb1b7df32c678af8f0bbfda801d6142dc.zip
* Reimplemented mmo_char_fromsql using sql statements. (fixes bugreport:93)
* Fixed buildin_gethominfo not being included in the script engine. (bugreport:124) * homunculus_evolution -> homevolution in script_commands.txt. * Deleted item DEFAULT from item_db.txt and regenerated item_db.sql. (bugreport:103) * Skip empty lines and give more feedback (for invalid lines) when reading item_db.txt/item_db2.txt. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11311 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/itemdb.c')
-rw-r--r--src/map/itemdb.c81
1 files changed, 51 insertions, 30 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 101738989..f6cdf6b3f 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -742,10 +742,10 @@ static bool itemdb_parse_dbrow(char** str, char* source, int line)
if (id->slot > MAX_SLOTS)
{
- ShowWarning("itemdb_parse_dbrow: Item %d (%s) specifies %d slots, but the server only supports up to %d\n", nameid, id->jname, id->slot, MAX_SLOTS);
+ ShowWarning("itemdb_parse_dbrow: Item %d (%s) specifies %d slots, but the server only supports up to %d. Using %d slots.\n", nameid, id->jname, id->slot, MAX_SLOTS, MAX_SLOTS);
id->slot = MAX_SLOTS;
}
-
+
itemdb_jobid2mapid(id->class_base, (unsigned int)strtoul(str[11],NULL,0));
id->class_upper = atoi(str[12]);
id->sex = atoi(str[13]);
@@ -812,58 +812,79 @@ static int itemdb_readdb(void)
// process rows one by one
while(fgets(line, sizeof(line), fp))
{
- char *str[32], *p, *np;
+ char *str[32], *p;
int i;
lines++;
if(line[0] == '/' && line[1] == '/')
continue;
memset(str, 0, sizeof(str));
- for(i = 0, np = p = line; i < 19 && p; i++)
+
+ p = line;
+ while( ISSPACE(*p) )
+ ++p;
+ if( *p == '\0' )
+ continue;// empty line
+ for( i = 0; i < 19; ++i )
{
str[i] = p;
- if ((p = strchr(p,',')) != NULL) {
- *p++ = '\0'; np = p;
- }
+ p = strchr(p,',');
+ if( p == NULL )
+ break;// comma not found
+ *p = '\0';
+ ++p;
}
- if( i < 19 )
+ if( p == NULL )
{
- ShowWarning("itemdb_readdb: Insufficient columns in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
+ ShowError("itemdb_readdb: Insufficient columns in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
continue;
}
- if((p=strchr(np,'{')) == NULL)
+ // Script
+ if( *p != '{' )
+ {
+ ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
continue;
- str[19] = p; //Script
- np = strchr(p,'}');
- while (np && np[1] && np[1] != ',')
- np = strchr(np+1,'}'); //Jump close brackets until the next field is found.
- if (!np || !np[1]) {
- continue; //Couldn't find the end of the script field.
}
- np[1] = '\0'; //Set end of script
- np += 2; //Skip to next field
+ str[19] = p;
+ p = strstr(p+1,"},");
+ if( p == NULL )
+ {
+ ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
+ continue;
+ }
+ p[1] = '\0';
+ p += 2;
- if(!np || (p=strchr(np,'{'))==NULL)
+ // OnEquip_Script
+ if( *p != '{' )
+ {
+ ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
continue;
- str[20] = p; //Equip Script
- np = strchr(p,'}');
- while (np && np[1] && np[1] != ',')
- np = strchr(np+1,'}'); //Jump close brackets until the next field is found.
- if (!np || !np[1]) {
- continue; //Couldn't find the end of the script field.
}
- np[1] = '\0'; //Set end of script
- np += 2; //Skip comma, to next field
+ str[20] = p;
+ p = strstr(p+1,"},");
+ if( p == NULL )
+ {
+ ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
+ continue;
+ }
+ p[1] = '\0';
+ p += 2;
- if(!np || (p=strchr(np,'{'))==NULL)
+ // OnUnequip_Script (last column)
+ if( *p != '{' )
+ {
+ ShowError("itemdb_readdb: Invalid format (OnUnequip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
continue;
- str[21] = p; //Unequip script, last column.
+ }
+ str[21] = p;
+
if (!itemdb_parse_dbrow(str, path, lines))
continue;
-
+
count++;
}