summaryrefslogtreecommitdiff
path: root/src/map/mob.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/mob.c')
-rw-r--r--src/map/mob.c36
1 files changed, 25 insertions, 11 deletions
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;