[10236] Implement SPELL_AURA_OPEN_STABLE (292).

(based on Wowka321's repo commit 213ceb0)

Signed-off-by: VladimirMangos <vladimir@getmangos.com>

Rewrited partly.
This commit is contained in:
Ceris 2010-07-21 04:04:34 +04:00 committed by VladimirMangos
parent e7093e3ebb
commit d7b6840634
6 changed files with 50 additions and 19 deletions

View file

@ -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;
}

View file

@ -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,

View file

@ -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)

View file

@ -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();

View file

@ -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]; }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10235"
#define REVISION_NR "10236"
#endif // __REVISION_NR_H__