summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2013-09-21 10:59:19 +0200
committerHaru <haru@dotalux.com>2013-09-21 10:59:19 +0200
commit0d12201adecaf21fccfee8e62a2d2a5582535ae3 (patch)
tree950c673626548818c1ea8abd0165541d40192da8 /src/map
parent51241f66ad6e78cf56b91c41e524c00a1d5abeb2 (diff)
downloadhercules-0d12201adecaf21fccfee8e62a2d2a5582535ae3.tar.gz
hercules-0d12201adecaf21fccfee8e62a2d2a5582535ae3.tar.bz2
hercules-0d12201adecaf21fccfee8e62a2d2a5582535ae3.tar.xz
hercules-0d12201adecaf21fccfee8e62a2d2a5582535ae3.zip
Corrected invalid values assigned to enum homun_type variables
- Fixes a warning in clang-5.0.0 (and a potentially incorrect/undefined behavior of the related code) Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c15
-rw-r--r--src/map/homunculus.c12
-rw-r--r--src/map/homunculus.h17
-rw-r--r--src/map/script.c6
4 files changed, 25 insertions, 25 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 8eb3bfd44..fa3108df8 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -6838,27 +6838,26 @@ ACMD(showmobs)
/*==========================================
* homunculus level up [orn]
*------------------------------------------*/
-ACMD(homlevel)
-{
+ACMD(homlevel) {
TBL_HOM * hd;
int level = 0;
enum homun_type htype;
nullpo_retr(-1, sd);
- if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
+ if( !message || !*message || ( level = atoi(message) ) < 1 ) {
clif->message(fd, msg_txt(1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
return false;
}
- if ( !homun_alive(sd->hd) ) {
+ if( !homun_alive(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
return false;
}
hd = sd->hd;
- if((htype = homun->class2type(hd->homunculus.class_)) == -1) {
+ if( (htype = homun->class2type(hd->homunculus.class_)) == HT_INVALID ) {
ShowError("atcommand_homlevel: invalid homun class %d (player %s)\n", hd->homunculus.class_,sd->status.name);
return false;
}
@@ -6920,12 +6919,12 @@ ACMD(hommutate) {
enum homun_type m_class, m_id;
nullpo_retr(-1, sd);
- if (!homun_alive(sd->hd)) {
+ if( !homun_alive(sd->hd) ) {
clif->message(fd, msg_txt(1254)); // You do not have a homunculus.
return false;
}
- if (!message || !*message) {
+ if( !message || !*message ) {
homun_id = 6048 + (rnd() % 4);
} else {
homun_id = atoi(message);
@@ -6934,7 +6933,7 @@ ACMD(hommutate) {
m_class = homun->class2type(sd->hd->homunculus.class_);
m_id = homun->class2type(homun_id);
- if (m_class != -1 && m_id != -1 && m_class == HT_EVO && m_id == HT_S && sd->hd->homunculus.level >= 99) {
+ if( m_class != HT_INVALID && m_id != HT_INVALID && m_class == HT_EVO && m_id == HT_S && sd->hd->homunculus.level >= 99 ) {
homun->mutate(sd->hd, homun_id);
} else {
clif->emotion(&sd->hd->bl, E_SWT);
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index 81971ebef..c14df7e0b 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -71,7 +71,7 @@ enum homun_type homunculus_class2type(int class_) {
case 6052:
return HT_S;
default:
- return -1;
+ return HT_INVALID;
}
}
@@ -288,7 +288,7 @@ bool homunculus_levelup(struct homun_data *hd) {
int growth_max_hp, growth_max_sp;
enum homun_type htype;
- if((htype = homun->class2type(hd->homunculus.class_)) == -1) {
+ if( (htype = homun->class2type(hd->homunculus.class_)) == HT_INVALID ) {
ShowError("homunculus_levelup: Invalid class %d. \n", hd->homunculus.class_);
return false;
}
@@ -435,14 +435,14 @@ bool homunculus_mutate(struct homun_data *hd, int homun_id) {
m_class = homun->class2type(hd->homunculus.class_);
m_id = homun->class2type(homun_id);
- if( m_class == -1 || m_id == -1 || m_class != HT_EVO || m_id != HT_S ) {
+ if( m_class == HT_INVALID || m_id == HT_INVALID || m_class != HT_EVO || m_id != HT_S ) {
clif->emotion(&hd->bl, E_SWT);
return false;
}
prev_class = hd->homunculus.class_;
- if (!homun->change_class(hd, homun_id)) {
+ if( !homun->change_class(hd, homun_id) ) {
ShowError("homunculus_mutate: Can't evolve homunc from %d to %d", hd->homunculus.class_, homun_id);
return false;
}
@@ -462,7 +462,7 @@ bool homunculus_mutate(struct homun_data *hd, int homun_id) {
hom->prev_class = prev_class;
status_calc_homunculus(hd,1);
- if (!(battle_config.hom_setting&0x2))
+ if( !(battle_config.hom_setting&0x2) )
skill->unit_move(&sd->hd->bl,iTimer->gettick(),1); // apply land skills immediately
return true;
@@ -474,7 +474,7 @@ int homunculus_gainexp(struct homun_data *hd,unsigned int exp) {
if(hd->homunculus.vaporize)
return 1;
- if((htype = homun->class2type(hd->homunculus.class_)) == -1) {
+ if( (htype = homun->class2type(hd->homunculus.class_)) == HT_INVALID ) {
ShowError("homunculus_gainexp: Invalid class %d. \n", hd->homunculus.class_);
return 0;
}
diff --git a/src/map/homunculus.h b/src/map/homunculus.h
index 4b35c0992..a90faf2e2 100644
--- a/src/map/homunculus.h
+++ b/src/map/homunculus.h
@@ -53,13 +53,13 @@ struct homun_data {
struct status_data base_status, battle_status;
struct status_change sc;
struct regen_data regen;
- struct s_homunculus_db *homunculusDB; //[orn]
- struct s_homunculus homunculus; //[orn]
+ struct s_homunculus_db *homunculusDB; //[orn]
+ struct s_homunculus homunculus; //[orn]
- struct map_session_data *master; //pointer back to its master
- int hungry_timer; //[orn]
+ struct map_session_data *master; //pointer back to its master
+ int hungry_timer; //[orn]
unsigned int exp_next;
- char blockskill[MAX_SKILL]; // [orn]
+ char blockskill[MAX_SKILL]; // [orn]
};
struct homun_skill_tree_entry {
@@ -74,9 +74,10 @@ struct homun_skill_tree_entry {
}; // Celest
enum homun_type {
- HT_REG = 0x1,
- HT_EVO = 0x2,
- HT_S = 0x4,
+ HT_REG, // Regular Homunculus
+ HT_EVO, // Evolved Homunculus
+ HT_S, // Homunculus S
+ HT_INVALID = -1, // Invalid Homunculus
};
/* homunculus.c interface */
diff --git a/src/map/script.c b/src/map/script.c
index 7ac638848..87d2b475c 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -9797,16 +9797,16 @@ BUILDIN(homunculus_mutate) {
if( sd == NULL || sd->hd == NULL )
return true;
- if(script_hasdata(st,2))
+ if( script_hasdata(st,2) )
homun_id = script_getnum(st,2);
else
homun_id = 6048 + (rnd() % 4);
- if(homun_alive(sd->hd)) {
+ if( homun_alive(sd->hd) ) {
m_class = homun->class2type(sd->hd->homunculus.class_);
m_id = homun->class2type(homun_id);
- if ( m_class != -1 && m_id != -1 && m_class == HT_EVO && m_id == HT_S && sd->hd->homunculus.level >= 99 )
+ if( m_class != HT_INVALID && m_id != HT_INVALID && m_class == HT_EVO && m_id == HT_S && sd->hd->homunculus.level >= 99 )
homun->mutate(sd->hd, homun_id);
else
clif->emotion(&sd->hd->bl, E_SWT);