From 878c036deb192616a69b058a14b16b345f295031 Mon Sep 17 00:00:00 2001 From: Warlockbugs Date: Sat, 30 Sep 2017 16:20:09 +0300 Subject: [PATCH] Improve some flags naming in enum UnitState UNIT_STAT_CONTROLLED -> UNIT_STAT_POSSESSED UNIT_STAT_DIED - > UNIT_STAT_FEIGN_DEATH --- src/game/AI/ScriptDevAI/base/escort_ai.cpp | 2 +- src/game/AI/ScriptDevAI/base/follower_ai.cpp | 2 +- src/game/Chat/ChatHandler.cpp | 4 ++-- src/game/Entities/Creature.cpp | 2 +- src/game/Entities/Pet.h | 2 +- src/game/Entities/PetHandler.cpp | 14 +++++++------- src/game/Entities/Unit.cpp | 12 ++++++------ src/game/Entities/Unit.h | 14 +++++++------- src/game/Entities/Vehicle.cpp | 4 ++-- src/game/MotionGenerators/MotionMaster.cpp | 2 +- src/game/Spells/SpellAuras.cpp | 4 ++-- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/game/AI/ScriptDevAI/base/escort_ai.cpp b/src/game/AI/ScriptDevAI/base/escort_ai.cpp index 183aed0247e..e5e9b5e29a2 100644 --- a/src/game/AI/ScriptDevAI/base/escort_ai.cpp +++ b/src/game/AI/ScriptDevAI/base/escort_ai.cpp @@ -64,7 +64,7 @@ bool npc_escortAI::AssistPlayerInCombat(Unit* pWho) return false; // unit state prevents (similar check is done in CanInitiateAttack which also include checking unit_flags. We skip those here) - if (m_creature->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_DIED | UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING)) + if (m_creature->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_FEIGN_DEATH | UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING)) return false; // victim of pWho is not a player diff --git a/src/game/AI/ScriptDevAI/base/follower_ai.cpp b/src/game/AI/ScriptDevAI/base/follower_ai.cpp index b2b46facf65..c73fe83ff14 100644 --- a/src/game/AI/ScriptDevAI/base/follower_ai.cpp +++ b/src/game/AI/ScriptDevAI/base/follower_ai.cpp @@ -53,7 +53,7 @@ bool FollowerAI::AssistPlayerInCombat(Unit* pWho) return false; // unit state prevents (similar check is done in CanInitiateAttack which also include checking unit_flags. We skip those here) - if (m_creature->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_DIED | UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING)) + if (m_creature->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_FEIGN_DEATH | UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING)) return false; // victim of pWho is not a player diff --git a/src/game/Chat/ChatHandler.cpp b/src/game/Chat/ChatHandler.cpp index 5360bb33ae6..62c0ff52b20 100644 --- a/src/game/Chat/ChatHandler.cpp +++ b/src/game/Chat/ChatHandler.cpp @@ -510,7 +510,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) void WorldSession::HandleEmoteOpcode(WorldPacket& recv_data) { - if (!GetPlayer()->isAlive() || GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (!GetPlayer()->isAlive() || GetPlayer()->hasUnitState(UNIT_STAT_FEIGN_DEATH)) return; uint32 emote; @@ -585,7 +585,7 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket& recv_data) default: { // in feign death state allowed only text emotes. - if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_FEIGN_DEATH)) break; GetPlayer()->HandleEmoteCommand(emote_id); diff --git a/src/game/Entities/Creature.cpp b/src/game/Entities/Creature.cpp index 2cf54af76a0..c6cc8d6c814 100644 --- a/src/game/Entities/Creature.cpp +++ b/src/game/Entities/Creature.cpp @@ -1923,7 +1923,7 @@ bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction / bool Creature::CanInitiateAttack() const { - if (hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_DIED)) + if (hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_FEIGN_DEATH)) return false; if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)) diff --git a/src/game/Entities/Pet.h b/src/game/Entities/Pet.h index 4ec8069c334..31788f76cce 100644 --- a/src/game/Entities/Pet.h +++ b/src/game/Entities/Pet.h @@ -273,7 +273,7 @@ class Pet : public Creature bool m_removed; // prevent overwrite pet state in DB at next Pet::Update if pet already removed(saved) // return charminfo ai only when this pet is possessed. (eye of the beast case for ex.) - virtual CreatureAI* AI() override { if (hasUnitState(UNIT_STAT_CONTROLLED) && m_charmInfo->GetAI()) return m_charmInfo->GetAI(); else return m_ai.get(); } + virtual CreatureAI* AI() override { if (hasUnitState(UNIT_STAT_POSSESSED) && m_charmInfo->GetAI()) return m_charmInfo->GetAI(); else return m_ai.get(); } virtual CombatData* GetCombatData() override { return m_combatData; } void InitTamedPetPassives(Unit* player); diff --git a/src/game/Entities/PetHandler.cpp b/src/game/Entities/PetHandler.cpp index aa31e4dc9d6..29e443d7103 100644 --- a/src/game/Entities/PetHandler.cpp +++ b/src/game/Entities/PetHandler.cpp @@ -85,7 +85,7 @@ void WorldSession::HandlePetAction(WorldPacket& recv_data) if (!pet) { - if (petUnit->hasUnitState(UNIT_STAT_CONTROLLED)) + if (petUnit->hasUnitState(UNIT_STAT_POSSESSED)) { // possess case if (flag != uint8(ACT_COMMAND)) @@ -132,7 +132,7 @@ void WorldSession::HandlePetAction(WorldPacket& recv_data) { case COMMAND_STAY: // flat=1792 // STAY { - if (!petUnit->hasUnitState(UNIT_STAT_CONTROLLED)) + if (!petUnit->hasUnitState(UNIT_STAT_POSSESSED)) { petUnit->StopMoving(); petUnit->GetMotionMaster()->Clear(); @@ -143,7 +143,7 @@ void WorldSession::HandlePetAction(WorldPacket& recv_data) } case COMMAND_FOLLOW: // spellid=1792 // FOLLOW { - if (!petUnit->hasUnitState(UNIT_STAT_CONTROLLED)) + if (!petUnit->hasUnitState(UNIT_STAT_POSSESSED)) { petUnit->StopMoving(); petUnit->GetMotionMaster()->Clear(); @@ -166,7 +166,7 @@ void WorldSession::HandlePetAction(WorldPacket& recv_data) if (petUnit->getVictim() != targetUnit) { petUnit->AttackStop(); - if (!petUnit->hasUnitState(UNIT_STAT_CONTROLLED)) + if (!petUnit->hasUnitState(UNIT_STAT_POSSESSED)) { petUnit->GetMotionMaster()->Clear(); @@ -278,7 +278,7 @@ void WorldSession::HandlePetAction(WorldPacket& recv_data) petUnit->AttackStop(); - if (!petUnit->hasUnitState(UNIT_STAT_CONTROLLED)) + if (!petUnit->hasUnitState(UNIT_STAT_POSSESSED)) { petUnit->GetMotionMaster()->Clear(); @@ -296,7 +296,7 @@ void WorldSession::HandlePetAction(WorldPacket& recv_data) } // auto turn to target unless possessed - if (result == SPELL_FAILED_UNIT_NOT_INFRONT && !petUnit->hasUnitState(UNIT_STAT_CONTROLLED)) + if (result == SPELL_FAILED_UNIT_NOT_INFRONT && !petUnit->hasUnitState(UNIT_STAT_POSSESSED)) { if (unit_target) { @@ -323,7 +323,7 @@ void WorldSession::HandlePetAction(WorldPacket& recv_data) } else { - if (petUnit->hasUnitState(UNIT_STAT_CONTROLLED)) + if (petUnit->hasUnitState(UNIT_STAT_POSSESSED)) Spell::SendCastResult(GetPlayer(), spellInfo, 0, result); else { diff --git a/src/game/Entities/Unit.cpp b/src/game/Entities/Unit.cpp index 83c6a5d5663..25552c29df4 100644 --- a/src/game/Entities/Unit.cpp +++ b/src/game/Entities/Unit.cpp @@ -8764,7 +8764,7 @@ bool Unit::isTargetableForAttack(bool inverseAlive /*=false*/) const if (isAlive() == inverseAlive) return false; - return IsInWorld() && !hasUnitState(UNIT_STAT_DIED) && !IsTaxiFlying(); + return IsInWorld() && !hasUnitState(UNIT_STAT_FEIGN_DEATH) && !IsTaxiFlying(); } int32 Unit::ModifyHealth(int32 dVal) @@ -11238,7 +11238,7 @@ void Unit::SetFeignDeath(bool apply, ObjectGuid casterGuid /*= ObjectGuid()*/) // blizz like 2.0.x SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); - addUnitState(UNIT_STAT_DIED); + addUnitState(UNIT_STAT_FEIGN_DEATH); CombatStop(); RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); @@ -11263,7 +11263,7 @@ void Unit::SetFeignDeath(bool apply, ObjectGuid casterGuid /*= ObjectGuid()*/) // blizz like 2.0.x RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); - clearUnitState(UNIT_STAT_DIED); + clearUnitState(UNIT_STAT_FEIGN_DEATH); if (GetTypeId() != TYPEID_PLAYER && isAlive()) { @@ -12273,7 +12273,7 @@ Unit* Unit::TakePossessOf(SpellEntry const* spellEntry, SummonPropertiesEntry co pCreature->SetCharmerGuid(GetObjectGuid()); // save guid of the charmer pCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellEntry->Id); // set the spell id used to create this (may be used for removing corresponding aura pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED); // set flag for client that mean this unit is controlled by a player - pCreature->addUnitState(UNIT_STAT_CONTROLLED); // also set internal unit state flag + pCreature->addUnitState(UNIT_STAT_POSSESSED); // also set internal unit state flag pCreature->SelectLevel(getLevel()); // set level to same level than summoner TODO:: not sure its always the case... pCreature->SetLinkedToOwnerAura(TEMPSPAWN_LINKED_AURA_OWNER_CHECK | TEMPSPAWN_LINKED_AURA_REMOVE_OWNER); // set what to do if linked aura is removed or the creature is dead. pCreature->SetWalk(IsWalking(), true); // sync the walking state with the summoner @@ -12332,7 +12332,7 @@ bool Unit::TakePossessOf(Unit* possessed) possessed->AttackStop(true, true); possessed->ClearInCombat(); - possessed->addUnitState(UNIT_STAT_CONTROLLED); + possessed->addUnitState(UNIT_STAT_POSSESSED); possessed->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED); possessed->SetCharmerGuid(GetObjectGuid()); @@ -12509,7 +12509,7 @@ void Unit::ResetControlState(bool attackCharmer /*= true*/) return; } - possessed->clearUnitState(UNIT_STAT_CONTROLLED); + possessed->clearUnitState(UNIT_STAT_POSSESSED); possessed->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED); possessed->SetCharmerGuid(ObjectGuid()); diff --git a/src/game/Entities/Unit.h b/src/game/Entities/Unit.h index be4c02fd319..97db7427f19 100644 --- a/src/game/Entities/Unit.h +++ b/src/game/Entities/Unit.h @@ -424,11 +424,11 @@ enum UnitState // persistent state (applied by aura/etc until expire) UNIT_STAT_MELEE_ATTACKING = 0x00000001, // unit is melee attacking someone Unit::Attack //UNIT_STAT_ATTACK_PLAYER = 0x00000002, // (Deprecated) unit attack player or player's controlled unit and have contested pvpv timer setup, until timer expire, combat end and etc - UNIT_STAT_DIED = 0x00000004, // Unit::SetFeignDeath + UNIT_STAT_FEIGN_DEATH = 0x00000004, // Unit::SetFeignDeath UNIT_STAT_STUNNED = 0x00000008, // Aura::HandleAuraModStun UNIT_STAT_ROOT = 0x00000010, // Aura::HandleAuraModRoot UNIT_STAT_ISOLATED = 0x00000020, // area auras do not affect other players, Aura::HandleAuraModSchoolImmunity - UNIT_STAT_CONTROLLED = 0x00000040, // Aura::HandleAuraModPossess + UNIT_STAT_POSSESSED = 0x00000040, // Aura::HandleAuraModPossess (duplicates UNIT_FLAG_POSSESSED) // persistent movement generator state (all time while movement generator applied to unit (independent from top state of movegen) UNIT_STAT_TAXI_FLIGHT = 0x00000080, // player is in flight mode (in fact interrupted at far teleport until next map telport landing) @@ -461,23 +461,23 @@ enum UnitState // masks (only for check) // can't move currently - UNIT_STAT_CAN_NOT_MOVE = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED, + UNIT_STAT_CAN_NOT_MOVE = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_FEIGN_DEATH, // stay by different reasons - UNIT_STAT_NOT_MOVE = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED | + UNIT_STAT_NOT_MOVE = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_FEIGN_DEATH | UNIT_STAT_DISTRACTED, // stay or scripted movement for effect( = in player case you can't move by client command) - UNIT_STAT_NO_FREE_MOVE = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED | + UNIT_STAT_NO_FREE_MOVE = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_FEIGN_DEATH | UNIT_STAT_TAXI_FLIGHT | UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING, // not react at move in sight or other - UNIT_STAT_CAN_NOT_REACT = UNIT_STAT_STUNNED | UNIT_STAT_DIED | + UNIT_STAT_CAN_NOT_REACT = UNIT_STAT_STUNNED | UNIT_STAT_FEIGN_DEATH | UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING, // AI disabled by some reason - UNIT_STAT_LOST_CONTROL = UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_CONTROLLED, + UNIT_STAT_LOST_CONTROL = UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_POSSESSED, // above 2 state cases UNIT_STAT_CAN_NOT_REACT_OR_LOST_CONTROL = UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_LOST_CONTROL, diff --git a/src/game/Entities/Vehicle.cpp b/src/game/Entities/Vehicle.cpp index ccbbe10d522..074145de049 100644 --- a/src/game/Entities/Vehicle.cpp +++ b/src/game/Entities/Vehicle.cpp @@ -525,7 +525,7 @@ void VehicleInfo::ApplySeatMods(Unit* passenger, uint32 seatFlags) pPlayer->SetCharm(pVehicle); pVehicle->SetCharmerGuid(pPlayer->GetObjectGuid()); - pVehicle->addUnitState(UNIT_STAT_CONTROLLED); + pVehicle->addUnitState(UNIT_STAT_POSSESSED); pVehicle->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED); pPlayer->SetClientControl(pVehicle, 1); @@ -596,7 +596,7 @@ void VehicleInfo::RemoveSeatMods(Unit* passenger, uint32 seatFlags) pPlayer->SetClientControl(pVehicle, 0); pPlayer->SetMover(nullptr); - pVehicle->clearUnitState(UNIT_STAT_CONTROLLED); + pVehicle->clearUnitState(UNIT_STAT_POSSESSED); pVehicle->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED); // must be called after movement control unapplying diff --git a/src/game/MotionGenerators/MotionMaster.cpp b/src/game/MotionGenerators/MotionMaster.cpp index 5dc369bb973..c8b43246e1e 100644 --- a/src/game/MotionGenerators/MotionMaster.cpp +++ b/src/game/MotionGenerators/MotionMaster.cpp @@ -51,7 +51,7 @@ void MotionMaster::Initialize() Clear(false, true); // set new default movement generator - if (m_owner->GetTypeId() == TYPEID_UNIT && !m_owner->hasUnitState(UNIT_STAT_CONTROLLED)) + if (m_owner->GetTypeId() == TYPEID_UNIT && !m_owner->hasUnitState(UNIT_STAT_POSSESSED)) { MovementGenerator* movement = FactorySelector::selectMovementGenerator((Creature*)m_owner); push(movement == nullptr ? &si_idleMovement : movement); diff --git a/src/game/Spells/SpellAuras.cpp b/src/game/Spells/SpellAuras.cpp index 1530d8ecf09..feb31e6fb5e 100644 --- a/src/game/Spells/SpellAuras.cpp +++ b/src/game/Spells/SpellAuras.cpp @@ -3078,14 +3078,14 @@ void Aura::HandleAuraDummy(bool apply, bool Real) target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29); target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); - target->addUnitState(UNIT_STAT_DIED); + target->addUnitState(UNIT_STAT_FEIGN_DEATH); } else { target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29); target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); - target->clearUnitState(UNIT_STAT_DIED); + target->clearUnitState(UNIT_STAT_FEIGN_DEATH); } } return;