· 8 years ago · May 20, 2018, 04:58 AM
1diff --git a/README.AHBOT b/README.AHBOT
2new file mode 100644
3index 0000000..dc42018
4--- /dev/null
5+++ b/README.AHBOT
6@@ -0,0 +1,179 @@
7+This patch modifies the core so it populates the auction houses with items. It
8+makes the game feel a bit more like official. Items and prices are chosen
9+randomly based on the parameters you define. If an auction expires, auctions
10+are deleted quietly. AHBot will not buy it's own items, and will not receive
11+mail from the AH or get returned mail.
12+
13+===============================================================================
14+~~HOW TO CONFIGURE~~
15+===============================================================================
16+Step 1.) Create a character that you are going to use as the auction house bot
17+ character. This character will be the auction's owner for all the
18+ items created by the bot.
19+Step 2.) Go into the realm database and note the account number for the
20+ character.
21+Step 3.) Go into the characters database and note the character's GUID.
22+Step 4.) Log in at least once with this character.
23+ (Do not change the configuration before this)
24+Step 5.) Tune the configuration options in the configuration file and the
25+ Database.
26+
27+#These are the settings in the configuration file:
28+AuctionHouseBot.EnableSeller = 0
29+AuctionHouseBot.EnableBuyer = 0
30+AuctionHouseBot.Account = 0
31+AuctionHouseBot.GUID = 0
32+AuctionHouseBot.VendorItems = 0
33+AuctionHouseBot.LootItems = 1
34+AuctionHouseBot.OtherItems = 0
35+AuctionHouseBot.No_Bind = 1
36+AuctionHouseBot.Bind_When_Picked_Up = 0
37+AuctionHouseBot.Bind_When_Equipped = 1
38+AuctionHouseBot.Bind_When_Use = 1
39+AuctionHouseBot.Bind_Quest_Item = 0
40+AuctionHouseBot.ItemsPerCycle = 200
41+AuctionHouseBot.UseBuyPriceForSeller = 0
42+AuctionHouseBot.UseBuyPriceForBuyer = 0
43+
44+AuctionHouseBot.EnableSeller enables (1) or disables (0) the Seller
45+AuctionHouseBot.EnableBuyer enables (1) or disables (0) the Buyer
46+AuctionHouseBot.Account is the account number (in realmd->account table) of the player you want to run as the auction bot. Note: a value of 0 will disable the bot.
47+AuctionHouseBot.GUID is the GUID (in characters->characters table) of the player you want to run as the auction bot. Note: a value of 0 will disable the bot.
48+AuctionHouseBot.VendorItems is a boolean value (0 or 1) that indicates whether to include Vendor only items
49+AuctionHouseBot.LootItems is a boolean value (0 or 1) that indicates whether to include Loot/Fish/Skin/etc. only items
50+AuctionHouseBot.OtherItems is a boolean value (0 or 1) that indicates whether to include Other items not covered by the first 2
51+AuctionHouseBot.No_Bind is a boolean value (0 or 1) that indicates whether to include items with a bonding of 0
52+AuctionHouseBot.Bind_When_Picked_Up = is a boolean value (0 or 1) that indicates whether to include items with a bonding of 1
53+AuctionHouseBot.Bind_When_Equipped = is a boolean value (0 or 1) that indicates whether to include items with a bonding of 2
54+AuctionHouseBot.Bind_When_Use = is a boolean value (0 or 1) that indicates whether to include items with a bonding of 3
55+AuctionHouseBot.Bind_Quest_Item = is a boolean value (0 or 1) that indicates whether to include items with a bonding of 4
56+AuctionHouseBot.ItemsPerCycle determines how many items are added each time AHBot is run (once per minute, by default)
57+AuctionHouseBot.UseBuyPriceForSeller Use SellPrice (0) or BuyPrice (1) for determining prices
58+AuctionHouseBot.UseBuyPriceForBuyer Use SellPrice (0) or BuyPrice (1) for determining prices
59+
60+#These are the settings in the Database:
61+#Each Auctionhouse has it's own set of these
62+
63+MinItems = 0
64+#The Minimum number of items you want to keep in the auction houses.
65+#(default 0 - minimum will be the same as maximum).
66+#If it is higher than the value of the corresponding maxItems setting,
67+#it will be set down to match the maxItems setting.
68+
69+MaxItems = 0
70+#The Maximum number of items you want to keep in the auction houses.
71+
72+MinTime = 8
73+#The minimum number of hours for an auction.
74+
75+MaxTime = 24
76+#The maximum number of hours for an auction.
77+
78+#These must add up to 100 each one is the percentage
79+#of the auction items that should be trade goods of
80+#that quality. A value of 0 will disable.
81+
82+PercentGreyTradeGoods = 0
83+PercentWhiteTradeGoods = 27
84+PercentGreenTradeGoods = 12
85+PercentBlueTradeGoods = 10
86+PercentPurpleTradeGoods = 1
87+PercentOrangeTradeGoods = 0
88+PercentYellowTradeGoods = 0
89+
90+PercentGreyItems = 0
91+PercentWhiteItems = 10
92+PercentGreenItems = 30
93+PercentBlueItems = 8
94+PercentPurpleItems = 2
95+PercentOrangeItems = 0
96+PercentYellowItems = 0
97+
98+#MinPrice(Color) is the minimum price adjustment for items. For example the default is 150, which means 150%. So if an item vendors for 1g it would go to auction for a minimum of 1.5g.
99+#MaxPrice(Color) is the maximum price adjustment for items.
100+#MinBidPrice(Color) these two control the starting bid as a percent of the buyout price. For example, if MinBidPrice is 30 and MaxBidPrice is 80 the starting bid for the auction will randomly be between 30-80% of the randomly chosen buyout price.
101+#MaxBidPrice(Color) these two control the starting bid as a percent of the buyout price. For example, if MinBidPrice is 30 and MaxBidPrice is 80 the starting bid for the auction will randomly be between 30-80% of the randomly chosen buyout price.
102+#MaxStack(Color) is maximum stack size to create for this quality type. A value of zero will disable the maximum stack size for this quality allowing the bot to create stacks (of random size) of items as big as the item type allows.
103+
104+MinPriceGrey = 100
105+MaxPriceGrey = 150
106+MinBidPriceGrey = 70
107+MaxBidPriceGrey = 100
108+MaxStackGrey = 0
109+MinPriceWhite = 150
110+MaxPriceWhite = 250
111+MinBidPriceWhite = 70
112+MaxBidPriceWhite = 100
113+MaxStackWhite = 0
114+MinPriceGreen = 800
115+MaxPriceGreen = 1400
116+MinBidPriceGreen = 80
117+MaxBidPriceGreen = 100
118+MaxStackGreen = 3
119+MinPriceBlue = 1250
120+MaxPriceBlue = 1750
121+MinBidPriceBlue = 75
122+MaxBidPriceBlue = 100
123+MaxStackBlue = 2
124+MinPricePurple = 2250
125+MaxPricePurple = 4550
126+MinBidPricePurple = 80
127+MaxBidPricePurple = 100
128+MaxStackPurple = 1
129+MinPriceOrange = 4250
130+MaxPriceOrange = 5550
131+MinBidPriceOrange = 80
132+MaxBidPriceOrange = 100
133+MaxStackOrange = 0
134+MinPriceYellow = 5250
135+MaxPriceYellow = 6550
136+MinBidPriceYellow = 80
137+MaxBidPriceYellow = 100
138+MaxStackYellow = 0
139+
140+#These are the multipliers that are applied to the vendor price for an item, that determines if AHBot will buy it or not.
141+#1 means AHBot will pay the same as (or less than) a vendor would pay, 2 means up to twice as much, etc.
142+
143+BuyerPriceGrey = 1
144+BuyerPriceWhite = 1
145+BuyerPriceGreen = 5
146+BuyerPriceBlue = 12
147+BuyerPricePurple = 15
148+BuyerPriceOrange = 20
149+BuyerPriceYellow = 22
150+
151+#BuyerBiddingInterval is the time (in minutes) between bids.
152+#BuyerBidsPerInterval is the number of bids the buyer will make in a cycle
153+
154+BuyerBiddingInterval = 1
155+BuyerBidsPerInterval = 1
156+
157+
158+
159+How to use ahcommands from the console (CLI) or in game with GM level 3 players:
160+ahbotoptions - will display usage instructions
161+ahbotoptions help - will display the list of commands
162+
163+ahexpire - will expire all the auctions in the requested auction house that were created by AHBot.
164+minitems - will set the minimum number of items in the AH before it starts being filled again.
165+maxitems - will set the maximum number of items in the AH.
166+mintime - will set the minimum time (in hours) for auctions to expire.
167+maxtime - will set the maximum time (in hours) for auctions to expire.
168+percentages - will set the percentage of each quality in the AH
169+minprice - will set the minimum price multiplier for auctions.
170+maxprice - will set the maximum price multiplier for auctions.
171+minbidprice - will set the minimum starting bid as a percent of the buyout price for auctions.
172+maxbidprice - will set the maximum starting bid as a percent of the buyout price for auctions.
173+maxstack - will set the maximum number of items in stacks for auctions. 0 will set the maximum to the maximum for that item type.
174+buyerprice - will set the bid price multiplier for auctions.
175+biddinginterval - will set the number of minutes between bids on auctions.
176+bidsperinterval - will set the number of bids to enter per cycle.
177+
178+The auction house IDs are:
179+2 - Alliance
180+6 - Horde
181+7 - Neutral
182+
183+AHBot Originally made by Chris K.
184+Much thanks to Chris K, grether and Dolomit6!
185+AHBot Now includes AHBuyer created by Kerbe as a derivative of AHBot, and later modified by Paradox
186diff --git a/sql/characters_auctionhousebot.sql b/sql/characters_auctionhousebot.sql
187new file mode 100644
188index 0000000..9941816
189--- /dev/null
190+++ b/sql/characters_auctionhousebot.sql
191@@ -0,0 +1,95 @@
192+/*
193+SQLyog Community Edition- MySQL GUI v6.03
194+Host - 5.0.51b-community-nt : Database - characters2
195+*********************************************************************
196+Server version : 5.0.51b-community-nt
197+*/
198+
199+/*!40101 SET NAMES utf8 */;
200+
201+/*!40101 SET SQL_MODE=''*/;
202+
203+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
204+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
205+
206+/*Table structure for table `auctionhousebot` */
207+
208+DROP TABLE IF EXISTS `auctionhousebot`;
209+CREATE TABLE `auctionhousebot` (
210+ `auctionhouse` int(11) NOT NULL default '0' COMMENT 'mapID of the auctionhouse.',
211+ `name` char(25) default NULL COMMENT 'Text name of the auctionhouse.',
212+ `minitems` int(11) default '0' COMMENT 'This is the minimum number of items you want to keep in the auction house. a 0 here will make it the same as the maximum.',
213+ `maxitems` int(11) default '0' COMMENT 'This is the number of items you want to keep in the auction house.',
214+ `mintime` int(11) default '8' COMMENT 'Sets the minimum number of hours for an auction.',
215+ `maxtime` int(11) default '24' COMMENT 'Sets the maximum number of hours for an auction.',
216+ `percentgreytradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Grey Trade Goods auction items',
217+ `percentwhitetradegoods` int(11) default '27' COMMENT 'Sets the percentage of the White Trade Goods auction items',
218+ `percentgreentradegoods` int(11) default '12' COMMENT 'Sets the percentage of the Green Trade Goods auction items',
219+ `percentbluetradegoods` int(11) default '10' COMMENT 'Sets the percentage of the Blue Trade Goods auction items',
220+ `percentpurpletradegoods` int(11) default '1' COMMENT 'Sets the percentage of the Purple Trade Goods auction items',
221+ `percentorangetradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Orange Trade Goods auction items',
222+ `percentyellowtradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Yellow Trade Goods auction items',
223+ `percentgreyitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Grey auction items',
224+ `percentwhiteitems` int(11) default '10' COMMENT 'Sets the percentage of the non trade White auction items',
225+ `percentgreenitems` int(11) default '30' COMMENT 'Sets the percentage of the non trade Green auction items',
226+ `percentblueitems` int(11) default '8' COMMENT 'Sets the percentage of the non trade Blue auction items',
227+ `percentpurpleitems` int(11) default '2' COMMENT 'Sets the percentage of the non trade Purple auction items',
228+ `percentorangeitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Orange auction items',
229+ `percentyellowitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Yellow auction items',
230+ `minpricegrey` int(11) default '100' COMMENT 'Minimum price of Grey items (percentage).',
231+ `maxpricegrey` int(11) default '150' COMMENT 'Maximum price of Grey items (percentage).',
232+ `minpricewhite` int(11) default '150' COMMENT 'Minimum price of White items (percentage).',
233+ `maxpricewhite` int(11) default '250' COMMENT 'Maximum price of White items (percentage).',
234+ `minpricegreen` int(11) default '800' COMMENT 'Minimum price of Green items (percentage).',
235+ `maxpricegreen` int(11) default '1400' COMMENT 'Maximum price of Green items (percentage).',
236+ `minpriceblue` int(11) default '1250' COMMENT 'Minimum price of Blue items (percentage).',
237+ `maxpriceblue` int(11) default '1750' COMMENT 'Maximum price of Blue items (percentage).',
238+ `minpricepurple` int(11) default '2250' COMMENT 'Minimum price of Purple items (percentage).',
239+ `maxpricepurple` int(11) default '4550' COMMENT 'Maximum price of Purple items (percentage).',
240+ `minpriceorange` int(11) default '3250' COMMENT 'Minimum price of Orange items (percentage).',
241+ `maxpriceorange` int(11) default '5550' COMMENT 'Maximum price of Orange items (percentage).',
242+ `minpriceyellow` int(11) default '5250' COMMENT 'Minimum price of Yellow items (percentage).',
243+ `maxpriceyellow` int(11) default '6550' COMMENT 'Maximum price of Yellow items (percentage).',
244+ `minbidpricegrey` int(11) default '70' COMMENT 'Starting bid price of Grey items as a percentage of the randomly chosen buyout price. Default: 70',
245+ `maxbidpricegrey` int(11) default '100' COMMENT 'Starting bid price of Grey items as a percentage of the randomly chosen buyout price. Default: 100',
246+ `minbidpricewhite` int(11) default '70' COMMENT 'Starting bid price of White items as a percentage of the randomly chosen buyout price. Default: 70',
247+ `maxbidpricewhite` int(11) default '100' COMMENT 'Starting bid price of White items as a percentage of the randomly chosen buyout price. Default: 100',
248+ `minbidpricegreen` int(11) default '80' COMMENT 'Starting bid price of Green items as a percentage of the randomly chosen buyout price. Default: 80',
249+ `maxbidpricegreen` int(11) default '100' COMMENT 'Starting bid price of Green items as a percentage of the randomly chosen buyout price. Default: 100',
250+ `minbidpriceblue` int(11) default '75' COMMENT 'Starting bid price of Blue items as a percentage of the randomly chosen buyout price. Default: 75',
251+ `maxbidpriceblue` int(11) default '100' COMMENT 'Starting bid price of Blue items as a percentage of the randomly chosen buyout price. Default: 100',
252+ `minbidpricepurple` int(11) default '80' COMMENT 'Starting bid price of Purple items as a percentage of the randomly chosen buyout price. Default: 80',
253+ `maxbidpricepurple` int(11) default '100' COMMENT 'Starting bid price of Purple items as a percentage of the randomly chosen buyout price. Default: 100',
254+ `minbidpriceorange` int(11) default '80' COMMENT 'Starting bid price of Orange items as a percentage of the randomly chosen buyout price. Default: 80',
255+ `maxbidpriceorange` int(11) default '100' COMMENT 'Starting bid price of Orange items as a percentage of the randomly chosen buyout price. Default: 100',
256+ `minbidpriceyellow` int(11) default '80' COMMENT 'Starting bid price of Yellow items as a percentage of the randomly chosen buyout price. Default: 80',
257+ `maxbidpriceyellow` int(11) default '100' COMMENT 'Starting bid price of Yellow items as a percentage of the randomly chosen buyout price. Default: 100',
258+ `maxstackgrey` int(11) default '0' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.',
259+ `maxstackwhite` int(11) default '0' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.',
260+ `maxstackgreen` int(11) default '3' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.',
261+ `maxstackblue` int(11) default '2' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.',
262+ `maxstackpurple` int(11) default '1' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.',
263+ `maxstackorange` int(11) default '1' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.',
264+ `maxstackyellow` int(11) default '1' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.',
265+ `buyerpricegrey` int(11) default '1' COMMENT 'Multiplier to vendorprice when buying grey items from auctionhouse',
266+ `buyerpricewhite` int(11) default '1' COMMENT 'Multiplier to vendorprice when buying white items from auctionhouse',
267+ `buyerpricegreen` int(11) default '5' COMMENT 'Multiplier to vendorprice when buying green items from auctionhouse',
268+ `buyerpriceblue` int(11) default '12' COMMENT 'Multiplier to vendorprice when buying blue items from auctionhouse',
269+ `buyerpricepurple` int(11) default '15' COMMENT 'Multiplier to vendorprice when buying purple items from auctionhouse',
270+ `buyerpriceorange` int(11) default '20' COMMENT 'Multiplier to vendorprice when buying orange items from auctionhouse',
271+ `buyerpriceyellow` int(11) default '22' COMMENT 'Multiplier to vendorprice when buying yellow items from auctionhouse',
272+ `buyerbiddinginterval` int(11) default '1' COMMENT 'Interval how frequently AHB bids on each AH. Time in minutes',
273+ `buyerbidsperinterval` int(11) default '1' COMMENT 'number of bids to put in per bidding interval',
274+ PRIMARY KEY (`auctionhouse`)
275+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
276+
277+/*Data for the table `auctionhousebot` */
278+
279+insert into `auctionhousebot`(`auctionhouse`,`name`,`minitems`,`maxitems`,`mintime`,`maxtime`,`percentgreytradegoods`,`percentwhitetradegoods`,`percentgreentradegoods`,`percentbluetradegoods`,`percentpurpletradegoods`,`percentorangetradegoods`,`percentyellowtradegoods`,`percentgreyitems`,`percentwhiteitems`,`percentgreenitems`,`percentblueitems`,`percentpurpleitems`,`percentorangeitems`,`percentyellowitems`,`minpricegrey`,`maxpricegrey`,`minpricewhite`,`maxpricewhite`,`minpricegreen`,`maxpricegreen`,`minpriceblue`,`maxpriceblue`,`minpricepurple`,`maxpricepurple`,`minpriceorange`,`maxpriceorange`,`minpriceyellow`,`maxpriceyellow`,`minbidpricegrey`,`maxbidpricegrey`,`minbidpricewhite`,`maxbidpricewhite`,`minbidpricegreen`,`maxbidpricegreen`,`minbidpriceblue`,`maxbidpriceblue`,`minbidpricepurple`,`maxbidpricepurple`,`minbidpriceorange`,`maxbidpriceorange`,`minbidpriceyellow`,`maxbidpriceyellow`,`maxstackgrey`,`maxstackwhite`,`maxstackgreen`,`maxstackblue`,`maxstackpurple`,`maxstackorange`,`maxstackyellow`,`buyerpricegrey`,`buyerpricewhite`,`buyerpricegreen`,`buyerpriceblue`,`buyerpricepurple`,`buyerpriceorange`,`buyerpriceyellow`,`buyerbiddinginterval`,`buyerbidsperinterval`) values
280+(2,'Alliance',0,0,8,24,0,27,12,10,1,0,0,0,10,30,8,2,0,0,100,150,150,250,800,1400,1250,1750,2250,4550,3250,5550,5250,6550,70,100,70,100,80,100,75,100,80,100,80,100,80,100,0,0,3,2,1,1,1,1,1,5,12,15,20,22,1,1),
281+(6,'Horde',0,0,8,24,0,27,12,10,1,0,0,0,10,30,8,2,0,0,100,150,150,250,800,1400,1250,1750,2250,4550,3250,5550,5250,6550,70,100,70,100,80,100,75,100,80,100,80,100,80,100,0,0,3,2,1,1,1,1,1,5,12,15,20,22,1,1),
282+(7,'Neutral',0,0,8,24,0,27,12,10,1,0,0,0,10,30,8,2,0,0,100,150,150,250,800,1400,1250,1750,2250,4550,3250,5550,5250,6550,70,100,70,100,80,100,75,100,80,100,80,100,80,100,0,0,3,2,1,1,1,1,1,5,12,15,20,22,1,1);
283+
284+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
285+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
286+
287diff --git a/sql/characters_auctionhousebot_update.sql b/sql/characters_auctionhousebot_update.sql
288new file mode 100644
289index 0000000..c4cd490
290--- /dev/null
291+++ b/sql/characters_auctionhousebot_update.sql
292@@ -0,0 +1,44 @@
293+/*
294+SQLyog Community Edition- MySQL GUI v6.03
295+Host - 5.0.51b-community-nt : Database - characters
296+*********************************************************************
297+Server version : 5.0.51b-community-nt
298+*/
299+
300+/*!40101 SET NAMES utf8 */;
301+
302+/*!40101 SET SQL_MODE=''*/;
303+
304+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
305+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
306+
307+/*Table structure for table `auctionhousebot` */
308+
309+ALTER TABLE `auctionhousebot`
310+ ADD COLUMN `percentgreytradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Grey Trade Goods auction items' AFTER `maxtime`,
311+ ADD COLUMN `percentorangetradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Orange Trade Goods auction items' AFTER `percentpurpletradegoods`,
312+ ADD COLUMN `percentyellowtradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Yellow Trade Goods auction items' AFTER `percentorangetradegoods`,
313+ ADD COLUMN `percentgreyitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Grey auction items' AFTER `percentyellowtradegoods`,
314+ ADD COLUMN `percentorangeitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Orange auction items' AFTER `percentpurpleitems`,
315+ ADD COLUMN `percentyellowitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Yellow auction items' AFTER `percentorangeitems`,
316+ ADD COLUMN `minpricegrey` int(11) default '100' COMMENT 'Minimum price of Grey items (percentage).' AFTER `percentyellowitems`,
317+ ADD COLUMN `maxpricegrey` int(11) default '150' COMMENT 'Maximum price of Grey items (percentage).' AFTER `minpricegrey`,
318+ ADD COLUMN `minpriceorange` int(11) default '3250' COMMENT 'Minimum price of Orange items (percentage).' AFTER `maxpricepurple`,
319+ ADD COLUMN `maxpriceorange` int(11) default '5550' COMMENT 'Maximum price of Orange items (percentage).' AFTER `minpriceorange`,
320+ ADD COLUMN `minpriceyellow` int(11) default '5250' COMMENT 'Minimum price of Yellow items (percentage).' AFTER `maxpriceorange`,
321+ ADD COLUMN `maxpriceyellow` int(11) default '6550' COMMENT 'Maximum price of Yellow items (percentage).' AFTER `minpriceyellow`,
322+ ADD COLUMN `minbidpricegrey` int(11) default '70' COMMENT 'Starting bid price of Grey items as a percentage of the randomly chosen buyout price. Default: 70' AFTER `maxpriceyellow`,
323+ ADD COLUMN `maxbidpricegrey` int(11) default '100' COMMENT 'Starting bid price of Grey items as a percentage of the randomly chosen buyout price. Default: 100' AFTER `minbidpricegrey`,
324+ ADD COLUMN `minbidpriceorange` int(11) default '80' COMMENT 'Starting bid price of Orange items as a percentage of the randomly chosen buyout price. Default: 80' AFTER `maxbidpricepurple`,
325+ ADD COLUMN `maxbidpriceorange` int(11) default '100' COMMENT 'Starting bid price of Orange items as a percentage of the randomly chosen buyout price. Default: 100' AFTER `minbidpriceorange`,
326+ ADD COLUMN `minbidpriceyellow` int(11) default '80' COMMENT 'Starting bid price of Yellow items as a percentage of the randomly chosen buyout price. Default: 80' AFTER `maxbidpriceorange`,
327+ ADD COLUMN `maxbidpriceyellow` int(11) default '100' COMMENT 'Starting bid price of Yellow items as a percentage of the randomly chosen buyout price. Default: 100' AFTER `minbidpriceyellow`,
328+ ADD COLUMN `maxstackgrey` int(11) default '0' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.' AFTER `maxbidpriceyellow`,
329+ ADD COLUMN `maxstackorange` int(11) default '1' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.' AFTER `maxstackpurple`,
330+ ADD COLUMN `maxstackyellow` int(11) default '1' COMMENT 'Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality, which will allow the bot to create items in stack as large as the item allows.' AFTER `maxstackorange`,
331+ ADD COLUMN `buyerpriceorange` int(11) default '20' COMMENT 'Multiplier to vendorprice when buying orange items from auctionhouse' AFTER `buyerpricepurple`,
332+ ADD COLUMN `buyerpriceyellow` int(11) default '22' COMMENT 'Multiplier to vendorprice when buying yellow items from auctionhouse' AFTER `buyerpriceorange`;
333+
334+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
335+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
336+
337diff --git a/src/game/AuctionHouseBot.cpp b/src/game/AuctionHouseBot.cpp
338new file mode 100644
339index 0000000..b44c3fe
340--- /dev/null
341+++ b/src/game/AuctionHouseBot.cpp
342@@ -0,0 +1,1487 @@
343+#include "AuctionHouseBot.h"
344+#include "ObjectMgr.h"
345+#include "AuctionHouseMgr.h"
346+
347+#include "Policies/SingletonImp.h"
348+
349+INSTANTIATE_SINGLETON_1( AuctionHouseBot );
350+
351+using namespace std;
352+
353+AuctionHouseBot::AuctionHouseBot()
354+{
355+ AHBSeller = 0;
356+ AHBBuyer = 0;
357+
358+ Vendor_Items = 0;
359+ Loot_Items = 0;
360+ Other_Items = 0;
361+
362+ No_Bind = 0;
363+ Bind_When_Picked_Up = 0;
364+ Bind_When_Equipped = 0;
365+ Bind_When_Use = 0;
366+ Bind_Quest_Item = 0;
367+
368+ AllianceConfig = AHBConfig(2);
369+ HordeConfig = AHBConfig(6);
370+ NeutralConfig = AHBConfig(7);
371+}
372+
373+AuctionHouseBot::~AuctionHouseBot()
374+{
375+
376+}
377+
378+void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
379+{
380+ if (!AHBSeller)
381+ return;
382+ AuctionHouseEntry const* ahEntry = sAuctionMgr.GetAuctionHouseEntry(config->GetAHFID());
383+ AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(config->GetAHFID());
384+ uint32 items = 0;
385+ uint32 minItems = config->GetMinItems();
386+ uint32 maxItems = config->GetMaxItems();
387+ uint32 auctions = auctionHouse->Getcount();
388+ uint32 AuctioneerGUID = 0;
389+ switch (config->GetAHID()){
390+ case 2:
391+ AuctioneerGUID = 79707; //Human in stormwind.
392+ break;
393+ case 6:
394+ AuctioneerGUID = 4656; //orc in Orgrimmar
395+ break;
396+ case 7:
397+ AuctioneerGUID = 23442; //goblin in GZ
398+ break;
399+ default:
400+ sLog.outError("GetAHID() - Default switch reached");
401+ AuctioneerGUID = 23442; //default to neutral 7
402+ break;
403+ }
404+
405+ if (auctions >= minItems)
406+ return;
407+
408+ if (auctions <= maxItems)
409+ {
410+ if ((maxItems - auctions) > ItemsPerCycle)
411+ items = ItemsPerCycle;
412+ else
413+ items = (maxItems - auctions);
414+ }
415+ uint32 greyTGcount = config->GetPercents(AHB_GREY_TG);
416+ uint32 whiteTGcount = config->GetPercents(AHB_WHITE_TG);
417+ uint32 greenTGcount = config->GetPercents(AHB_GREEN_TG);
418+ uint32 blueTGcount = config->GetPercents(AHB_BLUE_TG);
419+ uint32 purpleTGcount = config->GetPercents(AHB_PURPLE_TG);
420+ uint32 orangeTGcount = config->GetPercents(AHB_ORANGE_TG);
421+ uint32 yellowTGcount = config->GetPercents(AHB_YELLOW_TG);
422+ uint32 greyIcount = config->GetPercents(AHB_GREY_I);
423+ uint32 whiteIcount = config->GetPercents(AHB_WHITE_I);
424+ uint32 greenIcount = config->GetPercents(AHB_GREEN_I);
425+ uint32 blueIcount = config->GetPercents(AHB_BLUE_I);
426+ uint32 purpleIcount = config->GetPercents(AHB_PURPLE_I);
427+ uint32 orangeIcount = config->GetPercents(AHB_ORANGE_I);
428+ uint32 yellowIcount = config->GetPercents(AHB_YELLOW_I);
429+ uint32 total = greyTGcount + whiteTGcount + greenTGcount + blueTGcount
430+ + purpleTGcount + orangeTGcount + yellowTGcount
431+ + whiteIcount + greenIcount + blueIcount + purpleIcount
432+ + orangeIcount + yellowIcount;
433+
434+ uint32 greyTGoods = 0;
435+ uint32 whiteTGoods = 0;
436+ uint32 greenTGoods = 0;
437+ uint32 blueTGoods = 0;
438+ uint32 purpleTGoods = 0;
439+ uint32 orangeTGoods = 0;
440+ uint32 yellowTGoods = 0;
441+
442+ uint32 greyItems = 0;
443+ uint32 whiteItems = 0;
444+ uint32 greenItems = 0;
445+ uint32 blueItems = 0;
446+ uint32 purpleItems = 0;
447+ uint32 orangeItems = 0;
448+ uint32 yellowItems = 0;
449+
450+ for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin();itr != auctionHouse->GetAuctionsEnd();++itr)
451+ {
452+ AuctionEntry *Aentry = itr->second;
453+ Item *item = sAuctionMgr.GetAItem(Aentry->item_guidlow);
454+ if (item)
455+ {
456+ ItemPrototype const *prototype = item->GetProto();
457+ if (prototype)
458+ {
459+ switch (prototype->Quality)
460+ {
461+ case 0:
462+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
463+ ++greyTGoods;
464+ else
465+ ++greyItems;
466+ break;
467+ case 1:
468+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
469+ ++whiteTGoods;
470+ else
471+ ++whiteItems;
472+ break;
473+ case 2:
474+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
475+ ++greenTGoods;
476+ else
477+ ++greenItems;
478+ break;
479+ case 3:
480+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
481+ ++blueTGoods;
482+ else
483+ ++blueItems;
484+ break;
485+ case 4:
486+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
487+ ++purpleTGoods;
488+ else
489+ ++purpleItems;
490+ break;
491+ case 5:
492+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
493+ ++orangeTGoods;
494+ else
495+ ++orangeItems;
496+ break;
497+ case 6:
498+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
499+ ++yellowTGoods;
500+ else
501+ ++yellowItems;
502+ break;
503+ }
504+ }
505+ }
506+ }
507+
508+ // only insert a few at a time, so as not to peg the processor
509+ for (uint32 cnt = 1;cnt <= items;cnt++)
510+ {
511+ uint32 itemID = 0;
512+ uint32 loopBreaker = 0; // This will prevent endless looping condition where AHBot
513+ while (itemID == 0 && loopBreaker < 50) // cannot allocate an item.
514+ {
515+ uint32 choice = urand(0, 13);
516+ switch (choice)
517+ {
518+ case 0:
519+ if ((greyItemsBin.size() > 0) && (greyItems < greyIcount))
520+ {
521+ itemID = greyItemsBin[urand(0, greyItemsBin.size() - 1)];
522+ ++greyItems;
523+ }
524+ break;
525+ case 1:
526+ if ((whiteItemsBin.size() > 0) && (whiteItems < whiteIcount))
527+ {
528+ itemID = whiteItemsBin[urand(0, whiteItemsBin.size() - 1)];
529+ ++whiteItems;
530+ }
531+ break;
532+ case 2:
533+ if ((greenItemsBin.size() > 0) && (greenItems < greenIcount))
534+ {
535+ itemID = greenItemsBin[urand(0, greenItemsBin.size() - 1)];
536+ ++greenItems;
537+ }
538+ break;
539+ case 3:
540+ if ((blueItemsBin.size() > 0) && (blueItems < blueIcount))
541+ {
542+ itemID = blueItemsBin[urand(0, blueItemsBin.size() - 1)];
543+ ++blueItems;
544+ }
545+ break;
546+ case 4:
547+ if ((purpleItemsBin.size() > 0) && (purpleItems < purpleIcount))
548+ {
549+ itemID = purpleItemsBin[urand(0, purpleItemsBin.size() - 1)];
550+ ++purpleItems;
551+ }
552+ break;
553+ case 5:
554+ if ((orangeItemsBin.size() > 0) && (orangeItems < orangeIcount))
555+ {
556+ itemID = orangeItemsBin[urand(0, orangeItemsBin.size() - 1)];
557+ ++orangeItems;
558+ }
559+ break;
560+ case 6:
561+ if ((yellowItemsBin.size() > 0) && (yellowItems < yellowIcount))
562+ {
563+ itemID = yellowItemsBin[urand(0, yellowItemsBin.size() - 1)];
564+ ++yellowItems;
565+ }
566+ break;
567+ case 7:
568+ if ((greyTradeGoodsBin.size() > 0) && (greyTGoods < greyTGcount))
569+ {
570+ itemID = whiteTradeGoodsBin[urand(0, whiteTradeGoodsBin.size() - 1)];
571+ ++greyTGoods;
572+ }
573+ break;
574+ case 8:
575+ if ((whiteTradeGoodsBin.size() > 0) && (whiteTGoods < whiteTGcount))
576+ {
577+ itemID = whiteTradeGoodsBin[urand(0, whiteTradeGoodsBin.size() - 1)];
578+ ++whiteTGoods;
579+ }
580+ break;
581+ case 9:
582+ if ((greenTradeGoodsBin.size() > 0) && (greenTGoods < greenTGcount))
583+ {
584+ itemID = greenTradeGoodsBin[urand(0, greenTradeGoodsBin.size() - 1)];
585+ ++greenTGoods;
586+ }
587+ break;
588+ case 10:
589+ if ((blueTradeGoodsBin.size() > 0) && (blueTGoods < blueTGcount))
590+ {
591+ itemID = blueTradeGoodsBin[urand(0, blueTradeGoodsBin.size() - 1)];
592+ ++blueTGoods;
593+ }
594+ break;
595+ case 11:
596+ if ((purpleTradeGoodsBin.size() > 0) && (purpleTGoods < purpleTGcount))
597+ {
598+ itemID = purpleTradeGoodsBin[urand(0, purpleTradeGoodsBin.size() - 1)];
599+ ++purpleTGoods;
600+ }
601+ break;
602+ case 12:
603+ if ((orangeTradeGoodsBin.size() > 0) && (orangeTGoods < orangeTGcount))
604+ {
605+ itemID = orangeTradeGoodsBin[urand(0, orangeTradeGoodsBin.size() - 1)];
606+ ++orangeTGoods;
607+ }
608+ break;
609+ case 13:
610+ if ((yellowTradeGoodsBin.size() > 0) && (yellowTGoods < yellowTGcount))
611+ {
612+ itemID = yellowTradeGoodsBin[urand(0, yellowTradeGoodsBin.size() - 1)];
613+ ++yellowTGoods;
614+ }
615+ break;
616+ default:
617+ sLog.outString("AuctionHouseBot: itemID Switch - Default Reached");
618+ break;
619+ }
620+
621+ ++loopBreaker;
622+ }
623+
624+ if (itemID == 0)
625+ {
626+ if (debug_Out)
627+ sLog.outString("AuctionHouseBot: Item::CreateItem() - Unable to find item");
628+ continue;
629+ }
630+
631+ ItemPrototype const* prototype = sObjectMgr.GetItemPrototype(itemID);
632+ if (prototype == NULL)
633+ {
634+ sLog.outString("AuctionHouseBot: Huh?!?! prototype == NULL");
635+ continue;
636+ }
637+
638+ Item* item = Item::CreateItem(itemID, 1, AHBplayer);
639+ item->AddToUpdateQueueOf(AHBplayer);
640+ if (item == NULL)
641+ {
642+ sLog.outString("AuctionHouseBot: Item::CreateItem() returned NULL");
643+ break;
644+ }
645+
646+ uint32 randomPropertyId = Item::GenerateItemRandomPropertyId(itemID);
647+ if (randomPropertyId != 0)
648+ item->SetItemRandomProperties(randomPropertyId);
649+
650+ uint32 buyoutPrice;
651+ uint32 bidPrice = 0;
652+ uint32 stackCount = urand(1, item->GetMaxStackCount());
653+
654+ switch (SellMethod)
655+ {
656+ case 0:
657+ buyoutPrice = prototype->SellPrice * item->GetCount();
658+ break;
659+ case 1:
660+ buyoutPrice = prototype->BuyPrice * item->GetCount();
661+ break;
662+ }
663+
664+ switch (prototype->Quality)
665+ {
666+ case 0:
667+ if (config->GetMaxStack(AHB_GREY) != 0)
668+ {
669+ stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_GREY)));
670+ }
671+ buyoutPrice *= urand(config->GetMinPrice(AHB_GREY), config->GetMaxPrice(AHB_GREY)) * stackCount;
672+ buyoutPrice /= 100;
673+ bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_GREY), config->GetMaxBidPrice(AHB_GREY));
674+ bidPrice /= 100;
675+ break;
676+ case 1:
677+ if (config->GetMaxStack(AHB_WHITE) != 0)
678+ {
679+ stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_WHITE)));
680+ }
681+ buyoutPrice *= urand(config->GetMinPrice(AHB_WHITE), config->GetMaxPrice(AHB_WHITE)) * stackCount;
682+ buyoutPrice /= 100;
683+ bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_WHITE), config->GetMaxBidPrice(AHB_WHITE));
684+ bidPrice /= 100;
685+ break;
686+ case 2:
687+ if (config->GetMaxStack(AHB_GREEN) != 0)
688+ {
689+ stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_GREEN)));
690+ }
691+ buyoutPrice *= urand(config->GetMinPrice(AHB_GREEN), config->GetMaxPrice(AHB_GREEN)) * stackCount;
692+ buyoutPrice /= 100;
693+ bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_GREEN), config->GetMaxBidPrice(AHB_GREEN));
694+ bidPrice /= 100;
695+ break;
696+ case 3:
697+ if (config->GetMaxStack(AHB_BLUE) != 0)
698+ {
699+ stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_BLUE)));
700+ }
701+ buyoutPrice *= urand(config->GetMinPrice(AHB_BLUE), config->GetMaxPrice(AHB_BLUE)) * stackCount;
702+ buyoutPrice /= 100;
703+ bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_BLUE), config->GetMaxBidPrice(AHB_BLUE));
704+ bidPrice /= 100;
705+ break;
706+ case 4:
707+ if (config->GetMaxStack(AHB_PURPLE) != 0)
708+ {
709+ stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_PURPLE)));
710+ }
711+ buyoutPrice *= urand(config->GetMinPrice(AHB_PURPLE), config->GetMaxPrice(AHB_PURPLE)) * stackCount;
712+ buyoutPrice /= 100;
713+ bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_PURPLE), config->GetMaxBidPrice(AHB_PURPLE));
714+ bidPrice /= 100;
715+ break;
716+ case 5:
717+ if (config->GetMaxStack(AHB_ORANGE) != 0)
718+ {
719+ stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_ORANGE)));
720+ }
721+ buyoutPrice *= urand(config->GetMinPrice(AHB_ORANGE), config->GetMaxPrice(AHB_ORANGE)) * stackCount;
722+ buyoutPrice /= 100;
723+ bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_ORANGE), config->GetMaxBidPrice(AHB_ORANGE));
724+ bidPrice /= 100;
725+ break;
726+ case 6:
727+ if (config->GetMaxStack(AHB_YELLOW) != 0)
728+ {
729+ stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_YELLOW)));
730+ }
731+ buyoutPrice *= urand(config->GetMinPrice(AHB_YELLOW), config->GetMaxPrice(AHB_YELLOW)) * stackCount;
732+ buyoutPrice /= 100;
733+ bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_YELLOW), config->GetMaxBidPrice(AHB_YELLOW));
734+ bidPrice /= 100;
735+ break;
736+ }
737+
738+ item->SetCount(stackCount);
739+
740+ AuctionEntry* auctionEntry = new AuctionEntry;
741+ auctionEntry->Id = sObjectMgr.GenerateAuctionID();
742+ auctionEntry->auctioneer = AuctioneerGUID;
743+ auctionEntry->item_guidlow = item->GetGUIDLow();
744+ auctionEntry->item_template = item->GetEntry();
745+ auctionEntry->owner = AHBplayer->GetGUIDLow();
746+ auctionEntry->startbid = bidPrice;
747+ auctionEntry->buyout = buyoutPrice;
748+ auctionEntry->bidder = 0;
749+ auctionEntry->bid = 0;
750+ auctionEntry->deposit = 0;
751+ auctionEntry->expire_time = (time_t) (urand(config->GetMinTime(), config->GetMaxTime()) * 60 * 60 + time(NULL));
752+ auctionEntry->auctionHouseEntry = ahEntry;
753+ item->SaveToDB();
754+ item->RemoveFromUpdateQueueOf(AHBplayer);
755+ sAuctionMgr.AddAItem(item);
756+ auctionHouse->AddAuction(auctionEntry);
757+ auctionEntry->SaveToDB();
758+ }
759+}
760+
761+void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, WorldSession *session)
762+{
763+ if (!AHBBuyer)
764+ return;
765+
766+ // Fetches content of selected AH
767+ AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(config->GetAHFID());
768+ vector<uint32> possibleBids;
769+
770+ for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin();itr != auctionHouse->GetAuctionsEnd();++itr)
771+ {
772+ // Check if the auction is ours
773+ // if it is, we skip this iteration.
774+ if (itr->second->owner == AHBplayerGUID)
775+ {
776+ continue;
777+ }
778+ // Check that we haven't bidded in this auction already.
779+ if (itr->second->bidder != AHBplayerGUID)
780+ {
781+ uint32 tmpdata = itr->second->Id;
782+ possibleBids.push_back(tmpdata);
783+ }
784+ }
785+
786+ for (uint32 count = 0;count < config->GetBidsPerInterval();++count)
787+ {
788+
789+ // Do we have anything to bid? If not, stop here.
790+ if (possibleBids.empty())
791+ {
792+ count = config->GetBidsPerInterval();
793+ continue;
794+ }
795+
796+ // Choose random auction from possible auctions
797+ uint32 vectorPos = urand(0, possibleBids.size() - 1);
798+ uint32 auctionID = possibleBids[vectorPos];
799+
800+ // Erase the auction from the vector to prevent bidding on item in next iteration.
801+ vector<uint32>::iterator iter = possibleBids.begin();
802+ advance(iter, vectorPos);
803+ possibleBids.erase(iter);
804+
805+ // from auctionhousehandler.cpp, creates auction pointer & player pointer
806+ AuctionEntry* auction = auctionHouse->GetAuction(auctionID);
807+ if (!auction)
808+ {
809+ sLog.outError("Item doesn't exists, perhaps bought already?");
810+ continue;
811+ }
812+
813+ // get exact item information
814+ Item *pItem = sAuctionMgr.GetAItem(auction->item_guidlow);
815+ if (!pItem)
816+ {
817+ sLog.outError("Item doesn't exists, perhaps bought already?");
818+ continue;
819+ }
820+
821+ // get item prototype
822+ ItemPrototype const* prototype = sObjectMgr.GetItemPrototype(auction->item_template);
823+
824+ // check which price we have to use, startbid or if it is bidded already
825+ if (debug_Out)
826+ {
827+ sLog.outError("Auction Number: %u", auction->Id);
828+ sLog.outError("Item Template: %u", auction->item_template);
829+ sLog.outError("Buy Price: %u", prototype->BuyPrice);
830+ sLog.outError("Sell Price: %u", prototype->SellPrice);
831+ sLog.outError("Quality: %u", prototype->Quality);
832+ }
833+ uint32 currentprice;
834+ if (auction->bid)
835+ {
836+ currentprice = auction->bid;
837+ if (debug_Out)
838+ {
839+ sLog.outError("Current Price: %u", auction->bid);
840+ }
841+ }
842+ else
843+ {
844+ currentprice = auction->startbid;
845+ if (debug_Out)
846+ {
847+ sLog.outError("Current Price: %u", auction->startbid);
848+ }
849+ }
850+ uint32 bidprice;
851+
852+ // Prepare portion from maximum bid
853+ uint32 tmprate2 = urand(0, 100);
854+ double tmprate = static_cast<double>(tmprate2);
855+ if (debug_Out)
856+ {
857+ sLog.outError("tmprate: %f", tmprate);
858+ }
859+
860+ double bidrate = tmprate / 100;
861+ if (debug_Out)
862+ {
863+ sLog.outError("bidrate: %f", bidrate);
864+ }
865+
866+ long double bidMax = 0;
867+
868+ // check that bid has acceptable value and take bid based on vendorprice, stacksize and quality
869+ switch (BuyMethod)
870+ {
871+ case 0:
872+ switch (prototype->Quality)
873+ {
874+ case 0:
875+ if (currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY))
876+ {
877+ bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY);
878+ }
879+ break;
880+ case 1:
881+ if (currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE))
882+ {
883+ bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE);
884+ }
885+ break;
886+ case 2:
887+ if (currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN))
888+ {
889+ bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN);
890+ }
891+ break;
892+ case 3:
893+ if (currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE))
894+ {
895+ bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE);
896+ }
897+ break;
898+ case 4:
899+ if (currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE))
900+ {
901+ bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE);
902+ }
903+ break;
904+ case 5:
905+ if (currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE))
906+ {
907+ bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE);
908+ }
909+ break;
910+ case 6:
911+ if (currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW))
912+ {
913+ bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW);
914+ }
915+ break;
916+ default:
917+ // quality is something it shouldn't be, let's get out of here
918+ if (debug_Out)
919+ {
920+ sLog.outError("bidMax(fail): %f", bidMax);
921+ }
922+ continue;
923+ break;
924+ }
925+ break;
926+ case 1:
927+ switch (prototype->Quality)
928+ {
929+ case 0:
930+ if (currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY))
931+ {
932+ bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY);
933+ }
934+ break;
935+ case 1:
936+ if (currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE))
937+ {
938+ bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE);
939+ }
940+ break;
941+ case 2:
942+ if (currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN))
943+ {
944+ bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN);
945+ }
946+ break;
947+ case 3:
948+ if (currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE))
949+ {
950+ bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE);
951+ }
952+ break;
953+ case 4:
954+ if (currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE))
955+ {
956+ bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE);
957+ }
958+ break;
959+ case 5:
960+ if (currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE))
961+ {
962+ bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE);
963+ }
964+ break;
965+ case 6:
966+ if (currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW))
967+ {
968+ bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW);
969+ }
970+ break;
971+ default:
972+ // quality is something it shouldn't be, let's get out of here
973+ if (debug_Out)
974+ {
975+ sLog.outError("bidMax(fail): %f", bidMax);
976+ }
977+ continue;
978+ break;
979+ }
980+ break;
981+ }
982+
983+ if (debug_Out)
984+ {
985+ sLog.outError("bidMax(succeed): %f", bidMax);
986+ }
987+
988+ // check some special items, and do recalculating to their prices
989+ switch (prototype->Class)
990+ {
991+ // ammo
992+ case 6:
993+ bidMax = 0;
994+ break;
995+ default:
996+ break;
997+ }
998+
999+ if (bidMax == 0)
1000+ {
1001+ // quality check failed to get bidmax, let's get out of here
1002+ continue;
1003+ }
1004+
1005+ // Calculate our bid
1006+ long double bidvalue = currentprice + ((bidMax - currentprice) * bidrate);
1007+ if (debug_Out)
1008+ {
1009+ sLog.outError("bidvalue: %f", bidvalue);
1010+ }
1011+
1012+ // Convert to uint32
1013+ bidprice = static_cast<uint32>(bidvalue);
1014+ if (debug_Out)
1015+ {
1016+ sLog.outError("bidprice: %u", bidprice);
1017+ }
1018+
1019+ // Check our bid is high enough to be valid. If not, correct it to minimum.
1020+ if ((currentprice + auction->GetAuctionOutBid()) > bidprice)
1021+ {
1022+ bidprice = currentprice + auction->GetAuctionOutBid();
1023+ if (debug_Out)
1024+ {
1025+ sLog.outError("bidprice(>): %u", bidprice);
1026+ }
1027+ }
1028+
1029+ // Check wether we do normal bid, or buyout
1030+ if ((bidprice < auction->buyout) || (auction->buyout == 0))
1031+ {
1032+
1033+ if (auction->bidder > 0)
1034+ {
1035+ if (auction->bidder == AHBplayer->GetGUIDLow())
1036+ {
1037+ //pl->ModifyMoney(-int32(price - auction->bid));
1038+ }
1039+ else
1040+ {
1041+ // mail to last bidder and return money
1042+ session->SendAuctionOutbiddedMail(auction , bidprice);
1043+ //pl->ModifyMoney(-int32(price));
1044+ }
1045+ }
1046+
1047+ auction->bidder = AHBplayer->GetGUIDLow();
1048+ auction->bid = bidprice;
1049+
1050+ // Saving auction into database
1051+ CharacterDatabase.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);
1052+ }
1053+ else
1054+ {
1055+ //buyout
1056+ if (AHBplayer->GetGUIDLow() == auction->bidder)
1057+ {
1058+ //pl->ModifyMoney(-int32(auction->buyout - auction->bid));
1059+ }
1060+ else
1061+ {
1062+ //pl->ModifyMoney(-int32(auction->buyout));
1063+ if (auction->bidder)
1064+ {
1065+ session->SendAuctionOutbiddedMail(auction, auction->buyout);
1066+ }
1067+ }
1068+ auction->bidder = AHBplayer->GetGUIDLow();
1069+ auction->bid = auction->buyout;
1070+
1071+ // Send mails to buyer & seller
1072+ sAuctionMgr.SendAuctionSuccessfulMail(auction);
1073+ sAuctionMgr.SendAuctionWonMail(auction);
1074+
1075+ // Remove item from auctionhouse
1076+ sAuctionMgr.RemoveAItem(auction->item_guidlow);
1077+ // Remove auction
1078+ auctionHouse->RemoveAuction(auction->Id);
1079+ // Remove from database
1080+ auction->DeleteFromDB();
1081+ }
1082+ }
1083+}
1084+
1085+void AuctionHouseBot::Update()
1086+{
1087+ time_t _newrun = time(NULL);
1088+ if ((!AHBSeller) && (!AHBBuyer))
1089+ return;
1090+
1091+ WorldSession _session(AHBplayerAccount, NULL, SEC_PLAYER, true, 0, LOCALE_enUS);
1092+ Player _AHBplayer(&_session);
1093+ _AHBplayer.MinimalLoadFromDB(NULL, AHBplayerGUID);
1094+ ObjectAccessor::Instance().AddObject(&_AHBplayer);
1095+
1096+ // Add New Bids
1097+ if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
1098+ {
1099+ addNewAuctions(&_AHBplayer, &AllianceConfig);
1100+ if (((_newrun - _lastrun_a) > (AllianceConfig.GetBiddingInterval() * 60)) && (AllianceConfig.GetBidsPerInterval() > 0))
1101+ {
1102+ addNewAuctionBuyerBotBid(&_AHBplayer, &AllianceConfig, &_session);
1103+ _lastrun_a = _newrun;
1104+ }
1105+
1106+ addNewAuctions(&_AHBplayer, &HordeConfig);
1107+ if (((_newrun - _lastrun_h) > (HordeConfig.GetBiddingInterval() *60)) && (HordeConfig.GetBidsPerInterval() > 0))
1108+ {
1109+ addNewAuctionBuyerBotBid(&_AHBplayer, &HordeConfig, &_session);
1110+ _lastrun_h = _newrun;
1111+ }
1112+ }
1113+ addNewAuctions(&_AHBplayer, &NeutralConfig);
1114+ if (((_newrun - _lastrun_n) > (NeutralConfig.GetBiddingInterval() * 60)) && (NeutralConfig.GetBidsPerInterval() > 0))
1115+ {
1116+ addNewAuctionBuyerBotBid(&_AHBplayer, &NeutralConfig, &_session);
1117+ _lastrun_n = _newrun;
1118+ }
1119+
1120+ ObjectAccessor::Instance().RemoveObject(&_AHBplayer);
1121+}
1122+
1123+void AuctionHouseBot::Initialize()
1124+{
1125+ AHBSeller = sConfig.GetBoolDefault("AuctionHouseBot.EnableSeller", 0);
1126+ AHBBuyer = sConfig.GetBoolDefault("AuctionHouseBot.EnableBuyer", 0);
1127+ AHBplayerAccount = sConfig.GetIntDefault("AuctionHouseBot.Account", 0);
1128+ AHBplayerGUID = sConfig.GetIntDefault("AuctionHouseBot.GUID", 0);
1129+ debug_Out = sConfig.GetIntDefault("AuctionHouseBot.DEBUG", 0);
1130+ No_Bind = sConfig.GetBoolDefault("AuctionHouseBot.No_Bind", 1);
1131+ Bind_When_Picked_Up = sConfig.GetBoolDefault("AuctionHouseBot.Bind_When_Picked_Up", 0);
1132+ Bind_When_Equipped = sConfig.GetBoolDefault("AuctionHouseBot.Bind_When_Equipped", 1);
1133+ Bind_When_Use = sConfig.GetBoolDefault("AuctionHouseBot.Bind_When_Use", 1);
1134+ Bind_Quest_Item = sConfig.GetBoolDefault("AuctionHouseBot.Bind_Quest_Item", 0);
1135+ ItemsPerCycle = sConfig.GetIntDefault("AuctionHouseBot.ItemsPerCycle", 200);
1136+ SellMethod = sConfig.GetIntDefault("AuctionHouseBot.UseBuyPriceForSeller", 1);
1137+ BuyMethod = sConfig.GetIntDefault("AuctionHouseBot.UseBuyPriceForBuyer", 0);
1138+
1139+ if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
1140+ {
1141+ LoadValues(&AllianceConfig);
1142+ LoadValues(&HordeConfig);
1143+ }
1144+ LoadValues(&NeutralConfig);
1145+
1146+ if (AHBSeller)
1147+ {
1148+ Vendor_Items = sConfig.GetBoolDefault("AuctionHouseBot.VendorItems", 0);
1149+ Loot_Items = sConfig.GetBoolDefault("AuctionHouseBot.LootItems", 1);
1150+ Other_Items = sConfig.GetBoolDefault("AuctionHouseBot.OtherItems", 0);
1151+
1152+ QueryResult* results = (QueryResult*) NULL;
1153+ char npcQuery[] = "SELECT distinct `item` FROM `npc_vendor`";
1154+ results = WorldDatabase.PQuery(npcQuery);
1155+ if (results != NULL)
1156+ {
1157+ do
1158+ {
1159+ Field* fields = results->Fetch();
1160+ npcItems.push_back(fields[0].GetUInt32());
1161+
1162+ } while (results->NextRow());
1163+
1164+ delete results;
1165+ }
1166+ else
1167+ {
1168+ sLog.outString("AuctionHouseBot: \"%s\" failed", npcQuery);
1169+ }
1170+
1171+ char lootQuery[] = "SELECT `item` FROM `creature_loot_template` UNION "
1172+ "SELECT `item` FROM `disenchant_loot_template` UNION "
1173+ "SELECT `item` FROM `fishing_loot_template` UNION "
1174+ "SELECT `item` FROM `gameobject_loot_template` UNION "
1175+ "SELECT `item` FROM `item_loot_template` UNION "
1176+ "SELECT `item` FROM `milling_loot_template` UNION "
1177+ "SELECT `item` FROM `pickpocketing_loot_template` UNION "
1178+ "SELECT `item` FROM `prospecting_loot_template` UNION "
1179+ "SELECT `item` FROM `skinning_loot_template`";
1180+
1181+ results = WorldDatabase.PQuery(lootQuery);
1182+ if (results != NULL)
1183+ {
1184+ do
1185+ {
1186+ Field* fields = results->Fetch();
1187+ lootItems.push_back(fields[0].GetUInt32());
1188+
1189+ } while (results->NextRow());
1190+
1191+ delete results;
1192+ }
1193+ else
1194+ {
1195+ sLog.outString("AuctionHouseBot: \"%s\" failed", lootQuery);
1196+ }
1197+
1198+ for (uint32 itemID = 0; itemID < sItemStorage.MaxEntry; itemID++)
1199+ {
1200+ ItemPrototype const* prototype = sObjectMgr.GetItemPrototype(itemID);
1201+
1202+ if (prototype == NULL)
1203+ continue;
1204+
1205+ switch (prototype->Bonding)
1206+ {
1207+ case 0:
1208+ if (!No_Bind)
1209+ continue;
1210+ break;
1211+ case 1:
1212+ if (!Bind_When_Picked_Up)
1213+ continue;
1214+ break;
1215+ case 2:
1216+ if (!Bind_When_Equipped)
1217+ continue;
1218+ break;
1219+ case 3:
1220+ if (!Bind_When_Use)
1221+ continue;
1222+ break;
1223+ case 4:
1224+ if (!Bind_Quest_Item)
1225+ continue;
1226+ break;
1227+ default:
1228+ continue;
1229+ break;
1230+ }
1231+
1232+ switch (SellMethod)
1233+ {
1234+ case 0:
1235+ if (prototype->SellPrice == 0)
1236+ continue;
1237+ break;
1238+ case 1:
1239+ if (prototype->BuyPrice == 0)
1240+ continue;
1241+ break;
1242+ }
1243+
1244+ if ((prototype->Quality < 0) || (prototype->Quality > 6))
1245+ continue;
1246+
1247+ if (Vendor_Items == 0)
1248+ {
1249+ bool isVendorItem = false;
1250+
1251+ for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorItem); i++)
1252+ {
1253+ if (itemID == npcItems[i])
1254+ isVendorItem = true;
1255+ }
1256+
1257+ if (isVendorItem)
1258+ continue;
1259+ }
1260+
1261+ if (Loot_Items == 0)
1262+ {
1263+ bool isLootItem = false;
1264+
1265+ for (unsigned int i = 0; (i < lootItems.size()) && (!isLootItem); i++)
1266+ {
1267+ if (itemID == lootItems[i])
1268+ isLootItem = true;
1269+ }
1270+
1271+ if (isLootItem)
1272+ continue;
1273+ }
1274+
1275+ if (Other_Items == 0)
1276+ {
1277+ bool isVendorItem = false;
1278+ bool isLootItem = false;
1279+
1280+ for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorItem); i++)
1281+ {
1282+ if (itemID == npcItems[i])
1283+ isVendorItem = true;
1284+ }
1285+ for (unsigned int i = 0; (i < lootItems.size()) && (!isLootItem); i++)
1286+ {
1287+ if (itemID == lootItems[i])
1288+ isLootItem = true;
1289+ }
1290+ if ((!isLootItem) && (!isVendorItem))
1291+ continue;
1292+ }
1293+
1294+ switch (prototype->Quality)
1295+ {
1296+ case 0:
1297+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1298+ greyTradeGoodsBin.push_back(itemID);
1299+ else
1300+ greyItemsBin.push_back(itemID);
1301+ break;
1302+
1303+ case 1:
1304+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1305+ whiteTradeGoodsBin.push_back(itemID);
1306+ else
1307+ whiteItemsBin.push_back(itemID);
1308+ break;
1309+
1310+ case 2:
1311+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1312+ greenTradeGoodsBin.push_back(itemID);
1313+ else
1314+ greenItemsBin.push_back(itemID);
1315+ break;
1316+
1317+ case 3:
1318+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1319+ blueTradeGoodsBin.push_back(itemID);
1320+ else
1321+ blueItemsBin.push_back(itemID);
1322+ break;
1323+
1324+ case 4:
1325+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1326+ purpleTradeGoodsBin.push_back(itemID);
1327+ else
1328+ purpleItemsBin.push_back(itemID);
1329+ break;
1330+
1331+ case 5:
1332+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1333+ orangeTradeGoodsBin.push_back(itemID);
1334+ else
1335+ orangeItemsBin.push_back(itemID);
1336+ break;
1337+
1338+ case 6:
1339+ if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1340+ yellowTradeGoodsBin.push_back(itemID);
1341+ else
1342+ yellowItemsBin.push_back(itemID);
1343+ break;
1344+ }
1345+ }
1346+
1347+ if (
1348+ (greyTradeGoodsBin.size() == 0) &&
1349+ (whiteTradeGoodsBin.size() == 0) &&
1350+ (greenTradeGoodsBin.size() == 0) &&
1351+ (blueTradeGoodsBin.size() == 0) &&
1352+ (purpleTradeGoodsBin.size() == 0) &&
1353+ (orangeTradeGoodsBin.size() == 0) &&
1354+ (yellowTradeGoodsBin.size() == 0) &&
1355+ (greyItemsBin.size() == 0) &&
1356+ (whiteItemsBin.size() == 0) &&
1357+ (greenItemsBin.size() == 0) &&
1358+ (blueItemsBin.size() == 0) &&
1359+ (purpleItemsBin.size() == 0) &&
1360+ (orangeItemsBin.size() == 0) &&
1361+ (yellowItemsBin.size() == 0)
1362+ )
1363+ {
1364+ sLog.outString("AuctionHouseBot: No items");
1365+ AHBSeller = 0;
1366+ }
1367+
1368+ sLog.outString("AuctionHouseBot:");
1369+ sLog.outString("loaded %d grey trade goods", greyTradeGoodsBin.size());
1370+ sLog.outString("loaded %d white trade goods", whiteTradeGoodsBin.size());
1371+ sLog.outString("loaded %d green trade goods", greenTradeGoodsBin.size());
1372+ sLog.outString("loaded %d blue trade goods", blueTradeGoodsBin.size());
1373+ sLog.outString("loaded %d purple trade goods", purpleTradeGoodsBin.size());
1374+ sLog.outString("loaded %d orange trade goods", orangeTradeGoodsBin.size());
1375+ sLog.outString("loaded %d yellow trade goods", yellowTradeGoodsBin.size());
1376+ sLog.outString("loaded %d grey items", greyItemsBin.size());
1377+ sLog.outString("loaded %d white items", whiteItemsBin.size());
1378+ sLog.outString("loaded %d green items", greenItemsBin.size());
1379+ sLog.outString("loaded %d blue items", blueItemsBin.size());
1380+ sLog.outString("loaded %d purple items", purpleItemsBin.size());
1381+ sLog.outString("loaded %d orange items", orangeItemsBin.size());
1382+ sLog.outString("loaded %d yellow items", yellowItemsBin.size());
1383+ }
1384+ sLog.outString("AuctionHouseBot [AHBot-004-HotFix-05] is now loaded");
1385+ sLog.outString("AuctionHouseBot updated by Naicisum (original by ChrisK and Paradox)");
1386+ sLog.outString("AuctionHouseBot now includes AHBuyer by Kerbe and Paradox");
1387+}
1388+
1389+void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char* args)
1390+{
1391+ AHBConfig *config;
1392+ switch (ahMapID)
1393+ {
1394+ case 2:
1395+ config = &AllianceConfig;
1396+ break;
1397+ case 6:
1398+ config = &HordeConfig;
1399+ break;
1400+ case 7:
1401+ config = &NeutralConfig;
1402+ break;
1403+ }
1404+ std::string color;
1405+ switch (col)
1406+ {
1407+ case AHB_GREY:
1408+ color = "grey";
1409+ break;
1410+ case AHB_WHITE:
1411+ color = "white";
1412+ break;
1413+ case AHB_GREEN:
1414+ color = "green";
1415+ break;
1416+ case AHB_BLUE:
1417+ color = "blue";
1418+ break;
1419+ case AHB_PURPLE:
1420+ color = "purple";
1421+ break;
1422+ case AHB_ORANGE:
1423+ color = "orange";
1424+ break;
1425+ case AHB_YELLOW:
1426+ color = "yellow";
1427+ break;
1428+ default:
1429+ break;
1430+ }
1431+ switch (command)
1432+ {
1433+ case 0: //ahexpire
1434+ {
1435+ AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(config->GetAHFID());
1436+
1437+ AuctionHouseObject::AuctionEntryMap::iterator itr;
1438+ itr = auctionHouse->GetAuctionsBegin();
1439+
1440+ while (itr != auctionHouse->GetAuctionsEnd())
1441+ {
1442+ if (itr->second->owner == AHBplayerGUID)
1443+ itr->second->expire_time = sWorld.GetGameTime();
1444+
1445+ ++itr;
1446+ }
1447+ }break;
1448+ case 1: //min items
1449+ {
1450+ char * param1 = strtok(args, " ");
1451+ uint32 minItems = (uint32) strtoul(param1, NULL, 0);
1452+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET minitems = '%u' WHERE auctionhouse = '%u'", minItems, ahMapID);
1453+ config->SetMinItems(minItems);
1454+ }break;
1455+ case 2: //max items
1456+ {
1457+ char * param1 = strtok(args, " ");
1458+ uint32 maxItems = (uint32) strtoul(param1, NULL, 0);
1459+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxitems = '%u' WHERE auctionhouse = '%u'", maxItems, ahMapID);
1460+ config->SetMaxItems(maxItems);
1461+ }break;
1462+ case 3: //min time
1463+ {
1464+ char * param1 = strtok(args, " ");
1465+ uint32 minTime = (uint32) strtoul(param1, NULL, 0);
1466+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET mintime = '%u' WHERE auctionhouse = '%u'", minTime, ahMapID);
1467+ config->SetMinTime(minTime);
1468+ }break;
1469+ case 4: //max time
1470+ {
1471+ char * param1 = strtok(args, " ");
1472+ uint32 maxTime = (uint32) strtoul(param1, NULL, 0);
1473+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxtime = '%u' WHERE auctionhouse = '%u'", maxTime, ahMapID);
1474+ config->SetMaxTime(maxTime);
1475+ }break;
1476+ case 5: //percentages
1477+ {
1478+ char * param1 = strtok(args, " ");
1479+ char * param2 = strtok(NULL, " ");
1480+ char * param3 = strtok(NULL, " ");
1481+ char * param4 = strtok(NULL, " ");
1482+ char * param5 = strtok(NULL, " ");
1483+ char * param6 = strtok(NULL, " ");
1484+ char * param7 = strtok(NULL, " ");
1485+ char * param8 = strtok(NULL, " ");
1486+ char * param9 = strtok(NULL, " ");
1487+ char * param10 = strtok(NULL, " ");
1488+ char * param11 = strtok(NULL, " ");
1489+ char * param12 = strtok(NULL, " ");
1490+ char * param13 = strtok(NULL, " ");
1491+ char * param14 = strtok(NULL, " ");
1492+ uint32 greytg = (uint32) strtoul(param1, NULL, 0);
1493+ uint32 whitetg = (uint32) strtoul(param2, NULL, 0);
1494+ uint32 greentg = (uint32) strtoul(param3, NULL, 0);
1495+ uint32 bluetg = (uint32) strtoul(param4, NULL, 0);
1496+ uint32 purpletg = (uint32) strtoul(param5, NULL, 0);
1497+ uint32 orangetg = (uint32) strtoul(param6, NULL, 0);
1498+ uint32 yellowtg = (uint32) strtoul(param7, NULL, 0);
1499+ uint32 greyi = (uint32) strtoul(param8, NULL, 0);
1500+ uint32 whitei = (uint32) strtoul(param9, NULL, 0);
1501+ uint32 greeni = (uint32) strtoul(param10, NULL, 0);
1502+ uint32 bluei = (uint32) strtoul(param11, NULL, 0);
1503+ uint32 purplei = (uint32) strtoul(param12, NULL, 0);
1504+ uint32 orangei = (uint32) strtoul(param13, NULL, 0);
1505+ uint32 yellowi = (uint32) strtoul(param14, NULL, 0);
1506+
1507+ CharacterDatabase.BeginTransaction();
1508+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreytradegoods = '%u' WHERE auctionhouse = '%u'", greytg, ahMapID);
1509+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhitetradegoods = '%u' WHERE auctionhouse = '%u'", whitetg, ahMapID);
1510+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreentradegoods = '%u' WHERE auctionhouse = '%u'", greentg, ahMapID);
1511+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentbluetradegoods = '%u' WHERE auctionhouse = '%u'", bluetg, ahMapID);
1512+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentpurpletradegoods = '%u' WHERE auctionhouse = '%u'", purpletg, ahMapID);
1513+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentorangetradegoods = '%u' WHERE auctionhouse = '%u'", orangetg, ahMapID);
1514+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentyellowtradegoods = '%u' WHERE auctionhouse = '%u'", yellowtg, ahMapID);
1515+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreyitems = '%u' WHERE auctionhouse = '%u'", greyi, ahMapID);
1516+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhiteitems = '%u' WHERE auctionhouse = '%u'", whitei, ahMapID);
1517+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreenitems = '%u' WHERE auctionhouse = '%u'", greeni, ahMapID);
1518+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentblueitems = '%u' WHERE auctionhouse = '%u'", bluei, ahMapID);
1519+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentpurpleitems = '%u' WHERE auctionhouse = '%u'", purplei, ahMapID);
1520+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentorangeitems = '%u' WHERE auctionhouse = '%u'", orangei, ahMapID);
1521+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentyellowitems = '%u' WHERE auctionhouse = '%u'", yellowi, ahMapID);
1522+ CharacterDatabase.CommitTransaction();
1523+ config->SetPercentages(greytg, whitetg, greentg, bluetg, purpletg, orangetg, yellowtg, greyi, whitei, greeni, bluei, purplei, orangei, yellowi);
1524+ }break;
1525+ case 6: //min prices
1526+ {
1527+ char * param1 = strtok(args, " ");
1528+ uint32 minPrice = (uint32) strtoul(param1, NULL, 0);
1529+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET minprice%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), minPrice, ahMapID);
1530+ config->SetMinPrice(col, minPrice);
1531+ }break;
1532+ case 7: //max prices
1533+ {
1534+ char * param1 = strtok(args, " ");
1535+ uint32 maxPrice = (uint32) strtoul(param1, NULL, 0);
1536+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxprice%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), maxPrice, ahMapID);
1537+ config->SetMaxPrice(col, maxPrice);
1538+ }break;
1539+ case 8: //min bid price
1540+ {
1541+ char * param1 = strtok(args, " ");
1542+ uint32 minBidPrice = (uint32) strtoul(param1, NULL, 0);
1543+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET minbidprice%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), minBidPrice, ahMapID);
1544+ config->SetMinBidPrice(col, minBidPrice);
1545+ }break;
1546+ case 9: //max bid price
1547+ {
1548+ char * param1 = strtok(args, " ");
1549+ uint32 maxBidPrice = (uint32) strtoul(param1, NULL, 0);
1550+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxbidprice%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), maxBidPrice, ahMapID);
1551+ config->SetMaxBidPrice(col, maxBidPrice);
1552+ }break;
1553+ case 10: //max stacks
1554+ {
1555+ char * param1 = strtok(args, " ");
1556+ uint32 maxStack = (uint32) strtoul(param1, NULL, 0);
1557+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxstack%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), maxStack, ahMapID);
1558+ config->SetMaxStack(col, maxStack);
1559+ }break;
1560+ case 11: //buyer bid prices
1561+ {
1562+ char * param1 = strtok(args, " ");
1563+ uint32 buyerPrice = (uint32) strtoul(param1, NULL, 0);
1564+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET buyerprice%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), buyerPrice, ahMapID);
1565+ config->SetBuyerPrice(col, buyerPrice);
1566+ }break;
1567+ case 12: //buyer bidding interval
1568+ {
1569+ char * param1 = strtok(args, " ");
1570+ uint32 bidInterval = (uint32) strtoul(param1, NULL, 0);
1571+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET buyerbiddinginterval = '%u' WHERE auctionhouse = '%u'", bidInterval, ahMapID);
1572+ config->SetBiddingInterval(bidInterval);
1573+ }break;
1574+ case 13: //buyer bids per interval
1575+ {
1576+ char * param1 = strtok(args, " ");
1577+ uint32 bidsPerInterval = (uint32) strtoul(param1, NULL, 0);
1578+ CharacterDatabase.PExecute("UPDATE auctionhousebot SET buyerbidsperinterval = '%u' WHERE auctionhouse = '%u'", bidsPerInterval, ahMapID);
1579+ config->SetBidsPerInterval(bidsPerInterval);
1580+ }break;
1581+ default:
1582+ break;
1583+ }
1584+}
1585+
1586+void AuctionHouseBot::LoadValues(AHBConfig *config)
1587+{
1588+ if (AHBSeller)
1589+ {
1590+ //load min and max items
1591+ config->SetMinItems(CharacterDatabase.PQuery("SELECT minitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1592+ config->SetMaxItems(CharacterDatabase.PQuery("SELECT maxitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1593+ if (debug_Out)
1594+ {
1595+ sLog.outError("minItems = %u", config->GetMinItems());
1596+ sLog.outError("maxItems = %u", config->GetMaxItems());
1597+ }
1598+ //load min and max auction times
1599+ config->SetMinTime(CharacterDatabase.PQuery("SELECT mintime FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1600+ config->SetMaxTime(CharacterDatabase.PQuery("SELECT maxtime FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1601+ if (debug_Out)
1602+ {
1603+ sLog.outError("minTime = %u", config->GetMinTime());
1604+ sLog.outError("maxTime = %u", config->GetMaxTime());
1605+ }
1606+ //load percentages
1607+ uint32 greytg = CharacterDatabase.PQuery("SELECT percentgreytradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
1608+ uint32 whitetg = CharacterDatabase.PQuery("SELECT percentwhitetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
1609+ uint32 greentg = CharacterDatabase.PQuery("SELECT percentgreentradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
1610+ uint32 bluetg = CharacterDatabase.PQuery("SELECT percentbluetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
1611+ uint32 purpletg = CharacterDatabase.PQuery("SELECT percentpurpletradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
1612+ uint32 orangetg = CharacterDatabase.PQuery("SELECT percentorangetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
1613+ uint32 yellowtg = CharacterDatabase.PQuery("SELECT percentyellowtradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
1614+ uint32 greyi = CharacterDatabase.PQuery("SELECT percentgreyitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
1615+ uint32 whitei = CharacterDatabase.PQuery("SELECT percentwhiteitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
1616+ uint32 greeni = CharacterDatabase.PQuery("SELECT percentgreenitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
1617+ uint32 bluei = CharacterDatabase.PQuery("SELECT percentblueitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
1618+ uint32 purplei = CharacterDatabase.PQuery("SELECT percentpurpleitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
1619+ uint32 orangei = CharacterDatabase.PQuery("SELECT percentorangeitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
1620+ uint32 yellowi = CharacterDatabase.PQuery("SELECT percentyellowitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
1621+ config->SetPercentages(greytg, whitetg, greentg, bluetg, purpletg, orangetg, yellowtg, greyi, whitei, greeni, bluei, purplei, orangei, yellowi);
1622+ if (debug_Out)
1623+ {
1624+ sLog.outError("percentGreyTradeGoods = %u", config->GetPercentages(AHB_GREY_TG));
1625+ sLog.outError("percentWhiteTradeGoods = %u", config->GetPercentages(AHB_WHITE_TG));
1626+ sLog.outError("percentGreenTradeGoods = %u", config->GetPercentages(AHB_GREEN_TG));
1627+ sLog.outError("percentBlueTradeGoods = %u", config->GetPercentages(AHB_BLUE_TG));
1628+ sLog.outError("percentPurpleTradeGoods = %u", config->GetPercentages(AHB_PURPLE_TG));
1629+ sLog.outError("percentOrangeTradeGoods = %u", config->GetPercentages(AHB_ORANGE_TG));
1630+ sLog.outError("percentYellowTradeGoods = %u", config->GetPercentages(AHB_YELLOW_TG));
1631+ sLog.outError("percentGreyItems = %u", config->GetPercentages(AHB_GREY_I));
1632+ sLog.outError("percentWhiteItems = %u", config->GetPercentages(AHB_WHITE_I));
1633+ sLog.outError("percentGreenItems = %u", config->GetPercentages(AHB_GREEN_I));
1634+ sLog.outError("percentBlueItems = %u", config->GetPercentages(AHB_BLUE_I));
1635+ sLog.outError("percentPurpleItems = %u", config->GetPercentages(AHB_PURPLE_I));
1636+ sLog.outError("percentOrangeItems = %u", config->GetPercentages(AHB_ORANGE_I));
1637+ sLog.outError("percentYellowItems = %u", config->GetPercentages(AHB_YELLOW_I));
1638+ }
1639+ //load min and max prices
1640+ config->SetMinPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT minpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1641+ config->SetMaxPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT maxpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1642+ if (debug_Out)
1643+ {
1644+ sLog.outError("minPriceGrey = %u", config->GetMinPrice(AHB_GREY));
1645+ sLog.outError("maxPriceGrey = %u", config->GetMaxPrice(AHB_GREY));
1646+ }
1647+ config->SetMinPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT minpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1648+ config->SetMaxPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT maxpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1649+ if (debug_Out)
1650+ {
1651+ sLog.outError("minPriceWhite = %u", config->GetMinPrice(AHB_WHITE));
1652+ sLog.outError("maxPriceWhite = %u", config->GetMaxPrice(AHB_WHITE));
1653+ }
1654+ config->SetMinPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT minpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1655+ config->SetMaxPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT maxpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1656+ if (debug_Out)
1657+ {
1658+ sLog.outError("minPriceGreen = %u", config->GetMinPrice(AHB_GREEN));
1659+ sLog.outError("maxPriceGreen = %u", config->GetMaxPrice(AHB_GREEN));
1660+ }
1661+ config->SetMinPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT minpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1662+ config->SetMaxPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT maxpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1663+ if (debug_Out)
1664+ {
1665+ sLog.outError("minPriceBlue = %u", config->GetMinPrice(AHB_BLUE));
1666+ sLog.outError("maxPriceBlue = %u", config->GetMaxPrice(AHB_BLUE));
1667+ }
1668+ config->SetMinPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT minpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1669+ config->SetMaxPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT maxpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1670+ if (debug_Out)
1671+ {
1672+ sLog.outError("minPricePurple = %u", config->GetMinPrice(AHB_PURPLE));
1673+ sLog.outError("maxPricePurple = %u", config->GetMaxPrice(AHB_PURPLE));
1674+ }
1675+ config->SetMinPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT minpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1676+ config->SetMaxPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT maxpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1677+ if (debug_Out)
1678+ {
1679+ sLog.outError("minPriceOrange = %u", config->GetMinPrice(AHB_ORANGE));
1680+ sLog.outError("maxPriceOrange = %u", config->GetMaxPrice(AHB_ORANGE));
1681+ }
1682+ config->SetMinPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT minpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1683+ config->SetMaxPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT maxpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1684+ if (debug_Out)
1685+ {
1686+ sLog.outError("minPriceYellow = %u", config->GetMinPrice(AHB_YELLOW));
1687+ sLog.outError("maxPriceYellow = %u", config->GetMaxPrice(AHB_YELLOW));
1688+ }
1689+ //load min and max bid prices
1690+ config->SetMinBidPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT minbidpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1691+ if (debug_Out)
1692+ {
1693+ sLog.outError("minBidPriceGrey = %u", config->GetMinBidPrice(AHB_GREY));
1694+ }
1695+ config->SetMaxBidPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT maxbidpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1696+ if (debug_Out)
1697+ {
1698+ sLog.outError("maxBidPriceGrey = %u", config->GetMaxBidPrice(AHB_GREY));
1699+ }
1700+ config->SetMinBidPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT minbidpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1701+ if (debug_Out)
1702+ {
1703+ sLog.outError("minBidPriceWhite = %u", config->GetMinBidPrice(AHB_WHITE));
1704+ }
1705+ config->SetMaxBidPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT maxbidpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1706+ if (debug_Out)
1707+ {
1708+ sLog.outError("maxBidPriceWhite = %u", config->GetMaxBidPrice(AHB_WHITE));
1709+ }
1710+ config->SetMinBidPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT minbidpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1711+ if (debug_Out)
1712+ {
1713+ sLog.outError("minBidPriceGreen = %u", config->GetMinBidPrice(AHB_GREEN));
1714+ }
1715+ config->SetMaxBidPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT maxbidpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1716+ if (debug_Out)
1717+ {
1718+ sLog.outError("maxBidPriceGreen = %u", config->GetMaxBidPrice(AHB_GREEN));
1719+ }
1720+ config->SetMinBidPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT minbidpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1721+ if (debug_Out)
1722+ {
1723+ sLog.outError("minBidPriceBlue = %u", config->GetMinBidPrice(AHB_BLUE));
1724+ }
1725+ config->SetMaxBidPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT maxbidpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1726+ if (debug_Out)
1727+ {
1728+ sLog.outError("maxBidPriceBlue = %u", config->GetMinBidPrice(AHB_BLUE));
1729+ }
1730+ config->SetMinBidPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT minbidpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1731+ if (debug_Out)
1732+ {
1733+ sLog.outError("minBidPricePurple = %u", config->GetMinBidPrice(AHB_PURPLE));
1734+ }
1735+ config->SetMaxBidPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT maxbidpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1736+ if (debug_Out)
1737+ {
1738+ sLog.outError("maxBidPricePurple = %u", config->GetMaxBidPrice(AHB_PURPLE));
1739+ }
1740+ config->SetMinBidPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT minbidpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1741+ if (debug_Out)
1742+ {
1743+ sLog.outError("minBidPriceOrange = %u", config->GetMinBidPrice(AHB_ORANGE));
1744+ }
1745+ config->SetMaxBidPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT maxbidpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1746+ if (debug_Out)
1747+ {
1748+ sLog.outError("maxBidPriceOrange = %u", config->GetMaxBidPrice(AHB_ORANGE));
1749+ }
1750+ config->SetMinBidPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT minbidpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1751+ if (debug_Out)
1752+ {
1753+ sLog.outError("minBidPriceYellow = %u", config->GetMinBidPrice(AHB_YELLOW));
1754+ }
1755+ config->SetMaxBidPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT maxbidpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1756+ if (debug_Out)
1757+ {sLog.outError("maxBidPriceYellow = %u", config->GetMaxBidPrice(AHB_YELLOW));
1758+ }
1759+ //load max stacks
1760+ config->SetMaxStack(AHB_GREY, CharacterDatabase.PQuery("SELECT maxstackgrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1761+ if (debug_Out)
1762+ {
1763+ sLog.outError("maxStackGrey = %u", config->GetMaxStack(AHB_GREY));
1764+ }
1765+ config->SetMaxStack(AHB_WHITE, CharacterDatabase.PQuery("SELECT maxstackwhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1766+ if (debug_Out)
1767+ {
1768+ sLog.outError("maxStackWhite = %u", config->GetMaxStack(AHB_WHITE));
1769+ }
1770+ config->SetMaxStack(AHB_GREEN, CharacterDatabase.PQuery("SELECT maxstackgreen FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1771+ if (debug_Out)
1772+ {
1773+ sLog.outError("maxStackGreen = %u", config->GetMaxStack(AHB_GREEN));
1774+ }
1775+ config->SetMaxStack(AHB_BLUE, CharacterDatabase.PQuery("SELECT maxstackblue FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1776+ if (debug_Out)
1777+ {
1778+ sLog.outError("maxStackBlue = %u", config->GetMaxStack(AHB_BLUE));
1779+ }
1780+ config->SetMaxStack(AHB_PURPLE, CharacterDatabase.PQuery("SELECT maxstackpurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1781+ if (debug_Out)
1782+ {
1783+ sLog.outError("maxStackPurple = %u", config->GetMaxStack(AHB_PURPLE));
1784+ }
1785+ config->SetMaxStack(AHB_ORANGE, CharacterDatabase.PQuery("SELECT maxstackorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1786+ if (debug_Out)
1787+ {
1788+ sLog.outError("maxStackOrange = %u", config->GetMaxStack(AHB_ORANGE));
1789+ }
1790+ config->SetMaxStack(AHB_YELLOW, CharacterDatabase.PQuery("SELECT maxstackyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1791+ if (debug_Out)
1792+ {
1793+ sLog.outError("maxStackYellow = %u", config->GetMaxStack(AHB_YELLOW));
1794+ }
1795+ }
1796+ if (AHBBuyer)
1797+ {
1798+ //load buyer bid prices
1799+ config->SetBuyerPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT buyerpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1800+ config->SetBuyerPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT buyerpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1801+ config->SetBuyerPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT buyerpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1802+ config->SetBuyerPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT buyerpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1803+ config->SetBuyerPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT buyerpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1804+ config->SetBuyerPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT buyerpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1805+ config->SetBuyerPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT buyerpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1806+ if (debug_Out)
1807+ {
1808+ sLog.outError("buyerPriceGrey = %u", config->GetBuyerPrice(AHB_GREY));
1809+ sLog.outError("buyerPriceWhite = %u", config->GetBuyerPrice(AHB_WHITE));
1810+ sLog.outError("buyerPriceGreen = %u", config->GetBuyerPrice(AHB_GREEN));
1811+ sLog.outError("buyerPriceBlue = %u", config->GetBuyerPrice(AHB_BLUE));
1812+ sLog.outError("buyerPricePurple = %u", config->GetBuyerPrice(AHB_PURPLE));
1813+ sLog.outError("buyerPriceOrange = %u", config->GetBuyerPrice(AHB_ORANGE));
1814+ sLog.outError("buyerPriceYellow = %u", config->GetBuyerPrice(AHB_YELLOW));
1815+ }
1816+ //load bidding interval
1817+ config->SetBiddingInterval(CharacterDatabase.PQuery("SELECT buyerbiddinginterval FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1818+ if (debug_Out)
1819+ {
1820+ sLog.outError("buyerBiddingInterval = %u", config->GetBiddingInterval());
1821+ }
1822+ //load bids per interval
1823+ config->SetBidsPerInterval(CharacterDatabase.PQuery("SELECT buyerbidsperinterval FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
1824+ if (debug_Out)
1825+ {
1826+ sLog.outError("buyerBidsPerInterval = %u", config->GetBidsPerInterval());
1827+ }
1828+ }
1829+}
1830diff --git a/src/game/AuctionHouseBot.h b/src/game/AuctionHouseBot.h
1831new file mode 100644
1832index 0000000..b5810fa
1833--- /dev/null
1834+++ b/src/game/AuctionHouseBot.h
1835@@ -0,0 +1,979 @@
1836+#ifndef AUCTION_HOUSE_BOT_H
1837+#define AUCTION_HOUSE_BOT_H
1838+
1839+#include "World.h"
1840+#include "Config/ConfigEnv.h"
1841+#include "ace/Vector_T.h"
1842+
1843+#define AHB_GREY 0
1844+#define AHB_WHITE 1
1845+#define AHB_GREEN 2
1846+#define AHB_BLUE 3
1847+#define AHB_PURPLE 4
1848+#define AHB_ORANGE 5
1849+#define AHB_YELLOW 6
1850+#define AHB_GREY_TG 0
1851+#define AHB_WHITE_TG 1
1852+#define AHB_GREEN_TG 2
1853+#define AHB_BLUE_TG 3
1854+#define AHB_PURPLE_TG 4
1855+#define AHB_ORANGE_TG 5
1856+#define AHB_YELLOW_TG 6
1857+#define AHB_GREY_I 7
1858+#define AHB_WHITE_I 8
1859+#define AHB_GREEN_I 9
1860+#define AHB_BLUE_I 10
1861+#define AHB_PURPLE_I 11
1862+#define AHB_ORANGE_I 12
1863+#define AHB_YELLOW_I 13
1864+
1865+class AHBConfig
1866+{
1867+private:
1868+ uint32 AHID;
1869+ uint32 AHFID;
1870+ uint32 minItems;
1871+ uint32 maxItems;
1872+ uint32 minTime;
1873+ uint32 maxTime;
1874+ uint32 percentGreyTradeGoods;
1875+ uint32 percentWhiteTradeGoods;
1876+ uint32 percentGreenTradeGoods;
1877+ uint32 percentBlueTradeGoods;
1878+ uint32 percentPurpleTradeGoods;
1879+ uint32 percentOrangeTradeGoods;
1880+ uint32 percentYellowTradeGoods;
1881+ uint32 percentGreyItems;
1882+ uint32 percentWhiteItems;
1883+ uint32 percentGreenItems;
1884+ uint32 percentBlueItems;
1885+ uint32 percentPurpleItems;
1886+ uint32 percentOrangeItems;
1887+ uint32 percentYellowItems;
1888+ uint32 minPriceGrey;
1889+ uint32 maxPriceGrey;
1890+ uint32 minBidPriceGrey;
1891+ uint32 maxBidPriceGrey;
1892+ uint32 maxStackGrey;
1893+ uint32 minPriceWhite;
1894+ uint32 maxPriceWhite;
1895+ uint32 minBidPriceWhite;
1896+ uint32 maxBidPriceWhite;
1897+ uint32 maxStackWhite;
1898+ uint32 minPriceGreen;
1899+ uint32 maxPriceGreen;
1900+ uint32 minBidPriceGreen;
1901+ uint32 maxBidPriceGreen;
1902+ uint32 maxStackGreen;
1903+ uint32 minPriceBlue;
1904+ uint32 maxPriceBlue;
1905+ uint32 minBidPriceBlue;
1906+ uint32 maxBidPriceBlue;
1907+ uint32 maxStackBlue;
1908+ uint32 minPricePurple;
1909+ uint32 maxPricePurple;
1910+ uint32 minBidPricePurple;
1911+ uint32 maxBidPricePurple;
1912+ uint32 maxStackPurple;
1913+ uint32 minPriceOrange;
1914+ uint32 maxPriceOrange;
1915+ uint32 minBidPriceOrange;
1916+ uint32 maxBidPriceOrange;
1917+ uint32 maxStackOrange;
1918+ uint32 minPriceYellow;
1919+ uint32 maxPriceYellow;
1920+ uint32 minBidPriceYellow;
1921+ uint32 maxBidPriceYellow;
1922+ uint32 maxStackYellow;
1923+
1924+ uint32 buyerPriceGrey;
1925+ uint32 buyerPriceWhite;
1926+ uint32 buyerPriceGreen;
1927+ uint32 buyerPriceBlue;
1928+ uint32 buyerPricePurple;
1929+ uint32 buyerPriceOrange;
1930+ uint32 buyerPriceYellow;
1931+ uint32 buyerBiddingInterval;
1932+ uint32 buyerBidsPerInterval;
1933+
1934+ uint32 greytgp;
1935+ uint32 whitetgp;
1936+ uint32 greentgp;
1937+ uint32 bluetgp;
1938+ uint32 purpletgp;
1939+ uint32 orangetgp;
1940+ uint32 yellowtgp;
1941+ uint32 greyip;
1942+ uint32 whiteip;
1943+ uint32 greenip;
1944+ uint32 blueip;
1945+ uint32 purpleip;
1946+ uint32 orangeip;
1947+ uint32 yellowip;
1948+
1949+public:
1950+ AHBConfig(uint32 ahid)
1951+ {
1952+ AHID = ahid;
1953+ switch(ahid)
1954+ {
1955+ case 2:
1956+ AHFID = 55;
1957+ break;
1958+ case 6:
1959+ AHFID = 29;
1960+ break;
1961+ case 7:
1962+ AHFID = 120;
1963+ break;
1964+ default:
1965+ AHFID = 120;
1966+ break;
1967+ }
1968+ }
1969+ AHBConfig()
1970+ {
1971+ }
1972+ uint32 GetAHID()
1973+ {
1974+ return AHID;
1975+ }
1976+ uint32 GetAHFID()
1977+ {
1978+ return AHFID;
1979+ }
1980+ void SetMinItems(uint32 value)
1981+ {
1982+ minItems = value;
1983+ }
1984+ uint32 GetMinItems()
1985+ {
1986+ if ((minItems == 0) && (maxItems))
1987+ return maxItems;
1988+ else if ((maxItems) && (minItems > maxItems))
1989+ return maxItems;
1990+ else
1991+ return minItems;
1992+ }
1993+ void SetMaxItems(uint32 value)
1994+ {
1995+ maxItems = value;
1996+ CalculatePercents();
1997+ }
1998+ uint32 GetMaxItems()
1999+ {
2000+ return maxItems;
2001+ }
2002+ void SetMinTime(uint32 value)
2003+ {
2004+ minTime = value;
2005+ }
2006+ uint32 GetMinTime()
2007+ {
2008+ if (minTime < 1)
2009+ return 1;
2010+ else if ((maxTime) && (minTime > maxTime))
2011+ return maxTime;
2012+ else
2013+ return minTime;
2014+ }
2015+ void SetMaxTime(uint32 value)
2016+ {
2017+ maxTime = value;
2018+ }
2019+ uint32 GetMaxTime()
2020+ {
2021+ return maxTime;
2022+ }
2023+ 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)
2024+ {
2025+ uint32 totalPercent = greytg + whitetg + greentg + bluetg + purpletg + orangetg + yellowtg + greyi + whitei + greeni + bluei + purplei + orangei + yellowi;
2026+
2027+ if (totalPercent == 0)
2028+ {
2029+ maxItems = 0;
2030+ }
2031+ else if (totalPercent != 100)
2032+ {
2033+ greytg = 0;
2034+ whitetg = 27;
2035+ greentg = 12;
2036+ bluetg = 10;
2037+ purpletg = 1;
2038+ orangetg = 0;
2039+ yellowtg = 0;
2040+ greyi = 0;
2041+ whitei = 10;
2042+ greeni = 30;
2043+ bluei = 8;
2044+ purplei = 2;
2045+ orangei = 0;
2046+ yellowi = 0;
2047+ }
2048+ percentGreyTradeGoods = greytg;
2049+ percentWhiteTradeGoods = whitetg;
2050+ percentGreenTradeGoods = greentg;
2051+ percentBlueTradeGoods = bluetg;
2052+ percentPurpleTradeGoods = purpletg;
2053+ percentOrangeTradeGoods = orangetg;
2054+ percentYellowTradeGoods = yellowtg;
2055+ percentGreyItems = greyi;
2056+ percentWhiteItems = whitei;
2057+ percentGreenItems = greeni;
2058+ percentBlueItems = bluei;
2059+ percentPurpleItems = purplei;
2060+ percentOrangeItems = orangei;
2061+ percentYellowItems = yellowi;
2062+ CalculatePercents();
2063+ }
2064+ uint32 GetPercentages(uint32 color)
2065+ {
2066+ switch(color)
2067+ {
2068+ case AHB_GREY_TG:
2069+ return percentGreyTradeGoods;
2070+ break;
2071+ case AHB_WHITE_TG:
2072+ return percentWhiteTradeGoods;
2073+ break;
2074+ case AHB_GREEN_TG:
2075+ return percentGreenTradeGoods;
2076+ break;
2077+ case AHB_BLUE_TG:
2078+ return percentBlueTradeGoods;
2079+ break;
2080+ case AHB_PURPLE_TG:
2081+ return percentPurpleTradeGoods;
2082+ break;
2083+ case AHB_ORANGE_TG:
2084+ return percentOrangeTradeGoods;
2085+ break;
2086+ case AHB_YELLOW_TG:
2087+ return percentYellowTradeGoods;
2088+ break;
2089+ case AHB_GREY_I:
2090+ return percentGreyItems;
2091+ break;
2092+ case AHB_WHITE_I:
2093+ return percentWhiteItems;
2094+ break;
2095+ case AHB_GREEN_I:
2096+ return percentGreenItems;
2097+ break;
2098+ case AHB_BLUE_I:
2099+ return percentBlueItems;
2100+ break;
2101+ case AHB_PURPLE_I:
2102+ return percentPurpleItems;
2103+ break;
2104+ case AHB_ORANGE_I:
2105+ return percentOrangeItems;
2106+ break;
2107+ case AHB_YELLOW_I:
2108+ return percentYellowItems;
2109+ break;
2110+ default:
2111+ return 0;
2112+ break;
2113+ }
2114+ }
2115+ void SetMinPrice(uint32 color, uint32 value)
2116+ {
2117+ switch(color)
2118+ {
2119+ case AHB_GREY:
2120+ minPriceGrey = value;
2121+ break;
2122+ case AHB_WHITE:
2123+ minPriceWhite = value;
2124+ break;
2125+ case AHB_GREEN:
2126+ minPriceGreen = value;
2127+ break;
2128+ case AHB_BLUE:
2129+ minPriceBlue = value;
2130+ break;
2131+ case AHB_PURPLE:
2132+ minPricePurple = value;
2133+ break;
2134+ case AHB_ORANGE:
2135+ minPriceOrange = value;
2136+ break;
2137+ case AHB_YELLOW:
2138+ minPriceYellow = value;
2139+ break;
2140+ default:
2141+ break;
2142+ }
2143+ }
2144+ uint32 GetMinPrice(uint32 color)
2145+ {
2146+ switch(color)
2147+ {
2148+ case AHB_GREY:
2149+ {
2150+ if (minPriceGrey == 0)
2151+ return 100;
2152+ else if (minPriceGrey > maxPriceGrey)
2153+ return maxPriceGrey;
2154+ else
2155+ return minPriceGrey;
2156+ break;
2157+ }
2158+ case AHB_WHITE:
2159+ {
2160+ if (minPriceWhite == 0)
2161+ return 150;
2162+ else if (minPriceWhite > maxPriceWhite)
2163+ return maxPriceWhite;
2164+ else
2165+ return minPriceWhite;
2166+ break;
2167+ }
2168+ case AHB_GREEN:
2169+ {
2170+ if (minPriceGreen == 0)
2171+ return 200;
2172+ else if (minPriceGreen > maxPriceGreen)
2173+ return maxPriceGreen;
2174+ else
2175+ return minPriceGreen;
2176+ break;
2177+ }
2178+ case AHB_BLUE:
2179+ {
2180+ if (minPriceBlue == 0)
2181+ return 250;
2182+ else if (minPriceBlue > maxPriceBlue)
2183+ return maxPriceBlue;
2184+ else
2185+ return minPriceBlue;
2186+ break;
2187+ }
2188+ case AHB_PURPLE:
2189+ {
2190+ if (minPricePurple == 0)
2191+ return 300;
2192+ else if (minPricePurple > maxPricePurple)
2193+ return maxPricePurple;
2194+ else
2195+ return minPricePurple;
2196+ break;
2197+ }
2198+ case AHB_ORANGE:
2199+ {
2200+ if (minPriceOrange == 0)
2201+ return 400;
2202+ else if (minPriceOrange > maxPriceOrange)
2203+ return maxPriceOrange;
2204+ else
2205+ return minPriceOrange;
2206+ break;
2207+ }
2208+ case AHB_YELLOW:
2209+ {
2210+ if (minPriceYellow == 0)
2211+ return 500;
2212+ else if (minPriceYellow > maxPriceYellow)
2213+ return maxPriceYellow;
2214+ else
2215+ return minPriceYellow;
2216+ break;
2217+ }
2218+ default:
2219+ {
2220+ return 0;
2221+ break;
2222+ }
2223+ }
2224+ }
2225+ void SetMaxPrice(uint32 color, uint32 value)
2226+ {
2227+ switch(color)
2228+ {
2229+ case AHB_GREY:
2230+ maxPriceGrey = value;
2231+ break;
2232+ case AHB_WHITE:
2233+ maxPriceWhite = value;
2234+ break;
2235+ case AHB_GREEN:
2236+ maxPriceGreen = value;
2237+ break;
2238+ case AHB_BLUE:
2239+ maxPriceBlue = value;
2240+ break;
2241+ case AHB_PURPLE:
2242+ maxPricePurple = value;
2243+ break;
2244+ case AHB_ORANGE:
2245+ maxPriceOrange = value;
2246+ break;
2247+ case AHB_YELLOW:
2248+ maxPriceYellow = value;
2249+ break;
2250+ default:
2251+ break;
2252+ }
2253+ }
2254+ uint32 GetMaxPrice(uint32 color)
2255+ {
2256+ switch(color)
2257+ {
2258+ case AHB_GREY:
2259+ {
2260+ if (maxPriceGrey == 0)
2261+ return 150;
2262+ else
2263+ return maxPriceGrey;
2264+ break;
2265+ }
2266+ case AHB_WHITE:
2267+ {
2268+ if (maxPriceWhite == 0)
2269+ return 250;
2270+ else
2271+ return maxPriceWhite;
2272+ break;
2273+ }
2274+ case AHB_GREEN:
2275+ {
2276+ if (maxPriceGreen == 0)
2277+ return 300;
2278+ else
2279+ return maxPriceGreen;
2280+ break;
2281+ }
2282+ case AHB_BLUE:
2283+ {
2284+ if (maxPriceBlue == 0)
2285+ return 350;
2286+ else
2287+ return maxPriceBlue;
2288+ break;
2289+ }
2290+ case AHB_PURPLE:
2291+ {
2292+ if (maxPricePurple == 0)
2293+ return 450;
2294+ else
2295+ return maxPricePurple;
2296+ break;
2297+ }
2298+ case AHB_ORANGE:
2299+ {
2300+ if (maxPriceOrange == 0)
2301+ return 550;
2302+ else
2303+ return maxPriceOrange;
2304+ break;
2305+ }
2306+ case AHB_YELLOW:
2307+ {
2308+ if (maxPriceYellow == 0)
2309+ return 650;
2310+ else
2311+ return maxPriceYellow;
2312+ break;
2313+ }
2314+ default:
2315+ {
2316+ return 0;
2317+ break;
2318+ }
2319+ }
2320+ }
2321+ void SetMinBidPrice(uint32 color, uint32 value)
2322+ {
2323+ switch(color)
2324+ {
2325+ case AHB_GREY:
2326+ minBidPriceGrey = value;
2327+ break;
2328+ case AHB_WHITE:
2329+ minBidPriceWhite = value;
2330+ break;
2331+ case AHB_GREEN:
2332+ minBidPriceGreen = value;
2333+ break;
2334+ case AHB_BLUE:
2335+ minBidPriceBlue = value;
2336+ break;
2337+ case AHB_PURPLE:
2338+ minBidPricePurple = value;
2339+ break;
2340+ case AHB_ORANGE:
2341+ minBidPriceOrange = value;
2342+ break;
2343+ case AHB_YELLOW:
2344+ minBidPriceYellow = value;
2345+ break;
2346+ default:
2347+ break;
2348+ }
2349+ }
2350+ uint32 GetMinBidPrice(uint32 color)
2351+ {
2352+ switch(color)
2353+ {
2354+ case AHB_GREY:
2355+ {
2356+ if (minBidPriceGrey > 100)
2357+ return 100;
2358+ else
2359+ return minBidPriceGrey;
2360+ break;
2361+ }
2362+ case AHB_WHITE:
2363+ {
2364+ if (minBidPriceWhite > 100)
2365+ return 100;
2366+ else
2367+ return minBidPriceWhite;
2368+ break;
2369+ }
2370+ case AHB_GREEN:
2371+ {
2372+ if (minBidPriceGreen > 100)
2373+ return 100;
2374+ else
2375+ return minBidPriceGreen;
2376+ break;
2377+ }
2378+ case AHB_BLUE:
2379+ {
2380+ if (minBidPriceBlue > 100)
2381+ return 100;
2382+ else
2383+ return minBidPriceBlue;
2384+ break;
2385+ }
2386+ case AHB_PURPLE:
2387+ {
2388+ if (minBidPricePurple > 100)
2389+ return 100;
2390+ else
2391+ return minBidPricePurple;
2392+ break;
2393+ }
2394+ case AHB_ORANGE:
2395+ {
2396+ if (minBidPriceOrange > 100)
2397+ return 100;
2398+ else
2399+ return minBidPriceOrange;
2400+ break;
2401+ }
2402+ case AHB_YELLOW:
2403+ {
2404+ if (minBidPriceYellow > 100)
2405+ return 100;
2406+ else
2407+ return minBidPriceYellow;
2408+ break;
2409+ }
2410+ default:
2411+ {
2412+ return 0;
2413+ break;
2414+ }
2415+ }
2416+ }
2417+ void SetMaxBidPrice(uint32 color, uint32 value)
2418+ {
2419+ switch(color)
2420+ {
2421+ case AHB_GREY:
2422+ maxBidPriceGrey = value;
2423+ break;
2424+ case AHB_WHITE:
2425+ maxBidPriceWhite = value;
2426+ break;
2427+ case AHB_GREEN:
2428+ maxBidPriceGreen = value;
2429+ break;
2430+ case AHB_BLUE:
2431+ maxBidPriceBlue = value;
2432+ break;
2433+ case AHB_PURPLE:
2434+ maxBidPricePurple = value;
2435+ break;
2436+ case AHB_ORANGE:
2437+ maxBidPriceOrange = value;
2438+ break;
2439+ case AHB_YELLOW:
2440+ maxBidPriceYellow = value;
2441+ break;
2442+ default:
2443+ break;
2444+ }
2445+ }
2446+ uint32 GetMaxBidPrice(uint32 color)
2447+ {
2448+ switch(color)
2449+ {
2450+ case AHB_GREY:
2451+ {
2452+ if (maxBidPriceGrey > 100)
2453+ return 100;
2454+ else
2455+ return maxBidPriceGrey;
2456+ break;
2457+ }
2458+ case AHB_WHITE:
2459+ {
2460+ if (maxBidPriceWhite > 100)
2461+ return 100;
2462+ else
2463+ return maxBidPriceWhite;
2464+ break;
2465+ }
2466+ case AHB_GREEN:
2467+ {
2468+ if (maxBidPriceGreen > 100)
2469+ return 100;
2470+ else
2471+ return maxBidPriceGreen;
2472+ break;
2473+ }
2474+ case AHB_BLUE:
2475+ {
2476+ if (maxBidPriceBlue > 100)
2477+ return 100;
2478+ else
2479+ return maxBidPriceBlue;
2480+ break;
2481+ }
2482+ case AHB_PURPLE:
2483+ {
2484+ if (maxBidPricePurple > 100)
2485+ return 100;
2486+ else
2487+ return maxBidPricePurple;
2488+ break;
2489+ }
2490+ case AHB_ORANGE:
2491+ {
2492+ if (maxBidPriceOrange > 100)
2493+ return 100;
2494+ else
2495+ return maxBidPriceOrange;
2496+ break;
2497+ }
2498+ case AHB_YELLOW:
2499+ {
2500+ if (maxBidPriceYellow > 100)
2501+ return 100;
2502+ else
2503+ return maxBidPriceYellow;
2504+ break;
2505+ }
2506+ default:
2507+ {
2508+ return 0;
2509+ break;
2510+ }
2511+ }
2512+ }
2513+ void SetMaxStack(uint32 color, uint32 value)
2514+ {
2515+ switch(color)
2516+ {
2517+ case AHB_GREY:
2518+ maxStackGrey = value;
2519+ break;
2520+ case AHB_WHITE:
2521+ maxStackWhite = value;
2522+ break;
2523+ case AHB_GREEN:
2524+ maxStackGreen = value;
2525+ break;
2526+ case AHB_BLUE:
2527+ maxStackBlue = value;
2528+ break;
2529+ case AHB_PURPLE:
2530+ maxStackPurple = value;
2531+ break;
2532+ case AHB_ORANGE:
2533+ maxStackOrange = value;
2534+ break;
2535+ case AHB_YELLOW:
2536+ maxStackYellow = value;
2537+ break;
2538+ default:
2539+ break;
2540+ }
2541+ }
2542+ uint32 GetMaxStack(uint32 color)
2543+ {
2544+ switch(color)
2545+ {
2546+ case AHB_GREY:
2547+ {
2548+ return maxStackGrey;
2549+ break;
2550+ }
2551+ case AHB_WHITE:
2552+ {
2553+ return maxStackWhite;
2554+ break;
2555+ }
2556+ case AHB_GREEN:
2557+ {
2558+ return maxStackGreen;
2559+ break;
2560+ }
2561+ case AHB_BLUE:
2562+ {
2563+ return maxStackBlue;
2564+ break;
2565+ }
2566+ case AHB_PURPLE:
2567+ {
2568+ return maxStackPurple;
2569+ break;
2570+ }
2571+ case AHB_ORANGE:
2572+ {
2573+ return maxStackOrange;
2574+ break;
2575+ }
2576+ case AHB_YELLOW:
2577+ {
2578+ return maxStackYellow;
2579+ break;
2580+ }
2581+ default:
2582+ {
2583+ return 0;
2584+ break;
2585+ }
2586+ }
2587+ }
2588+ void SetBuyerPrice(uint32 color, uint32 value)
2589+ {
2590+ switch(color)
2591+ {
2592+ case AHB_GREY:
2593+ buyerPriceGrey = value;
2594+ break;
2595+ case AHB_WHITE:
2596+ buyerPriceWhite = value;
2597+ break;
2598+ case AHB_GREEN:
2599+ buyerPriceGreen = value;
2600+ break;
2601+ case AHB_BLUE:
2602+ buyerPriceBlue = value;
2603+ break;
2604+ case AHB_PURPLE:
2605+ buyerPricePurple = value;
2606+ break;
2607+ case AHB_ORANGE:
2608+ buyerPriceOrange = value;
2609+ break;
2610+ case AHB_YELLOW:
2611+ buyerPriceYellow = value;
2612+ break;
2613+ default:
2614+ break;
2615+ }
2616+ }
2617+ uint32 GetBuyerPrice(uint32 color)
2618+ {
2619+ switch(color)
2620+ {
2621+ case AHB_GREY:
2622+ return buyerPriceGrey;
2623+ break;
2624+ case AHB_WHITE:
2625+ return buyerPriceWhite;
2626+ break;
2627+ case AHB_GREEN:
2628+ return buyerPriceGreen;
2629+ break;
2630+ case AHB_BLUE:
2631+ return buyerPriceBlue;
2632+ break;
2633+ case AHB_PURPLE:
2634+ return buyerPricePurple;
2635+ break;
2636+ case AHB_ORANGE:
2637+ return buyerPriceOrange;
2638+ break;
2639+ case AHB_YELLOW:
2640+ return buyerPriceYellow;
2641+ break;
2642+ default:
2643+ return 0;
2644+ break;
2645+ }
2646+ }
2647+ void SetBiddingInterval(uint32 value)
2648+ {
2649+ buyerBiddingInterval = value;
2650+ }
2651+ uint32 GetBiddingInterval()
2652+ {
2653+ return buyerBiddingInterval;
2654+ }
2655+ void CalculatePercents()
2656+ {
2657+ greytgp = (uint32) (((double)percentGreyTradeGoods / 100.0) * maxItems);
2658+ whitetgp = (uint32) (((double)percentWhiteTradeGoods / 100.0) * maxItems);
2659+ greentgp = (uint32) (((double)percentGreenTradeGoods / 100.0) * maxItems);
2660+ bluetgp = (uint32) (((double)percentBlueTradeGoods / 100.0) * maxItems);
2661+ purpletgp = (uint32) (((double)percentPurpleTradeGoods / 100.0) * maxItems);
2662+ orangetgp = (uint32) (((double)percentOrangeTradeGoods / 100.0) * maxItems);
2663+ yellowtgp = (uint32) (((double)percentYellowTradeGoods / 100.0) * maxItems);
2664+ greyip = (uint32) (((double)percentGreyItems / 100.0) * maxItems);
2665+ whiteip = (uint32) (((double)percentWhiteItems / 100.0) * maxItems);
2666+ greenip = (uint32) (((double)percentGreenItems / 100.0) * maxItems);
2667+ blueip = (uint32) (((double)percentBlueItems / 100.0) * maxItems);
2668+ purpleip = (uint32) (((double)percentPurpleItems / 100.0) * maxItems);
2669+ orangeip = (uint32) (((double)percentOrangeItems / 100.0) * maxItems);
2670+ yellowip = (uint32) (((double)percentYellowItems / 100.0) * maxItems);
2671+ uint32 total = greytgp + whitetgp + greentgp + bluetgp + purpletgp + orangetgp + yellowtgp + greyip + whiteip + greenip + blueip + purpleip + orangeip + yellowip;
2672+ int32 diff = (maxItems - total);
2673+ if (diff < 0)
2674+ {
2675+ if ((whiteip - diff) > 0)
2676+ whiteip -= diff;
2677+ else if ((greenip - diff) > 0)
2678+ greenip -= diff;
2679+ }
2680+ else if (diff < 0)
2681+ {
2682+ whiteip += diff;
2683+ }
2684+ }
2685+ uint32 GetPercents(uint32 color)
2686+ {
2687+ switch(color)
2688+ {
2689+ case AHB_GREY_TG:
2690+ return greytgp;
2691+ break;
2692+ case AHB_WHITE_TG:
2693+ return whitetgp;
2694+ break;
2695+ case AHB_GREEN_TG:
2696+ return greentgp;
2697+ break;
2698+ case AHB_BLUE_TG:
2699+ return bluetgp;
2700+ break;
2701+ case AHB_PURPLE_TG:
2702+ return purpletgp;
2703+ break;
2704+ case AHB_ORANGE_TG:
2705+ return orangetgp;
2706+ break;
2707+ case AHB_YELLOW_TG:
2708+ return yellowtgp;
2709+ break;
2710+ case AHB_GREY_I:
2711+ return greyip;
2712+ break;
2713+ case AHB_WHITE_I:
2714+ return whiteip;
2715+ break;
2716+ case AHB_GREEN_I:
2717+ return greenip;
2718+ break;
2719+ case AHB_BLUE_I:
2720+ return blueip;
2721+ break;
2722+ case AHB_PURPLE_I:
2723+ return purpleip;
2724+ break;
2725+ case AHB_ORANGE_I:
2726+ return orangeip;
2727+ break;
2728+ case AHB_YELLOW_I:
2729+ return yellowip;
2730+ break;
2731+ default:
2732+ return 0;
2733+ break;
2734+ }
2735+ }
2736+ void SetBidsPerInterval(uint32 value)
2737+ {
2738+ buyerBidsPerInterval = value;
2739+ }
2740+ uint32 GetBidsPerInterval()
2741+ {
2742+ return buyerBidsPerInterval;
2743+ }
2744+ ~AHBConfig()
2745+ {
2746+ }
2747+};
2748+
2749+class AuctionHouseBot
2750+{
2751+private:
2752+ ACE_Vector<uint32> npcItems;
2753+ ACE_Vector<uint32> lootItems;
2754+ ACE_Vector<uint32> greyTradeGoodsBin;
2755+ ACE_Vector<uint32> whiteTradeGoodsBin;
2756+ ACE_Vector<uint32> greenTradeGoodsBin;
2757+ ACE_Vector<uint32> blueTradeGoodsBin;
2758+ ACE_Vector<uint32> purpleTradeGoodsBin;
2759+ ACE_Vector<uint32> orangeTradeGoodsBin;
2760+ ACE_Vector<uint32> yellowTradeGoodsBin;
2761+ ACE_Vector<uint32> greyItemsBin;
2762+ ACE_Vector<uint32> whiteItemsBin;
2763+ ACE_Vector<uint32> greenItemsBin;
2764+ ACE_Vector<uint32> blueItemsBin;
2765+ ACE_Vector<uint32> purpleItemsBin;
2766+ ACE_Vector<uint32> orangeItemsBin;
2767+ ACE_Vector<uint32> yellowItemsBin;
2768+
2769+ bool AHBSeller;
2770+ bool AHBBuyer;
2771+ bool BuyMethod;
2772+ bool SellMethod;
2773+
2774+ uint32 AHBplayerAccount;
2775+ uint32 AHBplayerGUID;
2776+ uint32 ItemsPerCycle;
2777+
2778+ bool debug_Out;
2779+
2780+ bool Vendor_Items;
2781+ bool Loot_Items;
2782+ bool Other_Items;
2783+
2784+ bool No_Bind;
2785+ bool Bind_When_Picked_Up;
2786+ bool Bind_When_Equipped;
2787+ bool Bind_When_Use;
2788+ bool Bind_Quest_Item;
2789+
2790+ AHBConfig AllianceConfig;
2791+ AHBConfig HordeConfig;
2792+ AHBConfig NeutralConfig;
2793+
2794+ time_t _lastrun_a;
2795+ time_t _lastrun_h;
2796+ time_t _lastrun_n;
2797+
2798+ inline uint32 minValue(uint32 a, uint32 b) { return a <= b ? a : b; };
2799+ void addNewAuctions(Player *AHBplayer, AHBConfig *config);
2800+ void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, WorldSession *session);
2801+
2802+public:
2803+ AuctionHouseBot();
2804+ ~AuctionHouseBot();
2805+ void Update();
2806+ void Initialize();
2807+ void LoadValues(AHBConfig*);
2808+ void Commands(uint32, uint32, uint32, char*);
2809+ uint32 GetAHBplayerGUID() { return AHBplayerGUID; };
2810+};
2811+
2812+#define auctionbot MaNGOS::Singleton<AuctionHouseBot>::Instance()
2813+
2814+#endif
2815diff --git a/src/game/AuctionHouseHandler.cpp b/src/game/AuctionHouseHandler.cpp
2816index 067d65a..e7a834a 100644
2817--- a/src/game/AuctionHouseHandler.cpp
2818+++ b/src/game/AuctionHouseHandler.cpp
2819@@ -27,6 +27,7 @@
2820 #include "UpdateMask.h"
2821 #include "AuctionHouseMgr.h"
2822 #include "Util.h"
2823+#include "AuctionHouseBot.h"
2824
2825 //please DO NOT use iterator++, because it is slower than ++iterator!!!
2826 //post-incrementation is always slower than pre-incrementation !
2827@@ -120,7 +121,10 @@ void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction, uint32 newPri
2828 std::ostringstream msgAuctionOutbiddedSubject;
2829 msgAuctionOutbiddedSubject << auction->item_template << ":0:" << AUCTION_OUTBIDDED;
2830
2831- if (oldBidder)
2832+ if (oldBidder && !_player)
2833+ oldBidder->GetSession()->SendAuctionBidderNotification( auction->GetHouseId(), auction->Id, auctionbot.GetAHBplayerGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template);
2834+
2835+ if (oldBidder && _player)
2836 oldBidder->GetSession()->SendAuctionBidderNotification( auction->GetHouseId(), auction->Id, _player->GetGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template);
2837
2838 MailDraft(msgAuctionOutbiddedSubject.str())
2839@@ -250,7 +254,10 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
2840
2841 AuctionEntry *AH = new AuctionEntry;
2842 AH->Id = sObjectMgr.GenerateAuctionID();
2843- AH->auctioneer = GUID_LOPART(auctioneer);
2844+ if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
2845+ AH->auctioneer = 23442;
2846+ else
2847+ AH->auctioneer = GUID_LOPART(auctioneer);
2848 AH->item_guidlow = GUID_LOPART(item);
2849 AH->item_template = it->GetEntry();
2850 AH->owner = pl->GetGUIDLow();
2851@@ -262,7 +269,7 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
2852 AH->deposit = deposit;
2853 AH->auctionHouseEntry = auctionHouseEntry;
2854
2855- sLog.outDetail("selling item %u to auctioneer %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u", GUID_LOPART(item), GUID_LOPART(auctioneer), bid, buyout, auction_time, AH->GetHouseId());
2856+ sLog.outDetail("selling item %u to auctioneer %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u", GUID_LOPART(item), AH->auctioneer, bid, buyout, auction_time, AH->GetHouseId());
2857 auctionHouse->AddAuction(AH);
2858
2859 sAuctionMgr.AddAItem(it);
2860diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp
2861index 7243dd4..0a837b5 100644
2862--- a/src/game/AuctionHouseMgr.cpp
2863+++ b/src/game/AuctionHouseMgr.cpp
2864@@ -463,12 +463,12 @@ void AuctionHouseMgr::Update()
2865
2866 AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTemplateId)
2867 {
2868- uint32 houseid = 1; // dwarf auction house (used for normal cut/etc percents)
2869+ uint32 houseid = 7; // goblin auction house
2870
2871 if(!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
2872 {
2873 //FIXME: found way for proper auctionhouse selection by another way
2874- // AuctionHo use.dbc have faction field with _player_ factions associated with auction house races.
2875+ // AuctionHouse.dbc have faction field with _player_ factions associated with auction house races.
2876 // but no easy way convert creature faction to player race faction for specific city
2877 switch(factionTemplateId)
2878 {
2879diff --git a/src/game/AuctionHouseMgr.h b/src/game/AuctionHouseMgr.h
2880index fbcba20..bf2d101 100644
2881--- a/src/game/AuctionHouseMgr.h
2882+++ b/src/game/AuctionHouseMgr.h
2883@@ -84,6 +84,9 @@ class AuctionHouseObject
2884
2885 uint32 Getcount() { return AuctionsMap.size(); }
2886
2887+ AuctionEntryMap::iterator GetAuctionsBegin() {return AuctionsMap.begin();}
2888+ AuctionEntryMap::iterator GetAuctionsEnd() {return AuctionsMap.end();}
2889+
2890 void AddAuction(AuctionEntry *ah)
2891 {
2892 ASSERT( ah );
2893diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
2894index f510fc0..c8b2e56 100644
2895--- a/src/game/Chat.cpp
2896+++ b/src/game/Chat.cpp
2897@@ -664,6 +664,7 @@ ChatCommand * ChatHandler::getCommandTable()
2898 { "cometome", SEC_ADMINISTRATOR, false, &ChatHandler::HandleComeToMeCommand, "", NULL },
2899 { "damage", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDamageCommand, "", NULL },
2900 { "combatstop", SEC_GAMEMASTER, false, &ChatHandler::HandleCombatStopCommand, "", NULL },
2901+ { "ahbotoptions", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAHBotOptionsCommand, "", NULL },
2902 { "flusharenapoints",SEC_ADMINISTRATOR, false, &ChatHandler::HandleFlushArenaPointsCommand, "", NULL },
2903 { "repairitems", SEC_GAMEMASTER, true, &ChatHandler::HandleRepairitemsCommand, "", NULL },
2904 { "waterwalk", SEC_GAMEMASTER, false, &ChatHandler::HandleWaterwalkCommand, "", NULL },
2905diff --git a/src/game/Chat.h b/src/game/Chat.h
2906index 84231ac..44b4036 100644
2907--- a/src/game/Chat.h
2908+++ b/src/game/Chat.h
2909@@ -104,6 +104,7 @@ class ChatHandler
2910 bool HandleAccountSetAddonCommand(const char* args);
2911 bool HandleAccountSetGmLevelCommand(const char* args);
2912 bool HandleAccountSetPasswordCommand(const char* args);
2913+ bool HandleAHBotOptionsCommand(const char* args);
2914
2915 bool HandleBanAccountCommand(const char* args);
2916 bool HandleBanCharacterCommand(const char* args);
2917diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp
2918index aa72b02..17ec56a 100644
2919--- a/src/game/Level3.cpp
2920+++ b/src/game/Level3.cpp
2921@@ -51,6 +51,477 @@
2922 #include "InstanceData.h"
2923 #include "CreatureEventAIMgr.h"
2924 #include "DBCEnums.h"
2925+#include "AuctionHouseBot.h"
2926+
2927+bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
2928+{
2929+ uint32 ahMapID = 0;
2930+ char * opt = strtok((char*)args, " ");
2931+ char * ahMapIdStr = strtok(NULL, " ");
2932+ if (ahMapIdStr)
2933+ {
2934+ ahMapID = (uint32) strtoul(ahMapIdStr, NULL, 0);
2935+ }
2936+ if (!opt)
2937+ {
2938+ PSendSysMessage("Syntax is: ahbotoptions $option $ahMapID (2, 6 or 7) $parameter");
2939+ PSendSysMessage("Try ahbotoptions help to see a list of options.");
2940+ return false;
2941+ }
2942+ int l = strlen(opt);
2943+
2944+ if (strncmp(opt,"help",l) == 0)
2945+ {
2946+ PSendSysMessage("AHBot commands:");
2947+ PSendSysMessage("ahexpire");
2948+ PSendSysMessage("minitems");
2949+ PSendSysMessage("maxitems");
2950+ PSendSysMessage("mintime");
2951+ PSendSysMessage("maxtime");
2952+ PSendSysMessage("percentages");
2953+ PSendSysMessage("minprice");
2954+ PSendSysMessage("maxprice");
2955+ PSendSysMessage("minbidprice");
2956+ PSendSysMessage("maxbidprice");
2957+ PSendSysMessage("maxstack");
2958+ PSendSysMessage("buyerprice");
2959+ PSendSysMessage("bidinterval");
2960+ PSendSysMessage("bidsperinterval");
2961+ return true;
2962+ }
2963+ else if (strncmp(opt,"ahexpire",l) == 0)
2964+ {
2965+ if (!ahMapIdStr)
2966+ {
2967+ PSendSysMessage("Syntax is: ahbotoptions ahexpire $ahMapID (2, 6 or 7)");
2968+ return false;
2969+ }
2970+ auctionbot.Commands(0, ahMapID, NULL, NULL);
2971+ }
2972+ else if (strncmp(opt,"minitems",l) == 0)
2973+ {
2974+ char * param1 = strtok(NULL, " ");
2975+ if ((!ahMapIdStr) || (!param1))
2976+ {
2977+ PSendSysMessage("Syntax is: ahbotoptions minitems $ahMapID (2, 6 or 7) $minItems");
2978+ return false;
2979+ }
2980+ auctionbot.Commands(1, ahMapID, NULL, param1);
2981+ }
2982+ else if (strncmp(opt,"maxitems",l) == 0)
2983+ {
2984+ char * param1 = strtok(NULL, " ");
2985+ if ((!ahMapIdStr) || (!param1))
2986+ {
2987+ PSendSysMessage("Syntax is: ahbotoptions maxitems $ahMapID (2, 6 or 7) $maxItems");
2988+ return false;
2989+ }
2990+ auctionbot.Commands(2, ahMapID, NULL, param1);
2991+ }
2992+ else if (strncmp(opt,"mintime",l) == 0)
2993+ {
2994+ char * param1 = strtok(NULL, " ");
2995+ if ((!ahMapIdStr) || (!param1))
2996+ {
2997+ PSendSysMessage("Syntax is: ahbotoptions mintime $ahMapID (2, 6 or 7) $mintime");
2998+ return false;
2999+ }
3000+ auctionbot.Commands(3, ahMapID, NULL, param1);
3001+ }
3002+ else if (strncmp(opt,"maxtime",l) == 0)
3003+ {
3004+ char * param1 = strtok(NULL, " ");
3005+ if ((!ahMapIdStr) || (!param1))
3006+ {
3007+ PSendSysMessage("Syntax is: ahbotoptions maxtime $ahMapID (2, 6 or 7) $maxtime");
3008+ return false;
3009+ }
3010+ auctionbot.Commands(4, ahMapID, NULL, param1);
3011+ }
3012+ else if (strncmp(opt,"percentages",l) == 0)
3013+ {
3014+ char * param1 = strtok(NULL, " ");
3015+ char * param2 = strtok(NULL, " ");
3016+ char * param3 = strtok(NULL, " ");
3017+ char * param4 = strtok(NULL, " ");
3018+ char * param5 = strtok(NULL, " ");
3019+ char * param6 = strtok(NULL, " ");
3020+ char * param7 = strtok(NULL, " ");
3021+ char * param8 = strtok(NULL, " ");
3022+ char * param9 = strtok(NULL, " ");
3023+ char * param10 = strtok(NULL, " ");
3024+ char * param11 = strtok(NULL, " ");
3025+ char * param12 = strtok(NULL, " ");
3026+ char * param13 = strtok(NULL, " ");
3027+ char * param14 = strtok(NULL, " ");
3028+ if ((!ahMapIdStr) || (!param14))
3029+ {
3030+ PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14");
3031+ PSendSysMessage("1 GreyTradeGoods 2 WhiteTradeGoods 3 GreenTradeGoods 4 BlueTradeGoods 5 PurpleTradeGoods");
3032+ PSendSysMessage("6 OrangeTradeGoods 7 YellowTradeGoods 8 GreyItems 9 WhiteItems 10 GreenItems 11 BlueItems");
3033+ PSendSysMessage("12 PurpleItems 13 OrangeItems 14 YellowItems");
3034+ PSendSysMessage("The total must add up to 100%");
3035+ return false;
3036+ }
3037+ uint32 greytg = (uint32) strtoul(param1, NULL, 0);
3038+ uint32 whitetg = (uint32) strtoul(param2, NULL, 0);
3039+ uint32 greentg = (uint32) strtoul(param3, NULL, 0);
3040+ uint32 bluetg = (uint32) strtoul(param3, NULL, 0);
3041+ uint32 purpletg = (uint32) strtoul(param5, NULL, 0);
3042+ uint32 orangetg = (uint32) strtoul(param6, NULL, 0);
3043+ uint32 yellowtg = (uint32) strtoul(param7, NULL, 0);
3044+ uint32 greyi = (uint32) strtoul(param8, NULL, 0);
3045+ uint32 whitei = (uint32) strtoul(param9, NULL, 0);
3046+ uint32 greeni = (uint32) strtoul(param10, NULL, 0);
3047+ uint32 bluei = (uint32) strtoul(param11, NULL, 0);
3048+ uint32 purplei = (uint32) strtoul(param12, NULL, 0);
3049+ uint32 orangei = (uint32) strtoul(param13, NULL, 0);
3050+ uint32 yellowi = (uint32) strtoul(param14, NULL, 0);
3051+ uint32 totalPercent = greytg + whitetg + greentg + bluetg + purpletg + orangetg + yellowtg + greyi + whitei + greeni + bluei + purplei + orangei + yellowi;
3052+ if ((totalPercent == 0) || (totalPercent != 100))
3053+ {
3054+ PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14");
3055+ PSendSysMessage("1 GreyTradeGoods 2 WhiteTradeGoods 3 GreenTradeGoods 4 BlueTradeGoods 5 PurpleTradeGoods");
3056+ PSendSysMessage("6 OrangeTradeGoods 7 YellowTradeGoods 8 GreyItems 9 WhiteItems 10 GreenItems 11 BlueItems");
3057+ PSendSysMessage("12 PurpleItems 13 OrangeItems 14 YellowItems");
3058+ PSendSysMessage("The total must add up to 100%");
3059+ return false;
3060+ }
3061+ char param[100];
3062+ param[0] = '\0';
3063+ strcat(param, param1);
3064+ strcat(param, " ");
3065+ strcat(param, param2);
3066+ strcat(param, " ");
3067+ strcat(param, param3);
3068+ strcat(param, " ");
3069+ strcat(param, param4);
3070+ strcat(param, " ");
3071+ strcat(param, param5);
3072+ strcat(param, " ");
3073+ strcat(param, param6);
3074+ strcat(param, " ");
3075+ strcat(param, param7);
3076+ strcat(param, " ");
3077+ strcat(param, param8);
3078+ strcat(param, " ");
3079+ strcat(param, param9);
3080+ strcat(param, " ");
3081+ strcat(param, param10);
3082+ strcat(param, " ");
3083+ strcat(param, param11);
3084+ strcat(param, " ");
3085+ strcat(param, param12);
3086+ strcat(param, " ");
3087+ strcat(param, param13);
3088+ strcat(param, " ");
3089+ strcat(param, param14);
3090+ auctionbot.Commands(5, ahMapID, NULL, param);
3091+ }
3092+ else if (strncmp(opt,"minprice",l) == 0)
3093+ {
3094+ char * param1 = strtok(NULL, " ");
3095+ char * param2 = strtok(NULL, " ");
3096+ if ((!ahMapIdStr) || (!param1) || (!param2))
3097+ {
3098+ PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
3099+ return false;
3100+ }
3101+ if (strncmp(param1,"grey",l) == 0)
3102+ {
3103+ auctionbot.Commands(6, ahMapID, AHB_GREY, param2);
3104+ }
3105+ else if (strncmp(param1,"white",l) == 0)
3106+ {
3107+ auctionbot.Commands(6, ahMapID, AHB_WHITE, param2);
3108+ }
3109+ else if (strncmp(param1,"green",l) == 0)
3110+ {
3111+ auctionbot.Commands(6, ahMapID, AHB_GREEN, param2);
3112+ }
3113+ else if (strncmp(param1,"blue",l) == 0)
3114+ {
3115+ auctionbot.Commands(6, ahMapID, AHB_BLUE, param2);
3116+ }
3117+ else if (strncmp(param1,"purple",l) == 0)
3118+ {
3119+ auctionbot.Commands(6, ahMapID, AHB_PURPLE, param2);
3120+ }
3121+ else if (strncmp(param1,"orange",l) == 0)
3122+ {
3123+ auctionbot.Commands(6, ahMapID, AHB_ORANGE, param2);
3124+ }
3125+ else if (strncmp(param1,"yellow",l) == 0)
3126+ {
3127+ auctionbot.Commands(6, ahMapID, AHB_YELLOW, param2);
3128+ }
3129+ else
3130+ {
3131+ PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
3132+ return false;
3133+ }
3134+ }
3135+ else if (strncmp(opt,"maxprice",l) == 0)
3136+ {
3137+ char * param1 = strtok(NULL, " ");
3138+ char * param2 = strtok(NULL, " ");
3139+ if ((!ahMapIdStr) || (!param1) || (!param2))
3140+ {
3141+ PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
3142+ return false;
3143+ }
3144+ if (strncmp(param1,"grey",l) == 0)
3145+ {
3146+ auctionbot.Commands(7, ahMapID, AHB_GREY, param2);
3147+ }
3148+ else if (strncmp(param1,"white",l) == 0)
3149+ {
3150+ auctionbot.Commands(7, ahMapID, AHB_WHITE, param2);
3151+ }
3152+ else if (strncmp(param1,"green",l) == 0)
3153+ {
3154+ auctionbot.Commands(7, ahMapID, AHB_GREEN, param2);
3155+ }
3156+ else if (strncmp(param1,"blue",l) == 0)
3157+ {
3158+ auctionbot.Commands(7, ahMapID, AHB_BLUE, param2);
3159+ }
3160+ else if (strncmp(param1,"purple",l) == 0)
3161+ {
3162+ auctionbot.Commands(7, ahMapID, AHB_PURPLE, param2);
3163+ }
3164+ else if (strncmp(param1,"orange",l) == 0)
3165+ {
3166+ auctionbot.Commands(7, ahMapID, AHB_ORANGE, param2);
3167+ }
3168+ else if (strncmp(param1,"yellow",l) == 0)
3169+ {
3170+ auctionbot.Commands(7, ahMapID, AHB_YELLOW, param2);
3171+ }
3172+ else
3173+ {
3174+ PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
3175+ return false;
3176+ }
3177+ }
3178+ else if (strncmp(opt,"minbidprice",l) == 0)
3179+ {
3180+ char * param1 = strtok(NULL, " ");
3181+ char * param2 = strtok(NULL, " ");
3182+ if ((!ahMapIdStr) || (!param1) || (!param2))
3183+ {
3184+ PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
3185+ return false;
3186+ }
3187+ uint32 minBidPrice = (uint32) strtoul(param2, NULL, 0);
3188+ if ((minBidPrice < 1) || (minBidPrice > 100))
3189+ {
3190+ PSendSysMessage("The min bid price multiplier must be between 1 and 100");
3191+ return false;
3192+ }
3193+ if (strncmp(param1,"grey",l) == 0)
3194+ {
3195+ auctionbot.Commands(8, ahMapID, AHB_GREY, param2);
3196+ }
3197+ else if (strncmp(param1,"white",l) == 0)
3198+ {
3199+ auctionbot.Commands(8, ahMapID, AHB_WHITE, param2);
3200+ }
3201+ else if (strncmp(param1,"green",l) == 0)
3202+ {
3203+ auctionbot.Commands(8, ahMapID, AHB_GREEN, param2);
3204+ }
3205+ else if (strncmp(param1,"blue",l) == 0)
3206+ {
3207+ auctionbot.Commands(8, ahMapID, AHB_BLUE, param2);
3208+ }
3209+ else if (strncmp(param1,"purple",l) == 0)
3210+ {
3211+ auctionbot.Commands(8, ahMapID, AHB_PURPLE, param2);
3212+ }
3213+ else if (strncmp(param1,"orange",l) == 0)
3214+ {
3215+ auctionbot.Commands(8, ahMapID, AHB_ORANGE, param2);
3216+ }
3217+ else if (strncmp(param1,"yellow",l) == 0)
3218+ {
3219+ auctionbot.Commands(8, ahMapID, AHB_YELLOW, param2);
3220+ }
3221+ else
3222+ {
3223+ PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
3224+ return false;
3225+ }
3226+ }
3227+ else if (strncmp(opt,"maxbidprice",l) == 0)
3228+ {
3229+ char * param1 = strtok(NULL, " ");
3230+ char * param2 = strtok(NULL, " ");
3231+ if ((!ahMapIdStr) || (!param1) || (!param2))
3232+ {
3233+ PSendSysMessage("Syntax is: ahbotoptions maxbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
3234+ return false;
3235+ }
3236+ uint32 maxBidPrice = (uint32) strtoul(param2, NULL, 0);
3237+ if ((maxBidPrice < 1) || (maxBidPrice > 100))
3238+ {
3239+ PSendSysMessage("The max bid price multiplier must be between 1 and 100");
3240+ return false;
3241+ }
3242+ if (strncmp(param1,"grey",l) == 0)
3243+ {
3244+ auctionbot.Commands(9, ahMapID, AHB_GREY, param2);
3245+ }
3246+ else if (strncmp(param1,"white",l) == 0)
3247+ {
3248+ auctionbot.Commands(9, ahMapID, AHB_WHITE, param2);
3249+ }
3250+ else if (strncmp(param1,"green",l) == 0)
3251+ {
3252+ auctionbot.Commands(9, ahMapID, AHB_GREEN, param2);
3253+ }
3254+ else if (strncmp(param1,"blue",l) == 0)
3255+ {
3256+ auctionbot.Commands(9, ahMapID, AHB_BLUE, param2);
3257+ }
3258+ else if (strncmp(param1,"purple",l) == 0)
3259+ {
3260+ auctionbot.Commands(9, ahMapID, AHB_PURPLE, param2);
3261+ }
3262+ else if (strncmp(param1,"orange",l) == 0)
3263+ {
3264+ auctionbot.Commands(9, ahMapID, AHB_ORANGE, param2);
3265+ }
3266+ else if (strncmp(param1,"yellow",l) == 0)
3267+ {
3268+ auctionbot.Commands(9, ahMapID, AHB_YELLOW, param2);
3269+ }
3270+ else
3271+ {
3272+ PSendSysMessage("Syntax is: ahbotoptions max bidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
3273+ return false;
3274+ }
3275+ }
3276+ else if (strncmp(opt,"maxstack",l) == 0)
3277+ {
3278+ char * param1 = strtok(NULL, " ");
3279+ char * param2 = strtok(NULL, " ");
3280+ if ((!ahMapIdStr) || (!param1) || (!param2))
3281+ {
3282+ PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $value");
3283+ return false;
3284+ }
3285+ uint32 maxStack = (uint32) strtoul(param2, NULL, 0);
3286+ if (maxStack < 0)
3287+ {
3288+ PSendSysMessage("maxstack can't be a negative number.");
3289+ return false;
3290+ }
3291+ if (strncmp(param1,"grey",l) == 0)
3292+ {
3293+ auctionbot.Commands(10, ahMapID, AHB_GREY, param2);
3294+ }
3295+ else if (strncmp(param1,"white",l) == 0)
3296+ {
3297+ auctionbot.Commands(10, ahMapID, AHB_WHITE, param2);
3298+ }
3299+ else if (strncmp(param1,"green",l) == 0)
3300+ {
3301+ auctionbot.Commands(10, ahMapID, AHB_GREEN, param2);
3302+ }
3303+ else if (strncmp(param1,"blue",l) == 0)
3304+ {
3305+ auctionbot.Commands(10, ahMapID, AHB_BLUE, param2);
3306+ }
3307+ else if (strncmp(param1,"purple",l) == 0)
3308+ {
3309+ auctionbot.Commands(10, ahMapID, AHB_PURPLE, param2);
3310+ }
3311+ else if (strncmp(param1,"orange",l) == 0)
3312+ {
3313+ auctionbot.Commands(10, ahMapID, AHB_ORANGE, param2);
3314+ }
3315+ else if (strncmp(param1,"yellow",l) == 0)
3316+ {
3317+ auctionbot.Commands(10, ahMapID, AHB_YELLOW, param2);
3318+ }
3319+ else
3320+ {
3321+ PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $value");
3322+ return false;
3323+ }
3324+ }
3325+ else if (strncmp(opt,"buyerprice",l) == 0)
3326+ {
3327+ char * param1 = strtok(NULL, " ");
3328+ char * param2 = strtok(NULL, " ");
3329+ if ((!ahMapIdStr) || (!param1) || (!param2))
3330+ {
3331+ PSendSysMessage("Syntax is: ahbotoptions buyerprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue or purple) $price");
3332+ return false;
3333+ }
3334+ if (strncmp(param1,"grey",l) == 0)
3335+ {
3336+ auctionbot.Commands(11, ahMapID, AHB_GREY, param2);
3337+ }
3338+ else if (strncmp(param1,"white",l) == 0)
3339+ {
3340+ auctionbot.Commands(11, ahMapID, AHB_WHITE, param2);
3341+ }
3342+ else if (strncmp(param1,"green",l) == 0)
3343+ {
3344+ auctionbot.Commands(11, ahMapID, AHB_GREEN, param2);
3345+ }
3346+ else if (strncmp(param1,"blue",l) == 0)
3347+ {
3348+ auctionbot.Commands(11, ahMapID, AHB_BLUE, param2);
3349+ }
3350+ else if (strncmp(param1,"purple",l) == 0)
3351+ {
3352+ auctionbot.Commands(11, ahMapID, AHB_PURPLE, param2);
3353+ }
3354+ else if (strncmp(param1,"orange",l) == 0)
3355+ {
3356+ auctionbot.Commands(11, ahMapID, AHB_ORANGE, param2);
3357+ }
3358+ else if (strncmp(param1,"yellow",l) == 0)
3359+ {
3360+ auctionbot.Commands(11, ahMapID, AHB_YELLOW, param2);
3361+ }
3362+ else
3363+ {
3364+ PSendSysMessage("Syntax is: ahbotoptions buyerprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue or purple) $price");
3365+ return false;
3366+ }
3367+ }
3368+ else if (strncmp(opt,"bidinterval",l) == 0)
3369+ {
3370+ char * param1 = strtok(NULL, " ");
3371+ if ((!ahMapIdStr) || (!param1))
3372+ {
3373+ PSendSysMessage("Syntax is: ahbotoptions bidinterval $ahMapID (2, 6 or 7) $interval(in minutes)");
3374+ return false;
3375+ }
3376+ auctionbot.Commands(12, ahMapID, NULL, param1);
3377+ }
3378+ else if (strncmp(opt,"bidsperinterval",l) == 0)
3379+ {
3380+ char * param1 = strtok(NULL, " ");
3381+ if ((!ahMapIdStr) || (!param1))
3382+ {
3383+ PSendSysMessage("Syntax is: ahbotoptions bidsperinterval $ahMapID (2, 6 or 7) $bids");
3384+ return false;
3385+ }
3386+ auctionbot.Commands(13, ahMapID, NULL, param1);
3387+ }
3388+ else
3389+ {
3390+ PSendSysMessage("Syntax is: ahbotoptions $option $ahMapID (2, 6 or 7) $parameter");
3391+ PSendSysMessage("Try ahbotoptions help to see a list of options.");
3392+ return false;
3393+ }
3394+ return true;
3395+}
3396
3397 //reload commands
3398 bool ChatHandler::HandleReloadAllCommand(const char*)
3399diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp
3400index 2903414..de18eb9 100644
3401--- a/src/game/Mail.cpp
3402+++ b/src/game/Mail.cpp
3403@@ -28,6 +28,7 @@
3404 #include "UpdateMask.h"
3405 #include "Unit.h"
3406 #include "Language.h"
3407+#include "AuctionHouseBot.h"
3408 #include "DBCStores.h"
3409 #include "BattleGroundMgr.h"
3410 #include "Item.h"
3411@@ -908,13 +909,30 @@ void MailDraft::SendReturnToSender(uint32 sender_acc, uint32 sender_guid, uint32
3412 uint32 deliver_delay = needItemDelay ? sWorld.getConfig(CONFIG_MAIL_DELIVERY_DELAY) : 0;
3413
3414 // will delete item or place to receiver mail list
3415- SendMailTo(MailReceiver(receiver,receiver_guid), MailSender(MAIL_NORMAL, sender_guid), MAIL_CHECK_MASK_RETURNED, deliver_delay);
3416+ if (sender_guid == auctionbot.GetAHBplayerGUID())
3417+ {
3418+ SendMailTo(MailReceiver(receiver,receiver_guid), MailSender(MAIL_CREATURE, sender_guid), MAIL_CHECK_MASK_RETURNED, deliver_delay);
3419+ }
3420+ else
3421+ {
3422+ SendMailTo(MailReceiver(receiver,receiver_guid), MailSender(MAIL_NORMAL, sender_guid), MAIL_CHECK_MASK_RETURNED, deliver_delay);
3423+ }
3424 }
3425
3426 void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sender, MailCheckMask checked, uint32 deliver_delay)
3427 {
3428 Player* pReceiver = receiver.GetPlayer(); // can be NULL
3429
3430+ if (receiver.GetPlayerGUIDLow() == auctionbot.GetAHBplayerGUID())
3431+ {
3432+ if (sender.GetMailMessageType() == MAIL_AUCTION && m_items.size())
3433+ {
3434+ deleteIncludedItems();
3435+ }
3436+ return;
3437+ }
3438+
3439+
3440 if (pReceiver)
3441 prepareItems(pReceiver); // generate mail template items
3442
3443diff --git a/src/game/Makefile.am b/src/game/Makefile.am
3444index d13bc32..095478d 100644
3445--- a/src/game/Makefile.am
3446+++ b/src/game/Makefile.am
3447@@ -38,6 +38,8 @@ libmangosgame_a_SOURCES = \
3448 ArenaTeam.cpp \
3449 ArenaTeam.h \
3450 ArenaTeamHandler.cpp \
3451+ AuctionHouseBot.cpp \
3452+ AuctionHouseBot.h \
3453 AuctionHouseHandler.cpp \
3454 AuctionHouseMgr.cpp \
3455 AuctionHouseMgr.h \
3456diff --git a/src/game/Player.cpp b/src/game/Player.cpp
3457index a010e9b..55d24e8 100644
3458--- a/src/game/Player.cpp
3459+++ b/src/game/Player.cpp
3460@@ -14312,6 +14312,61 @@ void Player::SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, uint64 guid, u
3461 /*** LOAD SYSTEM ***/
3462 /*********************************************************/
3463
3464+bool Player::MinimalLoadFromDB( QueryResult *result, uint32 guid )
3465+{
3466+ bool delete_result = true;
3467+ if (!result)
3468+ {
3469+ // 0 1 2 3 4 5 6 7 8 9 10 11
3470+ result = CharacterDatabase.PQuery("SELECT guid, data, name, position_x, position_y, position_z, map, totaltime, leveltime, at_login, zone, level FROM characters WHERE guid = '%u'",guid);
3471+ if (!result)
3472+ return false;
3473+ }
3474+ else
3475+ delete_result = false;
3476+
3477+ Field *fields = result->Fetch();
3478+
3479+ if (!LoadValues( fields[1].GetString()))
3480+ {
3481+ sLog.outError("Player #%d have broken data in `data` field. Can't be loaded for character list.",GUID_LOPART(guid));
3482+ if (delete_result)
3483+ delete result;
3484+ return false;
3485+ }
3486+
3487+ // overwrite possible wrong/corrupted guid
3488+ SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER));
3489+
3490+ m_name = fields[2].GetCppString();
3491+
3492+ Relocate(fields[3].GetFloat(),fields[4].GetFloat(),fields[5].GetFloat());
3493+ SetLocationMapId(fields[6].GetUInt32());
3494+
3495+ // the instance id is not needed at character enum
3496+
3497+ m_Played_time[PLAYED_TIME_TOTAL] = fields[7].GetUInt32();
3498+ m_Played_time[PLAYED_TIME_LEVEL] = fields[8].GetUInt32();
3499+
3500+ m_atLoginFlags = fields[9].GetUInt32();
3501+
3502+ // I don't see these used anywhere ..
3503+ /*_LoadGroup();
3504+
3505+ _LoadBoundInstances();*/
3506+
3507+ if (delete_result)
3508+ delete result;
3509+
3510+ for (int i = 0; i < PLAYER_SLOTS_COUNT; ++i)
3511+ m_items[i] = NULL;
3512+
3513+ if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
3514+ m_deathState = DEAD;
3515+
3516+ return true;
3517+}
3518+
3519 void Player::_LoadDeclinedNames(QueryResult* result)
3520 {
3521 if(!result)
3522diff --git a/src/game/Player.h b/src/game/Player.h
3523index 64854f2..a5ccd11 100644
3524--- a/src/game/Player.h
3525+++ b/src/game/Player.h
3526@@ -1423,6 +1423,7 @@ class MANGOS_DLL_SPEC Player : public Unit
3527
3528 bool LoadFromDB(uint32 guid, SqlQueryHolder *holder);
3529
3530+ bool MinimalLoadFromDB(QueryResult *result, uint32 guid);
3531 static bool LoadValuesArrayFromDB(Tokens& data,uint64 guid);
3532 static uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index);
3533 static float GetFloatValueFromArray(Tokens const& data, uint16 index);
3534diff --git a/src/game/World.cpp b/src/game/World.cpp
3535index ad772bd..2194ccf 100644
3536--- a/src/game/World.cpp
3537+++ b/src/game/World.cpp
3538@@ -62,6 +62,7 @@
3539 #include "WaypointManager.h"
3540 #include "GMTicketMgr.h"
3541 #include "Util.h"
3542+#include "AuctionHouseBot.h"
3543
3544 INSTANTIATE_SINGLETON_1( World );
3545
3546@@ -1519,6 +1520,9 @@ void World::SetInitialWorldSettings()
3547 uint32 nextGameEvent = sGameEventMgr.Initialize();
3548 m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent); //depend on next event
3549
3550+ sLog.outString("Initialize AuctionHouseBot...");
3551+ auctionbot.Initialize();
3552+
3553 sLog.outString( "WORLD: World initialized" );
3554
3555 uint32 uStartInterval = getMSTimeDiff(uStartTime, getMSTime());
3556@@ -1591,6 +1595,7 @@ void World::Update(uint32 diff)
3557 /// <ul><li> Handle auctions when the timer has passed
3558 if (m_timers[WUPDATE_AUCTIONS].Passed())
3559 {
3560+ auctionbot.Update();
3561 m_timers[WUPDATE_AUCTIONS].Reset();
3562
3563 ///- Update mails (return old mails with item, or delete them)
3564diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in
3565index 479a6ce..6a94b6f 100644
3566--- a/src/mangosd/mangosd.conf.dist.in
3567+++ b/src/mangosd/mangosd.conf.dist.in
3568@@ -1342,6 +1342,79 @@ Network.OutUBuff = 65536
3569 Network.TcpNodelay = 1
3570
3571 ###################################################################################################################
3572+# AUCTION HOUSE BOT SETTINGS
3573+#
3574+# AuctionHouseBot.EnableSeller
3575+# Enable/Disable the part of AHBot that puts items up for auction
3576+# Default 0 (disabled)
3577+#
3578+# AuctionHouseBot.EnableBuyer
3579+# Enable/Disable the part of AHBot that buys items from players
3580+# Default 0 (disabled)
3581+#
3582+# Auction House Bot character data
3583+# AuctionHouseBot.Account is the account number (in realmd->account table) of the player you want to run as the auction bot.
3584+# AuctionHouseBot.GUID is the GUID (in characters->characters table) of the player you want to run as the auction bot.
3585+# Default: 0 (Auction House Bot disabled)
3586+#
3587+# AuctionHouseBot.VendorItems
3588+# Include items that can be bought from vendors.
3589+# Default 0
3590+#
3591+# AuctionHouseBot.LootItems
3592+# Include items that can be looted or fished for.
3593+# Default 1
3594+#
3595+# AuctionHouseBot.OtherItems
3596+# Include misc. items.
3597+# Default 0
3598+#
3599+# AuctionHouseBot.Bonding_types
3600+# Indicates which bonding types to allow seller to put up for auction
3601+# No_Bind
3602+# Default 1
3603+# Bind_When_Picked_Up
3604+# Default 0
3605+# Bind_When_Equipped
3606+# Default 1
3607+# Bind_When_Use
3608+# Default 1
3609+# Bind_Quest_Item
3610+# Default 0
3611+#
3612+# AuctionHouseBot.ItemsPerCycle
3613+# Number of Items to Add/Remove from the AH during mass operations
3614+# Default 200
3615+#
3616+# AuctionHouseBot.UseBuyPriceForSeller
3617+# Should the Seller use BuyPrice or SellPrice to determine Bid Prices
3618+# Default 0 (use SellPrice)
3619+#
3620+# AuctionHouseBot.UseBuyPriceForBuyer
3621+# Should the Buyer use BuyPrice or SellPrice to determine Bid Prices
3622+# Default 0 (use SellPrice)
3623+#
3624+# All other settings have been moved to sql
3625+#
3626+###################################################################################################################
3627+
3628+AuctionHouseBot.EnableSeller = 0
3629+AuctionHouseBot.EnableBuyer = 0
3630+AuctionHouseBot.Account = 0
3631+AuctionHouseBot.GUID = 0
3632+AuctionHouseBot.VendorItems = 0
3633+AuctionHouseBot.LootItems = 1
3634+AuctionHouseBot.OtherItems = 0
3635+AuctionHouseBot.No_Bind = 1
3636+AuctionHouseBot.Bind_When_Picked_Up = 0
3637+AuctionHouseBot.Bind_When_Equipped = 1
3638+AuctionHouseBot.Bind_When_Use = 1
3639+AuctionHouseBot.Bind_Quest_Item = 0
3640+AuctionHouseBot.ItemsPerCycle = 200
3641+AuctionHouseBot.UseBuyPriceForSeller = 0
3642+AuctionHouseBot.UseBuyPriceForBuyer = 0
3643+
3644+###################################################################################################################
3645 # CONSOLE AND REMOTE ACCESS
3646 #
3647 # Console.Enable
3648diff --git a/win/VC100/game.vcxproj b/win/VC100/game.vcxproj
3649index eaa5566..3083dd0 100644
3650--- a/win/VC100/game.vcxproj
3651+++ b/win/VC100/game.vcxproj
3652@@ -349,6 +349,7 @@
3653 <ClCompile Include="..\..\src\game\AggressorAI.cpp" />
3654 <ClCompile Include="..\..\src\game\ArenaTeam.cpp" />
3655 <ClCompile Include="..\..\src\game\ArenaTeamHandler.cpp" />
3656+ <ClCompile Include="..\..\src\game\AuctionHouseBot.cpp" />
3657 <ClCompile Include="..\..\src\game\AuctionHouseHandler.cpp" />
3658 <ClCompile Include="..\..\src\game\AuctionHouseMgr.cpp" />
3659 <ClCompile Include="..\..\src\game\Bag.cpp" />
3660@@ -498,6 +499,7 @@
3661 <ClInclude Include="..\..\src\game\AggressorAI.h" />
3662 <ClInclude Include="..\..\src\game\AnimalRandomMovementGenerator.h" />
3663 <ClInclude Include="..\..\src\game\ArenaTeam.h" />
3664+ <ClInclude Include="..\..\src\game\AuctionHouseBot.h" />
3665 <ClInclude Include="..\..\src\game\AuctionHouseMgr.h" />
3666 <ClInclude Include="..\..\src\game\Bag.h" />
3667 <ClInclude Include="..\..\src\game\BattleGround.h" />
3668diff --git a/win/VC80/game.vcproj b/win/VC80/game.vcproj
3669index 590a5dc..44d665d 100644
3670--- a/win/VC80/game.vcproj
3671+++ b/win/VC80/game.vcproj
3672@@ -1034,6 +1034,12 @@
3673 >
3674 </File>
3675 <File
3676+ RelativePath="..\..\src\game\AuctionHouseBot.cpp">
3677+ </File>
3678+ <File
3679+ RelativePath="..\..\src\game\AuctionHouseBot.h">
3680+ </File>
3681+ <File
3682 RelativePath="..\..\src\game\AuctionHouseMgr.cpp"
3683 >
3684 </File>
3685diff --git a/win/VC90/game.vcproj b/win/VC90/game.vcproj
3686index d860b9f..09633a7 100644
3687--- a/win/VC90/game.vcproj
3688+++ b/win/VC90/game.vcproj
3689@@ -1035,6 +1035,12 @@
3690 >
3691 </File>
3692 <File
3693+ RelativePath="..\..\src\game\AuctionHouseBot.cpp">
3694+ </File>
3695+ <File
3696+ RelativePath="..\..\src\game\AuctionHouseBot.h">
3697+ </File>
3698+ <File
3699 RelativePath="..\..\src\game\AuctionHouseMgr.cpp"
3700 >
3701 </File>