diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
new file mode 100644
index 0000000..5610d2b
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -0,0 +1,72 @@
+name: Bug report
+description: Create a bug report to help us improve.
+title: "Bug: "
+body:
+ - type: textarea
+ id: current
+ attributes:
+ label: Current Behaviour
+ description: |
+ Description of the problem or issue here.
+ Include entries of affected creatures / items / quests / spells etc.
+ If this is a crash, post the crashlog (upload to https://gist.github.com/) and include the link here.
+ Never upload files! Use GIST for text and YouTube for videos!
+ validations:
+ required: true
+ - type: textarea
+ id: expected
+ attributes:
+ label: Expected Behaviour
+ description: |
+ Tell us what should happen instead.
+ validations:
+ required: true
+ - type: textarea
+ id: reproduce
+ attributes:
+ label: Steps to reproduce the problem
+ description: |
+ What does someone else need to do to encounter the same bug?
+ placeholder: |
+ 1. Step 1
+ 2. Step 2
+ 3. Step 3
+ validations:
+ required: true
+ - type: textarea
+ id: extra
+ attributes:
+ label: Extra Notes
+ description: |
+ Do you have any extra notes that can help solve the issue that does not fit any other field?
+ placeholder: |
+ None
+ validations:
+ required: false
+ - type: textarea
+ id: commit
+ attributes:
+ label: AC rev. hash/commit
+ description: |
+ Copy the result of the `.server debug` command (if you need to run it from the client get a prat addon)
+ validations:
+ required: true
+ - type: input
+ id: os
+ attributes:
+ label: Operating system
+ description: |
+ The Operating System the Server is running on.
+ i.e. Windows 11 x64, Debian 10 x64, macOS 12, Ubuntu 20.04
+ validations:
+ required: true
+ - type: textarea
+ id: custom
+ attributes:
+ label: Custom changes or Modules
+ description: |
+ List which custom changes or modules you have applied, i.e. Eluna module, etc.
+ placeholder: |
+ None
+ validations:
+ required: false
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml
new file mode 100644
index 0000000..58f79dd
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.yml
@@ -0,0 +1,33 @@
+name: Feature request
+description: Suggest an idea for this project
+title: "Feature: "
+body:
+ - type: markdown
+ attributes:
+ value: |
+ Thank you for taking your time to fill out a feature request. Remember to fill out all fields including the title above.
+ An issue that is not properly filled out will be closed.
+ - type: textarea
+ id: description
+ attributes:
+ label: Describe your feature request or suggestion in detail
+ description: |
+ A clear and concise description of what you want to happen.
+ validations:
+ required: true
+ - type: textarea
+ id: solution
+ attributes:
+ label: Describe a possible solution to your feature or suggestion in detail
+ description: |
+ A clear and concise description of any alternative solutions or features you've considered.
+ validations:
+ required: false
+ - type: textarea
+ id: additional
+ attributes:
+ label: Additional context
+ description: |
+ Add any other context or screenshots about the feature request here.
+ validations:
+ required: false
diff --git a/.github/workflows/core-build.yml b/.github/workflows/core-build.yml
index f0f3cb0..921c9eb 100644
--- a/.github/workflows/core-build.yml
+++ b/.github/workflows/core-build.yml
@@ -1,45 +1,12 @@
name: core-build
on:
push:
+ branches:
+ - 'master'
pull_request:
jobs:
build:
- strategy:
- fail-fast: false
- matrix:
- compiler: [clang]
- runs-on: ubuntu-20.04
- name: ${{ matrix.compiler }}
- env:
- COMPILER: ${{ matrix.compiler }}
- steps:
- - uses: actions/checkout@v2
- with:
- repository: 'azerothcore/azerothcore-wotlk'
- ref: 'master'
- submodules: 'recursive'
- - uses: actions/checkout@v2
- with:
- submodules: 'recursive'
- path: 'modules/mod-ah-bot'
- - name: Cache
- uses: actions/cache@v1.1.2
- with:
- path: /home/runner/.ccache
- key: ccache:${{ matrix.compiler }}:${{ github.ref }}:${{ github.sha }}
- restore-keys: |
- ccache:${{ matrix.compiler }}:${{ github.ref }}
- ccache:${{ matrix.compiler }}
- - name: Configure OS
- run: source ./apps/ci/ci-install.sh
- env:
- CONTINUOUS_INTEGRATION: true
- - name: Import db
- run: source ./apps/ci/ci-import-db.sh
- - name: Build
- run: source ./apps/ci/ci-compile.sh
- - name: Dry run
- run: source ./apps/ci/ci-worldserver-dry-run.sh
- - name: Check startup errors
- run: source ./apps/ci/ci-error-check.sh
\ No newline at end of file
+ uses: azerothcore/reusable-workflows/.github/workflows/core_build_modules.yml@main
+ with:
+ module_repo: ${{ github.event.repository.name }}
diff --git a/README.md b/README.md
index db90434..810b8e7 100644
--- a/README.md
+++ b/README.md
@@ -43,4 +43,3 @@ Notes:
- Ayase: ported the bot to AzerothCore
- Other contributors (check the contributors list)
-
diff --git a/conf/conf.sh.dist b/conf/conf.sh.dist
deleted file mode 100644
index 937a7bc..0000000
--- a/conf/conf.sh.dist
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env bash
-
-#
-# CUSTOM
-#
-
-DB_WORLD_CUSTOM_PATHS+=(
- $MOD_AH_BOT_ROOT"/sql/world/base/"
-)
diff --git a/conf/mod_ahbot.conf.dist b/conf/mod_ahbot.conf.dist
index 26d8fdf..de71a17 100644
--- a/conf/mod_ahbot.conf.dist
+++ b/conf/mod_ahbot.conf.dist
@@ -1,16 +1,6 @@
-[worldserver]
-
###############################################################################
# AUCTION HOUSE BOT SETTINGS
#
-# AuctionHouseBot.DEBUG
-# Enable/Disable Debugging output
-# Default 0 (disabled)
-#
-# AuctionHouseBot.DEBUG_FILTERS
-# Enable/Disable Debugging output from Filters
-# Default 0 (disabled)
-#
# AuctionHouseBot.EnableSeller
# Enable/Disable the part of AHBot that puts items up for auction
# Default 0 (disabled)
@@ -41,8 +31,6 @@
#
###############################################################################
-AuctionHouseBot.DEBUG = 0
-AuctionHouseBot.DEBUG_FILTERS = 0
AuctionHouseBot.EnableSeller = 0
AuctionHouseBot.EnableBuyer = 0
AuctionHouseBot.UseBuyPriceForSeller = 0
diff --git a/data/.gitkeep b/data/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/data/sql/db-auth/base/.gitkeep b/data/sql/db-auth/base/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/data/sql/db-auth/updates/.gitkeep b/data/sql/db-auth/updates/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/data/sql/db-characters/base/.gitkeep b/data/sql/db-characters/base/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/data/sql/db-characters/updates/.gitkeep b/data/sql/db-characters/updates/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/data/sql/db-world/base/.gitkeep b/data/sql/db-world/base/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/sql/world/base/mod_auctionhousebot.sql b/data/sql/db-world/base/mod_auctionhousebot.sql
similarity index 100%
rename from sql/world/base/mod_auctionhousebot.sql
rename to data/sql/db-world/base/mod_auctionhousebot.sql
diff --git a/data/sql/db-world/updates/.gitkeep b/data/sql/db-world/updates/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/include.sh b/include.sh
index 038ece6..e69de29 100644
--- a/include.sh
+++ b/include.sh
@@ -1,9 +0,0 @@
-#!/usr/bin/env bash
-
-MOD_AH_BOT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/" && pwd )"
-
-source $MOD_AH_BOT_ROOT"/conf/conf.sh.dist"
-
-if [ -f $MOD_AH_BOT_ROOT"/conf/conf.sh" ]; then
- source $MOD_AH_BOT_ROOT"/conf/conf.sh"
-fi
diff --git a/pull_request_template.md b/pull_request_template.md
new file mode 100644
index 0000000..21c9245
--- /dev/null
+++ b/pull_request_template.md
@@ -0,0 +1,25 @@
+
+
+## Changes Proposed:
+-
+-
+
+## Issues Addressed:
+
+- Closes
+
+## SOURCE:
+
+
+## Tests Performed:
+
+-
+-
+
+
+## How to Test the Changes:
+
+
+1.
+2.
+3.
diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp
index 9ceb204..dd80109 100644
--- a/src/AuctionHouseBot.cpp
+++ b/src/AuctionHouseBot.cpp
@@ -1,131 +1,59 @@
/*
- * Copyright (C) 2008-2010 Trinity
- * Copyright (C) 2005-2009 MaNGOS
+ * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published by the
+ * Free Software Foundation; either version 3 of the License, or (at your
+ * option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ * more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
*/
#include "ObjectMgr.h"
#include "AuctionHouseMgr.h"
#include "AuctionHouseBot.h"
+#include "ItemIndex.h"
+
+#include
+#include
+
#include "Config.h"
#include "Player.h"
#include "WorldSession.h"
#include "GameTime.h"
+#include "DatabaseEnv.h"
+#include "StringConvert.h"
+#include "StringFormat.h"
#include
-using namespace std;
-vector npcItems;
-vector lootItems;
-vector greyTradeGoodsBin;
-vector whiteTradeGoodsBin;
-vector greenTradeGoodsBin;
-vector blueTradeGoodsBin;
-vector purpleTradeGoodsBin;
-vector orangeTradeGoodsBin;
-vector yellowTradeGoodsBin;
-vector greyItemsBin;
-vector whiteItemsBin;
-vector greenItemsBin;
-vector blueItemsBin;
-vector purpleItemsBin;
-vector orangeItemsBin;
-vector yellowItemsBin;
-
AuctionHouseBot::AuctionHouseBot()
{
- debug_Out = false;
- debug_Out_Filters = false;
- AHBSeller = false;
- AHBBuyer = false;
-
- //Begin Filters
-
- Vendor_Items = false;
- Loot_Items = false;
- Other_Items = false;
- Vendor_TGs = false;
- Loot_TGs = false;
- Other_TGs = false;
-
- No_Bind = false;
- Bind_When_Picked_Up = false;
- Bind_When_Equipped = false;
- Bind_When_Use = false;
- Bind_Quest_Item = false;
-
- DisablePermEnchant = false;
- DisableConjured = false;
- DisableGems = false;
- DisableMoney = false;
- DisableMoneyLoot = false;
- DisableLootable = false;
- DisableKeys = false;
- DisableDuration = false;
- DisableBOP_Or_Quest_NoReqLevel = false;
-
- DisableWarriorItems = false;
- DisablePaladinItems = false;
- DisableHunterItems = false;
- DisableRogueItems = false;
- DisablePriestItems = false;
- DisableDKItems = false;
- DisableShamanItems = false;
- DisableMageItems = false;
- DisableWarlockItems = false;
- DisableUnusedClassItems = false;
- DisableDruidItems = false;
-
- DisableItemsBelowLevel = 0;
- DisableItemsAboveLevel = 0;
- DisableTGsBelowLevel = 0;
- DisableTGsAboveLevel = 0;
- DisableItemsBelowGUID = 0;
- DisableItemsAboveGUID = 0;
- DisableTGsBelowGUID = 0;
- DisableTGsAboveGUID = 0;
- DisableItemsBelowReqLevel = 0;
- DisableItemsAboveReqLevel = 0;
- DisableTGsBelowReqLevel = 0;
- DisableTGsAboveReqLevel = 0;
- DisableItemsBelowReqSkillRank = 0;
- DisableItemsAboveReqSkillRank = 0;
- DisableTGsBelowReqSkillRank = 0;
- DisableTGsAboveReqSkillRank = 0;
-
- //End Filters
-
- _lastrun_a = time(NULL);
- _lastrun_h = time(NULL);
- _lastrun_n = time(NULL);
-
- AllianceConfig = AHBConfig(2);
- HordeConfig = AHBConfig(6);
- NeutralConfig = AHBConfig(7);
+ _lastUpdateAlliance = GameTime::GetGameTime();
+ _lastUpdateHorde = GameTime::GetGameTime();
+ _lastUpdateNeutral = GameTime::GetGameTime();
+
+ AllianceConfig = AHBConfig(AUCTIONHOUSE_ALLIANCE);
+ HordeConfig = AHBConfig(AUCTIONHOUSE_HORDE);
+ NeutralConfig = AHBConfig(AUCTIONHOUSE_NEUTRAL);
}
-AuctionHouseBot::~AuctionHouseBot()
+/*static*/ AuctionHouseBot* AuctionHouseBot::instance()
{
+ static AuctionHouseBot instance;
+ return &instance;
}
-void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
+void AuctionHouseBot::AddNewAuctions(Player* AHBplayer, AHBConfig* config)
{
if (!AHBSeller)
{
- if (debug_Out)
- LOG_INFO("module", "AHSeller: Disabled");
+ LOG_DEBUG("module.ahbot", "AHSeller: Disabled");
return;
}
@@ -134,36 +62,34 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
if (maxItems == 0)
{
- //if (debug_Out) sLog->outString( "AHSeller: Auctions disabled");
+ LOG_DEBUG("module.ahbot", "Auctions disabled");
return;
}
- AuctionHouseEntry const* ahEntry = sAuctionMgr->GetAuctionHouseEntry(config->GetAHFID());
+ AuctionHouseEntry const* ahEntry = sAuctionMgr->GetAuctionHouseEntry(config->GetAuctionHouseFactionID());
if (!ahEntry)
{
return;
}
- AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID());
+
+ AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAuctionHouseFactionID());
if (!auctionHouse)
{
return;
}
uint32 auctions = auctionHouse->Getcount();
-
uint32 items = 0;
if (auctions >= minItems)
{
- if (debug_Out)
- LOG_ERROR("module", "AHSeller: Auctions above minimum");
+ LOG_ERROR("module.ahbot", "AHSeller: Auctions above minimum");
return;
}
if (auctions >= maxItems)
{
- if (debug_Out)
- LOG_ERROR("module", "AHSeller: Auctions at or above maximum");
+ LOG_ERROR("module.ahbot", "AHSeller: Auctions at or above maximum");
return;
}
@@ -172,194 +98,58 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
else
items = (maxItems - auctions);
- if (debug_Out)
- LOG_INFO("module", "AHSeller: Adding {} Auctions", items);
-
- if (debug_Out)
- LOG_ERROR("module", "AHSeller: Current house id is {}", config->GetAHID());
-
- uint32 greyTGcount = config->GetPercents(AHB_GREY_TG);
- uint32 whiteTGcount = config->GetPercents(AHB_WHITE_TG);
- uint32 greenTGcount = config->GetPercents(AHB_GREEN_TG);
- uint32 blueTGcount = config->GetPercents(AHB_BLUE_TG);
- uint32 purpleTGcount = config->GetPercents(AHB_PURPLE_TG);
- uint32 orangeTGcount = config->GetPercents(AHB_ORANGE_TG);
- uint32 yellowTGcount = config->GetPercents(AHB_YELLOW_TG);
- uint32 greyIcount = config->GetPercents(AHB_GREY_I);
- uint32 whiteIcount = config->GetPercents(AHB_WHITE_I);
- uint32 greenIcount = config->GetPercents(AHB_GREEN_I);
- uint32 blueIcount = config->GetPercents(AHB_BLUE_I);
- uint32 purpleIcount = config->GetPercents(AHB_PURPLE_I);
- uint32 orangeIcount = config->GetPercents(AHB_ORANGE_I);
- uint32 yellowIcount = config->GetPercents(AHB_YELLOW_I);
-/* uint32 total = greyTGcount + whiteTGcount + greenTGcount + blueTGcount
- + purpleTGcount + orangeTGcount + yellowTGcount
- + whiteIcount + greenIcount + blueIcount + purpleIcount
- + orangeIcount + yellowIcount;
-*/
- uint32 greyTGoods = config->GetItemCounts(AHB_GREY_TG);
- uint32 whiteTGoods = config->GetItemCounts(AHB_WHITE_TG);
- uint32 greenTGoods = config->GetItemCounts(AHB_GREEN_TG);
- uint32 blueTGoods = config->GetItemCounts(AHB_BLUE_TG);
- uint32 purpleTGoods = config->GetItemCounts(AHB_PURPLE_TG);
- uint32 orangeTGoods = config->GetItemCounts(AHB_ORANGE_TG);
- uint32 yellowTGoods = config->GetItemCounts(AHB_YELLOW_TG);
-
- uint32 greyItems = config->GetItemCounts(AHB_GREY_I);
- uint32 whiteItems = config->GetItemCounts(AHB_WHITE_I);
- uint32 greenItems = config->GetItemCounts(AHB_GREEN_I);
- uint32 blueItems = config->GetItemCounts(AHB_BLUE_I);
- uint32 purpleItems = config->GetItemCounts(AHB_PURPLE_I);
- uint32 orangeItems = config->GetItemCounts(AHB_ORANGE_I);
- uint32 yellowItems = config->GetItemCounts(AHB_YELLOW_I);
-
- if (debug_Out)
- LOG_ERROR("module", "AHSeller: {} items", items);
+ LOG_DEBUG("module.ahbot", "AHSeller: Adding {} Auctions", items);
+ LOG_DEBUG("module.ahbot", "AHSeller: Current house id is {}", config->GetAuctionHouseID());
+
+ std::array percents = *config->GetPercents();
+ std::array itemsCount = *config->GetItemCounts();
+
+ LOG_DEBUG("module.ahbot", "AHSeller: {} items", items);
+
+ auto const itemIndex = sAHIndex;
// only insert a few at a time, so as not to peg the processor
for (uint32 cnt = 1; cnt <= items; cnt++)
{
- if (debug_Out)
- LOG_ERROR("module", "AHSeller: {} count", cnt);
+ LOG_DEBUG("module.ahbot", "AHSeller: {} count", cnt);
uint32 itemID = 0;
uint32 itemColor = 99;
uint32 loopbreaker = 0;
+
while (itemID == 0 && loopbreaker <= 50)
{
++loopbreaker;
uint32 choice = urand(0, 13);
itemColor = choice;
- switch (choice)
- {
- case 0:
- {
- if ((greyItemsBin.size() > 0) && (greyItems < greyIcount))
- itemID = greyItemsBin[urand(0, greyItemsBin.size() - 1)];
- else continue;
- break;
- }
- case 1:
- {
- if ((whiteItemsBin.size() > 0) && (whiteItems < whiteIcount))
- itemID = whiteItemsBin[urand(0, whiteItemsBin.size() - 1)];
- else continue;
- break;
- }
- case 2:
- {
- if ((greenItemsBin.size() > 0) && (greenItems < greenIcount))
- itemID = greenItemsBin[urand(0, greenItemsBin.size() - 1)];
- else continue;
- break;
- }
- case 3:
- {
- if ((blueItemsBin.size() > 0) && (blueItems < blueIcount))
- itemID = blueItemsBin[urand(0, blueItemsBin.size() - 1)];
- else continue;
- break;
- }
- case 4:
- {
- if ((purpleItemsBin.size() > 0) && (purpleItems < purpleIcount))
- itemID = purpleItemsBin[urand(0, purpleItemsBin.size() - 1)];
- else continue;
- break;
- }
- case 5:
- {
- if ((orangeItemsBin.size() > 0) && (orangeItems < orangeIcount))
- itemID = orangeItemsBin[urand(0, orangeItemsBin.size() - 1)];
- else continue;
- break;
- }
- case 6:
- {
- if ((yellowItemsBin.size() > 0) && (yellowItems < yellowIcount))
- itemID = yellowItemsBin[urand(0, yellowItemsBin.size() - 1)];
- else continue;
- break;
- }
- case 7:
- {
- if ((greyTradeGoodsBin.size() > 0) && (greyTGoods < greyTGcount))
- itemID = greyTradeGoodsBin[urand(0, greyTradeGoodsBin.size() - 1)];
- else continue;
- break;
- }
- case 8:
- {
- if ((whiteTradeGoodsBin.size() > 0) && (whiteTGoods < whiteTGcount))
- itemID = whiteTradeGoodsBin[urand(0, whiteTradeGoodsBin.size() - 1)];
- else continue;
- break;
- }
- case 9:
- {
- if ((greenTradeGoodsBin.size() > 0) && (greenTGoods < greenTGcount))
- itemID = greenTradeGoodsBin[urand(0, greenTradeGoodsBin.size() - 1)];
- else continue;
- break;
- }
- case 10:
- {
- if ((blueTradeGoodsBin.size() > 0) && (blueTGoods < blueTGcount))
- itemID = blueTradeGoodsBin[urand(0, blueTradeGoodsBin.size() - 1)];
- else continue;
- break;
- }
- case 11:
- {
- if ((purpleTradeGoodsBin.size() > 0) && (purpleTGoods < purpleTGcount))
- itemID = purpleTradeGoodsBin[urand(0, purpleTradeGoodsBin.size() - 1)];
- else continue;
- break;
- }
- case 12:
- {
- if ((orangeTradeGoodsBin.size() > 0) && (orangeTGoods < orangeTGcount))
- itemID = orangeTradeGoodsBin[urand(0, orangeTradeGoodsBin.size() - 1)];
- else continue;
- break;
- }
- case 13:
- {
- if ((yellowTradeGoodsBin.size() > 0) && (yellowTGoods < yellowTGcount))
- itemID = yellowTradeGoodsBin[urand(0, yellowTradeGoodsBin.size() - 1)];
- else continue;
- break;
- }
- default:
- {
- if (debug_Out)
- LOG_ERROR("module", "AHSeller: itemID Switch - Default Reached");
- break;
- }
- }
- if (itemID == 0)
+ auto const& itemsBin = itemIndex->GetItemBin(choice);
+
+ if (!itemsBin.empty() && itemsCount[choice] < percents[choice])
+ itemID = Acore::Containers::SelectRandomContainerElement(itemsBin);
+ else
+ continue;
+
+ if (!itemID)
{
- if (debug_Out)
- LOG_ERROR("module", "AHSeller: Item::CreateItem() - ItemID is 0");
+ LOG_ERROR("module.ahbot", "AHSeller: Item::CreateItem() - ItemID is 0");
continue;
}
ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(itemID);
- if (prototype == NULL)
+ if (!prototype)
{
- if (debug_Out)
- LOG_ERROR("module", "AHSeller: Huh?!?! prototype == NULL");
+ LOG_ERROR("module.ahbot", "AHSeller: ItemTemplate is nullptr!");
continue;
}
Item* item = Item::CreateItem(itemID, 1, AHBplayer);
- if (item == NULL)
+ if (!item)
{
- if (debug_Out)
- LOG_ERROR("module", "AHSeller: Item::CreateItem() returned NULL");
+ LOG_ERROR("module.ahbot", "AHSeller: Item not created!");
break;
}
+
item->AddToUpdateQueueOf(AHBplayer);
uint32 randomPropertyId = Item::GenerateItemRandomPropertyId(itemID);
@@ -375,7 +165,7 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
else
buyoutPrice = prototype->SellPrice;
- if (prototype->Quality <= AHB_MAX_QUALITY)
+ if (prototype->Quality <= AHB_MAX_DEFAULT_QUALITY)
{
if (config->GetMaxStack(prototype->Quality) > 1 && item->GetMaxStackCount() > 1)
stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(prototype->Quality)));
@@ -383,6 +173,7 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
stackCount = urand(1, item->GetMaxStackCount());
else
stackCount = 1;
+
buyoutPrice *= urand(config->GetMinPrice(prototype->Quality), config->GetMaxPrice(prototype->Quality));
buyoutPrice /= 100;
bidPrice = buyoutPrice * urand(config->GetMinBidPrice(prototype->Quality), config->GetMaxBidPrice(prototype->Quality));
@@ -391,37 +182,40 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
else
{
// quality is something it shouldn't be, let's get out of here
- if (debug_Out)
- LOG_ERROR("module", "AHBuyer: Quality {} not Supported", prototype->Quality);
+ LOG_ERROR("module.ahbot", "AHBuyer: Quality {} not Supported", prototype->Quality);
item->RemoveFromUpdateQueueOf(AHBplayer);
continue;
}
uint32 etime = urand(1,3);
+ Seconds elapsedTime = 24h;
+
switch(etime)
{
case 1:
- etime = 43200;
+ elapsedTime = 12h;
break;
case 2:
- etime = 86400;
+ elapsedTime = 24h;
break;
case 3:
- etime = 172800;
+ elapsedTime = 48h;
break;
default:
- etime = 86400;
+ elapsedTime = 24h;
break;
}
+
item->SetCount(stackCount);
- uint32 dep = sAuctionMgr->GetAuctionDeposit(ahEntry, etime, item, stackCount);
+ uint32 dep = sAuctionMgr->GetAuctionDeposit(ahEntry, elapsedTime.count(), item, stackCount);
auto trans = CharacterDatabase.BeginTransaction();
+
AuctionEntry* auctionEntry = new AuctionEntry();
auctionEntry->Id = sObjectMgr->GenerateAuctionID();
- auctionEntry->houseId = config->GetAHID();
- auctionEntry->item_guid = item->GetGUID();
+ auctionEntry->houseId = config->GetAuctionHouseID();
+ auctionEntry->item_guid = item->GetGUID();
auctionEntry->item_template = item->GetEntry();
auctionEntry->itemCount = item->GetCount();
auctionEntry->owner = AHBplayer->GetGUID();
@@ -429,91 +223,52 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
auctionEntry->buyout = buyoutPrice * stackCount;
auctionEntry->bid = 0;
auctionEntry->deposit = dep;
- auctionEntry->expire_time = (time_t) etime + time(NULL);
+ auctionEntry->expire_time = elapsedTime.count() + GameTime::GetGameTime().count();
auctionEntry->auctionHouseEntry = ahEntry;
+
item->SaveToDB(trans);
item->RemoveFromUpdateQueueOf(AHBplayer);
+
sAuctionMgr->AddAItem(item);
+
auctionHouse->AddAuction(auctionEntry);
auctionEntry->SaveToDB(trans);
+
CharacterDatabase.CommitTransaction(trans);
- switch(itemColor)
- {
- case 0:
- ++greyItems;
- break;
- case 1:
- ++whiteItems;
- break;
- case 2:
- ++greenItems;
- break;
- case 3:
- ++blueItems;
- break;
- case 4:
- ++purpleItems;
- break;
- case 5:
- ++orangeItems;
- break;
- case 6:
- ++yellowItems;
- break;
- case 7:
- ++greyTGoods;
- break;
- case 8:
- ++whiteTGoods;
- break;
- case 9:
- ++greenTGoods;
- break;
- case 10:
- ++blueTGoods;
- break;
- case 11:
- ++purpleTGoods;
- break;
- case 12:
- ++orangeTGoods;
- break;
- case 13:
- ++yellowTGoods;
- break;
- default:
- break;
- }
+ itemsCount[itemColor]++;
}
}
}
-void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, WorldSession *session)
+
+void AuctionHouseBot::AddNewAuctionBuyerBotBid(std::shared_ptr player, std::shared_ptr session, AHBConfig* config)
{
if (!AHBBuyer)
{
- if (debug_Out)
- LOG_ERROR("module", "AHBuyer: Disabled");
+ LOG_ERROR("module.ahbot", "AHBuyer: Disabled");
return;
}
- QueryResult result = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE itemowner<>{} AND buyguid<>{}", AHBplayerGUID, AHBplayerGUID);
+ auto sharedConfig = std::make_shared(*config);
- if (!result)
- return;
+ _queryProcessor.AddCallback(CharacterDatabase.AsyncQuery(Acore::StringFormatFmt("SELECT id FROM auctionhouse WHERE itemowner<>{} AND buyguid<>{}", AHBplayerGUID, AHBplayerGUID)).
+ WithCallback(std::bind(&AuctionHouseBot::AddNewAuctionBuyerBotBidCallback, this, player, session, sharedConfig, std::placeholders::_1)));
+}
- if (result->GetRowCount() == 0)
+void AuctionHouseBot::AddNewAuctionBuyerBotBidCallback(std::shared_ptr player, std::shared_ptr /*session*/, std::shared_ptr config, QueryResult result)
+{
+ if (!result || !result->GetRowCount())
return;
// Fetches content of selected AH
- AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID());
- vector possibleBids;
+ AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAuctionHouseFactionID());
+ std::vector possibleBids;
do
{
uint32 tmpdata = result->Fetch()->Get();
possibleBids.push_back(tmpdata);
- }while (result->NextRow());
+ } while (result->NextRow());
for (uint32 count = 1; count <= config->GetBidsPerInterval(); ++count)
{
@@ -526,25 +281,22 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
}
// Choose random auction from possible auctions
- uint32 vectorPos = urand(0, possibleBids.size() - 1);
- vector::iterator iter = possibleBids.begin();
- advance(iter, vectorPos);
+ uint32 randomID = Acore::Containers::SelectRandomContainerElement(possibleBids);
// from auctionhousehandler.cpp, creates auction pointer & player pointer
- AuctionEntry* auction = auctionHouse->GetAuction(*iter);
+ AuctionEntry* auction = auctionHouse->GetAuction(randomID);
// Erase the auction from the vector to prevent bidding on item in next iteration.
- possibleBids.erase(iter);
+ std::erase(possibleBids, randomID);
if (!auction)
continue;
// get exact item information
- Item *pItem = sAuctionMgr->GetAItem(auction->item_guid);
+ Item* pItem = sAuctionMgr->GetAItem(auction->item_guid);
if (!pItem)
{
- if (debug_Out)
- LOG_ERROR("module", "AHBuyer: Item {} doesn't exist, perhaps bought already?", auction->item_guid.ToString());
+ LOG_DEBUG("module.ahbot", "AHBuyer: Item {} doesn't exist, perhaps bought already?", auction->item_guid.ToString());
continue;
}
@@ -559,13 +311,13 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
currentprice = auction->startbid;
// Prepare portion from maximum bid
- double bidrate = static_cast(urand(1, 100)) / 100;
- long double bidMax = 0;
+ float bidrate = frand(0.01f, 1.0f);
+ float bidMax = 0;
// check that bid has acceptable value and take bid based on vendorprice, stacksize and quality
if (BuyMethod)
{
- if (prototype->Quality <= AHB_MAX_QUALITY)
+ if (prototype->Quality <= AHB_MAX_DEFAULT_QUALITY)
{
if (currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(prototype->Quality))
bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(prototype->Quality);
@@ -573,14 +325,13 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
else
{
// quality is something it shouldn't be, let's get out of here
- if (debug_Out)
- LOG_ERROR("module", "AHBuyer: Quality {} not Supported", prototype->Quality);
- continue;
+ LOG_DEBUG("module.ahbot", "AHBuyer: Quality {} not Supported", prototype->Quality);
+ continue;
}
}
else
{
- if (prototype->Quality <= AHB_MAX_QUALITY)
+ if (prototype->Quality <= AHB_MAX_DEFAULT_QUALITY)
{
if (currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(prototype->Quality))
bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(prototype->Quality);
@@ -588,11 +339,10 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
else
{
// quality is something it shouldn't be, let's get out of here
- if (debug_Out)
- LOG_ERROR("module", "AHBuyer: Quality {} not Supported", prototype->Quality);
- continue;
+ LOG_DEBUG("module.ahbot", "AHBuyer: Quality {} not Supported", prototype->Quality);
+ continue;
}
- }
+ }
// check some special items, and do recalculating to their prices
switch (prototype->Class)
@@ -612,7 +362,8 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
}
// Calculate our bid
- long double bidvalue = currentprice + ((bidMax - currentprice) * bidrate);
+ float bidvalue = currentprice + ((bidMax - currentprice) * bidrate);
+
// Convert to uint32
uint32 bidprice = static_cast(bidvalue);
@@ -620,70 +371,57 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
if ((currentprice + auction->GetAuctionOutBid()) > bidprice)
bidprice = currentprice + auction->GetAuctionOutBid();
-
- if (debug_Out)
- {
- LOG_INFO("module", "-------------------------------------------------");
- LOG_INFO("module", "AHBuyer: Info for Auction #{}:", auction->Id);
- LOG_INFO("module", "AHBuyer: AuctionHouse: {}", auction->GetHouseId());
- LOG_INFO("module", "AHBuyer: Owner: {}", auction->owner.ToString());
- LOG_INFO("module", "AHBuyer: Bidder: {}", auction->bidder.ToString());
- LOG_INFO("module", "AHBuyer: Starting Bid: {}", auction->startbid);
- LOG_INFO("module", "AHBuyer: Current Bid: {}", currentprice);
- LOG_INFO("module", "AHBuyer: Buyout: {}", auction->buyout);
- LOG_INFO("module", "AHBuyer: Deposit: {}", auction->deposit);
- LOG_INFO("module", "AHBuyer: Expire Time: {}", uint32(auction->expire_time));
- LOG_INFO("module", "AHBuyer: Bid Rate: {}", bidrate);
- LOG_INFO("module", "AHBuyer: Bid Max: {}", bidMax);
- LOG_INFO("module", "AHBuyer: Bid Value: {}", bidvalue);
- LOG_INFO("module", "AHBuyer: Bid Price: {}", bidprice);
- LOG_INFO("module", "AHBuyer: Item GUID: {}", auction->item_guid.ToString());
- LOG_INFO("module", "AHBuyer: Item Template: {}", auction->item_template);
- LOG_INFO("module", "AHBuyer: Item Info:");
- LOG_INFO("module", "AHBuyer: Item ID: {}", prototype->ItemId);
- LOG_INFO("module", "AHBuyer: Buy Price: {}", prototype->BuyPrice);
- LOG_INFO("module", "AHBuyer: Sell Price: {}", prototype->SellPrice);
- LOG_INFO("module", "AHBuyer: Bonding: {}", prototype->Bonding);
- LOG_INFO("module", "AHBuyer: Quality: {}", prototype->Quality);
- LOG_INFO("module", "AHBuyer: Item Level: {}", prototype->ItemLevel);
- LOG_INFO("module", "AHBuyer: Ammo Type: {}", prototype->AmmoType);
- LOG_INFO("module", "-------------------------------------------------");
- }
+ LOG_DEBUG("module.ahbot", "-------------------------------------------------");
+ LOG_DEBUG("module.ahbot", "AHBuyer: Info for Auction #{}:", auction->Id);
+ LOG_DEBUG("module.ahbot", "AHBuyer: AuctionHouse: {}", auction->GetHouseId());
+ LOG_DEBUG("module.ahbot", "AHBuyer: Owner: {}", auction->owner.ToString());
+ LOG_DEBUG("module.ahbot", "AHBuyer: Bidder: {}", auction->bidder.ToString());
+ LOG_DEBUG("module.ahbot", "AHBuyer: Starting Bid: {}", auction->startbid);
+ LOG_DEBUG("module.ahbot", "AHBuyer: Current Bid: {}", currentprice);
+ LOG_DEBUG("module.ahbot", "AHBuyer: Buyout: {}", auction->buyout);
+ LOG_DEBUG("module.ahbot", "AHBuyer: Deposit: {}", auction->deposit);
+ LOG_DEBUG("module.ahbot", "AHBuyer: Expire Time: {}", uint32(auction->expire_time));
+ LOG_DEBUG("module.ahbot", "AHBuyer: Bid Rate: {}", bidrate);
+ LOG_DEBUG("module.ahbot", "AHBuyer: Bid Max: {}", bidMax);
+ LOG_DEBUG("module.ahbot", "AHBuyer: Bid Value: {}", bidvalue);
+ LOG_DEBUG("module.ahbot", "AHBuyer: Bid Price: {}", bidprice);
+ LOG_DEBUG("module.ahbot", "AHBuyer: Item GUID: {}", auction->item_guid.ToString());
+ LOG_DEBUG("module.ahbot", "AHBuyer: Item Template: {}", auction->item_template);
+ LOG_DEBUG("module.ahbot", "AHBuyer: Item Info:");
+ LOG_DEBUG("module.ahbot", "AHBuyer: Item ID: {}", prototype->ItemId);
+ LOG_DEBUG("module.ahbot", "AHBuyer: Buy Price: {}", prototype->BuyPrice);
+ LOG_DEBUG("module.ahbot", "AHBuyer: Sell Price: {}", prototype->SellPrice);
+ LOG_DEBUG("module.ahbot", "AHBuyer: Bonding: {}", prototype->Bonding);
+ LOG_DEBUG("module.ahbot", "AHBuyer: Quality: {}", prototype->Quality);
+ LOG_DEBUG("module.ahbot", "AHBuyer: Item Level: {}", prototype->ItemLevel);
+ LOG_DEBUG("module.ahbot", "AHBuyer: Ammo Type: {}", prototype->AmmoType);
+ LOG_DEBUG("module.ahbot", "-------------------------------------------------");
// Check whether we do normal bid, or buyout
- if ((bidprice < auction->buyout) || (auction->buyout == 0))
+ if (bidprice < auction->buyout || !auction->buyout)
{
- if (auction->bidder)
+ if (auction->bidder && auction->bidder != player->GetGUID())
{
- if (auction->bidder == AHBplayer->GetGUID())
- {
- //pl->ModifyMoney(-int32(price - auction->bid));
- }
- else
- {
- // mail to last bidder and return money
- auto trans = CharacterDatabase.BeginTransaction();
- sAuctionMgr->SendAuctionOutbiddedMail(auction, bidprice, session->GetPlayer(), trans);
- CharacterDatabase.CommitTransaction(trans);
- //pl->ModifyMoney(-int32(price));
- }
- }
+ auto trans = CharacterDatabase.BeginTransaction();
+ sAuctionMgr->SendAuctionOutbiddedMail(auction, bidprice, player.get(), trans);
+ CharacterDatabase.CommitTransaction(trans);
+ }
- auction->bidder = AHBplayer->GetGUID();
+ auction->bidder = player->GetGUID();
auction->bid = bidprice;
// Saving auction into database
- CharacterDatabase.Execute("UPDATE auctionhouse SET buyguid = '{}',lastbid = '{}' WHERE id = '{}'", auction->bidder.GetCounter(), auction->bid, auction->Id);
+ CharacterDatabase.Execute("UPDATE auctionhouse SET buyguid = '{}', lastbid = '{}' WHERE id = '{}'", auction->bidder.GetCounter(), auction->bid, auction->Id);
}
else
{
auto trans = CharacterDatabase.BeginTransaction();
- //buyout
- if ((auction->bidder) && (AHBplayer->GetGUID() != auction->bidder))
- {
- sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, session->GetPlayer(), trans);
- }
- auction->bidder = AHBplayer->GetGUID();
+
+ // Buyout
+ if (auction->bidder && player->GetGUID() != auction->bidder)
+ sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, player.get(), trans);
+
+ auction->bidder = player->GetGUID();
auction->bid = auction->buyout;
// Send mails to buyer & seller
@@ -692,7 +430,7 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
sAuctionMgr->SendAuctionWonMail(auction, trans);
auction->DeleteFromDB(trans);
- sAuctionMgr->RemoveAItem(auction->item_guid);
+ sAuctionMgr->RemoveAItem(auction->item_guid);
auctionHouse->RemoveAuction(auction);
CharacterDatabase.CommitTransaction(trans);
}
@@ -701,665 +439,98 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
void AuctionHouseBot::Update()
{
- time_t _newrun = time(NULL);
- if ((!AHBSeller) && (!AHBBuyer))
+ if (!AHBSeller && !AHBBuyer)
return;
- std::string accountName = "AuctionHouseBot" + std::to_string(AHBplayerAccount);
+ if (!AHBplayerAccount || !AHBplayerGUID)
+ {
+ LOG_ERROR("module.ahbot", "{}: Invalid player data. Account {}. Guid {}", __FUNCTION__, AHBplayerAccount, AHBplayerGUID);
+ return;
+ }
+
+ std::string accountName = "AuctionHouseBot_" + std::to_string(AHBplayerAccount);
+
+ auto session = std::make_shared(AHBplayerAccount, std::move(accountName), nullptr, SEC_PLAYER, sWorld->getIntConfig(CONFIG_EXPANSION), 0, LOCALE_enUS, 0, false, true, 0);
- WorldSession _session(AHBplayerAccount, std::move(accountName), nullptr, SEC_PLAYER, sWorld->getIntConfig(CONFIG_EXPANSION), 0, LOCALE_enUS, 0, false, false, 0);
- Player _AHBplayer(&_session);
- _AHBplayer.Initialize(AHBplayerGUID);
- ObjectAccessor::AddObject(&_AHBplayer);
+ std::shared_ptr playerBot(new Player(session.get()), [](Player* ptr)
+ {
+ ObjectAccessor::RemoveObject(ptr);
+ delete ptr;
+ });
+
+ playerBot->Initialize(AHBplayerGUID);
+
+ ObjectAccessor::AddObject(playerBot.get());
+
+ Seconds newUpdate = GameTime::GetGameTime();
// Add New Bids
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
{
- addNewAuctions(&_AHBplayer, &AllianceConfig);
- if (((_newrun - _lastrun_a) >= (AllianceConfig.GetBiddingInterval() * MINUTE)) && (AllianceConfig.GetBidsPerInterval() > 0))
+ AddNewAuctions(playerBot.get(), &AllianceConfig);
+ if ((newUpdate - _lastUpdateAlliance >= AllianceConfig.GetBiddingInterval()) && AllianceConfig.GetBidsPerInterval() > 0)
{
- //if (debug_Out) sLog->outError( "AHBuyer: %u seconds have passed since last bid", (_newrun - _lastrun_a));
- //if (debug_Out) sLog->outError( "AHBuyer: Bidding on Alliance Auctions");
- addNewAuctionBuyerBotBid(&_AHBplayer, &AllianceConfig, &_session);
- _lastrun_a = _newrun;
+ LOG_DEBUG("module.ahbot", "AHBuyer: {} seconds have passed since last bid", newUpdate.count() - _lastUpdateAlliance.count());
+ LOG_DEBUG("module.ahbot", "AHBuyer: Bidding on Alliance Auctions");
+ AddNewAuctionBuyerBotBid(playerBot, session, &AllianceConfig);
+ _lastUpdateAlliance = newUpdate;
}
- addNewAuctions(&_AHBplayer, &HordeConfig);
- if (((_newrun - _lastrun_h) >= (HordeConfig.GetBiddingInterval() * MINUTE)) && (HordeConfig.GetBidsPerInterval() > 0))
+ AddNewAuctions(playerBot.get(), &HordeConfig);
+ if ((newUpdate - _lastUpdateHorde >= HordeConfig.GetBiddingInterval()) && HordeConfig.GetBidsPerInterval() > 0)
{
- //if (debug_Out) sLog->outError( "AHBuyer: %u seconds have passed since last bid", (_newrun - _lastrun_h));
- //if (debug_Out) sLog->outError( "AHBuyer: Bidding on Horde Auctions");
- addNewAuctionBuyerBotBid(&_AHBplayer, &HordeConfig, &_session);
- _lastrun_h = _newrun;
+ LOG_DEBUG("module.ahbot", "AHBuyer: {} seconds have passed since last bid", newUpdate.count() - _lastUpdateHorde.count());
+ LOG_DEBUG("module.ahbot", "AHBuyer: Bidding on Horde Auctions");
+ AddNewAuctionBuyerBotBid(playerBot, session, &HordeConfig);
+ _lastUpdateHorde = newUpdate;
}
}
- addNewAuctions(&_AHBplayer, &NeutralConfig);
- if (((_newrun - _lastrun_n) >= (NeutralConfig.GetBiddingInterval() * MINUTE)) && (NeutralConfig.GetBidsPerInterval() > 0))
+ AddNewAuctions(playerBot.get(), &NeutralConfig);
+ if ((newUpdate - _lastUpdateNeutral >= NeutralConfig.GetBiddingInterval()) && NeutralConfig.GetBidsPerInterval() > 0)
{
- //if (debug_Out) sLog->outError( "AHBuyer: %u seconds have passed since last bid", (_newrun - _lastrun_n));
- //if (debug_Out) sLog->outError( "AHBuyer: Bidding on Neutral Auctions");
- addNewAuctionBuyerBotBid(&_AHBplayer, &NeutralConfig, &_session);
- _lastrun_n = _newrun;
+ LOG_DEBUG("module.ahbot", "AHBuyer: {} seconds have passed since last bid", newUpdate.count() - _lastUpdateNeutral.count());
+ LOG_DEBUG("module.ahbot", "AHBuyer: Bidding on Neutral Auctions");
+ AddNewAuctionBuyerBotBid(playerBot, session, &NeutralConfig);
+ _lastUpdateNeutral = newUpdate;
}
- ObjectAccessor::RemoveObject(&_AHBplayer);
+
+ ProcessQueryCallbacks();
}
void AuctionHouseBot::Initialize()
{
- DisableItemStore.clear();
- QueryResult result = WorldDatabase.Query("SELECT item FROM mod_auctionhousebot_disabled_items");
-
- if (result)
- {
- do
- {
- Field* fields = result->Fetch();
- DisableItemStore.insert(fields[0].Get());
- } while (result->NextRow());
- }
+ if (AHBSeller)
+ if (!sAHIndex->InitializeItemsToSell())
+ AHBSeller = false;
- //End Filters
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
{
LoadValues(&AllianceConfig);
LoadValues(&HordeConfig);
}
+
LoadValues(&NeutralConfig);
//
// check if the AHBot account/GUID in the config actually exists
//
- if ((AHBplayerAccount != 0) || (AHBplayerGUID != 0))
+ if (AHBplayerAccount || AHBplayerGUID)
{
QueryResult result = CharacterDatabase.Query("SELECT 1 FROM characters WHERE account = {} AND guid = {}", AHBplayerAccount, AHBplayerGUID);
if (!result)
{
- LOG_ERROR("module", "AuctionHouseBot: The account/GUID-information set for your AHBot is incorrect (account: {} guid: {})", AHBplayerAccount, AHBplayerGUID);
- return;
- }
- }
-
- if (AHBSeller)
- {
- QueryResult results = QueryResult(NULL);
- char npcQuery[] = "SELECT distinct item FROM npc_vendor";
- results = WorldDatabase.Query(npcQuery);
- if (results)
- {
- do
- {
- Field* fields = results->Fetch();
- npcItems.push_back(fields[0].Get());
-
- } while (results->NextRow());
- }
- else
- {
- if (debug_Out)
- LOG_ERROR("module", "AuctionHouseBot: \"{}\" failed", npcQuery);
- }
-
- char lootQuery[] = "SELECT item FROM creature_loot_template UNION "
- "SELECT item FROM reference_loot_template UNION "
- "SELECT item FROM disenchant_loot_template UNION "
- "SELECT item FROM fishing_loot_template UNION "
- "SELECT item FROM gameobject_loot_template UNION "
- "SELECT item FROM item_loot_template UNION "
- "SELECT item FROM milling_loot_template UNION "
- "SELECT item FROM pickpocketing_loot_template UNION "
- "SELECT item FROM prospecting_loot_template UNION "
- "SELECT item FROM skinning_loot_template";
-
- results = WorldDatabase.Query(lootQuery);
- if (results)
- {
- do
- {
- Field* fields = results->Fetch();
- lootItems.push_back(fields[0].Get());
-
- } while (results->NextRow());
- }
- else
- {
- if (debug_Out)
- LOG_ERROR("module", "AuctionHouseBot: \"{}\" failed", lootQuery);
- }
-
- ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
- for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
- {
- switch (itr->second.Bonding)
- {
- case NO_BIND:
- if (!No_Bind)
- continue;
- break;
- case BIND_WHEN_PICKED_UP:
- if (!Bind_When_Picked_Up)
- continue;
- break;
- case BIND_WHEN_EQUIPED:
- if (!Bind_When_Equipped)
- continue;
- break;
- case BIND_WHEN_USE:
- if (!Bind_When_Use)
- continue;
- break;
- case BIND_QUEST_ITEM:
- if (!Bind_Quest_Item)
- continue;
- break;
- default:
- continue;
- break;
- }
-
- if (SellMethod)
- {
- if (itr->second.BuyPrice == 0)
- continue;
- }
- else
- {
- if (itr->second.SellPrice == 0)
- continue;
- }
-
- if (itr->second.Quality > 6)
- continue;
-
- if ((Vendor_Items == 0) && !(itr->second.Class == ITEM_CLASS_TRADE_GOODS))
- {
- bool isVendorItem = false;
-
- for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorItem); i++)
- {
- if (itr->second.ItemId == npcItems[i])
- isVendorItem = true;
- }
-
- if (isVendorItem)
- continue;
- }
-
- if ((Vendor_TGs == 0) && (itr->second.Class == ITEM_CLASS_TRADE_GOODS))
- {
- bool isVendorTG = false;
-
- for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorTG); i++)
- {
- if (itr->second.ItemId == npcItems[i])
- isVendorTG = true;
- }
-
- if (isVendorTG)
- continue;
- }
-
- if ((Loot_Items == 0) && !(itr->second.Class == ITEM_CLASS_TRADE_GOODS))
- {
- bool isLootItem = false;
-
- for (unsigned int i = 0; (i < lootItems.size()) && (!isLootItem); i++)
- {
- if (itr->second.ItemId == lootItems[i])
- isLootItem = true;
- }
-
- if (isLootItem)
- continue;
- }
-
- if ((Loot_TGs == 0) && (itr->second.Class == ITEM_CLASS_TRADE_GOODS))
- {
- bool isLootTG = false;
-
- for (unsigned int i = 0; (i < lootItems.size()) && (!isLootTG); i++)
- {
- if (itr->second.ItemId == lootItems[i])
- isLootTG = true;
- }
-
- if (isLootTG)
- continue;
- }
-
- if ((Other_Items == 0) && !(itr->second.Class == ITEM_CLASS_TRADE_GOODS))
- {
- bool isVendorItem = false;
- bool isLootItem = false;
-
- for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorItem); i++)
- {
- if (itr->second.ItemId == npcItems[i])
- isVendorItem = true;
- }
- for (unsigned int i = 0; (i < lootItems.size()) && (!isLootItem); i++)
- {
- if (itr->second.ItemId == lootItems[i])
- isLootItem = true;
- }
- if ((!isLootItem) && (!isVendorItem))
- continue;
- }
-
- if ((Other_TGs == 0) && (itr->second.Class == ITEM_CLASS_TRADE_GOODS))
- {
- bool isVendorTG = false;
- bool isLootTG = false;
-
- for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorTG); i++)
- {
- if (itr->second.ItemId == npcItems[i])
- isVendorTG = true;
- }
- for (unsigned int i = 0; (i < lootItems.size()) && (!isLootTG); i++)
- {
- if (itr->second.ItemId == lootItems[i])
- isLootTG = true;
- }
- if ((!isLootTG) && (!isVendorTG))
- continue;
- }
-
- // Disable items by Id
- if (DisableItemStore.find(itr->second.ItemId) != DisableItemStore.end())
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (PTR/Beta/Unused Item)", itr->second.ItemId);
- continue;
- }
-
- // Disable permanent enchants items
- if ((DisablePermEnchant) && (itr->second.Class == ITEM_CLASS_PERMANENT))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Permanent Enchant Item)", itr->second.ItemId);
- continue;
- }
-
- // Disable conjured items
- if ((DisableConjured) && (itr->second.IsConjuredConsumable()))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Conjured Consumable)", itr->second.ItemId);
- continue;
- }
-
- // Disable gems
- if ((DisableGems) && (itr->second.Class == ITEM_CLASS_GEM))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Gem)", itr->second.ItemId);
- continue;
- }
-
- // Disable money
- if ((DisableMoney) && (itr->second.Class == ITEM_CLASS_MONEY))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Money)", itr->second.ItemId);
- continue;
- }
-
- // Disable moneyloot
- if ((DisableMoneyLoot) && (itr->second.MinMoneyLoot > 0))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (MoneyLoot)", itr->second.ItemId);
- continue;
- }
-
- // Disable lootable items
- if ((DisableLootable) && (itr->second.Flags & 4))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Lootable Item)", itr->second.ItemId);
- continue;
- }
-
- // Disable Keys
- if ((DisableKeys) && (itr->second.Class == ITEM_CLASS_KEY))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Quest Item)", itr->second.ItemId);
- continue;
- }
-
- // Disable items with duration
- if ((DisableDuration) && (itr->second.Duration > 0))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Has a Duration)", itr->second.ItemId);
- continue;
- }
-
- // Disable items which are BOP or Quest Items and have a required level lower than the item level
- if ((DisableBOP_Or_Quest_NoReqLevel) && ((itr->second.Bonding == BIND_WHEN_PICKED_UP || itr->second.Bonding == BIND_QUEST_ITEM) && (itr->second.RequiredLevel < itr->second.ItemLevel)))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (BOP or BQI and Required Level is less than Item Level)", itr->second.ItemId);
- continue;
- }
-
- // Disable items specifically for Warrior
- if ((DisableWarriorItems) && (itr->second.AllowableClass == 1))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Warrior Item)", itr->second.ItemId);
- continue;
- }
-
- // Disable items specifically for Paladin
- if ((DisablePaladinItems) && (itr->second.AllowableClass == 2))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Paladin Item)", itr->second.ItemId);
- continue;
- }
-
- // Disable items specifically for Hunter
- if ((DisableHunterItems) && (itr->second.AllowableClass == 4))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Hunter Item)", itr->second.ItemId);
- continue;
- }
-
- // Disable items specifically for Rogue
- if ((DisableRogueItems) && (itr->second.AllowableClass == 8))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Rogue Item)", itr->second.ItemId);
- continue;
- }
-
- // Disable items specifically for Priest
- if ((DisablePriestItems) && (itr->second.AllowableClass == 16))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Priest Item)", itr->second.ItemId);
- continue;
- }
-
- // Disable items specifically for DK
- if ((DisableDKItems) && (itr->second.AllowableClass == 32))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (DK Item)", itr->second.ItemId);
- continue;
- }
-
- // Disable items specifically for Shaman
- if ((DisableShamanItems) && (itr->second.AllowableClass == 64))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Shaman Item)", itr->second.ItemId);
- continue;
- }
-
- // Disable items specifically for Mage
- if ((DisableMageItems) && (itr->second.AllowableClass == 128))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Mage Item)", itr->second.ItemId);
- continue;
- }
-
- // Disable items specifically for Warlock
- if ((DisableWarlockItems) && (itr->second.AllowableClass == 256))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Warlock Item)", itr->second.ItemId);
- continue;
- }
-
- // Disable items specifically for Unused Class
- if ((DisableUnusedClassItems) && (itr->second.AllowableClass == 512))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Unused Item)", itr->second.ItemId);
- continue;
- }
-
- // Disable items specifically for Druid
- if ((DisableDruidItems) && (itr->second.AllowableClass == 1024))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Druid Item)", itr->second.ItemId);
- continue;
- }
-
- // Disable Items below level X
- if ((DisableItemsBelowLevel) && (itr->second.Class != ITEM_CLASS_TRADE_GOODS) && (itr->second.ItemLevel < DisableItemsBelowLevel))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Item Level = {})", itr->second.ItemId, itr->second.ItemLevel);
- continue;
- }
-
- // Disable Items above level X
- if ((DisableItemsAboveLevel) && (itr->second.Class != ITEM_CLASS_TRADE_GOODS) && (itr->second.ItemLevel > DisableItemsAboveLevel))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Item Level = {})", itr->second.ItemId, itr->second.ItemLevel);
- continue;
- }
-
- // Disable Trade Goods below level X
- if ((DisableTGsBelowLevel) && (itr->second.Class == ITEM_CLASS_TRADE_GOODS) && (itr->second.ItemLevel < DisableTGsBelowLevel))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Trade Good {} disabled (Trade Good Level = {})", itr->second.ItemId, itr->second.ItemLevel);
- continue;
- }
-
- // Disable Trade Goods above level X
- if ((DisableTGsAboveLevel) && (itr->second.Class == ITEM_CLASS_TRADE_GOODS) && (itr->second.ItemLevel > DisableTGsAboveLevel))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Trade Good {} disabled (Trade Good Level = {})", itr->second.ItemId, itr->second.ItemLevel);
- continue;
- }
-
- // Disable Items below GUID X
- if ((DisableItemsBelowGUID) && (itr->second.Class != ITEM_CLASS_TRADE_GOODS) && (itr->second.ItemId < DisableItemsBelowGUID))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Item Level = {})", itr->second.ItemId, itr->second.ItemLevel);
- continue;
- }
-
- // Disable Items above GUID X
- if ((DisableItemsAboveGUID) && (itr->second.Class != ITEM_CLASS_TRADE_GOODS) && (itr->second.ItemId > DisableItemsAboveGUID))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Item Level = {})", itr->second.ItemId, itr->second.ItemLevel);
- continue;
- }
-
- // Disable Trade Goods below GUID X
- if ((DisableTGsBelowGUID) && (itr->second.Class == ITEM_CLASS_TRADE_GOODS) && (itr->second.ItemId < DisableTGsBelowGUID))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Trade Good Level = {})", itr->second.ItemId, itr->second.ItemLevel);
- continue;
- }
-
- // Disable Trade Goods above GUID X
- if ((DisableTGsAboveGUID) && (itr->second.Class == ITEM_CLASS_TRADE_GOODS) && (itr->second.ItemId > DisableTGsAboveGUID))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Trade Good Level = {})", itr->second.ItemId, itr->second.ItemLevel);
- continue;
- }
-
- // Disable Items for level lower than X
- if ((DisableItemsBelowReqLevel) && (itr->second.RequiredLevel < DisableItemsBelowReqLevel))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (RequiredLevel = {})", itr->second.ItemId, itr->second.RequiredLevel);
- continue;
- }
-
- // Disable Items for level higher than X
- if ((DisableItemsAboveReqLevel) && (itr->second.RequiredLevel > DisableItemsAboveReqLevel))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (RequiredLevel = {})", itr->second.ItemId, itr->second.RequiredLevel);
- continue;
- }
-
- // Disable Trade Goods for level lower than X
- if ((DisableTGsBelowReqLevel) && (itr->second.RequiredLevel < DisableTGsBelowReqLevel))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Trade Good {} disabled (RequiredLevel = {})", itr->second.ItemId, itr->second.RequiredLevel);
- continue;
- }
-
- // Disable Trade Goods for level higher than X
- if ((DisableTGsAboveReqLevel) && (itr->second.RequiredLevel > DisableTGsAboveReqLevel))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Trade Good {} disabled (RequiredLevel = {})", itr->second.ItemId, itr->second.RequiredLevel);
- continue;
- }
-
- // Disable Items that require skill lower than X
- if ((DisableItemsBelowReqSkillRank) && (itr->second.RequiredSkillRank < DisableItemsBelowReqSkillRank))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (RequiredSkillRank = {})", itr->second.ItemId, itr->second.RequiredSkillRank);
- continue;
- }
-
- // Disable Items that require skill higher than X
- if ((DisableItemsAboveReqSkillRank) && (itr->second.RequiredSkillRank > DisableItemsAboveReqSkillRank))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (RequiredSkillRank = {})", itr->second.ItemId, itr->second.RequiredSkillRank);
- continue;
- }
-
- // Disable Trade Goods that require skill lower than X
- if ((DisableTGsBelowReqSkillRank) && (itr->second.RequiredSkillRank < DisableTGsBelowReqSkillRank))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (RequiredSkillRank = {})", itr->second.ItemId, itr->second.RequiredSkillRank);
- continue;
- }
-
- // Disable Trade Goods that require skill higher than X
- if ((DisableTGsAboveReqSkillRank) && (itr->second.RequiredSkillRank > DisableTGsAboveReqSkillRank))
- {
- if (debug_Out_Filters)
- LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (RequiredSkillRank = {})", itr->second.ItemId, itr->second.RequiredSkillRank);
- continue;
- }
-
- switch (itr->second.Quality)
- {
- case AHB_GREY:
- if (itr->second.Class == ITEM_CLASS_TRADE_GOODS)
- greyTradeGoodsBin.push_back(itr->second.ItemId);
- else
- greyItemsBin.push_back(itr->second.ItemId);
- break;
-
- case AHB_WHITE:
- if (itr->second.Class == ITEM_CLASS_TRADE_GOODS)
- whiteTradeGoodsBin.push_back(itr->second.ItemId);
- else
- whiteItemsBin.push_back(itr->second.ItemId);
- break;
-
- case AHB_GREEN:
- if (itr->second.Class == ITEM_CLASS_TRADE_GOODS)
- greenTradeGoodsBin.push_back(itr->second.ItemId);
- else
- greenItemsBin.push_back(itr->second.ItemId);
- break;
-
- case AHB_BLUE:
- if (itr->second.Class == ITEM_CLASS_TRADE_GOODS)
- blueTradeGoodsBin.push_back(itr->second.ItemId);
- else
- blueItemsBin.push_back(itr->second.ItemId);
- break;
-
- case AHB_PURPLE:
- if (itr->second.Class == ITEM_CLASS_TRADE_GOODS)
- purpleTradeGoodsBin.push_back(itr->second.ItemId);
- else
- purpleItemsBin.push_back(itr->second.ItemId);
- break;
-
- case AHB_ORANGE:
- if (itr->second.Class == ITEM_CLASS_TRADE_GOODS)
- orangeTradeGoodsBin.push_back(itr->second.ItemId);
- else
- orangeItemsBin.push_back(itr->second.ItemId);
- break;
-
- case AHB_YELLOW:
- if (itr->second.Class == ITEM_CLASS_TRADE_GOODS)
- yellowTradeGoodsBin.push_back(itr->second.ItemId);
- else
- yellowItemsBin.push_back(itr->second.ItemId);
- break;
- }
- }
-
- if ((greyTradeGoodsBin.size() == 0) &&
- (whiteTradeGoodsBin.size() == 0) &&
- (greenTradeGoodsBin.size() == 0) &&
- (blueTradeGoodsBin.size() == 0) &&
- (purpleTradeGoodsBin.size() == 0) &&
- (orangeTradeGoodsBin.size() == 0) &&
- (yellowTradeGoodsBin.size() == 0) &&
- (greyItemsBin.size() == 0) &&
- (whiteItemsBin.size() == 0) &&
- (greenItemsBin.size() == 0) &&
- (blueItemsBin.size() == 0) &&
- (purpleItemsBin.size() == 0) &&
- (orangeItemsBin.size() == 0) &&
- (yellowItemsBin.size() == 0))
- {
- LOG_ERROR("module", "AuctionHouseBot: No items");
- AHBSeller = 0;
+ LOG_ERROR("module", "AuctionHouseBot: The account/GUID-information set for your AHBot is incorrect (account: {} guid: {})", AHBplayerAccount, AHBplayerGUID);
+ return;
}
-
- LOG_INFO("module", "AuctionHouseBot:");
- LOG_INFO("module", "{} disabled items", uint32(DisableItemStore.size()));
- LOG_INFO("module", "loaded {} grey trade goods", uint32(greyTradeGoodsBin.size()));
- LOG_INFO("module", "loaded {} white trade goods", uint32(whiteTradeGoodsBin.size()));
- LOG_INFO("module", "loaded {} green trade goods", uint32(greenTradeGoodsBin.size()));
- LOG_INFO("module", "loaded {} blue trade goods", uint32(blueTradeGoodsBin.size()));
- LOG_INFO("module", "loaded {} purple trade goods", uint32(purpleTradeGoodsBin.size()));
- LOG_INFO("module", "loaded {} orange trade goods", uint32(orangeTradeGoodsBin.size()));
- LOG_INFO("module", "loaded {} yellow trade goods", uint32(yellowTradeGoodsBin.size()));
- LOG_INFO("module", "loaded {} grey items", uint32(greyItemsBin.size()));
- LOG_INFO("module", "loaded {} white items", uint32(whiteItemsBin.size()));
- LOG_INFO("module", "loaded {} green items", uint32(greenItemsBin.size()));
- LOG_INFO("module", "loaded {} blue items", uint32(blueItemsBin.size()));
- LOG_INFO("module", "loaded {} purple items", uint32(purpleItemsBin.size()));
- LOG_INFO("module", "loaded {} orange items", uint32(orangeItemsBin.size()));
- LOG_INFO("module", "loaded {} yellow items", uint32(yellowItemsBin.size()));
}
- LOG_INFO("module", "AuctionHouseBot and AuctionHouseBuyer have been loaded.");
+ LOG_INFO("module", "AuctionHouseBot has been loaded.");
}
void AuctionHouseBot::InitializeConfiguration()
{
- debug_Out = sConfigMgr->GetOption("AuctionHouseBot.DEBUG", false);
- debug_Out_Filters = sConfigMgr->GetOption("AuctionHouseBot.DEBUG_FILTERS", false);
-
AHBSeller = sConfigMgr->GetOption("AuctionHouseBot.EnableSeller", false);
AHBBuyer = sConfigMgr->GetOption("AuctionHouseBot.EnableBuyer", false);
SellMethod = sConfigMgr->GetOption("AuctionHouseBot.UseBuyPriceForSeller", false);
@@ -1368,107 +539,46 @@ void AuctionHouseBot::InitializeConfiguration()
AHBplayerAccount = sConfigMgr->GetOption("AuctionHouseBot.Account", 0);
AHBplayerGUID = sConfigMgr->GetOption("AuctionHouseBot.GUID", 0);
ItemsPerCycle = sConfigMgr->GetOption("AuctionHouseBot.ItemsPerCycle", 200);
-
- //Begin Filters
-
- Vendor_Items = sConfigMgr->GetOption("AuctionHouseBot.VendorItems", false);
- Loot_Items = sConfigMgr->GetOption("AuctionHouseBot.LootItems", true);
- Other_Items = sConfigMgr->GetOption("AuctionHouseBot.OtherItems", false);
- Vendor_TGs = sConfigMgr->GetOption("AuctionHouseBot.VendorTradeGoods", false);
- Loot_TGs = sConfigMgr->GetOption("AuctionHouseBot.LootTradeGoods", true);
- Other_TGs = sConfigMgr->GetOption("AuctionHouseBot.OtherTradeGoods", false);
-
- No_Bind = sConfigMgr->GetOption("AuctionHouseBot.No_Bind", true);
- Bind_When_Picked_Up = sConfigMgr->GetOption("AuctionHouseBot.Bind_When_Picked_Up", false);
- Bind_When_Equipped = sConfigMgr->GetOption("AuctionHouseBot.Bind_When_Equipped", true);
- Bind_When_Use = sConfigMgr->GetOption("AuctionHouseBot.Bind_When_Use", true);
- Bind_Quest_Item = sConfigMgr->GetOption("AuctionHouseBot.Bind_Quest_Item", false);
-
- DisablePermEnchant = sConfigMgr->GetOption("AuctionHouseBot.DisablePermEnchant", false);
- DisableConjured = sConfigMgr->GetOption("AuctionHouseBot.DisableConjured", false);
- DisableGems = sConfigMgr->GetOption("AuctionHouseBot.DisableGems", false);
- DisableMoney = sConfigMgr->GetOption("AuctionHouseBot.DisableMoney", false);
- DisableMoneyLoot = sConfigMgr->GetOption("AuctionHouseBot.DisableMoneyLoot", false);
- DisableLootable = sConfigMgr->GetOption("AuctionHouseBot.DisableLootable", false);
- DisableKeys = sConfigMgr->GetOption("AuctionHouseBot.DisableKeys", false);
- DisableDuration = sConfigMgr->GetOption("AuctionHouseBot.DisableDuration", false);
- DisableBOP_Or_Quest_NoReqLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableBOP_Or_Quest_NoReqLevel", false);
-
- DisableWarriorItems = sConfigMgr->GetOption("AuctionHouseBot.DisableWarriorItems", false);
- DisablePaladinItems = sConfigMgr->GetOption("AuctionHouseBot.DisablePaladinItems", false);
- DisableHunterItems = sConfigMgr->GetOption("AuctionHouseBot.DisableHunterItems", false);
- DisableRogueItems = sConfigMgr->GetOption("AuctionHouseBot.DisableRogueItems", false);
- DisablePriestItems = sConfigMgr->GetOption("AuctionHouseBot.DisablePriestItems", false);
- DisableDKItems = sConfigMgr->GetOption("AuctionHouseBot.DisableDKItems", false);
- DisableShamanItems = sConfigMgr->GetOption("AuctionHouseBot.DisableShamanItems", false);
- DisableMageItems = sConfigMgr->GetOption("AuctionHouseBot.DisableMageItems", false);
- DisableWarlockItems = sConfigMgr->GetOption("AuctionHouseBot.DisableWarlockItems", false);
- DisableUnusedClassItems = sConfigMgr->GetOption("AuctionHouseBot.DisableUnusedClassItems", false);
- DisableDruidItems = sConfigMgr->GetOption("AuctionHouseBot.DisableDruidItems", false);
-
- DisableItemsBelowLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableItemsBelowLevel", 0);
- DisableItemsAboveLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableItemsAboveLevel", 0);
- DisableTGsBelowLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableTGsBelowLevel", 0);
- DisableTGsAboveLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableTGsAboveLevel", 0);
- DisableItemsBelowGUID = sConfigMgr->GetOption("AuctionHouseBot.DisableItemsBelowGUID", 0);
- DisableItemsAboveGUID = sConfigMgr->GetOption("AuctionHouseBot.DisableItemsAboveGUID", 0);
- DisableTGsBelowGUID = sConfigMgr->GetOption("AuctionHouseBot.DisableTGsBelowGUID", 0);
- DisableTGsAboveGUID = sConfigMgr->GetOption("AuctionHouseBot.DisableTGsAboveGUID", 0);
- DisableItemsBelowReqLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableItemsBelowReqLevel", 0);
- DisableItemsAboveReqLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableItemsAboveReqLevel", 0);
- DisableTGsBelowReqLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableTGsBelowReqLevel", 0);
- DisableTGsAboveReqLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableTGsAboveReqLevel", 0);
- DisableItemsBelowReqSkillRank = sConfigMgr->GetOption("AuctionHouseBot.DisableItemsBelowReqSkillRank", 0);
- DisableItemsAboveReqSkillRank = sConfigMgr->GetOption("AuctionHouseBot.DisableItemsAboveReqSkillRank", 0);
- DisableTGsBelowReqSkillRank = sConfigMgr->GetOption("AuctionHouseBot.DisableTGsBelowReqSkillRank", 0);
- DisableTGsAboveReqSkillRank = sConfigMgr->GetOption("AuctionHouseBot.DisableTGsAboveReqSkillRank", 0);
}
void AuctionHouseBot::IncrementItemCounts(AuctionEntry* ah)
{
- // from auctionhousehandler.cpp, creates auction pointer & player pointer
-
// get exact item information
Item *pItem = sAuctionMgr->GetAItem(ah->item_guid);
if (!pItem)
{
- if (debug_Out)
- LOG_ERROR("module", "AHBot: Item {} doesn't exist, perhaps bought already?", ah->item_guid.ToString());
+ LOG_ERROR("module.ahbot", "AHBot: Item {} doesn't exist, perhaps bought already?", ah->item_guid.ToString());
return;
}
// get item prototype
ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(ah->item_template);
- AHBConfig *config;
+ AHBConfig* config = nullptr;
AuctionHouseEntry const* ahEntry = sAuctionHouseStore.LookupEntry(ah->GetHouseId());
if (!ahEntry)
{
- if (debug_Out)
- LOG_ERROR("module", "AHBot: {} returned as House Faction. Neutral", ah->GetHouseId());
+ LOG_DEBUG("module.ahbot", "AHBot: {} returned as House Faction. Neutral", ah->GetHouseId());
config = &NeutralConfig;
}
else if (ahEntry->houseId == AUCTIONHOUSE_ALLIANCE)
{
- if (debug_Out)
- LOG_ERROR("module", "AHBot: {} returned as House Faction. Alliance", ah->GetHouseId());
+ LOG_DEBUG("module.ahbot", "AHBot: {} returned as House Faction. Alliance", ah->GetHouseId());
config = &AllianceConfig;
}
else if (ahEntry->houseId == AUCTIONHOUSE_HORDE)
{
- if (debug_Out)
- LOG_ERROR("module", "AHBot: {} returned as House Faction. Horde", ah->GetHouseId());
+ LOG_DEBUG("module.ahbot", "AHBot: {} returned as House Faction. Horde", ah->GetHouseId());
config = &HordeConfig;
}
else
{
- if (debug_Out)
- LOG_ERROR("module", "AHBot: {} returned as House Faction. Neutral", ah->GetHouseId());
+ LOG_DEBUG("module.ahbot", "AHBot: {} returned as House Faction. Neutral", ah->GetHouseId());
config = &NeutralConfig;
}
- config->IncItemCounts(prototype->Class, prototype->Quality);
+ config->IncreaseItemCounts(prototype->Class, prototype->Quality);
}
void AuctionHouseBot::DecrementItemCounts(AuctionEntry* ah, uint32 itemEntry)
@@ -1476,98 +586,92 @@ void AuctionHouseBot::DecrementItemCounts(AuctionEntry* ah, uint32 itemEntry)
// get item prototype
ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(itemEntry);
- AHBConfig *config;
+ AHBConfig* config = nullptr;
AuctionHouseEntry const* ahEntry = sAuctionHouseStore.LookupEntry(ah->GetHouseId());
if (!ahEntry)
{
- if (debug_Out)
- LOG_ERROR("module", "AHBot: {} returned as House Faction. Neutral", ah->GetHouseId());
+ LOG_DEBUG("module.ahbot", "AHBot: {} returned as House Faction. Neutral", ah->GetHouseId());
config = &NeutralConfig;
}
else if (ahEntry->houseId == AUCTIONHOUSE_ALLIANCE)
{
- if (debug_Out)
- LOG_ERROR("module", "AHBot: {} returned as House Faction. Alliance", ah->GetHouseId());
+ LOG_DEBUG("module.ahbot", "AHBot: {} returned as House Faction. Alliance", ah->GetHouseId());
config = &AllianceConfig;
}
else if (ahEntry->houseId == AUCTIONHOUSE_HORDE)
{
- if (debug_Out)
- LOG_ERROR("module", "AHBot: {} returned as House Faction. Horde", ah->GetHouseId());
+ LOG_DEBUG("module.ahbot", "AHBot: {} returned as House Faction. Horde", ah->GetHouseId());
config = &HordeConfig;
}
else
{
- if (debug_Out)
- LOG_ERROR("module", "AHBot: {} returned as House Faction. Neutral", ah->GetHouseId());
+ LOG_DEBUG("module.ahbot", "AHBot: {} returned as House Faction. Neutral", ah->GetHouseId());
config = &NeutralConfig;
}
- config->DecItemCounts(prototype->Class, prototype->Quality);
+ config->DecreaseItemCounts(prototype->Class, prototype->Quality);
}
void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char* args)
{
- AHBConfig *config = NULL;
+ AHBConfig* config = nullptr;
switch (ahMapID)
{
- case 2:
+ case AUCTIONHOUSE_ALLIANCE:
config = &AllianceConfig;
break;
- case 6:
+ case AUCTIONHOUSE_HORDE:
config = &HordeConfig;
break;
- case 7:
+ case AUCTIONHOUSE_NEUTRAL:
config = &NeutralConfig;
break;
}
+
std::string color;
switch (col)
{
- case AHB_GREY:
+ case ITEM_QUALITY_POOR:
color = "grey";
break;
- case AHB_WHITE:
+ case ITEM_QUALITY_NORMAL:
color = "white";
break;
- case AHB_GREEN:
+ case ITEM_QUALITY_UNCOMMON:
color = "green";
break;
- case AHB_BLUE:
+ case ITEM_QUALITY_RARE:
color = "blue";
break;
- case AHB_PURPLE:
+ case ITEM_QUALITY_EPIC:
color = "purple";
break;
- case AHB_ORANGE:
+ case ITEM_QUALITY_LEGENDARY:
color = "orange";
break;
- case AHB_YELLOW:
+ case ITEM_QUALITY_ARTIFACT:
color = "yellow";
break;
default:
break;
}
+
switch (command)
{
case 0: //ahexpire
{
- AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID());
-
- AuctionHouseObject::AuctionEntryMap::iterator itr;
- itr = auctionHouse->GetAuctionsBegin();
+ AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAuctionHouseFactionID());
- while (itr != auctionHouse->GetAuctionsEnd())
+ for (auto const& [__, auction] : auctionHouse->GetAuctions())
{
- if (itr->second->owner.GetCounter() == AHBplayerGUID)
+ if (auction->owner.GetCounter() == AHBplayerGUID)
{
- itr->second->expire_time = GameTime::GetGameTime().count();
- uint32 id = itr->second->Id;
- uint32 expire_time = itr->second->expire_time;
+ auction->expire_time = GameTime::GetGameTime().count();
+ uint32 id = auction->Id;
+ uint32 expire_time = auction->expire_time;
CharacterDatabase.Execute("UPDATE auctionhouse SET time = '{}' WHERE id = '{}'", expire_time, id);
}
- ++itr;
}
}
break;
@@ -1623,6 +727,11 @@ void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char*
uint32 orangei = (uint32) strtoul(param13, NULL, 0);
uint32 yellowi = (uint32) strtoul(param14, NULL, 0);
+ std::array percentages =
+ {
+ greytg, whitetg, greentg, bluetg, purpletg, orangetg, yellowtg, greyi, whitei, greeni, bluei, purplei, orangei, yellowi
+ };
+
auto trans = WorldDatabase.BeginTransaction();
trans->Append("UPDATE mod_auctionhousebot SET percentgreytradegoods = '{}' WHERE auctionhouse = '{}'", greytg, ahMapID);
trans->Append("UPDATE mod_auctionhousebot SET percentwhitetradegoods = '{}' WHERE auctionhouse = '{}'", whitetg, ahMapID);
@@ -1639,7 +748,7 @@ void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char*
trans->Append("UPDATE mod_auctionhousebot SET percentorangeitems = '{}' WHERE auctionhouse = '{}'", orangei, ahMapID);
trans->Append("UPDATE mod_auctionhousebot SET percentyellowitems = '{}' WHERE auctionhouse = '{}'", yellowi, ahMapID);
WorldDatabase.CommitTransaction(trans);
- config->SetPercentages(greytg, whitetg, greentg, bluetg, purpletg, orangetg, yellowtg, greyi, whitei, greeni, bluei, purplei, orangei, yellowi);
+ config->SetPercentages(percentages);
}
break;
case 6: //min prices
@@ -1695,7 +804,7 @@ void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char*
char * param1 = strtok(args, " ");
uint32 bidInterval = (uint32) strtoul(param1, NULL, 0);
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET buyerbiddinginterval = '{}' WHERE auctionhouse = '{}'", bidInterval, ahMapID);
- config->SetBiddingInterval(bidInterval);
+ config->SetBiddingInterval(Minutes(bidInterval));
}
break;
case 13: //buyer bids per interval
@@ -1711,232 +820,270 @@ void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char*
}
}
-void AuctionHouseBot::LoadValues(AHBConfig *config)
+void AuctionHouseBot::LoadValues(AHBConfig* config)
{
- if (debug_Out)
- LOG_ERROR("module", "Start Settings for {} Auctionhouses:", WorldDatabase.Query("SELECT name FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
+ LOG_DEBUG("module.ahbot", "Start Settings for Auctionhouses");
if (AHBSeller)
{
- //load min and max items
- config->SetMinItems(WorldDatabase.Query("SELECT minitems FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxItems(WorldDatabase.Query("SELECT maxitems FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- //load percentages
- uint32 greytg = WorldDatabase.Query("SELECT percentgreytradegoods FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get();
- uint32 whitetg = WorldDatabase.Query("SELECT percentwhitetradegoods FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get();
- uint32 greentg = WorldDatabase.Query("SELECT percentgreentradegoods FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get();
- uint32 bluetg = WorldDatabase.Query("SELECT percentbluetradegoods FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get();
- uint32 purpletg = WorldDatabase.Query("SELECT percentpurpletradegoods FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get();
- uint32 orangetg = WorldDatabase.Query("SELECT percentorangetradegoods FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get();
- uint32 yellowtg = WorldDatabase.Query("SELECT percentyellowtradegoods FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get();
- uint32 greyi = WorldDatabase.Query("SELECT percentgreyitems FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get();
- uint32 whitei = WorldDatabase.Query("SELECT percentwhiteitems FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get();
- uint32 greeni = WorldDatabase.Query("SELECT percentgreenitems FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get();
- uint32 bluei = WorldDatabase.Query("SELECT percentblueitems FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get();
- uint32 purplei = WorldDatabase.Query("SELECT percentpurpleitems FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get();
- uint32 orangei = WorldDatabase.Query("SELECT percentorangeitems FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get();
- uint32 yellowi = WorldDatabase.Query("SELECT percentyellowitems FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get();
- config->SetPercentages(greytg, whitetg, greentg, bluetg, purpletg, orangetg, yellowtg, greyi, whitei, greeni, bluei, purplei, orangei, yellowi);
- //load min and max prices
- config->SetMinPrice(AHB_GREY, WorldDatabase.Query("SELECT minpricegrey FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxPrice(AHB_GREY, WorldDatabase.Query("SELECT maxpricegrey FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMinPrice(AHB_WHITE, WorldDatabase.Query("SELECT minpricewhite FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxPrice(AHB_WHITE, WorldDatabase.Query("SELECT maxpricewhite FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMinPrice(AHB_GREEN, WorldDatabase.Query("SELECT minpricegreen FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxPrice(AHB_GREEN, WorldDatabase.Query("SELECT maxpricegreen FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMinPrice(AHB_BLUE, WorldDatabase.Query("SELECT minpriceblue FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxPrice(AHB_BLUE, WorldDatabase.Query("SELECT maxpriceblue FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMinPrice(AHB_PURPLE, WorldDatabase.Query("SELECT minpricepurple FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxPrice(AHB_PURPLE, WorldDatabase.Query("SELECT maxpricepurple FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMinPrice(AHB_ORANGE, WorldDatabase.Query("SELECT minpriceorange FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxPrice(AHB_ORANGE, WorldDatabase.Query("SELECT maxpriceorange FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMinPrice(AHB_YELLOW, WorldDatabase.Query("SELECT minpriceyellow FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxPrice(AHB_YELLOW, WorldDatabase.Query("SELECT maxpriceyellow FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- //load min and max bid prices
- config->SetMinBidPrice(AHB_GREY, WorldDatabase.Query("SELECT minbidpricegrey FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxBidPrice(AHB_GREY, WorldDatabase.Query("SELECT maxbidpricegrey FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMinBidPrice(AHB_WHITE, WorldDatabase.Query("SELECT minbidpricewhite FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxBidPrice(AHB_WHITE, WorldDatabase.Query("SELECT maxbidpricewhite FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMinBidPrice(AHB_GREEN, WorldDatabase.Query("SELECT minbidpricegreen FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxBidPrice(AHB_GREEN, WorldDatabase.Query("SELECT maxbidpricegreen FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMinBidPrice(AHB_BLUE, WorldDatabase.Query("SELECT minbidpriceblue FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxBidPrice(AHB_BLUE, WorldDatabase.Query("SELECT maxbidpriceblue FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMinBidPrice(AHB_PURPLE, WorldDatabase.Query("SELECT minbidpricepurple FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxBidPrice(AHB_PURPLE, WorldDatabase.Query("SELECT maxbidpricepurple FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMinBidPrice(AHB_ORANGE, WorldDatabase.Query("SELECT minbidpriceorange FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxBidPrice(AHB_ORANGE, WorldDatabase.Query("SELECT maxbidpriceorange FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMinBidPrice(AHB_YELLOW, WorldDatabase.Query("SELECT minbidpriceyellow FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxBidPrice(AHB_YELLOW, WorldDatabase.Query("SELECT maxbidpriceyellow FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- //load max stacks
- config->SetMaxStack(AHB_GREY, WorldDatabase.Query("SELECT maxstackgrey FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxStack(AHB_WHITE, WorldDatabase.Query("SELECT maxstackwhite FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxStack(AHB_GREEN, WorldDatabase.Query("SELECT maxstackgreen FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxStack(AHB_BLUE, WorldDatabase.Query("SELECT maxstackblue FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxStack(AHB_PURPLE, WorldDatabase.Query("SELECT maxstackpurple FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxStack(AHB_ORANGE, WorldDatabase.Query("SELECT maxstackorange FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetMaxStack(AHB_YELLOW, WorldDatabase.Query("SELECT maxstackyellow FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- if (debug_Out)
+ std::string selectColumns = "minitems, maxitems,"; // min/max
+ selectColumns.append("percentgreytradegoods, percentwhitetradegoods, percentgreentradegoods, percentbluetradegoods, percentpurpletradegoods, percentorangetradegoods, percentyellowtradegoods,"); // tg items
+ selectColumns.append("percentgreyitems, percentwhiteitems, percentgreenitems, percentblueitems, percentpurpleitems, percentorangeitems, percentyellowitems,"); // default items
+ selectColumns.append("minpricegrey, minpricewhite, minpricegreen, minpriceblue, minpricepurple, minpriceorange, minpriceyellow,"); // min price
+ selectColumns.append("maxpricegrey, maxpricewhite, maxpricegreen, maxpriceblue, maxpricepurple, maxpriceorange, maxpriceyellow,"); // max price
+ selectColumns.append("minbidpricegrey, minbidpricewhite, minbidpricegreen, minbidpriceblue, minbidpricepurple, minbidpriceorange, minbidpriceyellow,"); // min bid prices
+ selectColumns.append("maxbidpricegrey, maxbidpricewhite, maxbidpricegreen, maxbidpriceblue, maxbidpricepurple, maxbidpriceorange, maxbidpriceyellow,"); // max bid prices
+ selectColumns.append("maxstackgrey, maxstackwhite, maxstackgreen, maxstackblue, maxstackpurple, maxstackorange, maxstackyellow,"); // max bid prices
+ selectColumns.append("name"); // auction name
+
+ auto result = WorldDatabase.Query("SELECT {} FROM mod_auctionhousebot WHERE auctionhouse = {}", selectColumns, config->GetAuctionHouseID());
+ if (!result)
{
- LOG_ERROR("module", "minItems = {}", config->GetMinItems());
- LOG_ERROR("module", "maxItems = {}", config->GetMaxItems());
- LOG_ERROR("module", "percentGreyTradeGoods = {}", config->GetPercentages(AHB_GREY_TG));
- LOG_ERROR("module", "percentWhiteTradeGoods = {}", config->GetPercentages(AHB_WHITE_TG));
- LOG_ERROR("module", "percentGreenTradeGoods = {}", config->GetPercentages(AHB_GREEN_TG));
- LOG_ERROR("module", "percentBlueTradeGoods = {}", config->GetPercentages(AHB_BLUE_TG));
- LOG_ERROR("module", "percentPurpleTradeGoods = {}", config->GetPercentages(AHB_PURPLE_TG));
- LOG_ERROR("module", "percentOrangeTradeGoods = {}", config->GetPercentages(AHB_ORANGE_TG));
- LOG_ERROR("module", "percentYellowTradeGoods = {}", config->GetPercentages(AHB_YELLOW_TG));
- LOG_ERROR("module", "percentGreyItems = {}", config->GetPercentages(AHB_GREY_I));
- LOG_ERROR("module", "percentWhiteItems = {}", config->GetPercentages(AHB_WHITE_I));
- LOG_ERROR("module", "percentGreenItems = {}", config->GetPercentages(AHB_GREEN_I));
- LOG_ERROR("module", "percentBlueItems = {}", config->GetPercentages(AHB_BLUE_I));
- LOG_ERROR("module", "percentPurpleItems = {}", config->GetPercentages(AHB_PURPLE_I));
- LOG_ERROR("module", "percentOrangeItems = {}", config->GetPercentages(AHB_ORANGE_I));
- LOG_ERROR("module", "percentYellowItems = {}", config->GetPercentages(AHB_YELLOW_I));
- LOG_ERROR("module", "minPriceGrey = {}", config->GetMinPrice(AHB_GREY));
- LOG_ERROR("module", "maxPriceGrey = {}", config->GetMaxPrice(AHB_GREY));
- LOG_ERROR("module", "minPriceWhite = {}", config->GetMinPrice(AHB_WHITE));
- LOG_ERROR("module", "maxPriceWhite = {}", config->GetMaxPrice(AHB_WHITE));
- LOG_ERROR("module", "minPriceGreen = {}", config->GetMinPrice(AHB_GREEN));
- LOG_ERROR("module", "maxPriceGreen = {}", config->GetMaxPrice(AHB_GREEN));
- LOG_ERROR("module", "minPriceBlue = {}", config->GetMinPrice(AHB_BLUE));
- LOG_ERROR("module", "maxPriceBlue = {}", config->GetMaxPrice(AHB_BLUE));
- LOG_ERROR("module", "minPricePurple = {}", config->GetMinPrice(AHB_PURPLE));
- LOG_ERROR("module", "maxPricePurple = {}", config->GetMaxPrice(AHB_PURPLE));
- LOG_ERROR("module", "minPriceOrange = {}", config->GetMinPrice(AHB_ORANGE));
- LOG_ERROR("module", "maxPriceOrange = {}", config->GetMaxPrice(AHB_ORANGE));
- LOG_ERROR("module", "minPriceYellow = {}", config->GetMinPrice(AHB_YELLOW));
- LOG_ERROR("module", "maxPriceYellow = {}", config->GetMaxPrice(AHB_YELLOW));
- LOG_ERROR("module", "minBidPriceGrey = {}", config->GetMinBidPrice(AHB_GREY));
- LOG_ERROR("module", "maxBidPriceGrey = {}", config->GetMaxBidPrice(AHB_GREY));
- LOG_ERROR("module", "minBidPriceWhite = {}", config->GetMinBidPrice(AHB_WHITE));
- LOG_ERROR("module", "maxBidPriceWhite = {}", config->GetMaxBidPrice(AHB_WHITE));
- LOG_ERROR("module", "minBidPriceGreen = {}", config->GetMinBidPrice(AHB_GREEN));
- LOG_ERROR("module", "maxBidPriceGreen = {}", config->GetMaxBidPrice(AHB_GREEN));
- LOG_ERROR("module", "minBidPriceBlue = {}", config->GetMinBidPrice(AHB_BLUE));
- LOG_ERROR("module", "maxBidPriceBlue = {}", config->GetMinBidPrice(AHB_BLUE));
- LOG_ERROR("module", "minBidPricePurple = {}", config->GetMinBidPrice(AHB_PURPLE));
- LOG_ERROR("module", "maxBidPricePurple = {}", config->GetMaxBidPrice(AHB_PURPLE));
- LOG_ERROR("module", "minBidPriceOrange = {}", config->GetMinBidPrice(AHB_ORANGE));
- LOG_ERROR("module", "maxBidPriceOrange = {}", config->GetMaxBidPrice(AHB_ORANGE));
- LOG_ERROR("module", "minBidPriceYellow = {}", config->GetMinBidPrice(AHB_YELLOW));
- LOG_ERROR("module", "maxBidPriceYellow = {}", config->GetMaxBidPrice(AHB_YELLOW));
- LOG_ERROR("module", "maxStackGrey = {}", config->GetMaxStack(AHB_GREY));
- LOG_ERROR("module", "maxStackWhite = {}", config->GetMaxStack(AHB_WHITE));
- LOG_ERROR("module", "maxStackGreen = {}", config->GetMaxStack(AHB_GREEN));
- LOG_ERROR("module", "maxStackBlue = {}", config->GetMaxStack(AHB_BLUE));
- LOG_ERROR("module", "maxStackPurple = {}", config->GetMaxStack(AHB_PURPLE));
- LOG_ERROR("module", "maxStackOrange = {}", config->GetMaxStack(AHB_ORANGE));
- LOG_ERROR("module", "maxStackYellow = {}", config->GetMaxStack(AHB_YELLOW));
+ LOG_ERROR("module.ahbot", "> Empty or invalid sql query for Auctionhouse: {}", config->GetAuctionHouseID());
+ return;
}
- //AuctionHouseEntry const* ahEntry = sAuctionMgr->GetAuctionHouseEntry(config->GetAHFID());
- AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID());
+ auto const& [minitems, maxitems,
+ percentgreytradegoods, percentwhitetradegoods, percentgreentradegoods, percentbluetradegoods, percentpurpletradegoods, percentorangetradegoods, percentyellowtradegoods,
+ percentgreyitems, percentwhiteitems, percentgreenitems, percentblueitems, percentpurpleitems, percentorangeitems, percentyellowitems,
+ minpricegrey, minpricewhite, minpricegreen, minpriceblue, minpricepurple, minpriceorange, minpriceyellow,
+ maxpricegrey, maxpricewhite, maxpricegreen, maxpriceblue, maxpricepurple, maxpriceorange, maxpriceyellow,
+ minbidpricegrey, minbidpricewhite, minbidpricegreen, minbidpriceblue, minbidpricepurple, minbidpriceorange, minbidpriceyellow,
+ maxbidpricegrey, maxbidpricewhite, maxbidpricegreen, maxbidpriceblue, maxbidpricepurple, maxbidpriceorange, maxbidpriceyellow,
+ maxstackgrey, maxstackwhite, maxstackgreen, maxstackblue, maxstackpurple, maxstackorange, maxstackyellow,
+ auctionName]
+ = result->FetchTuple();
+
+ // Load min and max items
+ config->SetMinItems(minitems);
+ config->SetMaxItems(maxitems);
+
+ std::array percetages = { percentgreytradegoods, percentwhitetradegoods, percentgreentradegoods, percentbluetradegoods, percentpurpletradegoods, percentorangetradegoods, percentyellowtradegoods,
+ percentgreyitems, percentwhiteitems, percentgreenitems, percentblueitems, percentpurpleitems, percentorangeitems, percentyellowitems };
+
+ config->SetPercentages(percetages);
+
+ // Load min and max prices
+ config->SetMinPrice(ITEM_QUALITY_POOR, minpricegrey);
+ config->SetMaxPrice(ITEM_QUALITY_POOR, maxpricegrey);
+ config->SetMinPrice(ITEM_QUALITY_NORMAL, minpricewhite);
+ config->SetMaxPrice(ITEM_QUALITY_NORMAL, maxpricewhite);
+ config->SetMinPrice(ITEM_QUALITY_UNCOMMON, minpricegreen);
+ config->SetMaxPrice(ITEM_QUALITY_UNCOMMON, maxpricegreen);
+ config->SetMinPrice(ITEM_QUALITY_RARE, minpriceblue);
+ config->SetMaxPrice(ITEM_QUALITY_RARE, maxpriceblue);
+ config->SetMinPrice(ITEM_QUALITY_EPIC, minpricepurple);
+ config->SetMaxPrice(ITEM_QUALITY_EPIC, maxpricepurple);
+ config->SetMinPrice(ITEM_QUALITY_LEGENDARY, minpriceorange);
+ config->SetMaxPrice(ITEM_QUALITY_LEGENDARY, maxpriceorange);
+ config->SetMinPrice(ITEM_QUALITY_ARTIFACT, minpriceyellow);
+ config->SetMaxPrice(ITEM_QUALITY_ARTIFACT, maxpriceyellow);
+
+ // Load min and max bid prices
+ config->SetMinBidPrice(ITEM_QUALITY_POOR, minbidpricegrey);
+ config->SetMaxBidPrice(ITEM_QUALITY_POOR, maxbidpricegrey);
+ config->SetMinBidPrice(ITEM_QUALITY_NORMAL, minbidpricewhite);
+ config->SetMaxBidPrice(ITEM_QUALITY_NORMAL, maxbidpricewhite);
+ config->SetMinBidPrice(ITEM_QUALITY_UNCOMMON, minbidpricegreen);
+ config->SetMaxBidPrice(ITEM_QUALITY_UNCOMMON, maxbidpricegreen);
+ config->SetMinBidPrice(ITEM_QUALITY_RARE, minbidpriceblue);
+ config->SetMaxBidPrice(ITEM_QUALITY_RARE, maxbidpriceblue);
+ config->SetMinBidPrice(ITEM_QUALITY_EPIC, minbidpricepurple);
+ config->SetMaxBidPrice(ITEM_QUALITY_EPIC, maxbidpricepurple);
+ config->SetMinBidPrice(ITEM_QUALITY_LEGENDARY, minbidpriceorange);
+ config->SetMaxBidPrice(ITEM_QUALITY_LEGENDARY, maxbidpriceorange);
+ config->SetMinBidPrice(ITEM_QUALITY_ARTIFACT, minbidpriceyellow);
+ config->SetMaxBidPrice(ITEM_QUALITY_ARTIFACT, maxbidpriceyellow);
+
+ // Load max stacks
+ config->SetMaxStack(ITEM_QUALITY_POOR, maxstackgrey);
+ config->SetMaxStack(ITEM_QUALITY_NORMAL, maxstackwhite);
+ config->SetMaxStack(ITEM_QUALITY_UNCOMMON, maxstackgreen);
+ config->SetMaxStack(ITEM_QUALITY_RARE, maxstackblue);
+ config->SetMaxStack(ITEM_QUALITY_EPIC, maxstackpurple);
+ config->SetMaxStack(ITEM_QUALITY_LEGENDARY, maxstackorange);
+ config->SetMaxStack(ITEM_QUALITY_ARTIFACT, maxstackyellow);
+
+ LOG_DEBUG("module.ahbot", "minItems = {}", config->GetMinItems());
+ LOG_DEBUG("module.ahbot", "maxItems = {}", config->GetMaxItems());
+ LOG_DEBUG("module.ahbot", "percentGreyTradeGoods = {}", config->GetPercentages(ITEM_QUALITY_POOR));
+ LOG_DEBUG("module.ahbot", "percentWhiteTradeGoods = {}", config->GetPercentages(ITEM_QUALITY_NORMAL));
+ LOG_DEBUG("module.ahbot", "percentGreenTradeGoods = {}", config->GetPercentages(ITEM_QUALITY_UNCOMMON));
+ LOG_DEBUG("module.ahbot", "percentBlueTradeGoods = {}", config->GetPercentages(ITEM_QUALITY_RARE));
+ LOG_DEBUG("module.ahbot", "percentPurpleTradeGoods = {}", config->GetPercentages(ITEM_QUALITY_EPIC));
+ LOG_DEBUG("module.ahbot", "percentOrangeTradeGoods = {}", config->GetPercentages(ITEM_QUALITY_LEGENDARY));
+ LOG_DEBUG("module.ahbot", "percentYellowTradeGoods = {}", config->GetPercentages(ITEM_QUALITY_ARTIFACT));
+ LOG_DEBUG("module.ahbot", "percentGreyItems = {}", config->GetPercentages(AHB_ITEM_QUALITY_POOR));
+ LOG_DEBUG("module.ahbot", "percentWhiteItems = {}", config->GetPercentages(AHB_ITEM_QUALITY_NORMAL));
+ LOG_DEBUG("module.ahbot", "percentGreenItems = {}", config->GetPercentages(AHB_ITEM_QUALITY_UNCOMMON));
+ LOG_DEBUG("module.ahbot", "percentBlueItems = {}", config->GetPercentages(AHB_ITEM_QUALITY_RARE));
+ LOG_DEBUG("module.ahbot", "percentPurpleItems = {}", config->GetPercentages(AHB_ITEM_QUALITY_EPIC));
+ LOG_DEBUG("module.ahbot", "percentOrangeItems = {}", config->GetPercentages(AHB_ITEM_QUALITY_LEGENDARY));
+ LOG_DEBUG("module.ahbot", "percentYellowItems = {}", config->GetPercentages(AHB_ITEM_QUALITY_ARTIFACT));
+ LOG_DEBUG("module.ahbot", "minPriceGrey = {}", config->GetMinPrice(ITEM_QUALITY_POOR));
+ LOG_DEBUG("module.ahbot", "maxPriceGrey = {}", config->GetMaxPrice(ITEM_QUALITY_POOR));
+ LOG_DEBUG("module.ahbot", "minPriceWhite = {}", config->GetMinPrice(ITEM_QUALITY_NORMAL));
+ LOG_DEBUG("module.ahbot", "maxPriceWhite = {}", config->GetMaxPrice(ITEM_QUALITY_NORMAL));
+ LOG_DEBUG("module.ahbot", "minPriceGreen = {}", config->GetMinPrice(ITEM_QUALITY_UNCOMMON));
+ LOG_DEBUG("module.ahbot", "maxPriceGreen = {}", config->GetMaxPrice(ITEM_QUALITY_UNCOMMON));
+ LOG_DEBUG("module.ahbot", "minPriceBlue = {}", config->GetMinPrice(ITEM_QUALITY_RARE));
+ LOG_DEBUG("module.ahbot", "maxPriceBlue = {}", config->GetMaxPrice(ITEM_QUALITY_RARE));
+ LOG_DEBUG("module.ahbot", "minPricePurple = {}", config->GetMinPrice(ITEM_QUALITY_EPIC));
+ LOG_DEBUG("module.ahbot", "maxPricePurple = {}", config->GetMaxPrice(ITEM_QUALITY_EPIC));
+ LOG_DEBUG("module.ahbot", "minPriceOrange = {}", config->GetMinPrice(ITEM_QUALITY_LEGENDARY));
+ LOG_DEBUG("module.ahbot", "maxPriceOrange = {}", config->GetMaxPrice(ITEM_QUALITY_LEGENDARY));
+ LOG_DEBUG("module.ahbot", "minPriceYellow = {}", config->GetMinPrice(ITEM_QUALITY_ARTIFACT));
+ LOG_DEBUG("module.ahbot", "maxPriceYellow = {}", config->GetMaxPrice(ITEM_QUALITY_ARTIFACT));
+ LOG_DEBUG("module.ahbot", "minBidPriceGrey = {}", config->GetMinBidPrice(ITEM_QUALITY_POOR));
+ LOG_DEBUG("module.ahbot", "maxBidPriceGrey = {}", config->GetMaxBidPrice(ITEM_QUALITY_POOR));
+ LOG_DEBUG("module.ahbot", "minBidPriceWhite = {}", config->GetMinBidPrice(ITEM_QUALITY_NORMAL));
+ LOG_DEBUG("module.ahbot", "maxBidPriceWhite = {}", config->GetMaxBidPrice(ITEM_QUALITY_NORMAL));
+ LOG_DEBUG("module.ahbot", "minBidPriceGreen = {}", config->GetMinBidPrice(ITEM_QUALITY_UNCOMMON));
+ LOG_DEBUG("module.ahbot", "maxBidPriceGreen = {}", config->GetMaxBidPrice(ITEM_QUALITY_UNCOMMON));
+ LOG_DEBUG("module.ahbot", "minBidPriceBlue = {}", config->GetMinBidPrice(ITEM_QUALITY_RARE));
+ LOG_DEBUG("module.ahbot", "maxBidPriceBlue = {}", config->GetMinBidPrice(ITEM_QUALITY_RARE));
+ LOG_DEBUG("module.ahbot", "minBidPricePurple = {}", config->GetMinBidPrice(ITEM_QUALITY_EPIC));
+ LOG_DEBUG("module.ahbot", "maxBidPricePurple = {}", config->GetMaxBidPrice(ITEM_QUALITY_EPIC));
+ LOG_DEBUG("module.ahbot", "minBidPriceOrange = {}", config->GetMinBidPrice(ITEM_QUALITY_LEGENDARY));
+ LOG_DEBUG("module.ahbot", "maxBidPriceOrange = {}", config->GetMaxBidPrice(ITEM_QUALITY_LEGENDARY));
+ LOG_DEBUG("module.ahbot", "minBidPriceYellow = {}", config->GetMinBidPrice(ITEM_QUALITY_ARTIFACT));
+ LOG_DEBUG("module.ahbot", "maxBidPriceYellow = {}", config->GetMaxBidPrice(ITEM_QUALITY_ARTIFACT));
+ LOG_DEBUG("module.ahbot", "maxStackGrey = {}", config->GetMaxStack(ITEM_QUALITY_POOR));
+ LOG_DEBUG("module.ahbot", "maxStackWhite = {}", config->GetMaxStack(ITEM_QUALITY_NORMAL));
+ LOG_DEBUG("module.ahbot", "maxStackGreen = {}", config->GetMaxStack(ITEM_QUALITY_UNCOMMON));
+ LOG_DEBUG("module.ahbot", "maxStackBlue = {}", config->GetMaxStack(ITEM_QUALITY_RARE));
+ LOG_DEBUG("module.ahbot", "maxStackPurple = {}", config->GetMaxStack(ITEM_QUALITY_EPIC));
+ LOG_DEBUG("module.ahbot", "maxStackOrange = {}", config->GetMaxStack(ITEM_QUALITY_LEGENDARY));
+ LOG_DEBUG("module.ahbot", "maxStackYellow = {}", config->GetMaxStack(ITEM_QUALITY_ARTIFACT));
+
+ AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAuctionHouseFactionID());
config->ResetItemCounts();
uint32 auctions = auctionHouse->Getcount();
if (auctions)
{
- for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin(); itr != auctionHouse->GetAuctionsEnd(); ++itr)
+ for (auto const& [__, auction] : auctionHouse->GetAuctions())
{
- AuctionEntry *Aentry = itr->second;
- Item *item = sAuctionMgr->GetAItem(Aentry->item_guid);
- if (item)
+ Item* item = sAuctionMgr->GetAItem(auction->item_guid);
+ if (!item)
+ continue;
+
+ ItemTemplate const* prototype = item->GetTemplate();
+ if (!prototype)
+ continue;
+
+ switch (prototype->Quality)
{
- ItemTemplate const *prototype = item->GetTemplate();
- if (prototype)
- {
- switch (prototype->Quality)
- {
- case 0:
- if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
- config->IncItemCounts(AHB_GREY_TG);
- else
- config->IncItemCounts(AHB_GREY_I);
- break;
- case 1:
- if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
- config->IncItemCounts(AHB_WHITE_TG);
- else
- config->IncItemCounts(AHB_WHITE_I);
- break;
- case 2:
- if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
- config->IncItemCounts(AHB_GREEN_TG);
- else
- config->IncItemCounts(AHB_GREEN_I);
- break;
- case 3:
- if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
- config->IncItemCounts(AHB_BLUE_TG);
- else
- config->IncItemCounts(AHB_BLUE_I);
- break;
- case 4:
- if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
- config->IncItemCounts(AHB_PURPLE_TG);
- else
- config->IncItemCounts(AHB_PURPLE_I);
- break;
- case 5:
- if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
- config->IncItemCounts(AHB_ORANGE_TG);
- else
- config->IncItemCounts(AHB_ORANGE_I);
- break;
- case 6:
- if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
- config->IncItemCounts(AHB_YELLOW_TG);
- else
- config->IncItemCounts(AHB_YELLOW_I);
- break;
- }
- }
+ case 0:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ config->IncreaseItemCounts(ITEM_QUALITY_POOR);
+ else
+ config->IncreaseItemCounts(AHB_ITEM_QUALITY_POOR);
+ break;
+ case 1:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ config->IncreaseItemCounts(ITEM_QUALITY_NORMAL);
+ else
+ config->IncreaseItemCounts(AHB_ITEM_QUALITY_NORMAL);
+ break;
+ case 2:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ config->IncreaseItemCounts(ITEM_QUALITY_UNCOMMON);
+ else
+ config->IncreaseItemCounts(AHB_ITEM_QUALITY_UNCOMMON);
+ break;
+ case 3:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ config->IncreaseItemCounts(ITEM_QUALITY_RARE);
+ else
+ config->IncreaseItemCounts(AHB_ITEM_QUALITY_RARE);
+ break;
+ case 4:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ config->IncreaseItemCounts(ITEM_QUALITY_EPIC);
+ else
+ config->IncreaseItemCounts(AHB_ITEM_QUALITY_EPIC);
+ break;
+ case 5:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ config->IncreaseItemCounts(ITEM_QUALITY_LEGENDARY);
+ else
+ config->IncreaseItemCounts(AHB_ITEM_QUALITY_LEGENDARY);
+ break;
+ case 6:
+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
+ config->IncreaseItemCounts(ITEM_QUALITY_ARTIFACT);
+ else
+ config->IncreaseItemCounts(AHB_ITEM_QUALITY_ARTIFACT);
+ break;
}
}
}
- if (debug_Out)
- {
- LOG_ERROR("module", "Current Settings for {} Auctionhouses:", WorldDatabase.Query("SELECT name FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- LOG_ERROR("module", "Grey Trade Goods\t{}\tGrey Items\t{}", config->GetItemCounts(AHB_GREY_TG), config->GetItemCounts(AHB_GREY_I));
- LOG_ERROR("module", "White Trade Goods\t{}\tWhite Items\t{}", config->GetItemCounts(AHB_WHITE_TG), config->GetItemCounts(AHB_WHITE_I));
- LOG_ERROR("module", "Green Trade Goods\t{}\tGreen Items\t{}", config->GetItemCounts(AHB_GREEN_TG), config->GetItemCounts(AHB_GREEN_I));
- LOG_ERROR("module", "Blue Trade Goods\t{}\tBlue Items\t{}", config->GetItemCounts(AHB_BLUE_TG), config->GetItemCounts(AHB_BLUE_I));
- LOG_ERROR("module", "Purple Trade Goods\t{}\tPurple Items\t{}", config->GetItemCounts(AHB_PURPLE_TG), config->GetItemCounts(AHB_PURPLE_I));
- LOG_ERROR("module", "Orange Trade Goods\t{}\tOrange Items\t{}", config->GetItemCounts(AHB_ORANGE_TG), config->GetItemCounts(AHB_ORANGE_I));
- LOG_ERROR("module", "Yellow Trade Goods\t{}\tYellow Items\t{}", config->GetItemCounts(AHB_YELLOW_TG), config->GetItemCounts(AHB_YELLOW_I));
- }
+ LOG_DEBUG("module.ahbot", "Current Settings for {} Auctionhouses:", auctionName);
+ LOG_DEBUG("module.ahbot", "Grey Trade Goods\t{}\tGrey Items\t{}", config->GetItemCounts(ITEM_QUALITY_POOR), config->GetItemCounts(AHB_ITEM_QUALITY_POOR));
+ LOG_DEBUG("module.ahbot", "White Trade Goods\t{}\tWhite Items\t{}", config->GetItemCounts(ITEM_QUALITY_NORMAL), config->GetItemCounts(AHB_ITEM_QUALITY_NORMAL));
+ LOG_DEBUG("module.ahbot", "Green Trade Goods\t{}\tGreen Items\t{}", config->GetItemCounts(ITEM_QUALITY_UNCOMMON), config->GetItemCounts(AHB_ITEM_QUALITY_UNCOMMON));
+ LOG_DEBUG("module.ahbot", "Blue Trade Goods\t{}\tBlue Items\t{}", config->GetItemCounts(ITEM_QUALITY_RARE), config->GetItemCounts(AHB_ITEM_QUALITY_RARE));
+ LOG_DEBUG("module.ahbot", "Purple Trade Goods\t{}\tPurple Items\t{}", config->GetItemCounts(ITEM_QUALITY_EPIC), config->GetItemCounts(AHB_ITEM_QUALITY_EPIC));
+ LOG_DEBUG("module.ahbot", "Orange Trade Goods\t{}\tOrange Items\t{}", config->GetItemCounts(ITEM_QUALITY_LEGENDARY), config->GetItemCounts(AHB_ITEM_QUALITY_LEGENDARY));
+ LOG_DEBUG("module.ahbot", "Yellow Trade Goods\t{}\tYellow Items\t{}", config->GetItemCounts(ITEM_QUALITY_ARTIFACT), config->GetItemCounts(AHB_ITEM_QUALITY_ARTIFACT));
}
+
if (AHBBuyer)
{
- //load buyer bid prices
- config->SetBuyerPrice(AHB_GREY, WorldDatabase.Query("SELECT buyerpricegrey FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetBuyerPrice(AHB_WHITE, WorldDatabase.Query("SELECT buyerpricewhite FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetBuyerPrice(AHB_GREEN, WorldDatabase.Query("SELECT buyerpricegreen FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetBuyerPrice(AHB_BLUE, WorldDatabase.Query("SELECT buyerpriceblue FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetBuyerPrice(AHB_PURPLE, WorldDatabase.Query("SELECT buyerpricepurple FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetBuyerPrice(AHB_ORANGE, WorldDatabase.Query("SELECT buyerpriceorange FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- config->SetBuyerPrice(AHB_YELLOW, WorldDatabase.Query("SELECT buyerpriceyellow FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- //load bidding interval
- config->SetBiddingInterval(WorldDatabase.Query("SELECT buyerbiddinginterval FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- //load bids per interval
- config->SetBidsPerInterval(WorldDatabase.Query("SELECT buyerbidsperinterval FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
- if (debug_Out)
+ auto result = WorldDatabase.Query("SELECT buyerpricegrey, buyerpricewhite, buyerpricegreen, buyerpriceblue, buyerpricepurple, buyerpriceorange, buyerpriceyellow, buyerbiddinginterval, buyerbidsperinterval "
+ "FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAuctionHouseID());
+
+ if (!result)
{
- LOG_ERROR("module", "buyerPriceGrey = {}", config->GetBuyerPrice(AHB_GREY));
- LOG_ERROR("module", "buyerPriceWhite = {}", config->GetBuyerPrice(AHB_WHITE));
- LOG_ERROR("module", "buyerPriceGreen = {}", config->GetBuyerPrice(AHB_GREEN));
- LOG_ERROR("module", "buyerPriceBlue = {}", config->GetBuyerPrice(AHB_BLUE));
- LOG_ERROR("module", "buyerPricePurple = {}", config->GetBuyerPrice(AHB_PURPLE));
- LOG_ERROR("module", "buyerPriceOrange = {}", config->GetBuyerPrice(AHB_ORANGE));
- LOG_ERROR("module", "buyerPriceYellow = {}", config->GetBuyerPrice(AHB_YELLOW));
- LOG_ERROR("module", "buyerBiddingInterval = {}", config->GetBiddingInterval());
- LOG_ERROR("module", "buyerBidsPerInterval = {}", config->GetBidsPerInterval());
+ LOG_ERROR("module.ahbot", "> Empty or invalid sql query for Auctionhouse: {}", config->GetAuctionHouseID());
+ return;
}
+
+ auto const& [buyerpricegrey, buyerpricewhite, buyerpricegreen, buyerpriceblue, buyerpricepurple, buyerpriceorange, buyerpriceyellow,
+ buyerbiddinginterval, buyerbidsperinterval]
+ = result->FetchTuple();
+
+ // Load buyer bid prices
+ config->SetBuyerPrice(ITEM_QUALITY_POOR, buyerpricegrey);
+ config->SetBuyerPrice(ITEM_QUALITY_NORMAL, buyerpricewhite);
+ config->SetBuyerPrice(ITEM_QUALITY_UNCOMMON, buyerpricegreen);
+ config->SetBuyerPrice(ITEM_QUALITY_RARE, buyerpriceblue);
+ config->SetBuyerPrice(ITEM_QUALITY_EPIC, buyerpricepurple);
+ config->SetBuyerPrice(ITEM_QUALITY_LEGENDARY, buyerpriceorange);
+ config->SetBuyerPrice(ITEM_QUALITY_ARTIFACT, buyerpriceyellow);
+
+ // Load bidding interval
+ config->SetBiddingInterval(Minutes(buyerbiddinginterval));
+
+ // Load bids per interval
+ config->SetBidsPerInterval(buyerbidsperinterval);
+
+ LOG_DEBUG("module.ahbot", "buyerPriceGrey = {}", config->GetBuyerPrice(ITEM_QUALITY_POOR));
+ LOG_DEBUG("module.ahbot", "buyerPriceWhite = {}", config->GetBuyerPrice(ITEM_QUALITY_NORMAL));
+ LOG_DEBUG("module.ahbot", "buyerPriceGreen = {}", config->GetBuyerPrice(ITEM_QUALITY_UNCOMMON));
+ LOG_DEBUG("module.ahbot", "buyerPriceBlue = {}", config->GetBuyerPrice(ITEM_QUALITY_RARE));
+ LOG_DEBUG("module.ahbot", "buyerPricePurple = {}", config->GetBuyerPrice(ITEM_QUALITY_EPIC));
+ LOG_DEBUG("module.ahbot", "buyerPriceOrange = {}", config->GetBuyerPrice(ITEM_QUALITY_LEGENDARY));
+ LOG_DEBUG("module.ahbot", "buyerPriceYellow = {}", config->GetBuyerPrice(ITEM_QUALITY_ARTIFACT));
+ LOG_DEBUG("module.ahbot", "buyerBiddingInterval = {}", config->GetBiddingInterval().count());
+ LOG_DEBUG("module.ahbot", "buyerBidsPerInterval = {}", config->GetBidsPerInterval());
}
- if (debug_Out)
- LOG_ERROR("module", "End Settings for {} Auctionhouses:", WorldDatabase.Query("SELECT name FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get());
+ LOG_DEBUG("module.ahbot", "End Settings for Auctionhouses");
+}
+
+void AuctionHouseBot::ProcessQueryCallbacks()
+{
+ _queryProcessor.ProcessReadyCallbacks();
}
diff --git a/src/AuctionHouseBot.h b/src/AuctionHouseBot.h
index a091f7d..19c10dd 100644
--- a/src/AuctionHouseBot.h
+++ b/src/AuctionHouseBot.h
@@ -1,1260 +1,81 @@
/*
- * Copyright (C) 2008-2010 Trinity
- * Copyright (C) 2005-2009 MaNGOS
+ * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published by the
+ * Free Software Foundation; either version 3 of the License, or (at your
+ * option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ * more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
*/
#ifndef AUCTION_HOUSE_BOT_H
#define AUCTION_HOUSE_BOT_H
-#include "Common.h"
#include "ObjectGuid.h"
+#include "ItemTemplate.h"
+#include "AuctionHouseBotConfig.h"
+#include "DatabaseEnvFwd.h"
+#include
+#include
struct AuctionEntry;
class Player;
class WorldSession;
-#include "ItemTemplate.h"
-
-#define AHB_GREY 0
-#define AHB_WHITE 1
-#define AHB_GREEN 2
-#define AHB_BLUE 3
-#define AHB_PURPLE 4
-#define AHB_ORANGE 5
-#define AHB_YELLOW 6
-#define AHB_MAX_QUALITY 6
-#define AHB_GREY_TG 0
-#define AHB_WHITE_TG 1
-#define AHB_GREEN_TG 2
-#define AHB_BLUE_TG 3
-#define AHB_PURPLE_TG 4
-#define AHB_ORANGE_TG 5
-#define AHB_YELLOW_TG 6
-#define AHB_GREY_I 7
-#define AHB_WHITE_I 8
-#define AHB_GREEN_I 9
-#define AHB_BLUE_I 10
-#define AHB_PURPLE_I 11
-#define AHB_ORANGE_I 12
-#define AHB_YELLOW_I 13
-
-class AHBConfig
+class AuctionHouseBot
{
-private:
- uint32 AHID;
- uint32 AHFID;
- uint32 minItems;
- uint32 maxItems;
- uint32 percentGreyTradeGoods;
- uint32 percentWhiteTradeGoods;
- uint32 percentGreenTradeGoods;
- uint32 percentBlueTradeGoods;
- uint32 percentPurpleTradeGoods;
- uint32 percentOrangeTradeGoods;
- uint32 percentYellowTradeGoods;
- uint32 percentGreyItems;
- uint32 percentWhiteItems;
- uint32 percentGreenItems;
- uint32 percentBlueItems;
- uint32 percentPurpleItems;
- uint32 percentOrangeItems;
- uint32 percentYellowItems;
- uint32 minPriceGrey;
- uint32 maxPriceGrey;
- uint32 minBidPriceGrey;
- uint32 maxBidPriceGrey;
- uint32 maxStackGrey;
- uint32 minPriceWhite;
- uint32 maxPriceWhite;
- uint32 minBidPriceWhite;
- uint32 maxBidPriceWhite;
- uint32 maxStackWhite;
- uint32 minPriceGreen;
- uint32 maxPriceGreen;
- uint32 minBidPriceGreen;
- uint32 maxBidPriceGreen;
- uint32 maxStackGreen;
- uint32 minPriceBlue;
- uint32 maxPriceBlue;
- uint32 minBidPriceBlue;
- uint32 maxBidPriceBlue;
- uint32 maxStackBlue;
- uint32 minPricePurple;
- uint32 maxPricePurple;
- uint32 minBidPricePurple;
- uint32 maxBidPricePurple;
- uint32 maxStackPurple;
- uint32 minPriceOrange;
- uint32 maxPriceOrange;
- uint32 minBidPriceOrange;
- uint32 maxBidPriceOrange;
- uint32 maxStackOrange;
- uint32 minPriceYellow;
- uint32 maxPriceYellow;
- uint32 minBidPriceYellow;
- uint32 maxBidPriceYellow;
- uint32 maxStackYellow;
-
- uint32 buyerPriceGrey;
- uint32 buyerPriceWhite;
- uint32 buyerPriceGreen;
- uint32 buyerPriceBlue;
- uint32 buyerPricePurple;
- uint32 buyerPriceOrange;
- uint32 buyerPriceYellow;
- uint32 buyerBiddingInterval;
- uint32 buyerBidsPerInterval;
-
- uint32 greytgp;
- uint32 whitetgp;
- uint32 greentgp;
- uint32 bluetgp;
- uint32 purpletgp;
- uint32 orangetgp;
- uint32 yellowtgp;
- uint32 greyip;
- uint32 whiteip;
- uint32 greenip;
- uint32 blueip;
- uint32 purpleip;
- uint32 orangeip;
- uint32 yellowip;
-
- uint32 greyTGoods;
- uint32 whiteTGoods;
- uint32 greenTGoods;
- uint32 blueTGoods;
- uint32 purpleTGoods;
- uint32 orangeTGoods;
- uint32 yellowTGoods;
-
- uint32 greyItems;
- uint32 whiteItems;
- uint32 greenItems;
- uint32 blueItems;
- uint32 purpleItems;
- uint32 orangeItems;
- uint32 yellowItems;
-
public:
- AHBConfig(uint32 ahid)
- {
- AHID = ahid;
- switch(ahid)
- {
- case 2:
- AHFID = 55;
- break;
- case 6:
- AHFID = 29;
- break;
- case 7:
- AHFID = 120;
- break;
- default:
- AHFID = 120;
- break;
- }
- }
- AHBConfig()
- {
- }
- uint32 GetAHID()
- {
- return AHID;
- }
- uint32 GetAHFID()
- {
- return AHFID;
- }
- void SetMinItems(uint32 value)
- {
- minItems = value;
- }
- uint32 GetMinItems()
- {
- if ((minItems == 0) && (maxItems))
- return maxItems;
- else if ((maxItems) && (minItems > maxItems))
- return maxItems;
- else
- return minItems;
- }
- void SetMaxItems(uint32 value)
- {
- maxItems = value;
- // CalculatePercents() needs to be called, but only if
- // SetPercentages() has been called at least once already.
- }
- uint32 GetMaxItems()
- {
- return maxItems;
- }
- void SetPercentages(uint32 greytg, uint32 whitetg, uint32 greentg, uint32 bluetg, uint32 purpletg, uint32 orangetg, uint32 yellowtg, uint32 greyi, uint32 whitei, uint32 greeni, uint32 bluei, uint32 purplei, uint32 orangei, uint32 yellowi)
- {
- uint32 totalPercent = greytg + whitetg + greentg + bluetg + purpletg + orangetg + yellowtg + greyi + whitei + greeni + bluei + purplei + orangei + yellowi;
-
- if (totalPercent == 0)
- {
- maxItems = 0;
- }
- else if (totalPercent != 100)
- {
- greytg = 0;
- whitetg = 27;
- greentg = 12;
- bluetg = 10;
- purpletg = 1;
- orangetg = 0;
- yellowtg = 0;
- greyi = 0;
- whitei = 10;
- greeni = 30;
- bluei = 8;
- purplei = 2;
- orangei = 0;
- yellowi = 0;
- }
- percentGreyTradeGoods = greytg;
- percentWhiteTradeGoods = whitetg;
- percentGreenTradeGoods = greentg;
- percentBlueTradeGoods = bluetg;
- percentPurpleTradeGoods = purpletg;
- percentOrangeTradeGoods = orangetg;
- percentYellowTradeGoods = yellowtg;
- percentGreyItems = greyi;
- percentWhiteItems = whitei;
- percentGreenItems = greeni;
- percentBlueItems = bluei;
- percentPurpleItems = purplei;
- percentOrangeItems = orangei;
- percentYellowItems = yellowi;
- CalculatePercents();
- }
- uint32 GetPercentages(uint32 color)
- {
- switch(color)
- {
- case AHB_GREY_TG:
- return percentGreyTradeGoods;
- break;
- case AHB_WHITE_TG:
- return percentWhiteTradeGoods;
- break;
- case AHB_GREEN_TG:
- return percentGreenTradeGoods;
- break;
- case AHB_BLUE_TG:
- return percentBlueTradeGoods;
- break;
- case AHB_PURPLE_TG:
- return percentPurpleTradeGoods;
- break;
- case AHB_ORANGE_TG:
- return percentOrangeTradeGoods;
- break;
- case AHB_YELLOW_TG:
- return percentYellowTradeGoods;
- break;
- case AHB_GREY_I:
- return percentGreyItems;
- break;
- case AHB_WHITE_I:
- return percentWhiteItems;
- break;
- case AHB_GREEN_I:
- return percentGreenItems;
- break;
- case AHB_BLUE_I:
- return percentBlueItems;
- break;
- case AHB_PURPLE_I:
- return percentPurpleItems;
- break;
- case AHB_ORANGE_I:
- return percentOrangeItems;
- break;
- case AHB_YELLOW_I:
- return percentYellowItems;
- break;
- default:
- return 0;
- break;
- }
- }
- void SetMinPrice(uint32 color, uint32 value)
- {
- switch(color)
- {
- case AHB_GREY:
- minPriceGrey = value;
- break;
- case AHB_WHITE:
- minPriceWhite = value;
- break;
- case AHB_GREEN:
- minPriceGreen = value;
- break;
- case AHB_BLUE:
- minPriceBlue = value;
- break;
- case AHB_PURPLE:
- minPricePurple = value;
- break;
- case AHB_ORANGE:
- minPriceOrange = value;
- break;
- case AHB_YELLOW:
- minPriceYellow = value;
- break;
- default:
- break;
- }
- }
- uint32 GetMinPrice(uint32 color)
- {
- switch(color)
- {
- case AHB_GREY:
- {
- if (minPriceGrey == 0)
- return 100;
- else if (minPriceGrey > maxPriceGrey)
- return maxPriceGrey;
- else
- return minPriceGrey;
- break;
- }
- case AHB_WHITE:
- {
- if (minPriceWhite == 0)
- return 150;
- else if (minPriceWhite > maxPriceWhite)
- return maxPriceWhite;
- else
- return minPriceWhite;
- break;
- }
- case AHB_GREEN:
- {
- if (minPriceGreen == 0)
- return 200;
- else if (minPriceGreen > maxPriceGreen)
- return maxPriceGreen;
- else
- return minPriceGreen;
- break;
- }
- case AHB_BLUE:
- {
- if (minPriceBlue == 0)
- return 250;
- else if (minPriceBlue > maxPriceBlue)
- return maxPriceBlue;
- else
- return minPriceBlue;
- break;
- }
- case AHB_PURPLE:
- {
- if (minPricePurple == 0)
- return 300;
- else if (minPricePurple > maxPricePurple)
- return maxPricePurple;
- else
- return minPricePurple;
- break;
- }
- case AHB_ORANGE:
- {
- if (minPriceOrange == 0)
- return 400;
- else if (minPriceOrange > maxPriceOrange)
- return maxPriceOrange;
- else
- return minPriceOrange;
- break;
- }
- case AHB_YELLOW:
- {
- if (minPriceYellow == 0)
- return 500;
- else if (minPriceYellow > maxPriceYellow)
- return maxPriceYellow;
- else
- return minPriceYellow;
- break;
- }
- default:
- {
- return 0;
- break;
- }
- }
- }
- void SetMaxPrice(uint32 color, uint32 value)
- {
- switch(color)
- {
- case AHB_GREY:
- maxPriceGrey = value;
- break;
- case AHB_WHITE:
- maxPriceWhite = value;
- break;
- case AHB_GREEN:
- maxPriceGreen = value;
- break;
- case AHB_BLUE:
- maxPriceBlue = value;
- break;
- case AHB_PURPLE:
- maxPricePurple = value;
- break;
- case AHB_ORANGE:
- maxPriceOrange = value;
- break;
- case AHB_YELLOW:
- maxPriceYellow = value;
- break;
- default:
- break;
- }
- }
- uint32 GetMaxPrice(uint32 color)
- {
- switch(color)
- {
- case AHB_GREY:
- {
- if (maxPriceGrey == 0)
- return 150;
- else
- return maxPriceGrey;
- break;
- }
- case AHB_WHITE:
- {
- if (maxPriceWhite == 0)
- return 250;
- else
- return maxPriceWhite;
- break;
- }
- case AHB_GREEN:
- {
- if (maxPriceGreen == 0)
- return 300;
- else
- return maxPriceGreen;
- break;
- }
- case AHB_BLUE:
- {
- if (maxPriceBlue == 0)
- return 350;
- else
- return maxPriceBlue;
- break;
- }
- case AHB_PURPLE:
- {
- if (maxPricePurple == 0)
- return 450;
- else
- return maxPricePurple;
- break;
- }
- case AHB_ORANGE:
- {
- if (maxPriceOrange == 0)
- return 550;
- else
- return maxPriceOrange;
- break;
- }
- case AHB_YELLOW:
- {
- if (maxPriceYellow == 0)
- return 650;
- else
- return maxPriceYellow;
- break;
- }
- default:
- {
- return 0;
- break;
- }
- }
- }
- void SetMinBidPrice(uint32 color, uint32 value)
- {
- switch(color)
- {
- case AHB_GREY:
- minBidPriceGrey = value;
- break;
- case AHB_WHITE:
- minBidPriceWhite = value;
- break;
- case AHB_GREEN:
- minBidPriceGreen = value;
- break;
- case AHB_BLUE:
- minBidPriceBlue = value;
- break;
- case AHB_PURPLE:
- minBidPricePurple = value;
- break;
- case AHB_ORANGE:
- minBidPriceOrange = value;
- break;
- case AHB_YELLOW:
- minBidPriceYellow = value;
- break;
- default:
- break;
- }
- }
- uint32 GetMinBidPrice(uint32 color)
- {
- switch(color)
- {
- case AHB_GREY:
- {
- if (minBidPriceGrey > 100)
- return 100;
- else
- return minBidPriceGrey;
- break;
- }
- case AHB_WHITE:
- {
- if (minBidPriceWhite > 100)
- return 100;
- else
- return minBidPriceWhite;
- break;
- }
- case AHB_GREEN:
- {
- if (minBidPriceGreen > 100)
- return 100;
- else
- return minBidPriceGreen;
- break;
- }
- case AHB_BLUE:
- {
- if (minBidPriceBlue > 100)
- return 100;
- else
- return minBidPriceBlue;
- break;
- }
- case AHB_PURPLE:
- {
- if (minBidPricePurple > 100)
- return 100;
- else
- return minBidPricePurple;
- break;
- }
- case AHB_ORANGE:
- {
- if (minBidPriceOrange > 100)
- return 100;
- else
- return minBidPriceOrange;
- break;
- }
- case AHB_YELLOW:
- {
- if (minBidPriceYellow > 100)
- return 100;
- else
- return minBidPriceYellow;
- break;
- }
- default:
- {
- return 0;
- break;
- }
- }
- }
- void SetMaxBidPrice(uint32 color, uint32 value)
- {
- switch(color)
- {
- case AHB_GREY:
- maxBidPriceGrey = value;
- break;
- case AHB_WHITE:
- maxBidPriceWhite = value;
- break;
- case AHB_GREEN:
- maxBidPriceGreen = value;
- break;
- case AHB_BLUE:
- maxBidPriceBlue = value;
- break;
- case AHB_PURPLE:
- maxBidPricePurple = value;
- break;
- case AHB_ORANGE:
- maxBidPriceOrange = value;
- break;
- case AHB_YELLOW:
- maxBidPriceYellow = value;
- break;
- default:
- break;
- }
- }
- uint32 GetMaxBidPrice(uint32 color)
- {
- switch(color)
- {
- case AHB_GREY:
- {
- if (maxBidPriceGrey > 100)
- return 100;
- else
- return maxBidPriceGrey;
- break;
- }
- case AHB_WHITE:
- {
- if (maxBidPriceWhite > 100)
- return 100;
- else
- return maxBidPriceWhite;
- break;
- }
- case AHB_GREEN:
- {
- if (maxBidPriceGreen > 100)
- return 100;
- else
- return maxBidPriceGreen;
- break;
- }
- case AHB_BLUE:
- {
- if (maxBidPriceBlue > 100)
- return 100;
- else
- return maxBidPriceBlue;
- break;
- }
- case AHB_PURPLE:
- {
- if (maxBidPricePurple > 100)
- return 100;
- else
- return maxBidPricePurple;
- break;
- }
- case AHB_ORANGE:
- {
- if (maxBidPriceOrange > 100)
- return 100;
- else
- return maxBidPriceOrange;
- break;
- }
- case AHB_YELLOW:
- {
- if (maxBidPriceYellow > 100)
- return 100;
- else
- return maxBidPriceYellow;
- break;
- }
- default:
- {
- return 0;
- break;
- }
- }
- }
- void SetMaxStack(uint32 color, uint32 value)
- {
- switch(color)
- {
- case AHB_GREY:
- maxStackGrey = value;
- break;
- case AHB_WHITE:
- maxStackWhite = value;
- break;
- case AHB_GREEN:
- maxStackGreen = value;
- break;
- case AHB_BLUE:
- maxStackBlue = value;
- break;
- case AHB_PURPLE:
- maxStackPurple = value;
- break;
- case AHB_ORANGE:
- maxStackOrange = value;
- break;
- case AHB_YELLOW:
- maxStackYellow = value;
- break;
- default:
- break;
- }
- }
- uint32 GetMaxStack(uint32 color)
- {
- switch(color)
- {
- case AHB_GREY:
- {
- return maxStackGrey;
- break;
- }
- case AHB_WHITE:
- {
- return maxStackWhite;
- break;
- }
- case AHB_GREEN:
- {
- return maxStackGreen;
- break;
- }
- case AHB_BLUE:
- {
- return maxStackBlue;
- break;
- }
- case AHB_PURPLE:
- {
- return maxStackPurple;
- break;
- }
- case AHB_ORANGE:
- {
- return maxStackOrange;
- break;
- }
- case AHB_YELLOW:
- {
- return maxStackYellow;
- break;
- }
- default:
- {
- return 0;
- break;
- }
- }
- }
- void SetBuyerPrice(uint32 color, uint32 value)
- {
- switch(color)
- {
- case AHB_GREY:
- buyerPriceGrey = value;
- break;
- case AHB_WHITE:
- buyerPriceWhite = value;
- break;
- case AHB_GREEN:
- buyerPriceGreen = value;
- break;
- case AHB_BLUE:
- buyerPriceBlue = value;
- break;
- case AHB_PURPLE:
- buyerPricePurple = value;
- break;
- case AHB_ORANGE:
- buyerPriceOrange = value;
- break;
- case AHB_YELLOW:
- buyerPriceYellow = value;
- break;
- default:
- break;
- }
- }
- uint32 GetBuyerPrice(uint32 color)
- {
- switch(color)
- {
- case AHB_GREY:
- return buyerPriceGrey;
- break;
- case AHB_WHITE:
- return buyerPriceWhite;
- break;
- case AHB_GREEN:
- return buyerPriceGreen;
- break;
- case AHB_BLUE:
- return buyerPriceBlue;
- break;
- case AHB_PURPLE:
- return buyerPricePurple;
- break;
- case AHB_ORANGE:
- return buyerPriceOrange;
- break;
- case AHB_YELLOW:
- return buyerPriceYellow;
- break;
- default:
- return 0;
- break;
- }
- }
- void SetBiddingInterval(uint32 value)
- {
- buyerBiddingInterval = value;
- }
- uint32 GetBiddingInterval()
- {
- return buyerBiddingInterval;
- }
- void CalculatePercents()
- {
- greytgp = (uint32) (((double)percentGreyTradeGoods / 100.0) * maxItems);
- whitetgp = (uint32) (((double)percentWhiteTradeGoods / 100.0) * maxItems);
- greentgp = (uint32) (((double)percentGreenTradeGoods / 100.0) * maxItems);
- bluetgp = (uint32) (((double)percentBlueTradeGoods / 100.0) * maxItems);
- purpletgp = (uint32) (((double)percentPurpleTradeGoods / 100.0) * maxItems);
- orangetgp = (uint32) (((double)percentOrangeTradeGoods / 100.0) * maxItems);
- yellowtgp = (uint32) (((double)percentYellowTradeGoods / 100.0) * maxItems);
- greyip = (uint32) (((double)percentGreyItems / 100.0) * maxItems);
- whiteip = (uint32) (((double)percentWhiteItems / 100.0) * maxItems);
- greenip = (uint32) (((double)percentGreenItems / 100.0) * maxItems);
- blueip = (uint32) (((double)percentBlueItems / 100.0) * maxItems);
- purpleip = (uint32) (((double)percentPurpleItems / 100.0) * maxItems);
- orangeip = (uint32) (((double)percentOrangeItems / 100.0) * maxItems);
- yellowip = (uint32) (((double)percentYellowItems / 100.0) * maxItems);
- uint32 total = greytgp + whitetgp + greentgp + bluetgp + purpletgp + orangetgp + yellowtgp + greyip + whiteip + greenip + blueip + purpleip + orangeip + yellowip;
- int32 diff = (maxItems - total);
- if (diff < 0)
- {
- if ((whiteip - diff) > 0)
- whiteip -= diff;
- else if ((greenip - diff) > 0)
- greenip -= diff;
- }
- else if (diff < 0)
- {
- whiteip += diff;
- }
- }
- uint32 GetPercents(uint32 color)
- {
- switch(color)
- {
- case AHB_GREY_TG:
- return greytgp;
- break;
- case AHB_WHITE_TG:
- return whitetgp;
- break;
- case AHB_GREEN_TG:
- return greentgp;
- break;
- case AHB_BLUE_TG:
- return bluetgp;
- break;
- case AHB_PURPLE_TG:
- return purpletgp;
- break;
- case AHB_ORANGE_TG:
- return orangetgp;
- break;
- case AHB_YELLOW_TG:
- return yellowtgp;
- break;
- case AHB_GREY_I:
- return greyip;
- break;
- case AHB_WHITE_I:
- return whiteip;
- break;
- case AHB_GREEN_I:
- return greenip;
- break;
- case AHB_BLUE_I:
- return blueip;
- break;
- case AHB_PURPLE_I:
- return purpleip;
- break;
- case AHB_ORANGE_I:
- return orangeip;
- break;
- case AHB_YELLOW_I:
- return yellowip;
- break;
- default:
- return 0;
- break;
- }
- }
-
- void DecItemCounts(uint32 Class, uint32 Quality)
- {
- switch(Class)
- {
- case ITEM_CLASS_TRADE_GOODS:
- DecItemCounts(Quality);
- break;
- default:
- DecItemCounts(Quality + 7);
- break;
- }
- }
-
- void DecItemCounts(uint32 color)
- {
- switch(color)
- {
- case AHB_GREY_TG:
- --greyTGoods;
- break;
- case AHB_WHITE_TG:
- --whiteTGoods;
- break;
- case AHB_GREEN_TG:
- --greenTGoods;
- break;
- case AHB_BLUE_TG:
- --blueTGoods;
- break;
- case AHB_PURPLE_TG:
- --purpleTGoods;
- break;
- case AHB_ORANGE_TG:
- --orangeTGoods;
- break;
- case AHB_YELLOW_TG:
- --yellowTGoods;
- break;
- case AHB_GREY_I:
- --greyItems;
- break;
- case AHB_WHITE_I:
- --whiteItems;
- break;
- case AHB_GREEN_I:
- --greenItems;
- break;
- case AHB_BLUE_I:
- --blueItems;
- break;
- case AHB_PURPLE_I:
- --purpleItems;
- break;
- case AHB_ORANGE_I:
- --orangeItems;
- break;
- case AHB_YELLOW_I:
- --yellowItems;
- break;
- default:
- break;
- }
- }
-
- void IncItemCounts(uint32 Class, uint32 Quality)
- {
- switch(Class)
- {
- case ITEM_CLASS_TRADE_GOODS:
- IncItemCounts(Quality);
- break;
- default:
- IncItemCounts(Quality + 7);
- break;
- }
- }
-
- void IncItemCounts(uint32 color)
- {
- switch(color)
- {
- case AHB_GREY_TG:
- ++greyTGoods;
- break;
- case AHB_WHITE_TG:
- ++whiteTGoods;
- break;
- case AHB_GREEN_TG:
- ++greenTGoods;
- break;
- case AHB_BLUE_TG:
- ++blueTGoods;
- break;
- case AHB_PURPLE_TG:
- ++purpleTGoods;
- break;
- case AHB_ORANGE_TG:
- ++orangeTGoods;
- break;
- case AHB_YELLOW_TG:
- ++yellowTGoods;
- break;
- case AHB_GREY_I:
- ++greyItems;
- break;
- case AHB_WHITE_I:
- ++whiteItems;
- break;
- case AHB_GREEN_I:
- ++greenItems;
- break;
- case AHB_BLUE_I:
- ++blueItems;
- break;
- case AHB_PURPLE_I:
- ++purpleItems;
- break;
- case AHB_ORANGE_I:
- ++orangeItems;
- break;
- case AHB_YELLOW_I:
- ++yellowItems;
- break;
- default:
- break;
- }
- }
-
- void ResetItemCounts()
- {
- greyTGoods = 0;
- whiteTGoods = 0;
- greenTGoods = 0;
- blueTGoods = 0;
- purpleTGoods = 0;
- orangeTGoods = 0;
- yellowTGoods = 0;
-
- greyItems = 0;
- whiteItems = 0;
- greenItems = 0;
- blueItems = 0;
- purpleItems = 0;
- orangeItems = 0;
- yellowItems = 0;
- }
+ AuctionHouseBot();
+ ~AuctionHouseBot() = default;
- uint32 TotalItemCounts()
- {
- return(
- greyTGoods +
- whiteTGoods +
- greenTGoods +
- blueTGoods +
- purpleTGoods +
- orangeTGoods +
- yellowTGoods +
+ static AuctionHouseBot* instance();
- greyItems +
- whiteItems +
- greenItems +
- blueItems +
- purpleItems +
- orangeItems +
- yellowItems);
- }
+ void Update();
+ void Initialize();
+ void InitializeConfiguration();
+ void LoadValues(AHBConfig*);
+ void DecrementItemCounts(AuctionEntry* ah, uint32 itemEntry);
+ void IncrementItemCounts(AuctionEntry* ah);
+ void Commands(uint32, uint32, uint32, char*);
+ ObjectGuid::LowType GetAHBplayerGUID() { return AHBplayerGUID; };
- uint32 GetItemCounts(uint32 color)
- {
- switch(color)
- {
- case AHB_GREY_TG:
- return greyTGoods;
- break;
- case AHB_WHITE_TG:
- return whiteTGoods;
- break;
- case AHB_GREEN_TG:
- return greenTGoods;
- break;
- case AHB_BLUE_TG:
- return blueTGoods;
- break;
- case AHB_PURPLE_TG:
- return purpleTGoods;
- break;
- case AHB_ORANGE_TG:
- return orangeTGoods;
- break;
- case AHB_YELLOW_TG:
- return yellowTGoods;
- break;
- case AHB_GREY_I:
- return greyItems;
- break;
- case AHB_WHITE_I:
- return whiteItems;
- break;
- case AHB_GREEN_I:
- return greenItems;
- break;
- case AHB_BLUE_I:
- return blueItems;
- break;
- case AHB_PURPLE_I:
- return purpleItems;
- break;
- case AHB_ORANGE_I:
- return orangeItems;
- break;
- case AHB_YELLOW_I:
- return yellowItems;
- break;
- default:
- return 0;
- break;
- }
- }
- void SetBidsPerInterval(uint32 value)
- {
- buyerBidsPerInterval = value;
- }
- uint32 GetBidsPerInterval()
- {
- return buyerBidsPerInterval;
- }
- ~AHBConfig()
- {
- }
-};
-class AuctionHouseBot
-{
private:
-
- bool debug_Out;
- bool debug_Out_Filters;
-
- bool AHBSeller;
- bool AHBBuyer;
- bool BuyMethod;
- bool SellMethod;
+ bool AHBSeller{ false };
+ bool AHBBuyer{ false };
+ bool BuyMethod{ false };
+ bool SellMethod{ false };
uint32 AHBplayerAccount;
ObjectGuid::LowType AHBplayerGUID;
uint32 ItemsPerCycle;
- //Begin Filters
-
- bool Vendor_Items;
- bool Loot_Items;
- bool Other_Items;
- bool Vendor_TGs;
- bool Loot_TGs;
- bool Other_TGs;
-
- bool No_Bind;
- bool Bind_When_Picked_Up;
- bool Bind_When_Equipped;
- bool Bind_When_Use;
- bool Bind_Quest_Item;
-
- bool DisablePermEnchant;
- bool DisableConjured;
- bool DisableGems;
- bool DisableMoney;
- bool DisableMoneyLoot;
- bool DisableLootable;
- bool DisableKeys;
- bool DisableDuration;
- bool DisableBOP_Or_Quest_NoReqLevel;
-
- bool DisableWarriorItems;
- bool DisablePaladinItems;
- bool DisableHunterItems;
- bool DisableRogueItems;
- bool DisablePriestItems;
- bool DisableDKItems;
- bool DisableShamanItems;
- bool DisableMageItems;
- bool DisableWarlockItems;
- bool DisableUnusedClassItems;
- bool DisableDruidItems;
-
- uint32 DisableItemsBelowLevel;
- uint32 DisableItemsAboveLevel;
- uint32 DisableTGsBelowLevel;
- uint32 DisableTGsAboveLevel;
- uint32 DisableItemsBelowGUID;
- uint32 DisableItemsAboveGUID;
- uint32 DisableTGsBelowGUID;
- uint32 DisableTGsAboveGUID;
- uint32 DisableItemsBelowReqLevel;
- uint32 DisableItemsAboveReqLevel;
- uint32 DisableTGsBelowReqLevel;
- uint32 DisableTGsAboveReqLevel;
- uint32 DisableItemsBelowReqSkillRank;
- uint32 DisableItemsAboveReqSkillRank;
- uint32 DisableTGsBelowReqSkillRank;
- uint32 DisableTGsAboveReqSkillRank;
-
- std::set DisableItemStore;
-
- //End Filters
+ std::unordered_set DisableItemStore{};
AHBConfig AllianceConfig;
AHBConfig HordeConfig;
AHBConfig NeutralConfig;
- time_t _lastrun_a;
- time_t _lastrun_h;
- time_t _lastrun_n;
+ Seconds _lastUpdateAlliance{ 0s };
+ Seconds _lastUpdateHorde{ 0s };
+ Seconds _lastUpdateNeutral{ 0s };
inline uint32 minValue(uint32 a, uint32 b) { return a <= b ? a : b; };
- void addNewAuctions(Player *AHBplayer, AHBConfig *config);
- void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, WorldSession *session);
-
-// friend class ACE_Singleton;
- AuctionHouseBot();
+ void AddNewAuctions(Player* AHBplayer, AHBConfig* config);
+ void AddNewAuctionBuyerBotBid(std::shared_ptr player, std::shared_ptr session, AHBConfig* config);
+ void AddNewAuctionBuyerBotBidCallback(std::shared_ptr player, std::shared_ptr session, std::shared_ptr config, QueryResult result);
-public:
- static AuctionHouseBot* instance()
- {
- static AuctionHouseBot instance;
- return &instance;
- }
+ void ProcessQueryCallbacks();
- ~AuctionHouseBot();
- void Update();
- void Initialize();
- void InitializeConfiguration();
- void LoadValues(AHBConfig*);
- void DecrementItemCounts(AuctionEntry* ah, uint32 itemEntry);
- void IncrementItemCounts(AuctionEntry* ah);
- void Commands(uint32, uint32, uint32, char*);
- ObjectGuid::LowType GetAHBplayerGUID() { return AHBplayerGUID; };
+ QueryCallbackProcessor _queryProcessor;
};
-#define auctionbot AuctionHouseBot::instance()
+#define sAHBot AuctionHouseBot::instance()
#endif
diff --git a/src/AuctionHouseBotConfig.cpp b/src/AuctionHouseBotConfig.cpp
new file mode 100644
index 0000000..8cfcda8
--- /dev/null
+++ b/src/AuctionHouseBotConfig.cpp
@@ -0,0 +1,311 @@
+/*
+ * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published by the
+ * Free Software Foundation; either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+
+#include "AuctionHouseBotConfig.h"
+#include "AuctionHouseMgr.h"
+#include "ItemTemplate.h"
+#include
+
+#include "Log.h"
+
+AHBConfig::AHBConfig(uint32 ahid)
+{
+ _auctionHouseID = ahid;
+
+ switch (ahid)
+ {
+ case AUCTIONHOUSE_ALLIANCE:
+ _auctionHouseFactionID = 55;
+ break;
+ case AUCTIONHOUSE_HORDE:
+ _auctionHouseFactionID = 29;
+ break;
+ case AUCTIONHOUSE_NEUTRAL:
+ _auctionHouseFactionID = 120;
+ break;
+ default:
+ _auctionHouseFactionID = 120;
+ break;
+ }
+}
+
+uint32 AHBConfig::GetMinItems()
+{
+ if (!_minItems && _maxItems)
+ return _maxItems;
+ else if (_maxItems && (_minItems > _maxItems))
+ return _maxItems;
+
+ return _minItems;
+}
+
+void AHBConfig::SetPercentages(std::array& percentages)
+{
+ uint32 totalPercent = std::accumulate(percentages.begin(), percentages.end(), 0);
+
+ if (totalPercent == 0)
+ {
+ _maxItems = 0;
+ }
+ else if (totalPercent != 100)
+ {
+ // re-normalize all percentages
+ const float fixMultiplier = 100.f / static_cast(totalPercent);
+
+ for (auto& it : percentages)
+ it *= fixMultiplier;
+
+ LOG_WARN("module.ahbot", "AHConfig: Percentages don't add up to 100 (was {}), they have been auto-normalized.", totalPercent);
+ }
+
+ std::copy_n(percentages.begin(), AHB_MAX_QUALITY, _itemsPercent.begin());
+
+ CalculatePercents();
+}
+
+uint32 AHBConfig::GetPercentages(uint32 color)
+{
+ if (color > AHB_ITEM_QUALITY_ARTIFACT)
+ return 0;
+
+ return _itemsPercent[color];
+}
+
+void AHBConfig::SetMinPrice(uint32 color, uint32 value)
+{
+ if (color >= AHB_DEFAULT_QUALITY_SIZE)
+ return;
+
+ _minPrice[color] = value;
+}
+
+uint32 AHBConfig::GetMinPrice(uint32 color)
+{
+ if (color >= AHB_DEFAULT_QUALITY_SIZE)
+ return 0;
+
+ auto _GetMinPrice = [this, color](uint32 returnValue)
+ {
+ uint32 minPrice = _minPrice[color];
+ uint32 maxPrice = _maxPrice[color];
+
+ if (!minPrice)
+ return returnValue;
+ else if (minPrice > maxPrice)
+ return maxPrice;
+
+ return minPrice;
+ };
+
+ switch (color)
+ {
+ case ITEM_QUALITY_POOR: return _GetMinPrice(100);
+ case ITEM_QUALITY_NORMAL: return _GetMinPrice(150);
+ case ITEM_QUALITY_UNCOMMON: return _GetMinPrice(200);
+ case ITEM_QUALITY_RARE: return _GetMinPrice(250);
+ case ITEM_QUALITY_EPIC: return _GetMinPrice(300);
+ case ITEM_QUALITY_LEGENDARY: return _GetMinPrice(400);
+ case ITEM_QUALITY_ARTIFACT: return _GetMinPrice(500);
+ default:
+ return 0;
+ }
+}
+
+void AHBConfig::SetMaxPrice(uint32 color, uint32 value)
+{
+ if (color >= AHB_DEFAULT_QUALITY_SIZE)
+ return;
+
+ _maxPrice[color] = value;
+}
+
+uint32 AHBConfig::GetMaxPrice(uint32 color)
+{
+ if (color >= AHB_DEFAULT_QUALITY_SIZE)
+ return 0;
+
+ uint32 maxPrice = _maxPrice[color];
+
+ switch (color)
+ {
+ case ITEM_QUALITY_POOR: return !maxPrice ? 150 : maxPrice;
+ case ITEM_QUALITY_NORMAL: return !maxPrice ? 250 : maxPrice;
+ case ITEM_QUALITY_UNCOMMON: return !maxPrice ? 300 : maxPrice;
+ case ITEM_QUALITY_RARE: return !maxPrice ? 350 : maxPrice;
+ case ITEM_QUALITY_EPIC: return !maxPrice ? 450 : maxPrice;
+ case ITEM_QUALITY_LEGENDARY: return !maxPrice ? 550 : maxPrice;
+ case ITEM_QUALITY_ARTIFACT: return !maxPrice ? 650 : maxPrice;
+ default:
+ return 0;
+ }
+}
+
+void AHBConfig::SetMinBidPrice(uint32 color, uint32 value)
+{
+ if (color >= AHB_DEFAULT_QUALITY_SIZE)
+ return;
+
+ _minBidPrice[color] = value;
+}
+
+uint32 AHBConfig::GetMinBidPrice(uint32 color)
+{
+ if (color >= AHB_DEFAULT_QUALITY_SIZE)
+ return 0;
+
+ uint32 minBidPrice = _minBidPrice[color];
+ return minBidPrice > 100 ? 100 : minBidPrice;
+}
+
+void AHBConfig::SetMaxBidPrice(uint32 color, uint32 value)
+{
+ if (color >= AHB_DEFAULT_QUALITY_SIZE)
+ return;
+
+ _maxBidPrice[color] = value;
+}
+
+uint32 AHBConfig::GetMaxBidPrice(uint32 color)
+{
+ if (color >= AHB_DEFAULT_QUALITY_SIZE)
+ return 0;
+
+ uint32 maxBidPrice = _maxBidPrice[color];
+ return maxBidPrice > 100 ? 100 : maxBidPrice;
+}
+
+void AHBConfig::SetMaxStack(uint32 color, uint32 value)
+{
+ if (color >= AHB_DEFAULT_QUALITY_SIZE)
+ return;
+
+ _maxStack[color] = value;
+}
+
+uint32 AHBConfig::GetMaxStack(uint32 color)
+{
+ if (color >= AHB_DEFAULT_QUALITY_SIZE)
+ return 0;
+
+ return _maxStack[color];
+}
+
+void AHBConfig::SetBuyerPrice(uint32 color, uint32 value)
+{
+ if (color >= AHB_DEFAULT_QUALITY_SIZE)
+ return;
+
+ _buyerPrice[color] = value;
+}
+
+uint32 AHBConfig::GetBuyerPrice(uint32 color)
+{
+ if (color >= AHB_DEFAULT_QUALITY_SIZE)
+ return 0;
+
+ return _buyerPrice[color];
+}
+
+void AHBConfig::CalculatePercents()
+{
+ for (size_t i = 0; i < AHB_MAX_QUALITY; i++)
+ {
+ double itemPercent = _itemsPercent[i];
+ _itemsPercentages[i] = uint32(itemPercent / 100 * _maxItems);
+ }
+
+ uint32 totalPercent = std::accumulate(_itemsPercentages.begin(), _itemsPercentages.end(), 0);
+ int32 diff = (_maxItems - totalPercent);
+
+ if (diff < 0)
+ {
+ if (_itemsPercentages[AHB_ITEM_QUALITY_NORMAL] - diff > 0)
+ _itemsPercentages[AHB_ITEM_QUALITY_NORMAL] -= diff;
+ else if (_itemsPercentages[AHB_ITEM_QUALITY_UNCOMMON] - diff > 0)
+ _itemsPercentages[AHB_ITEM_QUALITY_UNCOMMON] -= diff;
+ }
+ else if (diff < 0)
+ _itemsPercentages[AHB_ITEM_QUALITY_NORMAL] += diff;
+}
+
+uint32 AHBConfig::GetPercents(uint32 color)
+{
+ if (color >= AHB_MAX_QUALITY)
+ return 0;
+
+ return _itemsPercentages[color];
+}
+
+void AHBConfig::DecreaseItemCounts(uint32 Class, uint32 Quality)
+{
+ switch (Class)
+ {
+ case ITEM_CLASS_TRADE_GOODS:
+ DecreaseItemCounts(Quality);
+ break;
+ default:
+ DecreaseItemCounts(Quality + 7);
+ break;
+ }
+}
+
+void AHBConfig::DecreaseItemCounts(uint32 color)
+{
+ if (color >= AHB_MAX_QUALITY)
+ return;
+
+ _itemsCount[color]--;
+}
+
+void AHBConfig::IncreaseItemCounts(uint32 Class, uint32 Quality)
+{
+ switch (Class)
+ {
+ case ITEM_CLASS_TRADE_GOODS:
+ IncreaseItemCounts(Quality);
+ break;
+ default:
+ IncreaseItemCounts(Quality + AHB_MAX_DEFAULT_QUALITY + 1);
+ break;
+ }
+}
+
+void AHBConfig::IncreaseItemCounts(uint32 color)
+{
+ if (color >= AHB_MAX_QUALITY)
+ return;
+
+ _itemsCount[color]++;
+}
+
+void AHBConfig::ResetItemCounts()
+{
+ _itemsCount.fill(0);
+}
+
+uint32 AHBConfig::TotalItemCounts()
+{
+ return std::accumulate(_itemsCount.begin(), _itemsCount.end(), 0);
+}
+
+uint32 AHBConfig::GetItemCounts(uint32 color)
+{
+ if (color >= AHB_MAX_QUALITY)
+ return 0;
+
+ return _itemsCount[color];
+}
diff --git a/src/AuctionHouseBotConfig.h b/src/AuctionHouseBotConfig.h
new file mode 100644
index 0000000..ea66ece
--- /dev/null
+++ b/src/AuctionHouseBotConfig.h
@@ -0,0 +1,175 @@
+/*
+ * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published by the
+ * Free Software Foundation; either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+
+#ifndef AUCTION_HOUSE_BOT_CONFIG_H
+#define AUCTION_HOUSE_BOT_CONFIG_H
+
+#include "Define.h"
+#include "Duration.h"
+#include "SharedDefines.h"
+#include
+
+enum AHItemQualities
+{
+ AHB_ITEM_QUALITY_POOR = 7, // GREY
+ AHB_ITEM_QUALITY_NORMAL, // WHITE
+ AHB_ITEM_QUALITY_UNCOMMON, // GREEN
+ AHB_ITEM_QUALITY_RARE, // BLUE
+ AHB_ITEM_QUALITY_EPIC, // PURPLE
+ AHB_ITEM_QUALITY_LEGENDARY, // ORANGE
+ AHB_ITEM_QUALITY_ARTIFACT, // LIGHT YELLOW
+};
+
+constexpr uint32 AHB_MAX_DEFAULT_QUALITY = 6;
+constexpr uint32 AHB_DEFAULT_QUALITY_SIZE = AHB_MAX_DEFAULT_QUALITY + 1;
+constexpr uint32 AHB_MAX_QUALITY = AHB_ITEM_QUALITY_ARTIFACT + 1;
+
+class AHBConfig
+{
+public:
+ AHBConfig() = default;
+ ~AHBConfig() = default;
+
+ AHBConfig(uint32 ahid);
+
+ inline uint32 GetAuctionHouseID()
+ {
+ return _auctionHouseID;
+ }
+
+ inline uint32 GetAuctionHouseFactionID()
+ {
+ return _auctionHouseFactionID;
+ }
+
+ inline void SetMinItems(uint32 value)
+ {
+ _minItems = value;
+ }
+
+ uint32 GetMinItems();
+
+ inline void SetMaxItems(uint32 value)
+ {
+ _maxItems = value;
+ // CalculatePercents() needs to be called, but only if
+ // SetPercentages() has been called at least once already.
+ }
+
+ inline uint32 GetMaxItems()
+ {
+ return _maxItems;
+ }
+
+ void SetPercentages(std::array& percentages);
+
+ uint32 GetPercentages(uint32 color);
+
+ void SetMinPrice(uint32 color, uint32 value);
+
+ uint32 GetMinPrice(uint32 color);
+
+ void SetMaxPrice(uint32 color, uint32 value);
+
+ uint32 GetMaxPrice(uint32 color);
+
+ void SetMinBidPrice(uint32 color, uint32 value);
+
+ uint32 GetMinBidPrice(uint32 color);
+
+ void SetMaxBidPrice(uint32 color, uint32 value);
+
+ uint32 GetMaxBidPrice(uint32 color);
+
+ void SetMaxStack(uint32 color, uint32 value);
+
+ uint32 GetMaxStack(uint32 color);
+
+ void SetBuyerPrice(uint32 color, uint32 value);
+
+ uint32 GetBuyerPrice(uint32 color);
+
+ inline void SetBiddingInterval(Minutes value)
+ {
+ _buyerBiddingInterval = value;
+ }
+
+ inline Minutes GetBiddingInterval()
+ {
+ return _buyerBiddingInterval;
+ }
+
+ void CalculatePercents();
+
+ uint32 GetPercents(uint32 color);
+
+ inline std::array const* GetPercents()
+ {
+ return &_itemsPercentages;
+ }
+
+ void DecreaseItemCounts(uint32 Class, uint32 Quality);
+
+ void DecreaseItemCounts(uint32 color);
+
+ void IncreaseItemCounts(uint32 Class, uint32 Quality);
+
+ void IncreaseItemCounts(uint32 color);
+
+ void ResetItemCounts();
+
+ uint32 TotalItemCounts();
+
+ uint32 GetItemCounts(uint32 color);
+
+ inline std::array const* GetItemCounts()
+ {
+ return &_itemsCount;
+ }
+
+ inline void SetBidsPerInterval(uint32 value)
+ {
+ _buyerBidsPerInterval = value;
+ }
+
+ inline uint32 GetBidsPerInterval()
+ {
+ return _buyerBidsPerInterval;
+ }
+
+private:
+ uint32 _auctionHouseID{ 0 };
+ uint32 _auctionHouseFactionID{ 0 };
+
+ uint32 _minItems{ 0 };
+ uint32 _maxItems{ 0 };
+
+ Minutes _buyerBiddingInterval{ 0min };
+ uint32 _buyerBidsPerInterval{ 0 };
+
+ std::array _itemsPercent{};
+ std::array _itemsPercentages{};
+ std::array _buyerPrice{};
+ std::array _maxStack{};
+ std::array _minBidPrice{};
+ std::array _maxBidPrice{};
+ std::array _minPrice{};
+ std::array _maxPrice{};
+ std::array _itemsCount{};
+};
+
+#endif // AUCTION_HOUSE_BOT_CONFIG_H
diff --git a/src/AuctionHouseBotScript.cpp b/src/AuctionHouseBotScript.cpp
index 19ef7c8..0d9ca73 100644
--- a/src/AuctionHouseBotScript.cpp
+++ b/src/AuctionHouseBotScript.cpp
@@ -1,6 +1,19 @@
/*
- * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
-*/
+ * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published by the
+ * Free Software Foundation; either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
#include "ScriptMgr.h"
#include "AuctionHouseBot.h"
@@ -16,13 +29,13 @@ class AHBot_WorldScript : public WorldScript
void OnBeforeConfigLoad(bool /*reload*/) override
{
- auctionbot->InitializeConfiguration();
+ sAHBot->InitializeConfiguration();
}
void OnStartup() override
{
LOG_INFO("server.loading", "Initialize AuctionHouseBot...");
- auctionbot->Initialize();
+ sAHBot->Initialize();
}
};
@@ -33,7 +46,7 @@ class AHBot_AuctionHouseScript : public AuctionHouseScript
void OnBeforeAuctionHouseMgrSendAuctionSuccessfulMail(AuctionHouseMgr* /*auctionHouseMgr*/, AuctionEntry* /*auction*/, Player* owner, uint32& /*owner_accId*/, uint32& /*profit*/, bool& sendNotification, bool& updateAchievementCriteria, bool& /*sendMail*/) override
{
- if (owner && owner->GetGUID().GetCounter() == auctionbot->GetAHBplayerGUID())
+ if (owner && owner->GetGUID().GetCounter() == sAHBot->GetAHBplayerGUID())
{
sendNotification = false;
updateAchievementCriteria = false;
@@ -42,29 +55,29 @@ class AHBot_AuctionHouseScript : public AuctionHouseScript
void OnBeforeAuctionHouseMgrSendAuctionExpiredMail(AuctionHouseMgr* /*auctionHouseMgr*/, AuctionEntry* /*auction*/, Player* owner, uint32& /*owner_accId*/, bool& sendNotification, bool& /*sendMail*/) override
{
- if (owner && owner->GetGUID().GetCounter() == auctionbot->GetAHBplayerGUID())
+ if (owner && owner->GetGUID().GetCounter() == sAHBot->GetAHBplayerGUID())
sendNotification = false;
}
void OnBeforeAuctionHouseMgrSendAuctionOutbiddedMail(AuctionHouseMgr* /*auctionHouseMgr*/, AuctionEntry* auction, Player* oldBidder, uint32& /*oldBidder_accId*/, Player* newBidder, uint32& newPrice, bool& /*sendNotification*/, bool& /*sendMail*/) override
{
if (oldBidder && !newBidder)
- oldBidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, ObjectGuid::Create(auctionbot->GetAHBplayerGUID()), newPrice, auction->GetAuctionOutBid(), auction->item_template);
+ oldBidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, ObjectGuid::Create(sAHBot->GetAHBplayerGUID()), newPrice, auction->GetAuctionOutBid(), auction->item_template);
}
void OnAuctionAdd(AuctionHouseObject* /*ah*/, AuctionEntry* auction) override
{
- auctionbot->IncrementItemCounts(auction);
+ sAHBot->IncrementItemCounts(auction);
}
void OnAuctionRemove(AuctionHouseObject* /*ah*/, AuctionEntry* auction) override
{
- auctionbot->DecrementItemCounts(auction, auction->item_template);
+ sAHBot->DecrementItemCounts(auction, auction->item_template);
}
void OnBeforeAuctionHouseMgrUpdate() override
{
- auctionbot->Update();
+ sAHBot->Update();
}
};
@@ -75,7 +88,7 @@ class AHBot_MailScript : public MailScript
void OnBeforeMailDraftSendMailTo(MailDraft* /*mailDraft*/, MailReceiver const& receiver, MailSender const& sender, MailCheckMask& /*checked*/, uint32& /*deliver_delay*/, uint32& /*custom_expiration*/, bool& deleteMailItemsFromDB, bool& sendMail) override
{
- if (receiver.GetPlayerGUIDLow() == auctionbot->GetAHBplayerGUID())
+ if (receiver.GetPlayerGUIDLow() == sAHBot->GetAHBplayerGUID())
{
if (sender.GetMailMessageType() == MAIL_AUCTION) // auction mail with items
deleteMailItemsFromDB = true;
diff --git a/src/AuctionHouseBot_loader.cpp b/src/AuctionHouseBot_loader.cpp
new file mode 100644
index 0000000..65b98a8
--- /dev/null
+++ b/src/AuctionHouseBot_loader.cpp
@@ -0,0 +1,27 @@
+/*
+ * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published by the
+ * Free Software Foundation; either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+
+// From SC
+void AddAHBotCommandScripts();
+void AddAHBotScripts();
+
+// Add all
+void Addmod_ah_botScripts()
+{
+ AddAHBotCommandScripts();
+ AddAHBotScripts();
+}
diff --git a/src/ItemIndex.cpp b/src/ItemIndex.cpp
new file mode 100644
index 0000000..fb0a307
--- /dev/null
+++ b/src/ItemIndex.cpp
@@ -0,0 +1,576 @@
+/*
+ * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published by the
+ * Free Software Foundation; either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+
+#include "ItemIndex.h"
+
+#include
+
+#include "Config.h"
+#include "WorldSession.h"
+#include "DatabaseEnv.h"
+#include "Log.h"
+#include "ObjectMgr.h"
+#include "SmartEnum.h"
+
+AuctionHouseIndex* AuctionHouseIndex::instance()
+{
+ static AuctionHouseIndex instance;
+ return &instance;
+}
+
+struct ItemFilter
+{
+ bool SellMethod{ false };
+
+ bool Vendor_Items{ false };
+ bool Loot_Items{ false };
+ bool Other_Items{ false };
+ bool Vendor_TGs{ false };
+ bool Loot_TGs{ false };
+ bool Other_TGs{ false };
+
+ bool No_Bind{ false };
+ bool Bind_When_Picked_Up{ false };
+ bool Bind_When_Equipped{ false };
+ bool Bind_When_Use{ false };
+ bool Bind_Quest_Item{ false };
+
+ bool DisablePermEnchant{ false };
+ bool DisableConjured{ false };
+ bool DisableGems{ false };
+ bool DisableMoney{ false };
+ bool DisableMoneyLoot{ false };
+ bool DisableLootable{ false };;
+ bool DisableKeys{ false };
+ bool DisableDuration{ false };
+ bool DisableBOP_Or_Quest_NoReqLevel{ false };
+
+ std::bitset<32> DisableClassItemsMask;
+
+ uint32 DisableItemsBelowLevel{ 0 };
+ uint32 DisableItemsAboveLevel{ 0 };
+ uint32 DisableTGsBelowLevel{ 0 };
+ uint32 DisableTGsAboveLevel{ 0 };
+ uint32 DisableItemsBelowGUID{ 0 };
+ uint32 DisableItemsAboveGUID{ 0 };
+ uint32 DisableTGsBelowGUID{ 0 };
+ uint32 DisableTGsAboveGUID{ 0 };
+ uint32 DisableItemsBelowReqLevel{ 0 };
+ uint32 DisableItemsAboveReqLevel{ 0 };
+ uint32 DisableTGsBelowReqLevel{ 0 };
+ uint32 DisableTGsAboveReqLevel{ 0 };
+ uint32 DisableItemsBelowReqSkillRank{ 0 };
+ uint32 DisableItemsAboveReqSkillRank{ 0 };
+ uint32 DisableTGsBelowReqSkillRank{ 0 };
+ uint32 DisableTGsAboveReqSkillRank{ 0 };
+
+ std::unordered_set disabledItems{};
+ std::unordered_set npcItems{};
+ std::unordered_set lootItems{};
+
+ ItemFilter()
+ {
+ QueryResult results = WorldDatabase.Query("SELECT item FROM mod_auctionhousebot_disabled_items");
+
+ if (results)
+ {
+ do
+ {
+ const Field* fields = results->Fetch();
+ disabledItems.emplace(fields[0].Get());
+ } while (results->NextRow());
+ }
+
+ std::string npcQuery = "SELECT distinct item FROM npc_vendor";
+ results = WorldDatabase.Query(npcQuery);
+ if (results)
+ {
+ do
+ {
+ const Field* fields = results->Fetch();
+ npcItems.emplace(fields[0].Get());
+ } while (results->NextRow());
+ }
+ else
+ LOG_ERROR("module.ahbot", "AuctionHouseBot: \"{}\" failed", npcQuery);
+
+ std::string lootQuery = "SELECT item FROM creature_loot_template UNION "
+ "SELECT item FROM reference_loot_template UNION "
+ "SELECT item FROM disenchant_loot_template UNION "
+ "SELECT item FROM fishing_loot_template UNION "
+ "SELECT item FROM gameobject_loot_template UNION "
+ "SELECT item FROM item_loot_template UNION "
+ "SELECT item FROM milling_loot_template UNION "
+ "SELECT item FROM pickpocketing_loot_template UNION "
+ "SELECT item FROM prospecting_loot_template UNION "
+ "SELECT item FROM skinning_loot_template";
+
+ results = WorldDatabase.Query(lootQuery);
+ if (results)
+ {
+ do
+ {
+ const Field* fields = results->Fetch();
+ lootItems.emplace(fields[0].Get());
+ } while (results->NextRow());
+ }
+ else
+ LOG_ERROR("module.ahbot", "AuctionHouseBot: \"{}\" failed", lootQuery);
+
+
+
+ SellMethod = sConfigMgr->GetOption("AuctionHouseBot.UseBuyPriceForSeller", false);
+
+ // Begin Filters
+
+ Vendor_Items = sConfigMgr->GetOption("AuctionHouseBot.VendorItems", false);
+ Loot_Items = sConfigMgr->GetOption("AuctionHouseBot.LootItems", true);
+ Other_Items = sConfigMgr->GetOption("AuctionHouseBot.OtherItems", false);
+ Vendor_TGs = sConfigMgr->GetOption("AuctionHouseBot.VendorTradeGoods", false);
+ Loot_TGs = sConfigMgr->GetOption("AuctionHouseBot.LootTradeGoods", true);
+ Other_TGs = sConfigMgr->GetOption("AuctionHouseBot.OtherTradeGoods", false);
+
+ No_Bind = sConfigMgr->GetOption("AuctionHouseBot.No_Bind", true);
+ Bind_When_Picked_Up = sConfigMgr->GetOption("AuctionHouseBot.Bind_When_Picked_Up", false);
+ Bind_When_Equipped = sConfigMgr->GetOption("AuctionHouseBot.Bind_When_Equipped", true);
+ Bind_When_Use = sConfigMgr->GetOption("AuctionHouseBot.Bind_When_Use", true);
+ Bind_Quest_Item = sConfigMgr->GetOption("AuctionHouseBot.Bind_Quest_Item", false);
+
+ DisablePermEnchant = sConfigMgr->GetOption("AuctionHouseBot.DisablePermEnchant", false);
+ DisableConjured = sConfigMgr->GetOption("AuctionHouseBot.DisableConjured", false);
+ DisableGems = sConfigMgr->GetOption("AuctionHouseBot.DisableGems", false);
+ DisableMoney = sConfigMgr->GetOption("AuctionHouseBot.DisableMoney", false);
+ DisableMoneyLoot = sConfigMgr->GetOption("AuctionHouseBot.DisableMoneyLoot", false);
+ DisableLootable = sConfigMgr->GetOption("AuctionHouseBot.DisableLootable", false);
+ DisableKeys = sConfigMgr->GetOption("AuctionHouseBot.DisableKeys", false);
+ DisableDuration = sConfigMgr->GetOption("AuctionHouseBot.DisableDuration", false);
+ DisableBOP_Or_Quest_NoReqLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableBOP_Or_Quest_NoReqLevel", false);
+
+ // Classes are 1 based index, to get their flag bit we need zero based, so -1
+ DisableClassItemsMask.set(Classes::CLASS_WARRIOR - 1, sConfigMgr->GetOption("AuctionHouseBot.DisableWarriorItems", false));
+ DisableClassItemsMask.set(Classes::CLASS_PALADIN - 1, sConfigMgr->GetOption("AuctionHouseBot.DisablePaladinItems", false));
+ DisableClassItemsMask.set(Classes::CLASS_HUNTER - 1, sConfigMgr->GetOption("AuctionHouseBot.DisableHunterItems", false));
+ DisableClassItemsMask.set(Classes::CLASS_ROGUE - 1, sConfigMgr->GetOption("AuctionHouseBot.DisableRogueItems", false));
+ DisableClassItemsMask.set(Classes::CLASS_PRIEST - 1, sConfigMgr->GetOption("AuctionHouseBot.DisablePriestItems", false));
+ DisableClassItemsMask.set(Classes::CLASS_DEATH_KNIGHT - 1, sConfigMgr->GetOption("AuctionHouseBot.DisableDKItems", false));
+ DisableClassItemsMask.set(Classes::CLASS_SHAMAN - 1, sConfigMgr->GetOption("AuctionHouseBot.DisableShamanItems", false));
+ DisableClassItemsMask.set(Classes::CLASS_MAGE - 1, sConfigMgr->GetOption("AuctionHouseBot.DisableMageItems", false));
+ DisableClassItemsMask.set(Classes::CLASS_WARLOCK - 1, sConfigMgr->GetOption("AuctionHouseBot.DisableWarlockItems", false));
+ DisableClassItemsMask.set(10 - 1, sConfigMgr->GetOption("AuctionHouseBot.DisableUnusedClassItems", false));
+ DisableClassItemsMask.set(Classes::CLASS_DRUID - 1, sConfigMgr->GetOption("AuctionHouseBot.DisableDruidItems", false));
+ DisableClassItemsMask.set(Classes::CLASS_WARRIOR - 1, sConfigMgr->GetOption("AuctionHouseBot.DisableWarriorItems", false));
+
+ DisableItemsBelowLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableItemsBelowLevel", 0);
+ DisableItemsAboveLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableItemsAboveLevel", 0);
+ DisableTGsBelowLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableTGsBelowLevel", 0);
+ DisableTGsAboveLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableTGsAboveLevel", 0);
+ DisableItemsBelowGUID = sConfigMgr->GetOption("AuctionHouseBot.DisableItemsBelowGUID", 0);
+ DisableItemsAboveGUID = sConfigMgr->GetOption("AuctionHouseBot.DisableItemsAboveGUID", 0);
+ DisableTGsBelowGUID = sConfigMgr->GetOption("AuctionHouseBot.DisableTGsBelowGUID", 0);
+ DisableTGsAboveGUID = sConfigMgr->GetOption("AuctionHouseBot.DisableTGsAboveGUID", 0);
+ DisableItemsBelowReqLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableItemsBelowReqLevel", 0);
+ DisableItemsAboveReqLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableItemsAboveReqLevel", 0);
+ DisableTGsBelowReqLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableTGsBelowReqLevel", 0);
+ DisableTGsAboveReqLevel = sConfigMgr->GetOption("AuctionHouseBot.DisableTGsAboveReqLevel", 0);
+ DisableItemsBelowReqSkillRank = sConfigMgr->GetOption("AuctionHouseBot.DisableItemsBelowReqSkillRank", 0);
+ DisableItemsAboveReqSkillRank = sConfigMgr->GetOption("AuctionHouseBot.DisableItemsAboveReqSkillRank", 0);
+ DisableTGsBelowReqSkillRank = sConfigMgr->GetOption("AuctionHouseBot.DisableTGsBelowReqSkillRank", 0);
+ DisableTGsAboveReqSkillRank = sConfigMgr->GetOption("AuctionHouseBot.DisableTGsAboveReqSkillRank", 0);
+ }
+
+ bool IsAccepted(const ItemTemplate& itemTemplate) const
+ {
+ switch (itemTemplate.Bonding)
+ {
+ case NO_BIND:
+ if (!No_Bind)
+ return false;
+ break;
+ case BIND_WHEN_PICKED_UP:
+ if (!Bind_When_Picked_Up)
+ return false;
+ break;
+ case BIND_WHEN_EQUIPED:
+ if (!Bind_When_Equipped)
+ return false;
+ break;
+ case BIND_WHEN_USE:
+ if (!Bind_When_Use)
+ return false;
+ break;
+ case BIND_QUEST_ITEM:
+ if (!Bind_Quest_Item)
+ return false;
+ break;
+ default:
+ return false;
+ }
+
+ if (SellMethod)
+ {
+ if (!itemTemplate.BuyPrice)
+ return false;
+ }
+ else
+ {
+ if (!itemTemplate.SellPrice)
+ return false;
+ }
+
+ if (itemTemplate.Quality > ITEM_QUALITY_ARTIFACT)
+ return false;
+
+ auto isVendorItem = [this](const ItemTemplate& itemTemplate)
+ {
+ return npcItems.contains(itemTemplate.ItemId);
+ };
+
+ auto isLootItem = [this](const ItemTemplate& itemTemplate)
+ {
+ return lootItems.contains(itemTemplate.ItemId);
+ };
+
+ if (itemTemplate.Class != ITEM_CLASS_TRADE_GOODS)
+ {
+ // Item checks
+
+ if (!Vendor_Items)
+ {
+ if (isVendorItem(itemTemplate))
+ return false;
+ }
+
+ if (!Loot_Items)
+ {
+ if (isLootItem(itemTemplate))
+ return false;
+ }
+
+ if (!Other_Items)
+ {
+ if (!isLootItem(itemTemplate) && !isVendorItem(itemTemplate))
+ return false;
+ }
+ }
+ else if (itemTemplate.Class == ITEM_CLASS_TRADE_GOODS)
+ {
+ // Tradegood checks
+
+ if (!Vendor_TGs)
+ {
+ if (isVendorItem(itemTemplate))
+ return false;
+ }
+
+ if (!Loot_TGs)
+ {
+ if (isLootItem(itemTemplate))
+ return false;
+ }
+
+ if (!Other_TGs)
+ {
+ if (!isLootItem(itemTemplate) && !isVendorItem(itemTemplate))
+ return false;
+ }
+ }
+
+
+ // Disable items by Id
+ if (disabledItems.contains(itemTemplate.ItemId))
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (PTR/Beta/Unused Item)", itemTemplate.ItemId);
+ return false;
+ }
+
+ // Disable permanent enchants items
+ if (DisablePermEnchant && itemTemplate.Class == ITEM_CLASS_PERMANENT)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (Permanent Enchant Item)", itemTemplate.ItemId);
+ return false;
+ }
+
+ // Disable conjured items
+ if (DisableConjured && itemTemplate.IsConjuredConsumable())
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (Conjured Consumable)", itemTemplate.ItemId);
+ return false;
+ }
+
+ // Disable gems
+ if (DisableGems && itemTemplate.Class == ITEM_CLASS_GEM)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (Gem)", itemTemplate.ItemId);
+ return false;
+ }
+
+ // Disable money
+ if (DisableMoney && itemTemplate.Class == ITEM_CLASS_MONEY)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (Money)", itemTemplate.ItemId);
+ return false;
+ }
+
+ // Disable moneyloot
+ if (DisableMoneyLoot && itemTemplate.MinMoneyLoot)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (MoneyLoot)", itemTemplate.ItemId);
+ return false;
+ }
+
+ // Disable lootable items
+ if (DisableLootable && itemTemplate.Flags & 4)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (Lootable Item)", itemTemplate.ItemId);
+ return false;
+ }
+
+ // Disable Keys
+ if (DisableKeys && itemTemplate.Class == ITEM_CLASS_KEY)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (Quest Item)", itemTemplate.ItemId);
+ return false;
+ }
+
+ // Disable items with duration
+ if (DisableDuration && itemTemplate.Duration)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (Has a Duration)", itemTemplate.ItemId);
+ return false;
+ }
+
+ // Disable items which are BOP or Quest Items and have a required level lower than the item level
+ if (DisableBOP_Or_Quest_NoReqLevel && ((itemTemplate.Bonding == BIND_WHEN_PICKED_UP || itemTemplate.Bonding == BIND_QUEST_ITEM) && (itemTemplate.RequiredLevel < itemTemplate.ItemLevel)))
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (BOP or BQI and Required Level is less than Item Level)", itemTemplate.ItemId);
+ return false;
+ }
+
+
+ // We have disabled some class-specific items, lets see if this is one of them
+ if (DisableClassItemsMask.any())
+ {
+ const std::bitset<32> allowableClass(itemTemplate.AllowableClass);
+
+ // If this item is specific for just one class (as opposed to multiple classes), then check if its a class that we have disabled
+ if (allowableClass.count() == 1)
+ {
+ if ((DisableClassItemsMask & allowableClass).any())
+ {
+ // slightly ugly, find index of first bit that is set, to find out which class this is
+
+ Classes itemAllowClass = Classes::CLASS_NONE;
+ for (uint8 classBit = 0; classBit < MAX_CLASSES; ++classBit)
+ if (allowableClass.test(classBit))
+ itemAllowClass = static_cast(classBit + 1); // Zero based index back to 1 based
+
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled ({} Item)", itemTemplate.ItemId, Acore::Impl::EnumUtilsImpl::EnumUtils::ToString(itemAllowClass).Title);
+ return false;
+ }
+ }
+ }
+
+ if (itemTemplate.Class != ITEM_CLASS_TRADE_GOODS)
+ {
+ // Item filters
+
+ // Disable Items below level X
+ if (DisableItemsBelowLevel && itemTemplate.ItemLevel < DisableItemsBelowLevel)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (Item Level = {})", itemTemplate.ItemId, itemTemplate.ItemLevel);
+ return false;
+ }
+
+ // Disable Items above level X
+ if (DisableItemsAboveLevel && itemTemplate.ItemLevel > DisableItemsAboveLevel)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (Item Level = {})", itemTemplate.ItemId, itemTemplate.ItemLevel);
+ return false;
+ }
+
+ // Disable Items below GUID X
+ if (DisableItemsBelowGUID && itemTemplate.ItemId < DisableItemsBelowGUID)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (Item Level = {})", itemTemplate.ItemId, itemTemplate.ItemLevel);
+ return false;
+ }
+
+ // Disable Items above GUID X
+ if (DisableItemsAboveGUID && itemTemplate.ItemId > DisableItemsAboveGUID)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (Item Level = {})", itemTemplate.ItemId, itemTemplate.ItemLevel);
+ return false;
+ }
+ }
+ else
+ {
+ // TradeGood filters
+
+ // Disable Trade Goods below level X
+ if (DisableTGsBelowLevel && itemTemplate.ItemLevel < DisableTGsBelowLevel)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Trade Good {} disabled (Trade Good Level = {})", itemTemplate.ItemId, itemTemplate.ItemLevel);
+ return false;
+ }
+
+ // Disable Trade Goods above level X
+ if (DisableTGsAboveLevel && itemTemplate.ItemLevel > DisableTGsAboveLevel)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Trade Good {} disabled (Trade Good Level = {})", itemTemplate.ItemId, itemTemplate.ItemLevel);
+ return false;
+ }
+
+ // Disable Trade Goods below GUID X
+ if (DisableTGsBelowGUID && itemTemplate.ItemId < DisableTGsBelowGUID)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (Trade Good Level = {})", itemTemplate.ItemId, itemTemplate.ItemLevel);
+ return false;
+ }
+
+ // Disable Trade Goods above GUID X
+ if (DisableTGsAboveGUID && itemTemplate.ItemId > DisableTGsAboveGUID)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (Trade Good Level = {})", itemTemplate.ItemId, itemTemplate.ItemLevel);
+ return false;
+ }
+ }
+
+ // Disable Items for level lower than X
+ if (DisableItemsBelowReqLevel && itemTemplate.RequiredLevel < DisableItemsBelowReqLevel)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (RequiredLevel = {})", itemTemplate.ItemId, itemTemplate.RequiredLevel);
+ return false;
+ }
+
+ // Disable Items for level higher than X
+ if (DisableItemsAboveReqLevel && itemTemplate.RequiredLevel > DisableItemsAboveReqLevel)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (RequiredLevel = {})", itemTemplate.ItemId, itemTemplate.RequiredLevel);
+ return false;
+ }
+
+ // Disable Trade Goods for level lower than X
+ if (DisableTGsBelowReqLevel && itemTemplate.RequiredLevel < DisableTGsBelowReqLevel)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Trade Good {} disabled (RequiredLevel = {})", itemTemplate.ItemId, itemTemplate.RequiredLevel);
+ return false;
+ }
+
+ // Disable Trade Goods for level higher than X
+ if (DisableTGsAboveReqLevel && itemTemplate.RequiredLevel > DisableTGsAboveReqLevel)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Trade Good {} disabled (RequiredLevel = {})", itemTemplate.ItemId, itemTemplate.RequiredLevel);
+ return false;
+ }
+
+ // Disable Items that require skill lower than X
+ if (DisableItemsBelowReqSkillRank && itemTemplate.RequiredSkillRank < DisableItemsBelowReqSkillRank)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (RequiredSkillRank = {})", itemTemplate.ItemId, itemTemplate.RequiredSkillRank);
+ return false;
+ }
+
+ // Disable Items that require skill higher than X
+ if (DisableItemsAboveReqSkillRank && itemTemplate.RequiredSkillRank > DisableItemsAboveReqSkillRank)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (RequiredSkillRank = {})", itemTemplate.ItemId, itemTemplate.RequiredSkillRank);
+ return false;
+ }
+
+ // Disable Trade Goods that require skill lower than X
+ if (DisableTGsBelowReqSkillRank && itemTemplate.RequiredSkillRank < DisableTGsBelowReqSkillRank)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (RequiredSkillRank = {})", itemTemplate.ItemId, itemTemplate.RequiredSkillRank);
+ return false;
+ }
+
+ // Disable Trade Goods that require skill higher than X
+ if (DisableTGsAboveReqSkillRank && itemTemplate.RequiredSkillRank > DisableTGsAboveReqSkillRank)
+ {
+ LOG_DEBUG("module.ahbot.filters", "AuctionHouseBot: Item {} disabled (RequiredSkillRank = {})", itemTemplate.ItemId, itemTemplate.RequiredSkillRank);
+ return false;
+ }
+
+ return true;
+ }
+};
+
+
+
+bool AuctionHouseIndex::InitializeItemsToSell()
+{
+ const ItemFilter filter;
+
+
+ for (auto const& [itemID, itemTemplate] : *sObjectMgr->GetItemTemplateStore())
+ {
+ WPAssert(itemTemplate.ItemId, "ItemID cannot be zero");
+
+ if (!filter.IsAccepted(itemTemplate))
+ continue;
+
+ const uint32 itemQualityIndexStart = itemTemplate.Class == ITEM_CLASS_TRADE_GOODS ? 0 : AHB_DEFAULT_QUALITY_SIZE;
+ _itemsBin[itemQualityIndexStart + itemTemplate.Quality].emplace_back(itemTemplate.ItemId);
+ }
+
+ std::size_t totalItems = std::accumulate(_itemsBin.begin(), _itemsBin.end(), 0u, [](const std::size_t c, const std::vector& v) {return c + v.size(); });
+
+ if (!totalItems)
+ {
+ LOG_ERROR("module.ahbot", "AuctionHouseBot: No items");
+ return false;
+ }
+
+ LOG_INFO("module.ahbot", "AuctionHouseBot:");
+ LOG_INFO("module.ahbot", "{} disabled items", filter.disabledItems.size());
+ LOG_INFO("module.ahbot", "Loaded {} grey trade goods", _itemsBin[ITEM_QUALITY_POOR].size());
+ LOG_INFO("module.ahbot", "Loaded {} white trade goods", _itemsBin[ITEM_QUALITY_NORMAL].size());
+ LOG_INFO("module.ahbot", "Loaded {} green trade goods", _itemsBin[ITEM_QUALITY_UNCOMMON].size());
+ LOG_INFO("module.ahbot", "Loaded {} blue trade goods", _itemsBin[ITEM_QUALITY_RARE].size());
+ LOG_INFO("module.ahbot", "Loaded {} purple trade goods", _itemsBin[ITEM_QUALITY_EPIC].size());
+ LOG_INFO("module.ahbot", "Loaded {} orange trade goods", _itemsBin[ITEM_QUALITY_LEGENDARY].size());
+ LOG_INFO("module.ahbot", "Loaded {} yellow trade goods", _itemsBin[ITEM_QUALITY_ARTIFACT].size());
+ LOG_INFO("module.ahbot", "Loaded {} grey items", _itemsBin[AHB_ITEM_QUALITY_POOR].size());
+ LOG_INFO("module.ahbot", "Loaded {} white items", _itemsBin[AHB_ITEM_QUALITY_NORMAL].size());
+ LOG_INFO("module.ahbot", "Loaded {} green items", _itemsBin[AHB_ITEM_QUALITY_UNCOMMON].size());
+ LOG_INFO("module.ahbot", "Loaded {} blue items", _itemsBin[AHB_ITEM_QUALITY_RARE].size());
+ LOG_INFO("module.ahbot", "Loaded {} purple items", _itemsBin[AHB_ITEM_QUALITY_EPIC].size());
+ LOG_INFO("module.ahbot", "Loaded {} orange items", _itemsBin[AHB_ITEM_QUALITY_LEGENDARY].size());
+ LOG_INFO("module.ahbot", "Loaded {} yellow items", _itemsBin[AHB_ITEM_QUALITY_ARTIFACT].size());
+
+ return true;
+ /*
+ AuctionHouseBot:
+ 5957 disabled items
+ loaded 5 grey trade goods
+ loaded 471 white trade goods
+ loaded 58 green trade goods
+ loaded 26 blue trade goods
+ loaded 3 purple trade goods
+ loaded 1 orange trade goods
+ loaded 0 yellow trade goods
+ loaded 1633 grey items
+ loaded 2771 white items
+ loaded 5520 green items
+ loaded 1645 blue items
+ loaded 809 purple items
+ loaded 0 orange items
+ loaded 1 yellow items
+ */
+
+}
+
diff --git a/src/ItemIndex.h b/src/ItemIndex.h
new file mode 100644
index 0000000..e61f57b
--- /dev/null
+++ b/src/ItemIndex.h
@@ -0,0 +1,53 @@
+/*
+ * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published by the
+ * Free Software Foundation; either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+
+#ifndef ITEM_INDEX_H
+#define ITEM_INDEX_H
+
+#include "ObjectGuid.h"
+#include "ItemTemplate.h"
+#include "AuctionHouseBotConfig.h"
+#include "DatabaseEnvFwd.h"
+#include
+#include
+
+class AuctionHouseIndex
+{
+public:
+ AuctionHouseIndex() = default;
+ ~AuctionHouseIndex() = default;
+
+ static AuctionHouseIndex* instance();
+
+ bool InitializeItemsToSell();
+
+ const std::vector& GetItemBin(uint32 quality) const
+ {
+ return _itemsBin[quality];
+ }
+
+private:
+
+
+ std::array, AHB_MAX_QUALITY> _itemsBin{};
+
+};
+
+
+#define sAHIndex AuctionHouseIndex::instance()
+
+#endif
diff --git a/src/ah_bot_loader.cpp b/src/ah_bot_loader.cpp
deleted file mode 100644
index 1344243..0000000
--- a/src/ah_bot_loader.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
- * Copyright (C) 2021+ WarheadCore
- */
-
-// From SC
-void AddAHBotCommandScripts();
-void AddAHBotScripts();
-
-// Add all
-void Addmod_ah_botScripts()
-{
- AddAHBotCommandScripts();
- AddAHBotScripts();
-}
diff --git a/src/cs_ah_bot.cpp b/src/cs_ah_bot.cpp
index 469f7b5..07d64a3 100644
--- a/src/cs_ah_bot.cpp
+++ b/src/cs_ah_bot.cpp
@@ -1,27 +1,20 @@
/*
- * Copyright (C) 2008-2012 TrinityCore