Advertisement
Guest User

Untitled

a guest
Apr 4th, 2014
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.41 KB | None | 0 0
  1. diff --git a/src/game/Item.cpp b/src/game/Item.cpp
  2. index 1d806be..6ef2bc7 100644
  3. --- a/src/game/Item.cpp
  4. +++ b/src/game/Item.cpp
  5. @@ -845,8 +845,20 @@ bool Item::IsEquipped() const
  6.  
  7.  bool Item::CanBeTraded() const
  8.  {
  9. +  return CanBeTradedWithAccount(0);
  10. +}
  11. +
  12. +bool Item::CanBeTradedWithAccount(uint32 account) const
  13. +{
  14. +    Player* owner = GetOwner();
  15. +
  16. +    if (!owner)
  17. +        return false;
  18. +
  19.      if (IsSoulBound())
  20. +      if (account == 0 || !IsBoundAccountWide() || owner->GetSession()->GetAccountId() != account)
  21.          return false;
  22. +
  23.      if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty()))
  24.          return false;
  25.  
  26. @@ -1105,6 +1117,10 @@ bool Item::IsBindedNotWith(Player const* player) const
  27.      if (!IsSoulBound())
  28.          return false;
  29.  
  30. +    // Is the item bound to account ?
  31. +    if (IsBoundAccountWide())
  32. +        return false;
  33. +
  34.      return true;
  35.  }
  36.  
  37. diff --git a/src/game/Item.h b/src/game/Item.h
  38. index ebe17d6..531c76a 100644
  39. --- a/src/game/Item.h
  40. +++ b/src/game/Item.h
  41. @@ -274,7 +274,17 @@ class MANGOS_DLL_SPEC Item : public Object
  42.          Player* GetOwner()const;
  43.  
  44.          void SetBinding(bool val) { ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_BINDED, val); }
  45. -        bool IsSoulBound() const { return HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_BINDED); }
  46. +
  47. +        bool IsSoulBound() const
  48. +       {
  49. +         return HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_BINDED) || IsBoundAccountWide();
  50. +       }
  51. +
  52. +       bool IsBoundAccountWide () const
  53. +       {
  54. +         return (GetProto()->Bonding & BIND_ACCOUNT) != 0;
  55. +       }
  56. +
  57.          bool IsBindedNotWith(Player const* player) const;
  58.          bool IsBoundByEnchant() const;
  59.          virtual void SaveToDB();
  60. @@ -292,6 +302,7 @@ class MANGOS_DLL_SPEC Item : public Object
  61.          bool IsNotEmptyBag() const;
  62.          bool IsBroken() const { return GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0 && GetUInt32Value(ITEM_FIELD_DURABILITY) == 0; }
  63.          bool CanBeTraded() const;
  64. +       bool CanBeTradedWithAccount(uint32 account) const;
  65.          void SetInTrade(bool b = true) { mb_in_trade = b; }
  66.          bool IsInTrade() const { return mb_in_trade; }
  67.  
  68. diff --git a/src/game/ItemPrototype.h b/src/game/ItemPrototype.h
  69. index 7c8a0fd..55320d3 100644
  70. --- a/src/game/ItemPrototype.h
  71. +++ b/src/game/ItemPrototype.h
  72. @@ -79,10 +79,11 @@ enum ItemBondingType
  73.      BIND_WHEN_EQUIPPED                          = 2,
  74.      BIND_WHEN_USE                               = 3,
  75.      BIND_QUEST_ITEM                             = 4,
  76. -    BIND_QUEST_ITEM1                            = 5         // not used in game
  77. +    BIND_QUEST_ITEM1                            = 5,        // not used in game
  78. +    BIND_ACCOUNT                               = 6
  79.  };
  80.  
  81. -#define MAX_BIND_TYPE                             6
  82. +#define MAX_BIND_TYPE                             7
  83.  
  84.  // Mask for ItemPrototype.Flags field
  85.  enum ItemPrototypeFlags
  86. diff --git a/src/game/MailHandler.cpp b/src/game/MailHandler.cpp
  87. index 0264f4e..07ffe53 100644
  88. --- a/src/game/MailHandler.cpp
  89. +++ b/src/game/MailHandler.cpp
  90. @@ -204,7 +204,7 @@ void WorldSession::HandleSendMail(WorldPacket& recv_data)
  91.              return;
  92.          }
  93.  
  94. -        if (!item->CanBeTraded())
  95. +        if (!item->CanBeTradedWithAccount(rc_account))
  96.          {
  97.              pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
  98.              return;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement