From 8397547da1ff2f7e3f9c763e94841ec285fec6ca Mon Sep 17 00:00:00 2001 From: skotlex Date: Thu, 2 Mar 2006 01:11:47 +0000 Subject: [PATCH] - Some cleanup of the mob skill reading. Added error reporting for unknown states/conditions, error reporting now specifies the file and line number. git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@5419 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 +++ src/map/mob.c | 43 ++++++++++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 20f763fa68..82e2d6a965 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -5,6 +5,9 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. EV GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS 2006/03/01 + * Some cleanup of the mob skill reading. Added error reporting for unknown + states/conditions, error reporting now specifies the file and line number. + [Skotlex] * Silence will only block skills when they have begun casting, not when the cast bar is done. This also means that auto-spells will likely come-out even when silenced. [Skotlex] diff --git a/src/map/mob.c b/src/map/mob.c index 8719b6fa38..964506f538 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -4561,7 +4561,7 @@ static int mob_readskilldb(void) { FILE *fp; char line[1024]; - int i,tmp; + int i,tmp, count; const struct { char str[32]; @@ -4637,6 +4637,7 @@ static int mob_readskilldb(void) return 0; } for(x=0;x<2;x++){ + count = 0; sprintf(line, "%s/%s", db_path, filename[x]); fp=fopen(line,"r"); if(fp==NULL){ @@ -4650,6 +4651,7 @@ static int mob_readskilldb(void) struct mob_skill *ms, gms; int j=0; + count++; if(line[0] == '/' && line[1] == '/') continue; @@ -4659,10 +4661,15 @@ static int mob_readskilldb(void) if((p=strchr(p,','))!=NULL) *p++=0; } - if(i == 0 || (mob_id=atoi(sp[0]))== 0 || (mob_id > 0 && mob_db(mob_id) == mob_dummy)) + if(i == 0 || (mob_id=atoi(sp[0]))== 0) continue; if(i < 18) { - ShowError("Insufficient number of fields for Mob Skill (Mob ID[%s], Name[%s], Skill:[%s/Lv%s])\n", sp[0], i>1?sp[1]:"?", i>3?sp[3]:"?", i>4?sp[4]:"?"); + ShowError("mob_skill: Insufficient number of fields for skill at %s, line %d\n", filename[x], count); + continue; + } + if (mob_id > 0 && mob_db(mob_id) == mob_dummy) + { + ShowError("mob_skill: Invalid mob id %d at %s, line %d\n", mob_id, filename[x], count); continue; } if( strcmp(sp[1],"clear")==0 ){ @@ -4689,10 +4696,12 @@ static int mob_readskilldb(void) } ms->state=atoi(sp[2]); - for(j=0;jstate=state[j].id; - } + tmp = sizeof(state)/sizeof(state[0]); + for(j=0;jstate=state[j].id; + else + ShowError("mob_skill: Unrecognized state %s at %s, line %d\n", sp[2], filename[x], count); //Skill ID j=atoi(sp[3]); @@ -4731,15 +4740,19 @@ static int mob_readskilldb(void) ms->target=target[j].id; } ms->cond1=-1; - for(j=0;jcond1=cond1[j].id; - } + tmp = sizeof(cond1)/sizeof(cond1[0]); + for(j=0;jcond1=cond1[j].id; + else + ShowError("mob_skill: Unrecognized condition 1 %s at %s, line %d\n", sp[10], filename[x], count); + ms->cond2=atoi(sp[11]); - for(j=0;jcond2=cond2[j].id; - } + tmp = sizeof(cond2)/sizeof(cond2[0]); + for(j=0;jcond2=cond2[j].id; + ms->val[0]=atoi(sp[12]); ms->val[1]=atoi(sp[13]); ms->val[2]=atoi(sp[14]);