Jump to content

[11723][PATCH]Auction House Bot


Auntie Mangos

Recommended Posts

  • Replies 281
  • Created
  • Last Reply

Top Posters In This Topic

https://gist.github.com/833988 < adds ahbot to cmake.

MaNGOS [11187] and cyberiums last push 90640f9a45a499f40015

mangos>ahbot status
Name is set to AhBot
Items loaded for Alliance=5000, Horde=5000, Neutral=4000. Total = 14000

On Archlinux w/ gcc (GCC) 4.5.2 20110127 (prerelease)

Regards

Skirnir

PS: "AHBot> Boost value used to fill AH! (if this happens often adjust both ItemsPerCycle in mangosd.conf)" this should be changed to ahbot.conf

Link to comment
Share on other sites

  • 2 weeks later...

i get a stupid error when applying this patch to a later version of mangos

error: patch failed: src/game/cmakelist.txt:21

error: src/game/cmakelist.txt: patch does not apply

error: patch failed: src/game/world.cpp:1337

error: src/game/world.cpp: patch does not apply

error: patch failed: win/VC100/game.vcxproj.filters:454

error: win/VC100/game.vcxproj.filters: patch does not apply

im using mangos 11218 with playerbot merged into it

Link to comment
Share on other sites

@cyanidel337: You should have a look at the files cmakelist.txt, world.cpp and game.vcxproj.filters. in cmakelist.txt folders are added and you have to make sure you load both ahbot and playerbot, just merge the conflicting lines. In world.cpp you have to merge them as well. You have to initialize playerbot and ahbot loading (it should be enough to remove the lines starting with <<<<, ==== and >>>>). For the VS2010 file, I have no clue, I don't use VS.

And these errors aren't stupid ;) Think of it this way, you invite some friends to your party and say I live in the BLUE house with the BROWN roof between the two RED houses in MYSTREET. Late at night they are on their way to your party, they are in MYSTREET and see two RED houses, but there is a BLUE house with a BLACK roof (you changed the color of your roof because you were sick of these brown roof tiles). Now they phone you "we are at MYSTREET, but there is no BLUE house with a BROWN roof, there is a BLUE house with a BLACK roof between these two RED houses. Where exactly do you live?"

You have two patch files for a clean core, but both apply to the same files. Make sure you change the second patch, or manually fix these merge errors and you should be good to go :)

Regards

Skirnir

Link to comment
Share on other sites

  • 2 weeks later...

I just merged the master into my local new_ahbot and cleaned up the conflicts as this, seems to be working for me

diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp
index 1ed2536..99d1697 100644
--- a/src/game/Mail.cpp
+++ b/src/game/Mail.cpp
@@ -874,10 +874,10 @@ MailDraft& MailDraft::AddItem( Item* item )
/**
 * Prepares the items in a MailDraft.
 */
-void MailDraft::prepareItems(Player* receiver)
+bool MailDraft::prepareItems(Player* receiver)
{
    if (!m_mailTemplateId || !m_mailTemplateItemsNeed)
-        return;
+        return false;

    m_mailTemplateItemsNeed = false;

@@ -898,6 +898,8 @@ void MailDraft::prepareItems(Player* receiver)
            }
        }
    }
+
+    return true;
}
/**
 * Deletes the items included in a MailDraft.
@@ -1006,17 +1008,22 @@ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sende
{
    Player* pReceiver = receiver.GetPlayer();               // can be NULL

+    bool has_items = !m_items.empty();
+
    if (receiver.GetPlayerGuid() == auctionbot.GetAHBObjectGuid())
    {
-        if (sender.GetMailMessageType() == MAIL_AUCTION && !m_items.empty())
+        if (sender.GetMailMessageType() == MAIL_AUCTION && has_items)
            deleteIncludedItems(true);

        return;
    }

+    // generate mail template items for online player, for offline player items will generated at open
    if (pReceiver)
-        prepareItems(pReceiver);                            // generate mail template items
-
+    {
+        if (prepareItems(pReceiver))
+            has_items = true;
+    }

    uint32 mailId = sObjectMgr.GenerateMailID();

@@ -1042,7 +1049,7 @@ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sende
    CharacterDatabase.BeginTransaction();
    CharacterDatabase.PExecute("INSERT INTO mail (id,messageType,stationery,mailTemplateId,sender,receiver,subject,body,has_items,expire_time,deliver_time,money,cod,checked) "
        "VALUES
('%u', '%u', '%u', '%u', '%u', '%u', '%s', '%s', '%u', '" UI64FMTD "','" UI64FMTD "', '%u', '%u', '%u')",
-        mailId, sender.GetMailMessageType(), sender.GetStationery(), GetMailTemplateId(), sender.GetSenderId(), receiver.GetPlayerGuid().GetCounter(), safe_subject.c_str(), safe_body.c_str(), (m_items.empty() ? 0 : 1), (uint64)expire_time, (uint64)deliver_time, m_money, m_COD, checked);
+        mailId, sender.GetMailMessageType(), sender.GetStationery(), GetMailTemplateId(), sender.GetSenderId(), receiver.GetPlayerGuid().GetCounter(), safe_subject.c_str(), safe_body.c_str(), (has_items ? 1 : 0), (uint64)expire_time, (uint64)deliver_time, m_money, m_COD, checked);

    for(MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
    {
@@ -1091,4 +1098,48 @@ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sende
    else if (!m_items.empty())
        deleteIncludedItems();
}
+
+/**
+ * Generate items from template at mails loading (this happens when mail with mail template items send in time when receiver has been offline)
+ *
+ * @param receiver             reciver of mail
+ */
+
+void Mail::prepareTemplateItems( Player* receiver )
+{
+    if (!mailTemplateId || !items.empty())
+        return;
+
+    has_items = true;
+
+    Loot mailLoot;
+
+    // can be empty
+    mailLoot.FillLoot(mailTemplateId, LootTemplates_Mail, receiver, true, true);
+
+    CharacterDatabase.BeginTransaction();
+    CharacterDatabase.PExecute("UPDATE mail SET has_items = 1 WHERE id = %u", messageID);
+
+    uint32 max_slot = mailLoot.GetMaxSlotInLootFor(receiver);
+    for(uint32 i = 0; items.size() < MAX_MAIL_ITEMS && i < max_slot; ++i)
+    {
+        if (LootItem* lootitem = mailLoot.LootItemInSlot(i, receiver))
+        {
+            if (Item* item = Item::CreateItem(lootitem->itemid, lootitem->count, receiver))
+            {
+                item->SaveToDB();
+
+                AddItem(item->GetGUIDLow(), item->GetEntry());
+
+                receiver->AddMItem(item);
+
+                CharacterDatabase.PExecute("INSERT INTO mail_items (mail_id,item_guid,item_template,receiver) VALUES
('%u', '%u', '%u','%u')",
+                    messageID, item->GetGUIDLow(), item->GetEntry(), receiver->GetGUIDLow());
+            }
+        }
+    }
+
+    CharacterDatabase.CommitTransaction();
+}
+
/*! @} */

Note i changed the lines

- if (sender.GetMailMessageType() == MAIL_AUCTION && !m_items.empty())

+ if (sender.GetMailMessageType() == MAIL_AUCTION && has_items)

because of the implementation of the new bool variable has_items

Link to comment
Share on other sites

Guest
This topic is now 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