diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index 645df083e..9992eb69d 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -540,10 +540,34 @@ void WorldSession::SendStableResult(uint8 res) SendPacket(&data); } +bool WorldSession::CheckStableMaster(ObjectGuid guid) +{ + // spell case or GM + if (guid == GetPlayer()->GetObjectGuid()) + { + if (!GetPlayer()->isGameMaster() && !GetPlayer()->HasAuraType(SPELL_AURA_OPEN_STABLE)) + { + DEBUG_LOG("%s attempt open stable in cheating way.", guid.GetString().c_str()); + return false; + } + } + // stable master case + else + { + if (!GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_STABLEMASTER)) + { + DEBUG_LOG("Stablemaster %s not found or you can't interact with him.", guid.GetString().c_str()); + return false; + } + } + + return true; +} + void WorldSession::HandleStablePet( WorldPacket & recv_data ) { DEBUG_LOG("WORLD: Recv CMSG_STABLE_PET"); - uint64 npcGUID; + ObjectGuid npcGUID; recv_data >> npcGUID; @@ -553,10 +577,8 @@ void WorldSession::HandleStablePet( WorldPacket & recv_data ) return; } - Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(npcGUID, UNIT_NPC_FLAG_STABLEMASTER); - if (!unit) + if (!CheckStableMaster(npcGUID)) { - DEBUG_LOG( "WORLD: HandleStablePet - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); SendStableResult(STABLE_ERR_STABLE); return; } @@ -609,15 +631,13 @@ void WorldSession::HandleStablePet( WorldPacket & recv_data ) void WorldSession::HandleUnstablePet( WorldPacket & recv_data ) { DEBUG_LOG("WORLD: Recv CMSG_UNSTABLE_PET."); - uint64 npcGUID; + ObjectGuid npcGUID; uint32 petnumber; recv_data >> npcGUID >> petnumber; - Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(npcGUID, UNIT_NPC_FLAG_STABLEMASTER); - if (!unit) + if (!CheckStableMaster(npcGUID)) { - DEBUG_LOG( "WORLD: HandleUnstablePet - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); SendStableResult(STABLE_ERR_STABLE); return; } @@ -682,14 +702,12 @@ void WorldSession::HandleUnstablePet( WorldPacket & recv_data ) void WorldSession::HandleBuyStableSlot( WorldPacket & recv_data ) { DEBUG_LOG("WORLD: Recv CMSG_BUY_STABLE_SLOT."); - uint64 npcGUID; + ObjectGuid npcGUID; recv_data >> npcGUID; - Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(npcGUID, UNIT_NPC_FLAG_STABLEMASTER); - if (!unit) + if (!CheckStableMaster(npcGUID)) { - DEBUG_LOG( "WORLD: HandleBuyStableSlot - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); SendStableResult(STABLE_ERR_STABLE); return; } @@ -722,15 +740,13 @@ void WorldSession::HandleStableRevivePet( WorldPacket &/* recv_data */) void WorldSession::HandleStableSwapPet( WorldPacket & recv_data ) { DEBUG_LOG("WORLD: Recv CMSG_STABLE_SWAP_PET."); - uint64 npcGUID; + ObjectGuid npcGUID; uint32 pet_number; recv_data >> npcGUID >> pet_number; - Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(npcGUID, UNIT_NPC_FLAG_STABLEMASTER); - if (!unit) + if (!CheckStableMaster(npcGUID)) { - DEBUG_LOG( "WORLD: HandleStableSwapPet - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); SendStableResult(STABLE_ERR_STABLE); return; } diff --git a/src/game/SpellAuraDefines.h b/src/game/SpellAuraDefines.h index 353c4c237..630d2acef 100644 --- a/src/game/SpellAuraDefines.h +++ b/src/game/SpellAuraDefines.h @@ -327,7 +327,7 @@ enum AuraType SPELL_AURA_289 = 289, SPELL_AURA_MOD_ALL_CRIT_CHANCE = 290, SPELL_AURA_MOD_QUEST_XP_PCT = 291, - SPELL_AURA_292 = 292, + SPELL_AURA_OPEN_STABLE = 292, SPELL_AURA_293 = 293, SPELL_AURA_294 = 294, SPELL_AURA_295 = 295, diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index ac0f5c100..f40ed020d 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -342,7 +342,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]= &Aura::HandleUnused, //289 unused (3.2.2a) &Aura::HandleAuraModAllCritChance, //290 SPELL_AURA_MOD_ALL_CRIT_CHANCE &Aura::HandleNoImmediateEffect, //291 SPELL_AURA_MOD_QUEST_XP_PCT implemented in Player::GiveXP - &Aura::HandleNULL, //292 call stabled pet + &Aura::HandleAuraOpenStable, //292 call stabled pet &Aura::HandleNULL, //293 3 spells &Aura::HandleNULL, //294 2 spells, possible prevent mana regen &Aura::HandleUnused, //295 unused (3.2.2a) @@ -7431,6 +7431,19 @@ void Aura::HandleAuraControlVehicle(bool apply, bool Real) } } +void Aura::HandleAuraOpenStable(bool apply, bool Real) +{ + if(!Real || GetTarget()->GetTypeId() != TYPEID_PLAYER || !GetTarget()->IsInWorld()) + return; + + Player* player = (Player*)GetTarget(); + + if (apply) + player->GetSession()->SendStablePet(player->GetObjectGuid()); + + // client auto close stable dialog at !apply aura +} + void Aura::HandleAuraConvertRune(bool apply, bool Real) { if(!Real) diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h index 4ee01f9bb..0f7815888 100644 --- a/src/game/SpellAuras.h +++ b/src/game/SpellAuras.h @@ -364,6 +364,7 @@ class MANGOS_DLL_SPEC Aura void HandleModTargetArmorPct(bool Apply, bool Real); void HandleAuraModAllCritChance(bool Apply, bool Real); void HandleAllowOnlyAbility(bool Apply, bool Real); + void HandleAuraOpenStable(bool apply, bool Real); virtual ~Aura(); diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index 074f27563..d466008c7 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -234,6 +234,7 @@ class MANGOS_DLL_SPEC WorldSession void SendPetNameQuery(uint64 guid, uint32 petnumber); void SendStablePet(ObjectGuid guid ); void SendStableResult(uint8 res); + bool CheckStableMaster(ObjectGuid guid); // Account Data AccountData *GetAccountData(AccountDataType type) { return &m_accountData[type]; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 5a18cb3cb..cb83043e1 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 "10235" + #define REVISION_NR "10236" #endif // __REVISION_NR_H__