From 354a5b1d25c1fcb7dcd06dbbdf0104e76b61da48 Mon Sep 17 00:00:00 2001 From: panikon Date: Sat, 28 Jun 2014 05:24:13 -0300 Subject: Changes in npc_parsefile in order to decrease the number of unecessary calls to strcmp Fixed issue that different header syntax would lead to a deprecation warning instead of the proper error --- src/map/npc.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/map/npc.c b/src/map/npc.c index 81615022a..2aa572720 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -4138,15 +4138,16 @@ int npc_parsesrcfile(const char* filepath, bool runOnInit) { } } - if( strcmp(w2,"warp") == 0 && count > 3 ) + if( strcmp(w2,"mapflag") == 0 && count >= 3 ) { - p = npc->parse_warp(w1,w2,w3,w4, p, buffer, filepath, &success); + p = npc->parse_mapflag(w1, w2, trim(w3), trim(w4), p, buffer, filepath, &success); } - else if( (strcmp(w2,"shop") == 0 || strcmp(w2,"cashshop") == 0) && count > 3 ) - { - p = npc->parse_shop(w1,w2,w3,w4, p, buffer, filepath, &success); + else if( count == 3 ) { + ShowError("npc_parsesrcfile: Unable to parse, probably a missing TAB in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,p-buffer), w1, w2, w3, w4); + p = strchr(p,'\n');// skip and continue + success = EXIT_FAILURE; } - else if( strcmp(w2,"script") == 0 && count > 3 ) + else if( strcmp(w2,"script") == 0 ) { if( strcmp(w1,"function") == 0 ) { p = npc->parse_function(w1, w2, w3, w4, p, buffer, filepath, &success); @@ -4157,20 +4158,24 @@ int npc_parsesrcfile(const char* filepath, bool runOnInit) { p = npc->parse_script(w1,w2,w3,w4, p, buffer, filepath,runOnInit?NPO_ONINIT:NPO_NONE, &success); } } - else if( strcmp(w2,"trader") == 0 && count > 3 ) { + else if( strcmp(w2,"trader") == 0 ) { p = npc->parse_script(w1,w2,w3,w4, p, buffer, filepath,(runOnInit?NPO_ONINIT:NPO_NONE)|NPO_TRADER, &success); } - else if( (i=0, sscanf(w2,"duplicate%n",&i), (i > 0 && w2[i] == '(')) && count > 3 ) + else if( strcmp(w2,"warp") == 0 ) + { + p = npc->parse_warp(w1,w2,w3,w4, p, buffer, filepath, &success); + } + else if( (i=0, sscanf(w2,"duplicate%n",&i), (i > 0 && w2[i] == '(')) ) { p = npc->parse_duplicate(w1,w2,w3,w4, p, buffer, filepath, (runOnInit?NPO_ONINIT:NPO_NONE), &success); } - else if( (strcmp(w2,"monster") == 0 || strcmp(w2,"boss_monster") == 0) && count > 3 ) + else if( (strcmp(w2,"monster") == 0 || strcmp(w2,"boss_monster") == 0) ) { p = npc->parse_mob(w1, w2, w3, w4, p, buffer, filepath, &success); } - else if( strcmp(w2,"mapflag") == 0 && count >= 3 ) + else if( (strcmp(w2,"shop") == 0 || strcmp(w2,"cashshop") == 0) ) { - p = npc->parse_mapflag(w1, w2, trim(w3), trim(w4), p, buffer, filepath, &success); + p = npc->parse_shop(w1,w2,w3,w4, p, buffer, filepath, &success); } else { -- cgit v1.2.3-60-g2f50