Jump to content

Item bound to account


iowa

Recommended Posts

Hi all !

I added a new feature to Mangos One: items binding to account.

The idea is to add a value of "bonding" to flag the items to bind.

I tried to do that as clean as possible.

Feel free to post helpful comments

diff --git a/src/game/Item.cpp b/src/game/Item.cpp
index 1d806be..6ef2bc7 100644
--- a/src/game/Item.cpp
+++ b/src/game/Item.cpp
@@ -845,8 +845,20 @@ bool Item::IsEquipped() const

bool Item::CanBeTraded() const
{
+  return CanBeTradedWithAccount(0);
+}
+
+bool Item::CanBeTradedWithAccount(uint32 account) const
+{
+    Player* owner = GetOwner();
+
+    if (!owner)
+        return false;
+
    if (IsSoulBound())
+      if (account == 0 || !IsBoundAccountWide() || owner->GetSession()->GetAccountId() != account)
        return false;
+
    if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty()))
        return false;

@@ -1105,6 +1117,10 @@ bool Item::IsBindedNotWith(Player const* player) const
    if (!IsSoulBound())
        return false;

+    // Is the item bound to account ?
+    if (IsBoundAccountWide())
+        return false;
+
    return true;
}

diff --git a/src/game/Item.h b/src/game/Item.h
index ebe17d6..531c76a 100644
--- a/src/game/Item.h
+++ b/src/game/Item.h
@@ -274,7 +274,17 @@ class MANGOS_DLL_SPEC Item : public Object
        Player* GetOwner()const;

        void SetBinding(bool val) { ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_BINDED, val); }
-        bool IsSoulBound() const { return HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_BINDED); }
+
+        bool IsSoulBound() const
+       {
+         return HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_BINDED) || IsBoundAccountWide();
+       }
+
+       bool IsBoundAccountWide () const
+       {
+         return (GetProto()->Bonding & BIND_ACCOUNT) != 0;
+       }
+
        bool IsBindedNotWith(Player const* player) const;
        bool IsBoundByEnchant() const;
        virtual void SaveToDB();
@@ -292,6 +302,7 @@ class MANGOS_DLL_SPEC Item : public Object
        bool IsNotEmptyBag() const;
        bool IsBroken() const { return GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0 && GetUInt32Value(ITEM_FIELD_DURABILITY) == 0; }
        bool CanBeTraded() const;
+       bool CanBeTradedWithAccount(uint32 account) const;
        void SetInTrade(bool b = true) { mb_in_trade = b; }
        bool IsInTrade() const { return mb_in_trade; }

diff --git a/src/game/ItemPrototype.h b/src/game/ItemPrototype.h
index 7c8a0fd..55320d3 100644
--- a/src/game/ItemPrototype.h
+++ b/src/game/ItemPrototype.h
@@ -79,10 +79,11 @@ enum ItemBondingType
    BIND_WHEN_EQUIPPED                          = 2,
    BIND_WHEN_USE                               = 3,
    BIND_QUEST_ITEM                             = 4,
-    BIND_QUEST_ITEM1                            = 5         // not used in game
+    BIND_QUEST_ITEM1                            = 5,        // not used in game
+    BIND_ACCOUNT                               = 6
};

-#define MAX_BIND_TYPE                             6
+#define MAX_BIND_TYPE                             7

// Mask for ItemPrototype.Flags field
enum ItemPrototypeFlags
diff --git a/src/game/MailHandler.cpp b/src/game/MailHandler.cpp
index 0264f4e..07ffe53 100644
--- a/src/game/MailHandler.cpp
+++ b/src/game/MailHandler.cpp
@@ -204,7 +204,7 @@ void WorldSession::HandleSendMail(WorldPacket& recv_data)
            return;
        }

-        if (!item->CanBeTraded())
+        if (!item->CanBeTradedWithAccount(rc_account))
        {
            pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
            return;

(alternative link : [C++] diff --git a/src/game/Item.cpp b/src/game/Item.cpp index 1d806be..6ef2bc7 10064 - Pastebin.com)

Thank you

Link to comment
Share on other sites

Thanks for this patch.. Sadly, since this ability wasn't brought into WOW until Patch 4.1, we will not be adding it to mangos one as a default patch.

However, I have alerted the MangosThree team to your patch and hopefully they can work on incorporating it into that.

Bind to Account - WoWWiki - Your guide to the World of Warcraft

If you can make this function available to switch on/off via a mangos.conf setting, then it could be accepted.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use