From 55d42874dcf24c466f0104123d9efe280c0fd03c Mon Sep 17 00:00:00 2001 From: shennetsind Date: Tue, 9 Jul 2013 18:06:42 -0300 Subject: Mob Parse & Mob Skill Use fixes Special Thanks to Masao for bringing this to us. mob parser will now throw out warnings when a field in the mob db has a value higher than the field supported (e.g. if you get a monster with 70k hp it will tell you its higher and cap it to the maximum supported, which is 65k), this failsafe also works for def/mdef, str/agi/vit/int_/dex/luk. Modified the formula that measures skill field data for skill levels higher than the maximum (e.g. mistress' high-level jupitel thunder), to match the previous version, also fixed a issue where depending on the level the blewcount could get higher than the systems' hardcoded 25-cell maximum. Signed-off-by: shennetsind --- src/map/mob.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'src/map/mob.c') diff --git a/src/map/mob.c b/src/map/mob.c index 71c81749a..601ecd110 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -3634,7 +3634,17 @@ static void item_dropratio_adjust(int nameid, int mob_id, int *rate_adjust) *rate_adjust = item_drop_ratio_db[nameid]->drop_ratio; } } - +/* (mob_parse_dbrow)_cap_value */ +static inline int mob_parse_dbrow_cap_value(int class_, int min, int max, int value) { + if( value > max ) { + ShowError("mob_parse_dbrow: for class '%d', field value '%d' is higher than the maximum '%d'! capping...\n", class_, value, max); + return max; + } else if ( value < min ) { + ShowError("mob_parse_dbrow: for class '%d', field value '%d' is lower than the minimum '%d'! capping...\n", class_, value, min); + return min; + } + return value; +} /*========================================== * processes one mobdb entry *------------------------------------------*/ @@ -3683,16 +3693,20 @@ static bool mob_parse_dbrow(char** str) db->job_exp = (unsigned int)cap_value(exp, 0, UINT_MAX); status->rhw.range = atoi(str[9]); - status->rhw.atk = atoi(str[10]); - status->rhw.atk2 = atoi(str[11]); - status->def = atoi(str[12]); - status->mdef = atoi(str[13]); - status->str = atoi(str[14]); - status->agi = atoi(str[15]); - status->vit = atoi(str[16]); - status->int_ = atoi(str[17]); - status->dex = atoi(str[18]); - status->luk = atoi(str[19]); + + status->rhw.atk = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[10])); + status->rhw.atk2 = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[11])); + + status->def = mob_parse_dbrow_cap_value(class_,DEFTYPE_MIN,DEFTYPE_MAX,atoi(str[12])); + status->mdef = mob_parse_dbrow_cap_value(class_,DEFTYPE_MIN,DEFTYPE_MAX,atoi(str[13])); + + status->str = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[14])); + status->agi = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[15])); + status->vit = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[16])); + status->int_ = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[17])); + status->dex = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[18])); + status->luk = mob_parse_dbrow_cap_value(class_,UINT16_MIN,UINT16_MAX,atoi(str[19])); + //All status should be min 1 to prevent divisions by zero from some skills. [Skotlex] if (status->str < 1) status->str = 1; if (status->agi < 1) status->agi = 1; -- cgit v1.2.3-70-g09d2