diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/npc.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/map/npc.c b/src/map/npc.c index 97744a348..3649731ed 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1775,12 +1775,14 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons {// parsing script with curly const char* script_start; - if( strstr(w4,",{") == NULL ) + script_start = strstr(start,",{"); + end = strchr(start,'\n'); + if( strstr(w4,",{") == NULL || script_start == NULL || (end != NULL && script_start > end) ) { ShowError("npc_parse_script: Missing left curly ',{' in file '%s', line '%d'. Skipping the rest of the file.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4); return NULL;// can't continue } - script_start = strstr(start,",{")+1; + ++script_start; end = npc_skip_script(script_start, buffer, filepath); if( end == NULL ) @@ -2024,20 +2026,22 @@ static const char* npc_parse_function(char* w1, char* w2, char* w3, char* w4, co struct script_code *script; struct script_code *oldscript; const char* end; + const char* script_start; - start = strstr(start,"\t{"); - if( *w4 != '{' || start == NULL ) + script_start = strstr(start,"\t{"); + end = strchr(start,'\n'); + if( *w4 != '{' || script_start == NULL || (end != NULL && script_start > end) ) { ShowError("npc_parse_function: Missing left curly '%%TAB%%{' in file '%s', line '%d'. Skipping the rest of the file.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4); return NULL;// can't continue } + ++script_start; - end = npc_skip_script(start,buffer,filepath); + end = npc_skip_script(script_start,buffer,filepath); if( end == NULL ) return NULL;// (simple) parse error, don't continue - start = strchr(start,'{'); - script = parse_script(start, filepath, strline(buffer,start-buffer), SCRIPT_RETURN_EMPTY_SCRIPT); + script = parse_script(script_start, filepath, strline(buffer,start-buffer), SCRIPT_RETURN_EMPTY_SCRIPT); if( script == NULL )// parse error, continue return end; |