summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-08-20 21:57:54 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-08-20 21:57:54 +0000
commit60ede91019eefa35a4d161d55224cfef40aeddf7 (patch)
treee523561635ddf971dab817fe9dec54b1ecebdaa9
parentf076819852059809b4281ef2e87e50aee102cfd0 (diff)
downloadhercules-60ede91019eefa35a4d161d55224cfef40aeddf7.tar.gz
hercules-60ede91019eefa35a4d161d55224cfef40aeddf7.tar.bz2
hercules-60ede91019eefa35a4d161d55224cfef40aeddf7.tar.xz
hercules-60ede91019eefa35a4d161d55224cfef40aeddf7.zip
- Added a check during mob_db loading so that the six basic stats, max hp and max sp are never below 1, as this could cause crashes when using certain skills.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8393 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt3
-rw-r--r--src/map/mob.c35
2 files changed, 25 insertions, 13 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index d74c9d97d..663e4a63f 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -3,6 +3,9 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/08/20
+ * Added a check during mob_db loading so that the six basic stats, max hp
+ and max sp are never below 1, as this could cause crashes when using
+ certain skills. [Skotlex]
* Gravitation now only blocks the caster from using potions. [Skotlex]
* Corrected Madness Canceller letting you walk while the effect lasts.
[Skotlex]
diff --git a/src/map/mob.c b/src/map/mob.c
index e3bce2257..5e6284aa4 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -3191,6 +3191,14 @@ static int mob_readdb(void)
status->int_=atoi(str[17]);
status->dex=atoi(str[18]);
status->luk=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;
+ if (status->vit < 1) status->vit = 1;
+ if (status->int_< 1) status->int_= 1;
+ if (status->dex < 1) status->dex = 1;
+ if (status->luk < 1) status->luk = 1;
+
mob_db_data[class_]->range2=atoi(str[20]);
mob_db_data[class_]->range3=atoi(str[21]);
if (battle_config.view_range_rate!=100)
@@ -3250,10 +3258,11 @@ static int mob_readdb(void)
maxhp = maxhp * (double)battle_config.mvp_hp_rate /100.;
} else if (battle_config.monster_hp_rate != 100) //Normal mob
maxhp = maxhp * (double)battle_config.monster_hp_rate /100.;
- if (maxhp < 1) maxhp = 1;
- else if (maxhp > UINT_MAX) maxhp = UINT_MAX;
+ if (maxhp > UINT_MAX) maxhp = UINT_MAX;
status->max_hp = (unsigned int)maxhp;
+ if(status->max_hp < 1) status->max_hp = 1;
+ if(status->max_sp < 1) status->max_sp = 1;
status->hp = status->max_hp;
status->sp = status->max_sp;
@@ -3368,11 +3377,6 @@ static int mob_readdb(void)
id->mob[k].id = class_;
}
}
-
- if (status->max_hp <= 0) {
- ShowWarning ("Mob %d (%s) has no HP, using poring data for it\n", class_, mob_db_data[class_]->sprite);
- mob_makedummymobdb(class_);
- }
}
fclose(fp);
ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n",filename[fi]);
@@ -3880,6 +3884,14 @@ static int mob_read_sqldb(void)
status->int_ = TO_INT(17);
status->dex = TO_INT(18);
status->luk = TO_INT(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;
+ if (status->vit < 1) status->vit = 1;
+ if (status->int_< 1) status->int_= 1;
+ if (status->dex < 1) status->dex = 1;
+ if (status->luk < 1) status->luk = 1;
+
mob_db_data[class_]->range2 = TO_INT(20);
mob_db_data[class_]->range3 = TO_INT(21);
status->size = TO_INT(22);
@@ -3923,10 +3935,11 @@ static int mob_read_sqldb(void)
maxhp = maxhp * (double)battle_config.mvp_hp_rate /100.;
} else if (battle_config.monster_hp_rate != 100) //Normal mob
maxhp = maxhp * (double)battle_config.monster_hp_rate /100.;
- if (maxhp < 0) maxhp = 1;
- else if (maxhp > UINT_MAX) maxhp = UINT_MAX;
+ if (maxhp > UINT_MAX) maxhp = UINT_MAX;
status->max_hp = (unsigned int)maxhp;
+ if(status->max_hp < 1) status->max_hp = 1;
+ if(status->max_sp < 1) status->max_sp = 1;
//Since mobs always respawn with full life...
status->hp = status->max_hp;
status->sp = status->max_sp;
@@ -4038,10 +4051,6 @@ static int mob_read_sqldb(void)
id->mob[k].id = class_;
}
}
- if (status->max_hp <= 0) {
- ShowWarning ("Mob %d (%s) has no HP, using poring data for it\n", class_, mob_db_data[class_]->sprite);
- mob_makedummymobdb(class_);
- }
}
mysql_free_result(sql_res);