refactor(Core/Misc): Make DeathState enum class (#17607)

This commit is contained in:
Kitzunu
2023-10-28 10:54:03 +02:00
committed by GitHub
parent 79b39f9655
commit f757e93da5
47 changed files with 112 additions and 112 deletions

View File

@@ -316,7 +316,7 @@ void Creature::DisappearAndDie()
//SetVisibility(VISIBILITY_OFF);
//ObjectAccessor::UpdateObjectVisibility(this);
if (IsAlive())
setDeathState(JUST_DIED, true);
setDeathState(DeathState::JustDied, true);
RemoveCorpse(false, true);
}
@@ -342,11 +342,11 @@ void Creature::SearchFormation()
void Creature::RemoveCorpse(bool setSpawnTime, bool skipVisibility)
{
if (getDeathState() != CORPSE)
if (getDeathState() != DeathState::Corpse)
return;
m_corpseRemoveTime = GameTime::GetGameTime().count();
setDeathState(DEAD);
setDeathState(DeathState::Dead);
RemoveAllAuras();
if (!skipVisibility) // pussywizard
DestroyForNearbyPlayers(); // pussywizard: previous UpdateObjectVisibility()
@@ -604,15 +604,15 @@ void Creature::Update(uint32 diff)
switch (m_deathState)
{
case JUST_RESPAWNED:
case DeathState::JustRespawned:
// Must not be called, see Creature::setDeathState JUST_RESPAWNED -> ALIVE promoting.
LOG_ERROR("entities.unit", "Creature ({}) in wrong state: JUST_RESPAWNED (4)", GetGUID().ToString());
LOG_ERROR("entities.unit", "Creature ({}) in wrong state: DeathState::JustRespawned (4)", GetGUID().ToString());
break;
case JUST_DIED:
case DeathState::JustDied:
// Must not be called, see Creature::setDeathState JUST_DIED -> CORPSE promoting.
LOG_ERROR("entities.unit", "Creature ({}) in wrong state: JUST_DEAD (1)", GetGUID().ToString());
LOG_ERROR("entities.unit", "Creature ({}) in wrong state: DeathState::JustDead (1)", GetGUID().ToString());
break;
case DEAD:
case DeathState::Dead:
{
time_t now = GameTime::GetGameTime().count();
if (m_respawnTime <= now)
@@ -654,11 +654,11 @@ void Creature::Update(uint32 diff)
}
break;
}
case CORPSE:
case DeathState::Corpse:
{
Unit::Update(diff);
// deathstate changed on spells update, prevent problems
if (m_deathState != CORPSE)
if (m_deathState != DeathState::Corpse)
break;
if (m_groupLootTimer && lootingGroupLowGUID)
@@ -683,7 +683,7 @@ void Creature::Update(uint32 diff)
}
break;
}
case ALIVE:
case DeathState::Alive:
{
Unit::Update(diff);
@@ -1720,12 +1720,12 @@ bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool ad
m_wanderDistance = data->wander_distance;
m_respawnDelay = data->spawntimesecs;
m_deathState = ALIVE;
m_deathState = DeathState::Alive;
m_respawnTime = GetMap()->GetCreatureRespawnTime(m_spawnId);
if (m_respawnTime) // respawn on Update
{
m_deathState = DEAD;
m_deathState = DeathState::Dead;
if (CanFly())
{
float tz = map->GetHeight(GetPhaseMask(), data->posX, data->posY, data->posZ, true, MAX_FALL_DISTANCE);
@@ -1755,7 +1755,7 @@ bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool ad
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
}
SetHealth(m_deathState == ALIVE ? curhealth : 0);
SetHealth(m_deathState == DeathState::Alive ? curhealth : 0);
// checked at creature_template loading
m_defaultMovementType = MovementGeneratorType(data->movementType);
@@ -1950,7 +1950,7 @@ void Creature::setDeathState(DeathState s, bool despawn)
{
Unit::setDeathState(s, despawn);
if (s == JUST_DIED)
if (s == DeathState::JustDied)
{
_lastDamagedTime.reset();
@@ -1984,9 +1984,9 @@ void Creature::setDeathState(DeathState s, bool despawn)
if (needsFalling)
GetMotionMaster()->MoveFall(0, true);
Unit::setDeathState(CORPSE, despawn);
Unit::setDeathState(DeathState::Corpse, despawn);
}
else if (s == JUST_RESPAWNED)
else if (s == DeathState::JustRespawned)
{
//if (IsPet())
// setActive(true);
@@ -2008,7 +2008,7 @@ void Creature::setDeathState(DeathState s, bool despawn)
ClearUnitState(uint32(UNIT_STATE_ALL_STATE & ~(UNIT_STATE_IGNORE_PATHFINDING | UNIT_STATE_NO_ENVIRONMENT_UPD)));
SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool));
Unit::setDeathState(ALIVE, despawn);
Unit::setDeathState(DeathState::Alive, despawn);
Motion_Initialize();
LoadCreaturesAddon(true);
@@ -2024,14 +2024,14 @@ void Creature::Respawn(bool force)
if (force)
{
if (IsAlive())
setDeathState(JUST_DIED);
else if (getDeathState() != CORPSE)
setDeathState(CORPSE);
setDeathState(DeathState::JustDied);
else if (getDeathState() != DeathState::Corpse)
setDeathState(DeathState::Corpse);
}
RemoveCorpse(false, false);
if (getDeathState() == DEAD)
if (getDeathState() == DeathState::Dead)
{
if (m_spawnId)
{
@@ -2059,7 +2059,7 @@ void Creature::Respawn(bool force)
loot.clear();
SelectLevel();
setDeathState(JUST_RESPAWNED);
setDeathState(DeathState::JustRespawned);
// MDic - Acidmanifesto
// Do not override transform auras
@@ -2106,7 +2106,7 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds forceRespawnTimer)
}
if (IsAlive())
setDeathState(JUST_DIED, true);
setDeathState(DeathState::JustDied, true);
// Xinef: set new respawn time, ignore corpse decay time...
RemoveCorpse(true);