diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 31968e956..764baea96 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -944,7 +944,7 @@ void GameObject::Use(Unit* user) // fallback, will always work player->TeleportTo(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(),TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET); } - player->SetStandState(PLAYER_STATE_SIT_LOW_CHAIR+info->chair.height); + player->SetStandState(UNIT_STAND_STATE_SIT_LOW_CHAIR+info->chair.height); return; } //big gun, its a spell/aura @@ -1255,7 +1255,7 @@ void GameObject::Use(Unit* user) WorldPacket data(SMSG_ENABLE_BARBER_SHOP, 0); player->GetSession()->SendPacket(&data); - player->SetStandState(PLAYER_STATE_SIT_LOW_CHAIR+info->barberChair.chairheight); + player->SetStandState(UNIT_STAND_STATE_SIT_LOW_CHAIR+info->barberChair.chairheight); return; } default: diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index a2c791c6b..52ce0d565 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -300,7 +300,7 @@ void WorldSession::HandleLogoutRequestOpcode( WorldPacket & /*recv_data*/ ) // not set flags if player can't free move to prevent lost state at logout cancel if(GetPlayer()->CanFreeMove()) { - GetPlayer()->SetStandState(PLAYER_STATE_SIT); + GetPlayer()->SetStandState(UNIT_STAND_STATE_SIT); WorldPacket data( SMSG_FORCE_MOVE_ROOT, (8+4) ); // guess size data.append(GetPlayer()->GetPackGUID()); @@ -340,7 +340,7 @@ void WorldSession::HandleLogoutCancelOpcode( WorldPacket & /*recv_data*/ ) SendPacket( &data ); //! Stand Up - GetPlayer()->SetStandState(PLAYER_STATE_NONE); + GetPlayer()->SetStandState(UNIT_STAND_STATE_STAND); //! DISABLE_ROTATE GetPlayer()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index d7a9c32aa..7151f2134 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -5688,10 +5688,10 @@ void ObjectMgr::LoadGameobjectInfo() break; } case GAMEOBJECT_TYPE_CHAIR: //7 - if(goInfo->chair.height > 2) + if(goInfo->chair.height > (UNIT_STAND_STATE_SIT_HIGH_CHAIR-UNIT_STAND_STATE_SIT_LOW_CHAIR) ) { - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data1=%u but correct chair height in range 0..2.", - id,goInfo->type,goInfo->chair.height); + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data1=%u but correct chair height in range 0..%i.", + id,goInfo->type,goInfo->chair.height,UNIT_STAND_STATE_SIT_HIGH_CHAIR-UNIT_STAND_STATE_SIT_LOW_CHAIR); // prevent client and server unexpected work const_cast(goInfo)->chair.height = 0; @@ -5786,6 +5786,16 @@ void ObjectMgr::LoadGameobjectInfo() } break; } + case GAMEOBJECT_TYPE_BARBER_CHAIR: //32 + if(goInfo->barberChair.chairheight > (UNIT_STAND_STATE_SIT_HIGH_CHAIR-UNIT_STAND_STATE_SIT_LOW_CHAIR) ) + { + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data1=%u but correct chair height in range 0..%i.", + id,goInfo->type,goInfo->barberChair.chairheight,UNIT_STAND_STATE_SIT_HIGH_CHAIR-UNIT_STAND_STATE_SIT_LOW_CHAIR); + + // prevent client and server unexpected work + const_cast(goInfo)->barberChair.chairheight = 0; + } + break; } } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index de939cb28..c8cd91aa3 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -2371,7 +2371,7 @@ void Player::InitStatsForLevel(bool reapplyMods) // cleanup player flags (will be re-applied if need at aura load), to avoid have ghost flag without ghost aura, for example. RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK | PLAYER_FLAGS_DND | PLAYER_FLAGS_GM | PLAYER_FLAGS_GHOST); - SetByteValue(UNIT_FIELD_BYTES_1, 2, 0x00); // one form stealth modified bytes + RemoveStandFlags(UNIT_STAND_FLAGS_ALL); // one form stealth modified bytes RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP | UNIT_BYTE2_FLAG_SANCTUARY); // restore if need some important flags @@ -3814,7 +3814,8 @@ void Player::BuildPlayerRepop() SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, (float)1.0); //see radius of death player? - SetByteValue(UNIT_FIELD_BYTES_1, 3, PLAYER_STATE_FLAG_ALWAYS_STAND); + // set and clear other + SetByteValue(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND); } void Player::SendDelayResponse(const uint32 ml_seconds) @@ -15479,9 +15480,9 @@ void Player::SaveToDB() uint32 tmp_displayid = GetDisplayId(); // Set player sit state to standing on save, also stealth and shifted form - SetByteValue(UNIT_FIELD_BYTES_1, 0, 0); // stand state + SetStandState(UNIT_STAND_STATE_STAND); // stand state + RemoveStandFlags(UNIT_STAND_FLAGS_ALL); // stand flags? SetByteValue(UNIT_FIELD_BYTES_2, 3, 0); // shapeshift - SetByteValue(UNIT_FIELD_BYTES_1, 3, 0); // stand flags? RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); SetDisplayId(GetNativeDisplayId()); diff --git a/src/game/Player.h b/src/game/Player.h index f1d16025e..5894014da 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -373,52 +373,6 @@ enum DrunkenState DRUNKEN_SMASHED = 3 }; -enum PlayerStateType -{ - /* - PLAYER_STATE_DANCE - PLAYER_STATE_SLEEP - PLAYER_STATE_SIT - PLAYER_STATE_STAND - PLAYER_STATE_READYUNARMED - PLAYER_STATE_WORK - PLAYER_STATE_POINT(DNR) - PLAYER_STATE_NONE // not used or just no state, just standing there? - PLAYER_STATE_STUN - PLAYER_STATE_DEAD - PLAYER_STATE_KNEEL - PLAYER_STATE_USESTANDING - PLAYER_STATE_STUN_NOSHEATHE - PLAYER_STATE_USESTANDING_NOSHEATHE - PLAYER_STATE_WORK_NOSHEATHE - PLAYER_STATE_SPELLPRECAST - PLAYER_STATE_READYRIFLE - PLAYER_STATE_WORK_NOSHEATHE_MINING - PLAYER_STATE_WORK_NOSHEATHE_CHOPWOOD - PLAYER_STATE_AT_EASE - PLAYER_STATE_READY1H - PLAYER_STATE_SPELLKNEELSTART - PLAYER_STATE_SUBMERGED - */ - - PLAYER_STATE_NONE = 0, - PLAYER_STATE_SIT = 1, - PLAYER_STATE_SIT_CHAIR = 2, - PLAYER_STATE_SLEEP = 3, - PLAYER_STATE_SIT_LOW_CHAIR = 4, - PLAYER_STATE_SIT_MEDIUM_CHAIR = 5, - PLAYER_STATE_SIT_HIGH_CHAIR = 6, - PLAYER_STATE_DEAD = 7, - PLAYER_STATE_KNEEL = 8, - - PLAYER_STATE_FORM_ALL = 0x00FF0000, - - PLAYER_STATE_FLAG_ALWAYS_STAND = 0x01, // byte 4 - PLAYER_STATE_FLAG_CREEP = 0x02000000, - PLAYER_STATE_FLAG_UNTRACKABLE = 0x04000000, - PLAYER_STATE_FLAG_ALL = 0xFF000000, -}; - enum PlayerFlags { PLAYER_FLAGS_GROUP_LEADER = 0x00000001, diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index d1d8506c6..83299a0b6 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -1908,13 +1908,14 @@ enum CorpseDynFlags }; // Passive Spell codes explicit used in code -#define SPELL_ID_GENERIC_LEARN 483 -#define SPELL_ID_GENERIC_LEARN_PET 55884 // used for learning mounts and companions -#define SPELL_ID_PASSIVE_BATTLE_STANCE 2457 -#define SPELL_ID_PASSIVE_RESURRECTION_SICKNESS 15007 -#define SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_5s 6119 -#define SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_0s 6123 -#define SPELL_ID_AUTOSHOT 75 // used for checks in other spells interruption +#define SPELL_ID_GENERIC_LEARN 483 +#define SPELL_ID_GENERIC_LEARN_PET 55884 // used for learning mounts and companions +#define SPELL_ID_PASSIVE_BATTLE_STANCE 2457 +#define SPELL_ID_PASSIVE_RESURRECTION_SICKNESS 15007 +#define SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_5s 6119 +#define SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_0s 6123 +#define SPELL_ID_AUTOSHOT 75 // used for checks in other spells interruption +#define SPELL_ID_SHADOWMELD 58984 // used for check ignore stealth stance state enum WeatherType { diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 352e86647..61a3477d3 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1087,7 +1087,7 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) if( !(m_spellInfo->AttributesEx & SPELL_ATTR_EX_NO_INITIAL_AGGRO) ) { if(!unit->IsStandState() && !unit->hasUnitState(UNIT_STAT_STUNNED)) - unit->SetStandState(PLAYER_STATE_NONE); + unit->SetStandState(UNIT_STAND_STATE_STAND); if(!unit->isInCombat() && unit->GetTypeId() != TYPEID_PLAYER && ((Creature*)unit)->AI()) ((Creature*)unit)->AI()->AttackStart(m_caster); diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 0c8e9fc8d..e8aa83cde 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -945,7 +945,7 @@ void Aura::_AddAura() { // Sitdown on apply aura req seated if (m_spellProto->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED && !m_target->IsSitState()) - m_target->SetStandState(PLAYER_STATE_SIT); + m_target->SetStandState(UNIT_STAND_STATE_SIT); // register aura diminishing on apply if (getDiminishGroup() != DIMINISHING_NONE ) @@ -3406,7 +3406,7 @@ void Aura::HandleModStealth(bool apply, bool Real) // only at real aura add if(Real) { - m_target->SetByteValue(UNIT_FIELD_BYTES_1, 2, 0x02); + m_target->SetStandFlags(UNIT_STAND_FLAGS_CREEP); if(m_target->GetTypeId()==TYPEID_PLAYER) m_target->SetFlag(PLAYER_FIELD_BYTES2, 0x2000); @@ -3426,7 +3426,7 @@ void Aura::HandleModStealth(bool apply, bool Real) // if last SPELL_AURA_MOD_STEALTH and no GM invisibility if(!m_target->HasAuraType(SPELL_AURA_MOD_STEALTH) && m_target->GetVisibility()!=VISIBILITY_OFF) { - m_target->SetByteValue(UNIT_FIELD_BYTES_1, 2, 0x00); + m_target->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP); if(m_target->GetTypeId()==TYPEID_PLAYER) m_target->RemoveFlag(PLAYER_FIELD_BYTES2, 0x2000); @@ -5282,9 +5282,9 @@ void Aura::HandleAuraEmpathy(bool apply, bool Real) void Aura::HandleAuraUntrackable(bool apply, bool Real) { if(apply) - m_target->SetFlag(UNIT_FIELD_BYTES_1, PLAYER_STATE_FLAG_UNTRACKABLE); + m_target->SetByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE); else - m_target->RemoveFlag(UNIT_FIELD_BYTES_1, PLAYER_STATE_FLAG_UNTRACKABLE); + m_target->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE); } void Aura::HandleAuraModPacify(bool apply, bool Real) @@ -5451,7 +5451,7 @@ void Aura::HandleSpiritOfRedemption( bool apply, bool Real ) // set stand state (expected in this form) if(!m_target->IsStandState()) - m_target->SetStandState(PLAYER_STATE_NONE); + m_target->SetStandState(UNIT_STAND_STATE_STAND); } m_target->SetHealth(1); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 069eb957b..ec7cc2643 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -412,7 +412,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa RemoveSpellsCausingAura(SPELL_AURA_MOD_INVISIBILITY); if(pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->IsStandState() && !pVictim->hasUnitState(UNIT_STAT_STUNNED)) - pVictim->SetStandState(PLAYER_STATE_NONE); + pVictim->SetStandState(UNIT_STAND_STATE_STAND); } //Script Event damage Deal @@ -10756,15 +10756,16 @@ void Unit::SetConfused(bool apply, uint64 casterGUID, uint32 spellID) bool Unit::IsSitState() const { uint8 s = getStandState(); - return s == PLAYER_STATE_SIT_CHAIR || s == PLAYER_STATE_SIT_LOW_CHAIR || - s == PLAYER_STATE_SIT_MEDIUM_CHAIR || s == PLAYER_STATE_SIT_HIGH_CHAIR || - s == PLAYER_STATE_SIT; + return + s == UNIT_STAND_STATE_SIT_CHAIR || s == UNIT_STAND_STATE_SIT_LOW_CHAIR || + s == UNIT_STAND_STATE_SIT_MEDIUM_CHAIR || s == UNIT_STAND_STATE_SIT_HIGH_CHAIR || + s == UNIT_STAND_STATE_SIT; } bool Unit::IsStandState() const { uint8 s = getStandState(); - return !IsSitState() && s != PLAYER_STATE_SLEEP && s != PLAYER_STATE_KNEEL; + return !IsSitState() && s != UNIT_STAND_STATE_SLEEP && s != UNIT_STAND_STATE_KNEEL; } void Unit::SetStandState(uint8 state) diff --git a/src/game/Unit.h b/src/game/Unit.h index 2f37d39e8..69d994cca 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -125,6 +125,35 @@ enum SpellFacingFlags #define BASE_MAXDAMAGE 2.0f #define BASE_ATTACK_TIME 2000 +// byte value (UNIT_FIELD_BYTES_1,0) +enum UnitStandStateType +{ + UNIT_STAND_STATE_STAND = 0, + UNIT_STAND_STATE_SIT = 1, + UNIT_STAND_STATE_SIT_CHAIR = 2, + UNIT_STAND_STATE_SLEEP = 3, + UNIT_STAND_STATE_SIT_LOW_CHAIR = 4, + UNIT_STAND_STATE_SIT_MEDIUM_CHAIR = 5, + UNIT_STAND_STATE_SIT_HIGH_CHAIR = 6, + UNIT_STAND_STATE_DEAD = 7, + UNIT_STAND_STATE_KNEEL = 8 +}; + +// byte flag value (UNIT_FIELD_BYTES_1,2) +enum UnitStandFlags +{ + UNIT_STAND_FLAGS_CREEP = 0x02, + UNIT_STAND_FLAGS_ALL = 0xFF +}; + +// byte flags value (UNIT_FIELD_BYTES_1,3) +enum UnitBytes1_Flags +{ + UNIT_BYTE1_FLAG_ALWAYS_STAND = 0x01, + UNIT_BYTE1_FLAG_UNTRACKABLE = 0x04, + UNIT_BYTE1_FLAG_ALL = 0xFF +}; + // high byte (3 from 0..3) of UNIT_FIELD_BYTES_2 enum ShapeshiftForm { @@ -909,6 +938,9 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool IsStandState() const; void SetStandState(uint8 state); + void SetStandFlags(uint8 flags) { SetByteFlag(UNIT_FIELD_BYTES_1, 2,flags); } + void RemoveStandFlags(uint8 flags) { RemoveByteFlag(UNIT_FIELD_BYTES_1, 2,flags); } + bool IsMounted() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT ); } uint32 GetMountID() const { return GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID); } void Mount(uint32 mount);