summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorxantara <xantara@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-08-01 04:46:52 +0000
committerxantara <xantara@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-08-01 04:46:52 +0000
commitf7f45451e5191148b7e28754d05b75b9f6322249 (patch)
treef5e0840f81cce2baa74e00986d5227c60916910d /src
parent8832adba3ec9df0f7f890154f69f0993b8d1d8e5 (diff)
downloadhercules-f7f45451e5191148b7e28754d05b75b9f6322249.tar.gz
hercules-f7f45451e5191148b7e28754d05b75b9f6322249.tar.bz2
hercules-f7f45451e5191148b7e28754d05b75b9f6322249.tar.xz
hercules-f7f45451e5191148b7e28754d05b75b9f6322249.zip
Added checks for when a homunculus class is invalid when passing through the hom_class2mapid function. Special thanks to Variant.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16546 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/map/homunculus.c14
-rw-r--r--src/map/script.c2
2 files changed, 11 insertions, 5 deletions
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index aaf6dd410..56d87002d 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -242,10 +242,13 @@ int merc_hom_levelup(struct homun_data *hd)
char output[256] ;
int m_class;
- m_class = hom_class2mapid(hd->homunculus.class_);
+ if((m_class = hom_class2mapid(hd->homunculus.class_)) == -1) {
+ ShowError("merc_hom_levelup: Invalid class %d. \n", hd->homunculus.class_);
+ return 0;
+ }
if((m_class&HOM_REG) && (hd->homunculus.level >= battle_config.hom_max_level || ((m_class&HOM_S) && hd->homunculus.level >= battle_config.hom_S_max_level) || !hd->exp_next || hd->homunculus.exp < hd->exp_next))
- return 0 ;
+ return 0;
hom = &hd->homunculus;
hom->level++ ;
@@ -371,7 +374,7 @@ int hom_mutate(struct homun_data *hd, int homun_id)
m_class = hom_class2mapid(hd->homunculus.class_);
m_id = hom_class2mapid(homun_id);
- if( !(m_class&HOM_EVO) || !(m_id&HOM_S) ) {
+ if( m_class == -1 || m_id == -1 || !(m_class&HOM_EVO) || !(m_id&HOM_S) ) {
clif_emotion(&hd->bl, E_SWT);
return 0;
}
@@ -411,7 +414,10 @@ int merc_hom_gainexp(struct homun_data *hd,int exp)
if(hd->homunculus.vaporize)
return 1;
- m_class = hom_class2mapid(hd->homunculus.class_);
+ if((m_class = hom_class2mapid(hd->homunculus.class_)) == -1) {
+ ShowError("merc_hom_gainexp: Invalid class %d. \n", hd->homunculus.class_);
+ return 0;
+ }
if( hd->exp_next == 0 ||
((m_class&HOM_REG) && hd->homunculus.level >= battle_config.hom_max_level) ||
diff --git a/src/map/script.c b/src/map/script.c
index fa858c181..6b3ab6e8e 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -9593,7 +9593,7 @@ BUILDIN_FUNC(homunculus_mutate)
m_class = hom_class2mapid(sd->hd->homunculus.class_);
m_id = hom_class2mapid(homun_id);
- if ( m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99 )
+ if ( m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99 )
hom_mutate(sd->hd, homun_id);
else
clif_emotion(&sd->hd->bl, E_SWT);