diff options
-rw-r--r-- | src/server/game/Server/Protocol/Handlers/NPCHandler.cpp | 95 | ||||
-rw-r--r-- | src/server/game/Server/Protocol/Handlers/PetHandler.cpp | 23 | ||||
-rw-r--r-- | src/server/game/Server/WorldSession.h | 6 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraDefines.h | 2 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 18 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.h | 1 |
6 files changed, 100 insertions, 45 deletions
diff --git a/src/server/game/Server/Protocol/Handlers/NPCHandler.cpp b/src/server/game/Server/Protocol/Handlers/NPCHandler.cpp index 00da860db89..8ec3dca845d 100644 --- a/src/server/game/Server/Protocol/Handlers/NPCHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/NPCHandler.cpp @@ -38,6 +38,16 @@ #include "Guild.h" #include "ScriptMgr.h" +enum StableResultCode +{ + STABLE_ERR_MONEY = 0x01, // "you don't have enough money" + STABLE_ERR_STABLE = 0x06, // currently used in most fail cases + STABLE_SUCCESS_STABLE = 0x08, // stable success + STABLE_SUCCESS_UNSTABLE = 0x09, // unstable/swap success + STABLE_SUCCESS_BUY_SLOT = 0x0A, // buy slot success + STABLE_ERR_EXOTIC = 0x0C, // "you are unable to control exotic creatures" +}; + void WorldSession::HandleTabardVendorActivateOpcode(WorldPacket & recv_data) { uint64 guid; @@ -560,6 +570,14 @@ void WorldSession::SendStablePet(uint64 guid) SendPacket(&data); } + +void WorldSession::SendStableResult(uint8 res) +{ + WorldPacket data(SMSG_STABLE_RESULT, 1); + data << uint8(res); + SendPacket(&data); +} + void WorldSession::HandleStablePet(WorldPacket & recv_data) { sLog.outDebug("WORLD: Recv CMSG_STABLE_PET"); @@ -568,12 +586,16 @@ void WorldSession::HandleStablePet(WorldPacket & recv_data) recv_data >> npcGUID; if (!GetPlayer()->isAlive()) + { + SendStableResult(STABLE_ERR_STABLE); return; + } Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(npcGUID, UNIT_NPC_FLAG_STABLEMASTER); if (!unit) { sLog.outDebug("WORLD: HandleStablePet - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(npcGUID))); + SendStableResult(STABLE_ERR_STABLE); return; } @@ -586,9 +608,7 @@ void WorldSession::HandleStablePet(WorldPacket & recv_data) // can't place in stable dead pet if (!pet||!pet->isAlive()||pet->getPetType() != HUNTER_PET) { - WorldPacket data(SMSG_STABLE_RESULT, 1); - data << uint8(0x06); - SendPacket(&data); + SendStableResult(STABLE_ERR_STABLE); return; } @@ -617,12 +637,10 @@ void WorldSession::HandleStablePet(WorldPacket & recv_data) if (free_slot > 0 && free_slot <= GetPlayer()->m_stableSlots) { _player->RemovePet(pet,PetSaveMode(free_slot)); - data << uint8(0x08); + SendStableResult(STABLE_SUCCESS_STABLE); } else - data << uint8(0x06); - - SendPacket(&data); + SendStableResult(STABLE_ERR_STABLE); } void WorldSession::HandleUnstablePet(WorldPacket & recv_data) @@ -637,6 +655,7 @@ void WorldSession::HandleUnstablePet(WorldPacket & recv_data) if (!unit) { sLog.outDebug("WORLD: HandleUnstablePet - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(npcGUID))); + SendStableResult(STABLE_ERR_STABLE); return; } @@ -658,27 +677,25 @@ void WorldSession::HandleUnstablePet(WorldPacket & recv_data) if (!creature_id) { - WorldPacket data(SMSG_STABLE_RESULT, 1); - data << uint8(0x06); - SendPacket(&data); + SendStableResult(STABLE_ERR_STABLE); return; } CreatureInfo const* creatureInfo = objmgr.GetCreatureTemplate(creature_id); if (!creatureInfo || !creatureInfo->isTameable(_player->CanTameExoticPets())) { - WorldPacket data(SMSG_STABLE_RESULT, 1); - data << uint8(0x06); - SendPacket(&data); + // if problem in exotic pet + if (creatureInfo && creatureInfo->isTameable(true)) + SendStableResult(STABLE_ERR_EXOTIC); + else + SendStableResult(STABLE_ERR_STABLE); return; } Pet* pet = _player->GetPet(); if (pet && pet->isAlive()) { - WorldPacket data(SMSG_STABLE_RESULT, 1); - data << uint8(0x06); - SendPacket(&data); + SendStableResult(STABLE_ERR_STABLE); return; } @@ -691,15 +708,11 @@ void WorldSession::HandleUnstablePet(WorldPacket & recv_data) { delete newpet; newpet = NULL; - WorldPacket data(SMSG_STABLE_RESULT, 1); - data << uint8(0x06); - SendPacket(&data); + SendStableResult(STABLE_ERR_STABLE); return; } - WorldPacket data(SMSG_STABLE_RESULT, 1); - data << uint8(0x09); - SendPacket(&data); + SendStableResult(STABLE_SUCCESS_UNSTABLE); } void WorldSession::HandleBuyStableSlot(WorldPacket & recv_data) @@ -713,6 +726,7 @@ void WorldSession::HandleBuyStableSlot(WorldPacket & recv_data) if (!unit) { sLog.outDebug("WORLD: HandleBuyStableSlot - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(npcGUID))); + SendStableResult(STABLE_ERR_STABLE); return; } @@ -720,8 +734,6 @@ void WorldSession::HandleBuyStableSlot(WorldPacket & recv_data) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - WorldPacket data(SMSG_STABLE_RESULT, 200); - if (GetPlayer()->m_stableSlots < MAX_PET_STABLES) { StableSlotPricesEntry const *SlotPrice = sStableSlotPricesStore.LookupEntry(GetPlayer()->m_stableSlots+1); @@ -729,15 +741,13 @@ void WorldSession::HandleBuyStableSlot(WorldPacket & recv_data) { ++GetPlayer()->m_stableSlots; _player->ModifyMoney(-int32(SlotPrice->Price)); - data << uint8(0x0A); // success buy + SendStableResult(STABLE_SUCCESS_BUY_SLOT); } else - data << uint8(0x06); + SendStableResult(STABLE_ERR_MONEY); } else - data << uint8(0x06); - - SendPacket(&data); + SendStableResult(STABLE_ERR_STABLE); } void WorldSession::HandleStableRevivePet(WorldPacket &/* recv_data */) @@ -757,6 +767,7 @@ void WorldSession::HandleStableSwapPet(WorldPacket & recv_data) if (!unit) { sLog.outDebug("WORLD: HandleStableSwapPet - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(npcGUID))); + SendStableResult(STABLE_ERR_STABLE); return; } @@ -764,18 +775,22 @@ void WorldSession::HandleStableSwapPet(WorldPacket & recv_data) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - WorldPacket data(SMSG_STABLE_RESULT, 200); // guess size - Pet* pet = _player->GetPet(); if (!pet || pet->getPetType() != HUNTER_PET) + { + SendStableResult(STABLE_ERR_STABLE); return; + } // find swapped pet slot in stable QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT slot,entry FROM character_pet WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(),pet_number); if (!result) + { + SendStableResult(STABLE_ERR_STABLE); return; + } Field *fields = result->Fetch(); @@ -784,18 +799,18 @@ void WorldSession::HandleStableSwapPet(WorldPacket & recv_data) if (!creature_id) { - WorldPacket data(SMSG_STABLE_RESULT, 1); - data << uint8(0x06); - SendPacket(&data); + SendStableResult(STABLE_ERR_STABLE); return; } CreatureInfo const* creatureInfo = objmgr.GetCreatureTemplate(creature_id); if (!creatureInfo || !creatureInfo->isTameable(_player->CanTameExoticPets())) { - WorldPacket data(SMSG_STABLE_RESULT, 1); - data << uint8(0x06); - SendPacket(&data); + // if problem in exotic pet + if (creatureInfo && creatureInfo->isTameable(true)) + SendStableResult(STABLE_ERR_EXOTIC); + else + SendStableResult(STABLE_ERR_STABLE); return; } @@ -807,12 +822,10 @@ void WorldSession::HandleStableSwapPet(WorldPacket & recv_data) if (!newpet->LoadPetFromDB(_player,creature_id,pet_number)) { delete newpet; - data << uint8(0x06); + SendStableResult(STABLE_ERR_STABLE); } else - data << uint8(0x09); - - SendPacket(&data); + SendStableResult(STABLE_SUCCESS_UNSTABLE); } void WorldSession::HandleRepairItemOpcode(WorldPacket & recv_data) diff --git a/src/server/game/Server/Protocol/Handlers/PetHandler.cpp b/src/server/game/Server/Protocol/Handlers/PetHandler.cpp index 34e6845762b..5beff7e597d 100644 --- a/src/server/game/Server/Protocol/Handlers/PetHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/PetHandler.cpp @@ -410,6 +410,29 @@ void WorldSession::SendPetNameQuery(uint64 petguid, uint32 petnumber) _player->GetSession()->SendPacket(&data); } +bool WorldSession::CheckStableMaster(uint64 guid) +{ + // spell case or GM + if (guid == GetPlayer()->GetGUID()) + { + if (!GetPlayer()->isGameMaster() && !GetPlayer()->HasAuraType(SPELL_AURA_OPEN_STABLE)) + { + DEBUG_LOG("Player (GUID:%u) attempt open stable in cheating way.", GUID_LOPART(guid)); + return false; + } + } + // stable master case + else + { + if (!GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_STABLEMASTER)) + { + DEBUG_LOG("Stablemaster (GUID:%u) not found or you can't interact with him.", GUID_LOPART(guid)); + return false; + } + } + return true; +} + void WorldSession::HandlePetSetAction(WorldPacket & recv_data) { sLog.outDetail("HandlePetSetAction. CMSG_PET_SET_ACTION"); diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 2da8c9440f7..f88b34d3127 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -206,14 +206,16 @@ class WorldSession void SendBattlegGroundList(uint64 guid, BattleGroundTypeId bgTypeId); void SendTradeStatus(TradeStatus status); + void SendUpdateTrade(bool trader_data = true); void SendCancelTrade(); - void SendStablePet(uint64 guid); void SendPetitionQueryOpcode(uint64 petitionguid); - void SendUpdateTrade(bool trader_data = true); //pet void SendPetNameQuery(uint64 guid, uint32 petnumber); + void SendStablePet(uint64 guid); + void SendStableResult(uint8 guid); + bool CheckStableMaster(uint64 guid); // Account Data AccountData *GetAccountData(AccountDataType type) { return &m_accountData[type]; } diff --git a/src/server/game/Spells/Auras/SpellAuraDefines.h b/src/server/game/Spells/Auras/SpellAuraDefines.h index a3a037ae5a8..4e36798705c 100644 --- a/src/server/game/Spells/Auras/SpellAuraDefines.h +++ b/src/server/game/Spells/Auras/SpellAuraDefines.h @@ -336,7 +336,7 @@ enum AuraType SPELL_AURA_289 = 289, SPELL_AURA_MOD_CRIT_PCT = 290, SPELL_AURA_MOD_XP_QUEST_PCT = 291, - SPELL_AURA_292 = 292, + SPELL_AURA_OPEN_STABLE = 292, SPELL_AURA_293 = 293, SPELL_AURA_PREVENT_REGENERATE_POWER = 294, SPELL_AURA_295 = 295, diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 0078c08bd78..8f15f98f101 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -346,7 +346,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]= &AuraEffect::HandleNULL, //289 unused (3.2.0) &AuraEffect::HandleAuraModCritPct, //290 SPELL_AURA_MOD_CRIT_PCT &AuraEffect::HandleNoImmediateEffect, //291 SPELL_AURA_MOD_XP_QUEST_PCT implemented in Player::RewardQuest - &AuraEffect::HandleNULL, //292 call stabled pet + &AuraEffect::HandleAuraOpenStable, //292 SPELL_AURA_OPEN_STABLE &AuraEffect::HandleNULL, //293 auras which probably add set of abilities to their target based on it's miscvalue &AuraEffect::HandleNoImmediateEffect, //294 SPELL_AURA_PREVENT_REGENERATE_POWER implemented in Player::Regenerate(Powers power) &AuraEffect::HandleNULL, //295 0 spells in 3.3.5 @@ -6256,3 +6256,19 @@ void AuraEffect::HandleAuraLinked(AuraApplication const * aurApp, uint8 mode, bo else target->RemoveAura(m_spellProto->EffectTriggerSpell[m_effIndex], GetCasterGUID(), 0, AuraRemoveMode(aurApp->GetRemoveMode())); } + +void AuraEffect::HandleAuraOpenStable(AuraApplication const * aurApp, uint8 mode, bool apply) const +{ + if (!(mode & AURA_EFFECT_HANDLE_REAL)) + return; + + Unit * target = aurApp->GetTarget(); + + if (target->GetTypeId() != TYPEID_PLAYER || !target->IsInWorld()) + return; + + if (apply) + target->ToPlayer()->GetSession()->SendStablePet(target->GetGUID()); + + // client auto close stable dialog at !apply aura +} diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h index d44e73f360f..bbd1d2499d9 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.h +++ b/src/server/game/Spells/Auras/SpellAuraEffects.h @@ -264,6 +264,7 @@ class AuraEffect void HandleComprehendLanguage(AuraApplication const * aurApp, uint8 mode, bool apply) const; void HandleAuraConvertRune(AuraApplication const * aurApp, uint8 mode, bool apply) const; void HandleAuraLinked(AuraApplication const * aurApp, uint8 mode, bool apply) const; + void HandleAuraOpenStable(AuraApplication const * aurApp, uint8 mode, bool apply) const; }; #endif
\ No newline at end of file |