Prechádzať zdrojové kódy

Corrected item_db script curly parsing (#2998)

* Fixes #2964
* Correctly finds the last right curly.
Thanks to @ecdarreola
Vincent Stumpf 7 rokov pred
rodič
commit
ec1470b613
1 zmenil súbory, kde vykonal 6 pridanie a 3 odobranie
  1. 6 3
      src/map/itemdb.cpp

+ 6 - 3
src/map/itemdb.cpp

@@ -1484,7 +1484,7 @@ 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 + 1;
+			str[21] = p;
 			p = &str[21][strlen(str[21]) - 2];
 
 			if ( *p != '}' ) {
@@ -1494,8 +1494,10 @@ static int itemdb_readdb(void){
 				for( v = 0; v < strlen(str[21]); v++ ) {
 					if( str[21][v] == '{' )
 						lcurly++;
-					else if ( str[21][v] == '}' )
+					else if (str[21][v] == '}') {
 						rcurly++;
+						p = &str[21][v];
+					}
 				}
 
 				if( lcurly != rcurly ) {
@@ -1503,7 +1505,8 @@ static int itemdb_readdb(void){
 					continue;
 				}
 			}
-			*p = '\0';
+			str[21] = str[21] + 1;  //skip the first left curly
+			*p = '\0';              //null the last right curly
 
 			if (!itemdb_parse_dbrow(str, path, lines, SCRIPT_IGNORE_EXTERNAL_BRACKETS))
 				continue;