summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorpanikon <panikon@zoho.com>2014-06-28 05:24:13 -0300
committerpanikon <panikon@zoho.com>2014-06-28 05:24:13 -0300
commit354a5b1d25c1fcb7dcd06dbbdf0104e76b61da48 (patch)
tree3a41ac2656100fbb57965d8a78317e43f5781b37 /src/map
parentdf04deafc4da602655ea849f010b991d808f02c0 (diff)
downloadhercules-354a5b1d25c1fcb7dcd06dbbdf0104e76b61da48.tar.gz
hercules-354a5b1d25c1fcb7dcd06dbbdf0104e76b61da48.tar.bz2
hercules-354a5b1d25c1fcb7dcd06dbbdf0104e76b61da48.tar.xz
hercules-354a5b1d25c1fcb7dcd06dbbdf0104e76b61da48.zip
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
Diffstat (limited to 'src/map')
-rw-r--r--src/map/npc.c27
1 files changed, 16 insertions, 11 deletions
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
{