From d2b39816313c0bd4410f3a34092c40f5f1568009 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 8 Nov 2010 02:09:08 +0300 Subject: [PATCH] [10695] Cleanup some death state enums usage. --- src/game/Creature.cpp | 10 +++++----- src/game/Creature.h | 2 ++ src/game/TemporarySummon.cpp | 10 +++++----- src/game/Unit.h | 14 +++++++------- src/shared/revision_nr.h | 2 +- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index f1fcbcdbb..0a71da145 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -557,7 +557,7 @@ void Creature::Update(uint32 update_diff, uint32 tick_diff) m_regenTimer = REGEN_TIME_FULL; break; } - case DEAD_FALLING: + case CORPSE_FALLING: { SetDeathState(CORPSE); } @@ -1396,7 +1396,7 @@ void Creature::SetDeathState(DeathState s) UpdateSpeed(MOVE_RUN, false); } - // return, since we promote to DEAD_FALLING. DEAD_FALLING is promoted to CORPSE at next update. + // return, since we promote to CORPSE_FALLING. CORPSE_FALLING is promoted to CORPSE at next update. if (CanFly() && FallGround()) return; @@ -1422,7 +1422,7 @@ void Creature::SetDeathState(DeathState s) bool Creature::FallGround() { - // Only if state is JUST_DIED. DEAD_FALLING is set below and promoted to CORPSE later + // Only if state is JUST_DIED. CORPSE_FALLING is set below and promoted to CORPSE later if (getDeathState() != JUST_DIED) return false; @@ -1439,7 +1439,7 @@ bool Creature::FallGround() if (fabs(GetPositionZ() - tz) < 0.1f) return false; - Unit::SetDeathState(DEAD_FALLING); + Unit::SetDeathState(CORPSE_FALLING); float dz = tz - GetPositionZ(); float distance = sqrt(dz*dz); @@ -1474,7 +1474,7 @@ void Creature::Respawn() SetVisibility(currentVis); // restore visibility state UpdateObjectVisibility(); - if(getDeathState() == DEAD) + if (IsDespawned()) { if (m_DBTableGuid) sObjectMgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(), 0); diff --git a/src/game/Creature.h b/src/game/Creature.h index f01169ecf..66fe74afd 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -412,6 +412,8 @@ class MANGOS_DLL_SPEC Creature : public Unit bool IsTotem() const { return m_subtype == CREATURE_SUBTYPE_TOTEM; } bool IsTemporarySummon() const { return m_subtype == CREATURE_SUBTYPE_TEMPORARY_SUMMON; } + bool IsCorpse() const { return getDeathState() == CORPSE; } + bool IsDespawned() const { return getDeathState() == DEAD; } void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; } bool IsRacialLeader() const { return GetCreatureInfo()->RacialLeader; } bool IsCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; } diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index c93656d30..2a048c689 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -63,7 +63,7 @@ void TemporarySummon::Update(uint32 update_diff, uint32 tick_diff) case TEMPSUMMON_CORPSE_TIMED_DESPAWN: { - if (m_deathState == CORPSE) + if (IsCorpse()) { if (m_timer <= update_diff) { @@ -78,7 +78,7 @@ void TemporarySummon::Update(uint32 update_diff, uint32 tick_diff) case TEMPSUMMON_CORPSE_DESPAWN: { // if m_deathState is DEAD, CORPSE was skipped - if (m_deathState == CORPSE || m_deathState == DEAD) + if (isDead()) { UnSummon(); return; @@ -88,7 +88,7 @@ void TemporarySummon::Update(uint32 update_diff, uint32 tick_diff) } case TEMPSUMMON_DEAD_DESPAWN: { - if (m_deathState == DEAD) + if (IsDespawned()) { UnSummon(); return; @@ -98,7 +98,7 @@ void TemporarySummon::Update(uint32 update_diff, uint32 tick_diff) case TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN: { // if m_deathState is DEAD, CORPSE was skipped - if (m_deathState == CORPSE || m_deathState == DEAD) + if (isDead()) { UnSummon(); return; @@ -121,7 +121,7 @@ void TemporarySummon::Update(uint32 update_diff, uint32 tick_diff) case TEMPSUMMON_TIMED_OR_DEAD_DESPAWN: { // if m_deathState is DEAD, CORPSE was skipped - if (m_deathState == DEAD) + if (IsDespawned()) { UnSummon(); return; diff --git a/src/game/Unit.h b/src/game/Unit.h index f1b0f43a0..8a786c977 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -403,12 +403,12 @@ enum BaseModType enum DeathState { - ALIVE = 0, - JUST_DIED = 1, - CORPSE = 2, - DEAD = 3, - JUST_ALIVED = 4, - DEAD_FALLING= 5 + ALIVE = 0, // show as alive + JUST_DIED = 1, // temporary state at die, for creature auto converted to CORPSE, for player at next update call + CORPSE = 2, // corpse state, for player this also meaning that player not leave corpse + DEAD = 3, // for creature despawned state (corpse despawned), for player CORPSE/DEAD not clear way switches (FIXME), and use m_deathtimer > 0 check for real corpse state + JUST_ALIVED = 4, // temporary state at resurrection, for creature auto converted to ALIVE, for player at next update call + CORPSE_FALLING = 5 // corpse state in case when corpse still falling to ground }; // internal state flags for some auras and movement generators, other. @@ -1478,7 +1478,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool isAlive() const { return (m_deathState == ALIVE); }; bool isDead() const { return ( m_deathState == DEAD || m_deathState == CORPSE ); }; - DeathState getDeathState() { return m_deathState; }; + DeathState getDeathState() const { return m_deathState; }; virtual void SetDeathState(DeathState s); // overwritten in Creature/Player/Pet ObjectGuid const& GetOwnerGuid() const { return GetGuidValue(UNIT_FIELD_SUMMONEDBY); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 2e36fdecf..437a87825 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10694" + #define REVISION_NR "10695" #endif // __REVISION_NR_H__