From 3c0ca51db3ff495804a7d25b0d9508c67ce77d3f Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 30 May 2011 02:07:26 +0400 Subject: [PATCH] [11563] Add support mailbox access for npc with CREATURE_TYPEFLAGS_SQUIRE --- src/game/MailHandler.cpp | 26 ++++++++++++++++++++++++-- src/game/SharedDefines.h | 2 +- src/shared/revision_nr.h | 2 +- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/game/MailHandler.cpp b/src/game/MailHandler.cpp index f7403de8f..cbee55478 100644 --- a/src/game/MailHandler.cpp +++ b/src/game/MailHandler.cpp @@ -51,11 +51,33 @@ bool WorldSession::CheckMailBox(ObjectGuid guid) } } // mailbox case - else + else if (guid.IsGameObject()) { if (!GetPlayer()->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_MAILBOX)) { - DEBUG_LOG("Mailbox %s not found or you can't interact with him.", guid.GetString().c_str()); + DEBUG_LOG("Mailbox %s not found or %s can't interact with him.", guid.GetString().c_str(), GetPlayer()->GetGuidStr().c_str()); + return false; + } + } + // squire case + else if (guid.IsAnyTypeCreature()) + { + Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); + if (!creature) + { + DEBUG_LOG("%s not found or %s can't interact with him.", creature->GetGuidStr().c_str(), GetPlayer()->GetGuidStr().c_str()); + return false; + } + + if (!(creature->GetCreatureInfo()->type_flags & CREATURE_TYPEFLAGS_SQUIRE)) + { + DEBUG_LOG("%s not have access to mailbox.", creature->GetGuidStr().c_str()); + return false; + } + + if (creature->GetOwnerGuid() != GetPlayer()->GetObjectGuid()) + { + DEBUG_LOG("%s not owned by %s for access to mailbox.", creature->GetGuidStr().c_str(), GetPlayer()->GetGuidStr().c_str()); return false; } } diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 905190e7f..91abdb0c2 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -1994,7 +1994,7 @@ enum CreatureTypeFlags CREATURE_TYPEFLAGS_UNK21 = 0x00100000, // no idea, but it used by client, may be related to rendering CREATURE_TYPEFLAGS_UNK22 = 0x00200000, // may be has something to do with animation (disable animation?) CREATURE_TYPEFLAGS_UNK23 = 0x00400000, // this one probably controls some creature visual - CREATURE_TYPEFLAGS_UNK24 = 0x00800000, // ? First seen in 3.2.2. Related to banner/backpack of creature/companion, used in CanInteract function by client + CREATURE_TYPEFLAGS_SQUIRE = 0x00800000, // First seen in 3.2.2. Related to banner/backpack of creature/companion, used in CanInteract function by client CREATURE_TYPEFLAGS_UNK25 = 0x01000000, // pet sounds related? CREATURE_TYPEFLAGS_UNK26 = 0x02000000, // this one probably controls some creature visual CREATURE_TYPEFLAGS_UNK27 = 0x04000000, // creature has no type, or forces creature to be considered as in party, may be related to creature assistance diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index e66a1347e..6c6da8f0d 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 "11562" + #define REVISION_NR "11563" #endif // __REVISION_NR_H__