Skip to content

Commit

Permalink
[10695] Cleanup some death state enums usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirMangos committed Nov 7, 2010
1 parent 3a82098 commit a8075e7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
10 changes: 5 additions & 5 deletions src/game/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/game/Creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
10 changes: 5 additions & 5 deletions src/game/TemporarySummon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions src/game/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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); }
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10694"
#define REVISION_NR "10695"
#endif // __REVISION_NR_H__

0 comments on commit a8075e7

Please sign in to comment.