Fixed a few issues with TXT item db parsing (#2940)
Fixed an issue with comments in the middle of the line Fixed the curly mismatches not being reported Fixes #2938 Thanks to @kaninhot004
This commit is contained in:
@@ -1419,6 +1419,12 @@ static int itemdb_readdb(void){
|
||||
continue;
|
||||
memset(str, 0, sizeof(str));
|
||||
|
||||
p = strstr(line,"//");
|
||||
|
||||
if( p != nullptr ){
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
p = line;
|
||||
while( ISSPACE(*p) )
|
||||
++p;
|
||||
@@ -1446,14 +1452,14 @@ static int itemdb_readdb(void){
|
||||
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;
|
||||
str[19] = p + 1;
|
||||
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 = '\0';
|
||||
p += 2;
|
||||
|
||||
// OnEquip_Script
|
||||
@@ -1462,14 +1468,14 @@ static int itemdb_readdb(void){
|
||||
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;
|
||||
str[20] = p + 1;
|
||||
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 = '\0';
|
||||
p += 2;
|
||||
|
||||
// OnUnequip_Script (last column)
|
||||
@@ -1478,9 +1484,10 @@ static int itemdb_readdb(void){
|
||||
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;
|
||||
str[21] = p + 1;
|
||||
p = &str[21][strlen(str[21]) - 2];
|
||||
|
||||
if ( str[21][strlen(str[21])-2] != '}' ) {
|
||||
if ( *p != '}' ) {
|
||||
/* lets count to ensure it's not something silly e.g. a extra space at line ending */
|
||||
int v, lcurly = 0, rcurly = 0;
|
||||
|
||||
@@ -1496,8 +1503,9 @@ static int itemdb_readdb(void){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
if (!itemdb_parse_dbrow(str, path, lines, 0))
|
||||
if (!itemdb_parse_dbrow(str, path, lines, SCRIPT_IGNORE_EXTERNAL_BRACKETS))
|
||||
continue;
|
||||
|
||||
count++;
|
||||
|
||||
Reference in New Issue
Block a user