From ec1470b613e41fb4ec6fa2ca6734ea6c1b9e1d69 Mon Sep 17 00:00:00 2001 From: Vincent Stumpf Date: Sat, 7 Apr 2018 15:32:59 -0700 Subject: [PATCH] Corrected item_db script curly parsing (#2998) * Fixes #2964 * Correctly finds the last right curly. Thanks to @ecdarreola --- src/map/itemdb.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp index e84738d8ed..4f0988d6c1 100644 --- a/src/map/itemdb.cpp +++ b/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;