--HG--
branch : trunk
This commit is contained in:
megamage
2009-03-07 00:54:55 -06:00
29 changed files with 2016 additions and 1188 deletions
+55 -50
View File
@@ -53,21 +53,53 @@ AuctionHouseBot.UseBuyPriceForBuyer Use SellPrice (0) or BuyPrice (1) for determ
#These are the settings in the Database:
#Each Auctionhouse has it's own set of these
MinItems = 0
MaxItems = 0
MinTime = 8
MaxTime = 24
MinItems = 0
#The Minimum number of items you want to keep in the auction houses.
#(default 0 - minimum will be the same as maximum).
#If it is higher than the value of the corresponding maxItems setting,
#it will be set down to match the maxItems setting.
MaxItems = 0
#The Maximum number of items you want to keep in the auction houses.
MinTime = 8
#The minimum number of hours for an auction.
MaxTime = 24
#The maximum number of hours for an auction.
#These must add up to 100 each one is the percentage
#of the auction items that should be trade goods of
#that quality. A value of 0 will disable.
PercentGreyTradeGoods = 0
PercentWhiteTradeGoods = 27
PercentGreenTradeGoods = 12
PercentBlueTradeGoods = 10
PercentPurpleTradeGoods = 1
PercentOrangeTradeGoods = 0
PercentYellowTradeGoods = 0
PercentGreyItems = 0
PercentWhiteItems = 10
PercentGreenItems = 30
PercentBlueItems = 8
PercentPurpleItems = 2
PercentOrangeItems = 0
PercentYellowItems = 0
#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.
#MaxPrice(Color) is the maximum price adjustment for items.
#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.
#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.
#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.
MinPriceGrey = 100
MaxPriceGrey = 150
MinBidPriceGrey = 70
MaxBidPriceGrey = 100
MaxStackGrey = 0
MinPriceWhite = 150
MaxPriceWhite = 250
MinBidPriceWhite = 70
@@ -88,62 +120,35 @@ MaxPricePurple = 4550
MinBidPricePurple = 80
MaxBidPricePurple = 100
MaxStackPurple = 1
MinPriceOrange = 4250
MaxPriceOrange = 5550
MinBidPriceOrange = 80
MaxBidPriceOrange = 100
MaxStackOrange = 0
MinPriceYellow = 5250
MaxPriceYellow = 6550
MinBidPriceYellow = 80
MaxBidPriceYellow = 100
MaxStackYellow = 0
#These are the multipliers that are applied to the vendor price for an item, that determines if AHBot will buy it or not.
#1 means AHBot will pay the same as (or less than) a vendor would pay, 2 means up to twice as much, etc.
BuyerPriceGrey = 1
BuyerPriceWhite = 1
BuyerPriceGreen = 5
BuyerPriceBlue = 12
BuyerPricePurple = 15
BuyerPriceOrange = 20
BuyerPriceYellow = 22
#BuyerBiddingInterval is the time (in minutes) between bids.
#BuyerBidsPerInterval is the number of bids the buyer will make in a cycle
BuyerBiddingInterval = 1
BuyerBidsPerInterval = 1
MaxItems is the number of items you want to keep in the auction houses.
MinItems Minimum items in auctionhouses (default 0 - minimum will be the same as maximum). If it is higher than the value of the corresponding maxItems setting, it will be set down to match the maxItems setting.
MinTime is the minimum number of hours for an auction.
MaxTime is the maximum number of hours for an auction.
#These must add up to 100
PercentWhiteTradeGoods is the percentage of the auction items that should be trade goods of white quality. A value of 0 will disable.
PercentGreenTradeGoods is the percentage of the auction items that should be trade goods of green quality. A value of 0 will disable.
PercentBlueTradeGoods is the percentage of the auction items that should be trade goods of blue quality. A value of 0 will disable.
PercentPurpleTradeGoods is the percentage of the auction items that should be trade goods of purple quality. A value of 0 will disable.
PercentWhiteItems is the percentage of the auction items that should be items of white quality. A value of 0 will disable.
PercentGreenItems is the percentage of the auction items that should be items of green quality. A value of 0 will disable.
PercentBlueItems is the percentage of the auction items that should be items of blue quality. A value of 0 will disable.
PercentPurpleItems is the percentage of the auction items that should be items of purple quality. A value of 0 will disable.
MinPriceWhite is the minimum price adjustment for white 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.
MaxPriceWhite is the maximum price adjustment for white items.
MinBidPriceWhite 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.
MaxBidPriceWhite 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.
MaxStackWhite 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.
MinPriceGreen - see above
MaxPriceGreen - see above
MinBidPriceGreen - see above
MaxBidPriceGreen - see above
MaxStackGreen - see above
MinPriceBlue - see above
MaxPriceBlue - see above
MinBidPriceBlue - see above
MaxBidPriceBlue - see above
MaxStackBlue - see above
MinPricePurple - see above
MaxPricePurple - see above
MinBidPricePurple - see above
MaxBidPricePurple - see above
MaxStackPurple - see above
#These are the multipliers that are applied to the vendor price for an item, that determines if AHBot will buy it or not.
#1 means AHBot will pay the same as (or less than) a vendor would pay, 2 means up to twice as much, etc.
BuyerPriceGrey
BuyerPriceWhite
BuyerPriceGreen
BuyerPriceBlue
BuyerPricePurple
BuyerBiddingInterval is the time (in minutes) between bids.
BuyerBidsPerInterval is the number of bids the buyer will make in a cycle
How to use ahcommands from the console (CLI) or in game with GM level 3 players:
ahbotoptions - will display usage instructions
+35 -13
View File
@@ -108,7 +108,6 @@ CREATE TABLE `auctionhouse` (
`lastbid` int(11) NOT NULL default '0',
`startbid` int(11) NOT NULL default '0',
`deposit` int(11) NOT NULL default '0',
`location` tinyint(3) unsigned NOT NULL default '3',
PRIMARY KEY (`id`),
UNIQUE KEY `item_guid` (`itemguid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -134,14 +133,22 @@ CREATE TABLE `auctionhousebot` (
`maxitems` int(11) default '0' COMMENT 'This is the number of items you want to keep in the auction house.',
`mintime` int(11) default '8' COMMENT 'Sets the minimum number of hours for an auction.',
`maxtime` int(11) default '24' COMMENT 'Sets the maximum number of hours for an auction.',
`percentgreytradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Grey Trade Goods auction items',
`percentwhitetradegoods` int(11) default '27' COMMENT 'Sets the percentage of the White Trade Goods auction items',
`percentgreentradegoods` int(11) default '12' COMMENT 'Sets the percentage of the Green Trade Goods auction items',
`percentbluetradegoods` int(11) default '10' COMMENT 'Sets the percentage of the Blue Trade Goods auction items',
`percentpurpletradegoods` int(11) default '1' COMMENT 'Sets the percentage of the Purple Trade Goods auction items',
`percentorangetradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Orange Trade Goods auction items',
`percentyellowtradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Yellow Trade Goods auction items',
`percentgreyitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Grey auction items',
`percentwhiteitems` int(11) default '10' COMMENT 'Sets the percentage of the non trade White auction items',
`percentgreenitems` int(11) default '30' COMMENT 'Sets the percentage of the non trade Green auction items',
`percentblueitems` int(11) default '8' COMMENT 'Sets the percentage of the non trade Blue auction items',
`percentpurpleitems` int(11) default '2' COMMENT 'Sets the percentage of the non trade Purple auction items',
`percentorangeitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Orange auction items',
`percentyellowitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Yellow auction items',
`minpricegrey` int(11) default '100' COMMENT 'Minimum price of Grey items (percentage).',
`maxpricegrey` int(11) default '150' COMMENT 'Maximum price of Grey items (percentage).',
`minpricewhite` int(11) default '150' COMMENT 'Minimum price of White items (percentage).',
`maxpricewhite` int(11) default '250' COMMENT 'Maximum price of White items (percentage).',
`minpricegreen` int(11) default '800' COMMENT 'Minimum price of Green items (percentage).',
@@ -150,23 +157,38 @@ CREATE TABLE `auctionhousebot` (
`maxpriceblue` int(11) default '1750' COMMENT 'Maximum price of Blue items (percentage).',
`minpricepurple` int(11) default '2250' COMMENT 'Minimum price of Purple items (percentage).',
`maxpricepurple` int(11) default '4550' COMMENT 'Maximum price of Purple items (percentage).',
`minbidpricewhite` int(11) default '70' COMMENT 'Starting bid price of White items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)',
`maxbidpricewhite` int(11) default '100' COMMENT 'Starting bid price of White items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)',
`minbidpricegreen` int(11) default '80' COMMENT 'Starting bid price of Green items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)',
`maxbidpricegreen` int(11) default '100' COMMENT 'Starting bid price of Green items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)',
`minbidpriceblue` int(11) default '75' COMMENT 'Starting bid price of Blue items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)',
`maxbidpriceblue` int(11) default '100' COMMENT 'Starting bid price of Blue items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)',
`minbidpricepurple` int(11) default '80' COMMENT 'Starting bid price of Purple items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)',
`maxbidpricepurple` int(11) default '100' COMMENT 'Starting bid price of Purple items as a percentage of the randomly chosen buyout price. Default: 100 (Bid and buyout price the same)',
`minpriceorange` int(11) default '3250' COMMENT 'Minimum price of Orange items (percentage).',
`maxpriceorange` int(11) default '5550' COMMENT 'Maximum price of Orange items (percentage).',
`minpriceyellow` int(11) default '5250' COMMENT 'Minimum price of Yellow items (percentage).',
`maxpriceyellow` int(11) default '6550' COMMENT 'Maximum price of Yellow items (percentage).',
`minbidpricegrey` int(11) default '70' COMMENT 'Starting bid price of Grey items as a percentage of the randomly chosen buyout price. Default: 70',
`maxbidpricegrey` int(11) default '100' COMMENT 'Starting bid price of Grey items as a percentage of the randomly chosen buyout price. Default: 100',
`minbidpricewhite` int(11) default '70' COMMENT 'Starting bid price of White items as a percentage of the randomly chosen buyout price. Default: 70',
`maxbidpricewhite` int(11) default '100' COMMENT 'Starting bid price of White items as a percentage of the randomly chosen buyout price. Default: 100',
`minbidpricegreen` int(11) default '80' COMMENT 'Starting bid price of Green items as a percentage of the randomly chosen buyout price. Default: 80',
`maxbidpricegreen` int(11) default '100' COMMENT 'Starting bid price of Green items as a percentage of the randomly chosen buyout price. Default: 100',
`minbidpriceblue` int(11) default '75' COMMENT 'Starting bid price of Blue items as a percentage of the randomly chosen buyout price. Default: 75',
`maxbidpriceblue` int(11) default '100' COMMENT 'Starting bid price of Blue items as a percentage of the randomly chosen buyout price. Default: 100',
`minbidpricepurple` int(11) default '80' COMMENT 'Starting bid price of Purple items as a percentage of the randomly chosen buyout price. Default: 80',
`maxbidpricepurple` int(11) default '100' COMMENT 'Starting bid price of Purple items as a percentage of the randomly chosen buyout price. Default: 100',
`minbidpriceorange` int(11) default '80' COMMENT 'Starting bid price of Orange items as a percentage of the randomly chosen buyout price. Default: 80',
`maxbidpriceorange` int(11) default '100' COMMENT 'Starting bid price of Orange items as a percentage of the randomly chosen buyout price. Default: 100',
`minbidpriceyellow` int(11) default '80' COMMENT 'Starting bid price of Yellow items as a percentage of the randomly chosen buyout price. Default: 80',
`maxbidpriceyellow` int(11) default '100' COMMENT 'Starting bid price of Yellow items as a percentage of the randomly chosen buyout price. Default: 100',
`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.',
`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.',
`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.',
`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.',
`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.',
`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.',
`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.',
`buyerpricegrey` int(11) default '1' COMMENT 'Multiplier to vendorprice when buying grey items from auctionhouse',
`buyerpricewhite` int(11) default '1' COMMENT 'Multiplier to vendorprice when buying white items from auctionhouse',
`buyerpricegreen` int(11) default '5' COMMENT 'Multiplier to vendorprice when buying green items from auctionhouse',
`buyerpriceblue` int(11) default '12' COMMENT 'Multiplier to vendorprice when buying blue items from auctionhouse',
`buyerpricepurple` int(11) default '15' COMMENT 'Multiplier to vendorprice when buying purple items from auctionhouse',
`buyerpriceorange` int(11) default '20' COMMENT 'Multiplier to vendorprice when buying orange items from auctionhouse',
`buyerpriceyellow` int(11) default '22' COMMENT 'Multiplier to vendorprice when buying yellow items from auctionhouse',
`buyerbiddinginterval` int(11) default '1' COMMENT 'Interval how frequently AHB bids on each AH. Time in minutes',
`buyerbidsperinterval` int(11) default '1' COMMENT 'number of bids to put in per bidding interval',
PRIMARY KEY (`auctionhouse`)
@@ -176,10 +198,10 @@ CREATE TABLE `auctionhousebot` (
-- Data for table `auctionhousebot`
--
insert into `auctionhousebot`(`auctionhouse`,`name`,`minitems`,`maxitems`,`mintime`,`maxtime`,`percentwhitetradegoods`,`percentgreentradegoods`,`percentbluetradegoods`,`percentpurpletradegoods`,`percentwhiteitems`,`percentgreenitems`,`percentblueitems`,`percentpurpleitems`,`minpricewhite`,`maxpricewhite`,`minpricegreen`,`maxpricegreen`,`minpriceblue`,`maxpriceblue`,`minpricepurple`,`maxpricepurple`,`minbidpricewhite`,`maxbidpricewhite`,`minbidpricegreen`,`maxbidpricegreen`,`minbidpriceblue`,`maxbidpriceblue`,`minbidpricepurple`,`maxbidpricepurple`,`maxstackwhite`,`maxstackgreen`,`maxstackblue`,`maxstackpurple`,`buyerpricegrey`,`buyerpricewhite`,`buyerpricegreen`,`buyerpriceblue`,`buyerpricepurple`,`buyerbiddinginterval`,`buyerbidsperinterval`) values
(2,'Alliance',0,0,8,24,27,12,10,1,10,30,8,2,150,250,800,1400,1250,1750,2250,4550,70,100,80,100,75,100,80,100,0,3,2,1,1,1,5,12,15,1,1),
(6,'Horde',0,0,8,24,27,12,10,1,10,30,8,2,150,250,800,1400,1250,1750,2250,4550,70,100,80,100,75,100,80,100,0,3,2,1,1,1,5,12,15,1,1),
(7,'Neutral',0,0,8,24,27,12,10,1,10,30,8,2,150,250,800,1400,1250,1750,2250,4550,70,100,80,100,75,100,80,100,0,3,2,1,1,1,5,12,15,1,1);
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
(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),
(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),
(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);
--
-- Table structure for table `bugreport`
+27
View File
@@ -0,0 +1,27 @@
ALTER TABLE auctionhouse
DROP COLUMN location;
ALTER TABLE `auctionhousebot`
ADD COLUMN `percentgreytradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Grey Trade Goods auction items' AFTER `maxtime`,
ADD COLUMN `percentorangetradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Orange Trade Goods auction items' AFTER `percentpurpletradegoods`,
ADD COLUMN `percentyellowtradegoods` int(11) default '0' COMMENT 'Sets the percentage of the Yellow Trade Goods auction items' AFTER `percentorangetradegoods`,
ADD COLUMN `percentgreyitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Grey auction items' AFTER `percentyellowtradegoods`,
ADD COLUMN `percentorangeitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Orange auction items' AFTER `percentpurpleitems`,
ADD COLUMN `percentyellowitems` int(11) default '0' COMMENT 'Sets the percentage of the non trade Yellow auction items' AFTER `percentorangeitems`,
ADD COLUMN `minpricegrey` int(11) default '100' COMMENT 'Minimum price of Grey items (percentage).' AFTER `percentyellowitems`,
ADD COLUMN `maxpricegrey` int(11) default '150' COMMENT 'Maximum price of Grey items (percentage).' AFTER `minpricegrey`,
ADD COLUMN `minpriceorange` int(11) default '3250' COMMENT 'Minimum price of Orange items (percentage).' AFTER `maxpricepurple`,
ADD COLUMN `maxpriceorange` int(11) default '5550' COMMENT 'Maximum price of Orange items (percentage).' AFTER `minpriceorange`,
ADD COLUMN `minpriceyellow` int(11) default '5250' COMMENT 'Minimum price of Yellow items (percentage).' AFTER `maxpriceorange`,
ADD COLUMN `maxpriceyellow` int(11) default '6550' COMMENT 'Maximum price of Yellow items (percentage).' AFTER `minpriceyellow`,
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`,
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`,
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`,
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`,
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`,
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`,
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`,
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`,
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`,
ADD COLUMN `buyerpriceorange` int(11) default '20' COMMENT 'Multiplier to vendorprice when buying orange items from auctionhouse' AFTER `buyerpricepurple`,
ADD COLUMN `buyerpriceyellow` int(11) default '22' COMMENT 'Multiplier to vendorprice when buying yellow items from auctionhouse' AFTER `buyerpriceorange`;
+1
View File
@@ -172,4 +172,5 @@ INSTALL(FILES
1142_world.sql
1159_world.sql
1160_world.sql
1164_characters.sql
DESTINATION share/trinity/sql/updates)
+442 -187
View File
@@ -4,6 +4,7 @@
#include "Database/DatabaseEnv.h"
#include "Item.h"
#include "Log.h"
#include "AuctionHouseMgr.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "World.h"
@@ -18,14 +19,20 @@ static bool debug_Out = sConfig.GetIntDefault("AuctionHouseBot.DEBUG", 0);
static vector<uint32> npcItems;
static vector<uint32> lootItems;
static vector<uint32> whiteTradeGoods;
static vector<uint32> greenTradeGoods;
static vector<uint32> blueTradeGoods;
static vector<uint32> purpleTradeGoods;
static vector<uint32> whiteItems;
static vector<uint32> greenItems;
static vector<uint32> blueItems;
static vector<uint32> purpleItems;
static vector<uint32> greyTradeGoodsBin;
static vector<uint32> whiteTradeGoodsBin;
static vector<uint32> greenTradeGoodsBin;
static vector<uint32> blueTradeGoodsBin;
static vector<uint32> purpleTradeGoodsBin;
static vector<uint32> orangeTradeGoodsBin;
static vector<uint32> yellowTradeGoodsBin;
static vector<uint32> greyItemsBin;
static vector<uint32> whiteItemsBin;
static vector<uint32> greenItemsBin;
static vector<uint32> blueItemsBin;
static vector<uint32> purpleItemsBin;
static vector<uint32> orangeItemsBin;
static vector<uint32> yellowItemsBin;
static bool AHBSeller = 0;
static bool AHBBuyer = 0;
@@ -62,11 +69,23 @@ static void addNewAuctions(Player *AHBplayer, AHBConfig *config)
{
if (!AHBSeller)
return;
AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(config->GetAHID());
AuctionHouseEntry const* ahEntry = auctionmgr.GetAuctionHouseEntry(config->GetAHFID());
AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(config->GetAHFID());
uint32 items = 0;
uint32 minItems = config->GetMinItems();
uint32 maxItems = config->GetMaxItems();
uint32 auctions = auctionHouse->Getcount();
uint32 AuctioneerGUID = 0;
switch (config->GetAHID()){
case 2:
AuctioneerGUID = 79707; //Human in stormwind.
case 6:
AuctioneerGUID = 4656; //orc in Orgrimmar
case 7:
AuctioneerGUID = 23442; //goblin in GZ
default:
AuctioneerGUID = 23442; //default to neutral 7
}
if (auctions >= minItems)
return;
@@ -77,28 +96,45 @@ static void addNewAuctions(Player *AHBplayer, AHBConfig *config)
else
items = (maxItems - auctions);
}
uint32 wtgbin = config->GetPercents(AHB_WHITE_TG);
uint32 gtgbin = config->GetPercents(AHB_GREEN_TG);
uint32 btgbin = config->GetPercents(AHB_BLUE_TG);
uint32 ptgbin = config->GetPercents(AHB_PURPLE_TG);
uint32 wibin = config->GetPercents(AHB_WHITE_I);
uint32 gibin = config->GetPercents(AHB_GREEN_I);
uint32 bibin = config->GetPercents(AHB_BLUE_I);
uint32 pibin = config->GetPercents(AHB_PURPLE_I);
uint32 total = wtgbin + gtgbin + btgbin + ptgbin + wibin + gibin + bibin + pibin;
uint32 greyTGcount = config->GetPercents(AHB_GREY_TG);
uint32 whiteTGcount = config->GetPercents(AHB_WHITE_TG);
uint32 greenTGcount = config->GetPercents(AHB_GREEN_TG);
uint32 blueTGcount = config->GetPercents(AHB_BLUE_TG);
uint32 purpleTGcount = config->GetPercents(AHB_PURPLE_TG);
uint32 orangeTGcount = config->GetPercents(AHB_ORANGE_TG);
uint32 yellowTGcount = config->GetPercents(AHB_YELLOW_TG);
uint32 greyIcount = config->GetPercents(AHB_GREY_I);
uint32 whiteIcount = config->GetPercents(AHB_WHITE_I);
uint32 greenIcount = config->GetPercents(AHB_GREEN_I);
uint32 blueIcount = config->GetPercents(AHB_BLUE_I);
uint32 purpleIcount = config->GetPercents(AHB_PURPLE_I);
uint32 orangeIcount = config->GetPercents(AHB_ORANGE_I);
uint32 yellowIcount = config->GetPercents(AHB_YELLOW_I);
uint32 total = greyTGcount + whiteTGcount + greenTGcount + blueTGcount
+ purpleTGcount + orangeTGcount + yellowTGcount
+ whiteIcount + greenIcount + blueIcount + purpleIcount
+ orangeIcount + yellowIcount;
uint32 greyTGoods = 0;
uint32 whiteTGoods = 0;
uint32 greenTGoods = 0;
uint32 blueTGoods = 0;
uint32 purpleTGoods = 0;
uint32 orangeTGoods = 0;
uint32 yellowTGoods = 0;
uint32 greyItems = 0;
uint32 whiteItems = 0;
uint32 greenItems = 0;
uint32 blueItems = 0;
uint32 purpleItems = 0;
uint32 orangeItems = 0;
uint32 yellowItems = 0;
uint32 pItems = 0;
uint32 bItems = 0;
uint32 gItems = 0;
uint32 wItems = 0;
uint32 pTGoods = 0;
uint32 bTGoods = 0;
uint32 gTGoods = 0;
uint32 wTGoods = 0;
for (AuctionHouseObject::AuctionEntryMap::iterator itr = auctionHouse->GetAuctionsBegin();itr != auctionHouse->GetAuctionsEnd();++itr)
{
AuctionEntry *Aentry = itr->second;
Item *item = objmgr.GetAItem(Aentry->item_guidlow);
Item *item = auctionmgr.GetAItem(Aentry->item_guidlow);
if( item )
{
ItemPrototype const *prototype = item->GetProto();
@@ -108,37 +144,51 @@ static void addNewAuctions(Player *AHBplayer, AHBConfig *config)
{
case 0:
if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
wTGoods = wTGoods + 1;
++greyTGoods;
else
wItems = wItems + 1;
++greyItems;
break;
case 1:
if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
wTGoods = wTGoods + 1;
++whiteTGoods;
else
wItems = wItems + 1;
++whiteItems;
break;
case 2:
if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
gTGoods = gTGoods + 1;
++greenTGoods;
else
gItems = gItems + 1;
++greenItems;
break;
case 3:
if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
bTGoods = bTGoods + 1;
++blueTGoods;
else
bItems = bItems + 1;
++blueItems;
break;
case 4:
if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
pTGoods = pTGoods + 1;
++purpleTGoods;
else
pItems = pItems + 1;
++purpleItems;
break;
case 5:
if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
++orangeTGoods;
else
++orangeItems;
break;
case 6:
if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
++yellowTGoods;
else
++yellowItems;
break;
}
}
@@ -150,78 +200,132 @@ static void addNewAuctions(Player *AHBplayer, AHBConfig *config)
uint32 itemID = 0;
while (itemID == 0)
{
uint32 choice = urand(1, 8);
uint32 choice = urand(0, 13);
switch (choice)
{
case 0:
{
if ((greyItemsBin.size() > 0) && (greyItems < greyIcount))
{
itemID = greyItemsBin[urand(0, greyItemsBin.size() - 1)];
++greyItems;
break;
}
}
case 1:
{
if ((purpleItems.size() > 0) && (pItems < pibin))
if ((whiteItemsBin.size() > 0) && (whiteItems < whiteIcount))
{
itemID = purpleItems[urand(0, purpleItems.size() - 1)];
pItems = pItems + 1;
break;
itemID = whiteItemsBin[urand(0, whiteItemsBin.size() - 1)];
++whiteItems;
break;
}
}
case 2:
{
if ((blueItems.size() > 0) && (bItems < bibin))
if ((greenItemsBin.size() > 0) && (greenItems < greenIcount))
{
itemID = blueItems[urand(0, blueItems.size() - 1)];
bItems = bItems + 1;
itemID = greenItemsBin[urand(0, greenItemsBin.size() - 1)];
++greenItems;
break;
}
}
case 3:
{
if ((greenItems.size() > 0) && (gItems < gibin))
if ((blueItemsBin.size() > 0) && (blueItems < blueIcount))
{
itemID = greenItems[urand(0, greenItems.size() - 1)];
gItems = gItems + 1;
itemID = blueItemsBin[urand(0, blueItemsBin.size() - 1)];
++blueItems;
break;
}
}
case 4:
{
if ((whiteItems.size() > 0) && (wItems < wibin))
if ((purpleItemsBin.size() > 0) && (purpleItems < purpleIcount))
{
itemID = whiteItems[urand(0, whiteItems.size() - 1)];
wItems = wItems + 1;
break;
itemID = purpleItemsBin[urand(0, purpleItemsBin.size() - 1)];
++purpleItems;
break;
}
}
case 5:
{
if ((purpleTradeGoods.size() > 0) && (pTGoods < ptgbin))
if ((orangeItemsBin.size() > 0) && (orangeItems < orangeIcount))
{
itemID = purpleTradeGoods[urand(0, purpleTradeGoods.size() - 1)];
pTGoods = pTGoods + 1;
break;
itemID = orangeItemsBin[urand(0, orangeItemsBin.size() - 1)];
++orangeItems;
break;
}
}
case 6:
{
if ((blueTradeGoods.size() > 0) && (bTGoods < btgbin))
if ((yellowItemsBin.size() > 0) && (yellowItems < yellowIcount))
{
itemID = blueTradeGoods[urand(0, blueTradeGoods.size() - 1)];
bTGoods = bTGoods + 1;
break;
itemID = yellowItemsBin[urand(0, yellowItemsBin.size() - 1)];
++yellowItems;
break;
}
}
case 7:
{
if ((greenTradeGoods.size() > 0) && (gTGoods < gtgbin))
if ((greyTradeGoodsBin.size() > 0) && (greyTGoods < greyTGcount))
{
itemID = greenTradeGoods[urand(0, greenTradeGoods.size() - 1)];
gTGoods = gTGoods + 1;
itemID = whiteTradeGoodsBin[urand(0, whiteTradeGoodsBin.size() - 1)];
++greyTGoods;
break;
}
}
case 8:
{
if ((whiteTradeGoods.size() > 0) && (wTGoods < wtgbin))
if ((whiteTradeGoodsBin.size() > 0) && (whiteTGoods < whiteTGcount))
{
itemID = whiteTradeGoods[urand(0, whiteTradeGoods.size() - 1)];
wTGoods = wTGoods + 1;
itemID = whiteTradeGoodsBin[urand(0, whiteTradeGoodsBin.size() - 1)];
++whiteTGoods;
break;
}
}
case 9:
{
if ((greenTradeGoodsBin.size() > 0) && (greenTGoods < greenTGcount))
{
itemID = greenTradeGoodsBin[urand(0, greenTradeGoodsBin.size() - 1)];
++greenTGoods;
break;
}
}
case 10:
{
if ((blueTradeGoodsBin.size() > 0) && (blueTGoods < blueTGcount))
{
itemID = blueTradeGoodsBin[urand(0, blueTradeGoodsBin.size() - 1)];
++blueTGoods;
break;
}
}
case 11:
{
if ((purpleTradeGoodsBin.size() > 0) && (purpleTGoods < purpleTGcount))
{
itemID = purpleTradeGoodsBin[urand(0, purpleTradeGoodsBin.size() - 1)];
++purpleTGoods;
break;
}
}
case 12:
{
if ((orangeTradeGoodsBin.size() > 0) && (orangeTGoods < orangeTGcount))
{
itemID = orangeTradeGoodsBin[urand(0, orangeTradeGoodsBin.size() - 1)];
++orangeTGoods;
break;
}
}
case 13:
{
if ((yellowTradeGoodsBin.size() > 0) && (yellowTGoods < yellowTGcount))
{
itemID = yellowTradeGoodsBin[urand(0, yellowTradeGoodsBin.size() - 1)];
++yellowTGoods;
break;
}
}
@@ -270,6 +374,17 @@ static void addNewAuctions(Player *AHBplayer, AHBConfig *config)
switch (prototype->Quality)
{
case 0:
if (config->GetMaxStack(AHB_GREY) != 0)
{
stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_GREY)));
}
buyoutPrice *= urand(config->GetMinPrice(AHB_GREY), config->GetMaxPrice(AHB_GREY)) * stackCount;
buyoutPrice /= 100;
bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_GREY), config->GetMaxBidPrice(AHB_GREY));
bidPrice /= 100;
break;
case 1:
if (config->GetMaxStack(AHB_WHITE) != 0)
{
@@ -313,13 +428,33 @@ static void addNewAuctions(Player *AHBplayer, AHBConfig *config)
bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_PURPLE), config->GetMaxBidPrice(AHB_PURPLE));
bidPrice /= 100;
break;
case 5:
if (config->GetMaxStack(AHB_ORANGE) != 0)
{
stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_ORANGE)));
}
buyoutPrice *= urand(config->GetMinPrice(AHB_ORANGE), config->GetMaxPrice(AHB_ORANGE)) * stackCount;
buyoutPrice /= 100;
bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_ORANGE), config->GetMaxBidPrice(AHB_ORANGE));
bidPrice /= 100;
break;
case 6:
if (config->GetMaxStack(AHB_YELLOW) != 0)
{
stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(AHB_YELLOW)));
}
buyoutPrice *= urand(config->GetMinPrice(AHB_YELLOW), config->GetMaxPrice(AHB_YELLOW)) * stackCount;
buyoutPrice /= 100;
bidPrice = buyoutPrice * urand(config->GetMinBidPrice(AHB_YELLOW), config->GetMaxBidPrice(AHB_YELLOW));
bidPrice /= 100;
break;
}
item->SetCount(stackCount);
AuctionEntry* auctionEntry = new AuctionEntry;
auctionEntry->Id = objmgr.GenerateAuctionID();
auctionEntry->auctioneer = 0;
auctionEntry->auctioneer = AuctioneerGUID;
auctionEntry->item_guidlow = item->GetGUIDLow();
auctionEntry->item_template = item->GetEntry();
auctionEntry->owner = AHBplayer->GetGUIDLow();
@@ -328,31 +463,13 @@ static void addNewAuctions(Player *AHBplayer, AHBConfig *config)
auctionEntry->bidder = 0;
auctionEntry->bid = 0;
auctionEntry->deposit = 0;
auctionEntry->location = config->GetAHID();
auctionEntry->time = (time_t) (urand(config->GetMinTime(), config->GetMaxTime()) * 60 * 60 + time(NULL));
auctionEntry->expire_time = (time_t) (urand(config->GetMinTime(), config->GetMaxTime()) * 60 * 60 + time(NULL));
auctionEntry->auctionHouseEntry = ahEntry;
item->SaveToDB();
item->RemoveFromUpdateQueueOf(AHBplayer);
objmgr.AddAItem(item);
auctionmgr.AddAItem(item);
auctionHouse->AddAuction(auctionEntry);
CharacterDatabase.PExecute("INSERT INTO `auctionhouse` (`id`,"
"`auctioneerguid`,`itemguid`,`item_template`,"
"`itemowner`,`buyoutprice`,`time`,`buyguid`,"
"`lastbid`,`startbid`,`deposit`,`location`) "
"VALUES ('%u', '%u', '%u', '%u', '%u', '%u', "
"'" I64FMTD "', '%u', '%u', '%u', '%u', '%u')",
auctionEntry->Id,
auctionEntry->auctioneer,
auctionEntry->item_guidlow,
auctionEntry->item_template,
auctionEntry->owner,
auctionEntry->buyout,
(uint64) auctionEntry->time,
auctionEntry->bidder,
auctionEntry->bid,
auctionEntry->startbid,
auctionEntry->deposit,
auctionEntry->location);
auctionEntry->SaveToDB();
}
}
@@ -362,7 +479,7 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World
return;
// Fetches content of selected AH
AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(config->GetAHID());
AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(config->GetAHFID());
AuctionHouseObject::AuctionEntryMap::iterator itr;
itr = auctionHouse->GetAuctionsBegin();
@@ -395,11 +512,11 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World
// Choose random auction from possible auctions
uint32 auctionID = possibleBids[urand(0, possibleBids.size() - 1)];
// from auctionhouse.cpp, creates auction pointer & player pointer
// from auctionhousehandler.cpp, creates auction pointer & player pointer
AuctionEntry* auction = auctionHouse->GetAuction(auctionID);
// get exact item information
Item *pItem = objmgr.GetAItem(auction->item_guidlow);
Item *pItem = auctionmgr.GetAItem(auction->item_guidlow);
if (!pItem)
{
sLog.outError("Item doesn't exists, perhaps bought already?");
@@ -410,16 +527,14 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World
ItemPrototype const* prototype = objmgr.GetItemPrototype(auction->item_template);
// check which price we have to use, startbid or if it is bidded already
if(debug_Out)
{sLog.outError("Auction Number: %u", auction->Id);}
if(debug_Out)
{sLog.outError("Item Template: %u", auction->item_template);}
if(debug_Out)
{sLog.outError("Buy Price: %u", prototype->BuyPrice);}
if(debug_Out)
{sLog.outError("Sell Price: %u", prototype->SellPrice);}
if(debug_Out)
{sLog.outError("Quality: %u", prototype->Quality);}
if(debug_Out)
{
sLog.outError("Auction Number: %u", auction->Id);
sLog.outError("Item Template: %u", auction->item_template);
sLog.outError("Buy Price: %u", prototype->BuyPrice);
sLog.outError("Sell Price: %u", prototype->SellPrice);
sLog.outError("Quality: %u", prototype->Quality);
}
uint32 currentprice;
if(auction->bid)
{
@@ -480,6 +595,16 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World
{
bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE);
}
case 5:
if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE))
{
bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE);
}
case 6:
if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW))
{
bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW);
}
break;
default:
// quality is something it shouldn't be, let's get out of here
@@ -521,6 +646,16 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World
{
bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE);
}
case 5:
if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE))
{
bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE);
}
case 6:
if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW))
{
bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW);
}
break;
default:
// quality is something it shouldn't be, let's get out of here
@@ -564,9 +699,9 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World
{sLog.outError("bidprice: %u", bidprice);}
// Check our bid is high enough to be valid. If not, correct it to minimum.
if((currentprice + objmgr.GetAuctionOutBid(currentprice)) > bidprice)
if((currentprice + auction->GetAuctionOutBid()) > bidprice)
{
bidprice = currentprice + objmgr.GetAuctionOutBid(currentprice);
bidprice = currentprice + auction->GetAuctionOutBid();
if(debug_Out)
{sLog.outError("bidprice(>): %u", bidprice);}
}
@@ -614,15 +749,15 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World
auction->bid = auction->buyout;
// Send mails to buyer & seller
objmgr.SendAuctionSuccessfulMail( auction );
objmgr.SendAuctionWonMail( auction );
auctionmgr.SendAuctionSuccessfulMail( auction );
auctionmgr.SendAuctionWonMail( auction );
// Remove item from auctionhouse
objmgr.RemoveAItem(auction->item_guidlow);
auctionmgr.RemoveAItem(auction->item_guidlow);
// Remove auction
auctionHouse->RemoveAuction(auction->Id);
// Remove from database
CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",auction->Id);
auction->DeleteFromDB();
delete auction;
}
@@ -641,7 +776,7 @@ void AuctionHouseBot()
_AHBplayer.MinimalLoadFromDB(NULL, AHBplayerGUID);
ObjectAccessor::Instance().AddObject(&_AHBplayer);
if(sConfig.GetIntDefault("AllowTwoSide.Interaction.Auction",0) == 0)
if(!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
{
addNewAuctions(&_AHBplayer, &AllianceConfig);
if (((_newrun - _lastrun_a) > (AllianceConfig.GetBiddingInterval() * 60)) && (AllianceConfig.GetBidsPerInterval() > 0))
@@ -689,7 +824,7 @@ void AuctionHouseBotInit()
Bind_When_Use = sConfig.GetBoolDefault("AuctionHouseBot.Bind_When_Use", 1);
Bind_Quest_Item = sConfig.GetBoolDefault("AuctionHouseBot.Bind_Quest_Item", 0);
if(sConfig.GetBoolDefault("AllowTwoSide.Interaction.Auction",0) == 0)
if(!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
{
AuctionHouseBotLoadValues(&AllianceConfig);
AuctionHouseBotLoadValues(&HordeConfig);
@@ -796,7 +931,7 @@ void AuctionHouseBotInit()
break;
}
if ((prototype->Quality < 1) || (prototype->Quality > 4))
if ((prototype->Quality < 0) || (prototype->Quality > 6))
continue;
if (Vendor_Items == 0)
@@ -848,58 +983,93 @@ void AuctionHouseBotInit()
switch (prototype->Quality)
{
case 0:
if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
greyTradeGoodsBin.push_back(itemID);
else
greyItemsBin.push_back(itemID);
break;
case 1:
if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
whiteTradeGoods.push_back(itemID);
whiteTradeGoodsBin.push_back(itemID);
else
whiteItems.push_back(itemID);
whiteItemsBin.push_back(itemID);
break;
case 2:
if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
greenTradeGoods.push_back(itemID);
greenTradeGoodsBin.push_back(itemID);
else
greenItems.push_back(itemID);
greenItemsBin.push_back(itemID);
break;
case 3:
if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
blueTradeGoods.push_back(itemID);
blueTradeGoodsBin.push_back(itemID);
else
blueItems.push_back(itemID);
blueItemsBin.push_back(itemID);
break;
case 4:
if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
purpleTradeGoods.push_back(itemID);
purpleTradeGoodsBin.push_back(itemID);
else
purpleItems.push_back(itemID);
purpleItemsBin.push_back(itemID);
break;
case 5:
if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
orangeTradeGoodsBin.push_back(itemID);
else
orangeItemsBin.push_back(itemID);
break;
case 6:
if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
yellowTradeGoodsBin.push_back(itemID);
else
yellowItemsBin.push_back(itemID);
break;
}
}
if ((whiteTradeGoods.size() == 0) &&
(greenTradeGoods.size() == 0) &&
(blueTradeGoods.size() == 0) &&
(purpleTradeGoods.size() == 0) &&
(whiteItems.size() == 0) &&
(greenItems.size() == 0) &&
(blueItems.size() == 0) &&
(purpleItems.size() == 0))
if (
(greyTradeGoodsBin.size() == 0) &&
(whiteTradeGoodsBin.size() == 0) &&
(greenTradeGoodsBin.size() == 0) &&
(blueTradeGoodsBin.size() == 0) &&
(purpleTradeGoodsBin.size() == 0) &&
(orangeTradeGoodsBin.size() == 0) &&
(yellowTradeGoodsBin.size() == 0) &&
(greyItemsBin.size() == 0) &&
(whiteItemsBin.size() == 0) &&
(greenItemsBin.size() == 0) &&
(blueItemsBin.size() == 0) &&
(purpleItemsBin.size() == 0) &&
(orangeItemsBin.size() == 0) &&
(yellowItemsBin.size() == 0)
)
{
sLog.outString("AuctionHouseBot: No items");
AHBSeller = 0;
}
sLog.outString("AuctionHouseBot:");
sLog.outString("loaded %d white trade goods", whiteTradeGoods.size());
sLog.outString("loaded %d green trade goods", greenTradeGoods.size());
sLog.outString("loaded %d blue trade goods", blueTradeGoods.size());
sLog.outString("loaded %d purple trade goods", purpleTradeGoods.size());
sLog.outString("loaded %d white items", whiteItems.size());
sLog.outString("loaded %d green items", greenItems.size());
sLog.outString("loaded %d blue items", blueItems.size());
sLog.outString("loaded %d purple items", purpleItems.size());
sLog.outString("loaded %d grey trade goods", greyTradeGoodsBin.size());
sLog.outString("loaded %d white trade goods", whiteTradeGoodsBin.size());
sLog.outString("loaded %d green trade goods", greenTradeGoodsBin.size());
sLog.outString("loaded %d blue trade goods", blueTradeGoodsBin.size());
sLog.outString("loaded %d purple trade goods", purpleTradeGoodsBin.size());
sLog.outString("loaded %d orange trade goods", orangeTradeGoodsBin.size());
sLog.outString("loaded %d yellow trade goods", yellowTradeGoodsBin.size());
sLog.outString("loaded %d grey items", greyItemsBin.size());
sLog.outString("loaded %d white items", whiteItemsBin.size());
sLog.outString("loaded %d green items", greenItemsBin.size());
sLog.outString("loaded %d blue items", blueItemsBin.size());
sLog.outString("loaded %d purple items", purpleItemsBin.size());
sLog.outString("loaded %d orange items", orangeItemsBin.size());
sLog.outString("loaded %d yellow items", yellowItemsBin.size());
}
sLog.outString("AuctionHouseBot by Paradox (original by ChrisK) has been loaded.");
sLog.outString("AuctionHouseBot now includes AHBuyer by Kerbe and Paradox");
@@ -938,14 +1108,20 @@ void AuctionHouseBotCommands(uint32 command, uint32 ahMapID, uint32 col, char* a
case AHB_PURPLE:
color = "purple";
break;
case AHB_ORANGE:
color = "orange";
break;
case AHB_YELLOW:
color = "yellow";
break;
default:
break;
}
switch (command)
{
case 0: //ahexpire
case 0: //ahexpire
{
AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(ahMapID);
AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap(config->GetAHFID());
AuctionHouseObject::AuctionEntryMap::iterator itr;
itr = auctionHouse->GetAuctionsBegin();
@@ -953,40 +1129,40 @@ void AuctionHouseBotCommands(uint32 command, uint32 ahMapID, uint32 col, char* a
while (itr != auctionHouse->GetAuctionsEnd())
{
if (itr->second->owner == AHBplayerGUID)
itr->second->time = sWorld.GetGameTime();
itr->second->expire_time = sWorld.GetGameTime();
++itr;
}
}break;
case 1: //min items
case 1: //min items
{
char * param1 = strtok(args, " ");
uint32 minItems = (uint32) strtoul(param1, NULL, 0);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET minitems = '%u' WHERE auctionhouse = '%u'", minItems, ahMapID);
config->SetMinItems(minItems);
}break;
case 2: //max items
case 2: //max items
{
char * param1 = strtok(args, " ");
uint32 maxItems = (uint32) strtoul(param1, NULL, 0);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxitems = '%u' WHERE auctionhouse = '%u'", maxItems, ahMapID);
config->SetMaxItems(maxItems);
}break;
case 3: //min time
case 3: //min time
{
char * param1 = strtok(args, " ");
uint32 minTime = (uint32) strtoul(param1, NULL, 0);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET mintime = '%u' WHERE auctionhouse = '%u'", minTime, ahMapID);
config->SetMinTime(minTime);
}break;
case 4: //max time
case 4: //max time
{
char * param1 = strtok(args, " ");
uint32 maxTime = (uint32) strtoul(param1, NULL, 0);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxtime = '%u' WHERE auctionhouse = '%u'", maxTime, ahMapID);
config->SetMaxTime(maxTime);
}break;
case 5: //percentages
case 5: //percentages
{
char * param1 = strtok(args, " ");
char * param2 = strtok(NULL, " ");
@@ -996,49 +1172,67 @@ void AuctionHouseBotCommands(uint32 command, uint32 ahMapID, uint32 col, char* a
char * param6 = strtok(NULL, " ");
char * param7 = strtok(NULL, " ");
char * param8 = strtok(NULL, " ");
uint32 wtg = (uint32) strtoul(param1, NULL, 0);
uint32 gtg = (uint32) strtoul(param2, NULL, 0);
uint32 btg = (uint32) strtoul(param3, NULL, 0);
uint32 ptg = (uint32) strtoul(param4, NULL, 0);
uint32 wi = (uint32) strtoul(param5, NULL, 0);
uint32 gi = (uint32) strtoul(param6, NULL, 0);
uint32 bi = (uint32) strtoul(param7, NULL, 0);
uint32 pi = (uint32) strtoul(param8, NULL, 0);
char * param9 = strtok(NULL, " ");
char * param10 = strtok(NULL, " ");
char * param11 = strtok(NULL, " ");
char * param12 = strtok(NULL, " ");
char * param13 = strtok(NULL, " ");
char * param14 = strtok(NULL, " ");
uint32 greytg = (uint32) strtoul(param1, NULL, 0);
uint32 whitetg = (uint32) strtoul(param2, NULL, 0);
uint32 greentg = (uint32) strtoul(param3, NULL, 0);
uint32 bluetg = (uint32) strtoul(param4, NULL, 0);
uint32 purpletg = (uint32) strtoul(param5, NULL, 0);
uint32 orangetg = (uint32) strtoul(param6, NULL, 0);
uint32 yellowtg = (uint32) strtoul(param7, NULL, 0);
uint32 greyi = (uint32) strtoul(param8, NULL, 0);
uint32 whitei = (uint32) strtoul(param9, NULL, 0);
uint32 greeni = (uint32) strtoul(param10, NULL, 0);
uint32 bluei = (uint32) strtoul(param11, NULL, 0);
uint32 purplei = (uint32) strtoul(param12, NULL, 0);
uint32 orangei = (uint32) strtoul(param13, NULL, 0);
uint32 yellowi = (uint32) strtoul(param14, NULL, 0);
CharacterDatabase.BeginTransaction();
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhitetradegoods = '%u' WHERE auctionhouse = '%u'", wtg, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreentradegoods = '%u' WHERE auctionhouse = '%u'", gtg, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentbluetradegoods = '%u' WHERE auctionhouse = '%u'", btg, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentpurpletradegoods = '%u' WHERE auctionhouse = '%u'", ptg, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhiteitems = '%u' WHERE auctionhouse = '%u'", wi, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreenitems = '%u' WHERE auctionhouse = '%u'", gi, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentblueitems = '%u' WHERE auctionhouse = '%u'", bi, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentpurpleitems = '%u' WHERE auctionhouse = '%u'", pi, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreytradegoods = '%u' WHERE auctionhouse = '%u'", greytg, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhitetradegoods = '%u' WHERE auctionhouse = '%u'", whitetg, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreentradegoods = '%u' WHERE auctionhouse = '%u'", greentg, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentbluetradegoods = '%u' WHERE auctionhouse = '%u'", bluetg, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentpurpletradegoods = '%u' WHERE auctionhouse = '%u'", purpletg, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentorangetradegoods = '%u' WHERE auctionhouse = '%u'", orangetg, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentyellowtradegoods = '%u' WHERE auctionhouse = '%u'", yellowtg, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreyitems = '%u' WHERE auctionhouse = '%u'", greyi, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhiteitems = '%u' WHERE auctionhouse = '%u'", whitei, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreenitems = '%u' WHERE auctionhouse = '%u'", greeni, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentblueitems = '%u' WHERE auctionhouse = '%u'", bluei, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentpurpleitems = '%u' WHERE auctionhouse = '%u'", purplei, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentorangeitems = '%u' WHERE auctionhouse = '%u'", orangei, ahMapID);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentyellowitems = '%u' WHERE auctionhouse = '%u'", yellowi, ahMapID);
CharacterDatabase.CommitTransaction();
config->SetPercentages(wtg, gtg, btg, ptg, wi, gi, bi, pi);
config->SetPercentages(greytg, whitetg, greentg, bluetg, purpletg, orangetg, yellowtg, greyi, whitei, greeni, bluei, purplei, orangei, yellowi);
}break;
case 6: //min prices
case 6: //min prices
{
char * param1 = strtok(args, " ");
uint32 minPrice = (uint32) strtoul(param1, NULL, 0);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET minprice%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), minPrice, ahMapID);
config->SetMinPrice(col, minPrice);
}break;
case 7: //max prices
case 7: //max prices
{
char * param1 = strtok(args, " ");
uint32 maxPrice = (uint32) strtoul(param1, NULL, 0);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxprice%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), maxPrice, ahMapID);
config->SetMaxPrice(col, maxPrice);
}break;
case 8: //min bid price
case 8: //min bid price
{
char * param1 = strtok(args, " ");
uint32 minBidPrice = (uint32) strtoul(param1, NULL, 0);
CharacterDatabase.PExecute("UPDATE auctionhousebot SET minbidprice%s = '%u' WHERE auctionhouse = '%u'",color.c_str(), minBidPrice, ahMapID);
config->SetMinBidPrice(col, minBidPrice);
}break;
case 9: //max bid price
case 9: //max bid price
{
char * param1 = strtok(args, " ");
uint32 maxBidPrice = (uint32) strtoul(param1, NULL, 0);
@@ -1094,25 +1288,44 @@ void AuctionHouseBotLoadValues(AHBConfig *config)
{sLog.outError("minTime = %u", config->GetMinTime());
sLog.outError("maxTime = %u", config->GetMaxTime());}
//load percentages
uint32 wtg = CharacterDatabase.PQuery("SELECT percentwhitetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 gtg = CharacterDatabase.PQuery("SELECT percentgreentradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 btg = CharacterDatabase.PQuery("SELECT percentbluetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 ptg = CharacterDatabase.PQuery("SELECT percentpurpletradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 wi = CharacterDatabase.PQuery("SELECT percentwhiteitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 gi = CharacterDatabase.PQuery("SELECT percentgreenitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 bi = CharacterDatabase.PQuery("SELECT percentblueitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 pi = CharacterDatabase.PQuery("SELECT percentpurpleitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
config->SetPercentages(wtg, gtg, btg, ptg, wi, gi, bi, pi);
uint32 greytg = CharacterDatabase.PQuery("SELECT percentgreytradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 whitetg = CharacterDatabase.PQuery("SELECT percentwhitetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 greentg = CharacterDatabase.PQuery("SELECT percentgreentradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 bluetg = CharacterDatabase.PQuery("SELECT percentbluetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 purpletg = CharacterDatabase.PQuery("SELECT percentpurpletradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 orangetg = CharacterDatabase.PQuery("SELECT percentorangetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 yellowtg = CharacterDatabase.PQuery("SELECT percentyellowtradegoods FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 greyi = CharacterDatabase.PQuery("SELECT percentgreyitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 whitei = CharacterDatabase.PQuery("SELECT percentwhiteitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 greeni = CharacterDatabase.PQuery("SELECT percentgreenitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 bluei = CharacterDatabase.PQuery("SELECT percentblueitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 purplei = CharacterDatabase.PQuery("SELECT percentpurpleitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 orangei = CharacterDatabase.PQuery("SELECT percentorangeitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
uint32 yellowi = CharacterDatabase.PQuery("SELECT percentyellowitems FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32();
config->SetPercentages(greytg, whitetg, greentg, bluetg, purpletg, orangetg, yellowtg, greyi, whitei, greeni, bluei, purplei, orangei, yellowi);
if(debug_Out)
{sLog.outError("percentWhiteTradeGoods = %u", config->GetPercentages(AHB_WHITE_TG));
sLog.outError("percentGreenTradeGoods = %u", config->GetPercentages(AHB_GREEN_TG));
sLog.outError("percentBlueTradeGoods = %u", config->GetPercentages(AHB_BLUE_TG));
sLog.outError("percentPurpleTradeGoods = %u", config->GetPercentages(AHB_PURPLE_TG));
sLog.outError("percentWhiteItems = %u", config->GetPercentages(AHB_WHITE_I));
sLog.outError("percentGreenItems = %u", config->GetPercentages(AHB_GREEN_I));
sLog.outError("percentBlueItems = %u", config->GetPercentages(AHB_BLUE_I));
sLog.outError("percentPurpleItems = %u", config->GetPercentages(AHB_PURPLE_I));}
{
sLog.outError("percentGreyTradeGoods = %u", config->GetPercentages(AHB_GREY_TG));
sLog.outError("percentWhiteTradeGoods = %u", config->GetPercentages(AHB_WHITE_TG));
sLog.outError("percentGreenTradeGoods = %u", config->GetPercentages(AHB_GREEN_TG));
sLog.outError("percentBlueTradeGoods = %u", config->GetPercentages(AHB_BLUE_TG));
sLog.outError("percentPurpleTradeGoods = %u", config->GetPercentages(AHB_PURPLE_TG));
sLog.outError("percentOrangeTradeGoods = %u", config->GetPercentages(AHB_ORANGE_TG));
sLog.outError("percentYellowTradeGoods = %u", config->GetPercentages(AHB_YELLOW_TG));
sLog.outError("percentGreyItems = %u", config->GetPercentages(AHB_GREY_I));
sLog.outError("percentWhiteItems = %u", config->GetPercentages(AHB_WHITE_I));
sLog.outError("percentGreenItems = %u", config->GetPercentages(AHB_GREEN_I));
sLog.outError("percentBlueItems = %u", config->GetPercentages(AHB_BLUE_I));
sLog.outError("percentPurpleItems = %u", config->GetPercentages(AHB_PURPLE_I));
sLog.outError("percentOrangeItems = %u", config->GetPercentages(AHB_ORANGE_I));
sLog.outError("percentYellowItems = %u", config->GetPercentages(AHB_YELLOW_I));
}
//load min and max prices
config->SetMinPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT minpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
config->SetMaxPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT maxpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError("minPriceGrey = %u", config->GetMinPrice(AHB_GREY));
sLog.outError("maxPriceGrey = %u", config->GetMaxPrice(AHB_GREY));}
config->SetMinPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT minpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
config->SetMaxPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT maxpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
@@ -1133,7 +1346,23 @@ void AuctionHouseBotLoadValues(AHBConfig *config)
if(debug_Out)
{sLog.outError("minPricePurple = %u", config->GetMinPrice(AHB_PURPLE));
sLog.outError("maxPricePurple = %u", config->GetMaxPrice(AHB_PURPLE));}
config->SetMinPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT minpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
config->SetMaxPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT maxpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError("minPriceOrange = %u", config->GetMinPrice(AHB_ORANGE));
sLog.outError("maxPriceOrange = %u", config->GetMaxPrice(AHB_ORANGE));}
config->SetMinPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT minpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
config->SetMaxPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT maxpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError("minPriceYellow = %u", config->GetMinPrice(AHB_YELLOW));
sLog.outError("maxPriceYellow = %u", config->GetMaxPrice(AHB_YELLOW));}
//load min and max bid prices
config->SetMinBidPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT minbidpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError(",minBidPriceGrey = %u", config->GetMinBidPrice(AHB_GREY));}
config->SetMaxBidPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT maxbidpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError("maxBidPriceGrey = %u", config->GetMaxBidPrice(AHB_GREY));}
config->SetMinBidPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT minbidpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError(",minBidPriceWhite = %u", config->GetMinBidPrice(AHB_WHITE));}
@@ -1158,7 +1387,22 @@ void AuctionHouseBotLoadValues(AHBConfig *config)
config->SetMaxBidPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT maxbidpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError("maxBidPricePurple = %u", config->GetMaxBidPrice(AHB_PURPLE));}
config->SetMinBidPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT minbidpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError("minBidPriceOrange = %u", config->GetMinBidPrice(AHB_ORANGE));}
config->SetMaxBidPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT maxbidpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError("maxBidPriceOrange = %u", config->GetMaxBidPrice(AHB_ORANGE));}
config->SetMinBidPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT minbidpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError("minBidPriceYellow = %u", config->GetMinBidPrice(AHB_YELLOW));}
config->SetMaxBidPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT maxbidpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError("maxBidPriceYellow = %u", config->GetMaxBidPrice(AHB_YELLOW));}
//load max stacks
config->SetMaxStack(AHB_GREY, CharacterDatabase.PQuery("SELECT maxstackgrey FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError("maxStackGrey = %u", config->GetMaxStack(AHB_GREY));}
config->SetMaxStack(AHB_WHITE, CharacterDatabase.PQuery("SELECT maxstackwhite FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError("maxStackWhite = %u", config->GetMaxStack(AHB_WHITE));}
@@ -1171,6 +1415,12 @@ void AuctionHouseBotLoadValues(AHBConfig *config)
config->SetMaxStack(AHB_PURPLE, CharacterDatabase.PQuery("SELECT maxstackpurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError("maxStackPurple = %u", config->GetMaxStack(AHB_PURPLE));}
config->SetMaxStack(AHB_ORANGE, CharacterDatabase.PQuery("SELECT maxstackorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError("maxStackOrange = %u", config->GetMaxStack(AHB_ORANGE));}
config->SetMaxStack(AHB_YELLOW, CharacterDatabase.PQuery("SELECT maxstackyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError("maxStackYellow = %u", config->GetMaxStack(AHB_YELLOW));}
}
if (AHBBuyer)
{
@@ -1180,12 +1430,18 @@ void AuctionHouseBotLoadValues(AHBConfig *config)
config->SetBuyerPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT buyerpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
config->SetBuyerPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT buyerpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
config->SetBuyerPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT buyerpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
config->SetBuyerPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT buyerpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
config->SetBuyerPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT buyerpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
{sLog.outError("buyerPriceGrey = %u", config->GetBuyerPrice(AHB_GREY));
sLog.outError("buyerPriceWhite = %u", config->GetBuyerPrice(AHB_WHITE));
sLog.outError("buyerPriceGreen = %u", config->GetBuyerPrice(AHB_GREEN));
sLog.outError("buyerPriceBlue = %u", config->GetBuyerPrice(AHB_BLUE));
sLog.outError("buyerPricePurple = %u", config->GetBuyerPrice(AHB_PURPLE));}
{
sLog.outError("buyerPriceGrey = %u", config->GetBuyerPrice(AHB_GREY));
sLog.outError("buyerPriceWhite = %u", config->GetBuyerPrice(AHB_WHITE));
sLog.outError("buyerPriceGreen = %u", config->GetBuyerPrice(AHB_GREEN));
sLog.outError("buyerPriceBlue = %u", config->GetBuyerPrice(AHB_BLUE));
sLog.outError("buyerPricePurple = %u", config->GetBuyerPrice(AHB_PURPLE));
sLog.outError("buyerPriceOrange = %u", config->GetBuyerPrice(AHB_ORANGE));
sLog.outError("buyerPriceYellow = %u", config->GetBuyerPrice(AHB_YELLOW));
}
//load bidding interval
config->SetBiddingInterval(CharacterDatabase.PQuery("SELECT buyerbiddinginterval FROM auctionhousebot WHERE auctionhouse = %u",config->GetAHID())->Fetch()->GetUInt32());
if(debug_Out)
@@ -1196,4 +1452,3 @@ void AuctionHouseBotLoadValues(AHBConfig *config)
{sLog.outError("buyerBidsPerInterval = %u", config->GetBidsPerInterval());}
}
}
+303 -72
View File
@@ -8,16 +8,22 @@
#define AHB_GREEN 2
#define AHB_BLUE 3
#define AHB_PURPLE 4
#define AHB_ORANGE 5
#define AHB_YELLOW 6
#define AHB_GREY_TG 0
#define AHB_WHITE_TG 1
#define AHB_GREEN_TG 2
#define AHB_BLUE_TG 3
#define AHB_PURPLE_TG 4
#define AHB_GREY_I 5
#define AHB_WHITE_I 6
#define AHB_GREEN_I 7
#define AHB_BLUE_I 8
#define AHB_PURPLE_I 9
#define AHB_ORANGE_TG 5
#define AHB_YELLOW_TG 6
#define AHB_GREY_I 7
#define AHB_WHITE_I 8
#define AHB_GREEN_I 9
#define AHB_BLUE_I 10
#define AHB_PURPLE_I 11
#define AHB_ORANGE_I 12
#define AHB_YELLOW_I 13
#define AHBplayerAccount sConfig.GetIntDefault("AuctionHouseBot.Account", 0)
#define AHBplayerGUID sConfig.GetIntDefault("AuctionHouseBot.GUID", 0)
#define ItemsPerCycle sConfig.GetIntDefault("AuctionHouseBot.ItemsPerCycle", 200)
@@ -28,18 +34,30 @@ class AHBConfig
{
private:
uint32 AHID;
uint32 AHFID;
uint32 minItems;
uint32 maxItems;
uint32 minTime;
uint32 maxTime;
uint32 percentGreyTradeGoods;
uint32 percentWhiteTradeGoods;
uint32 percentGreenTradeGoods;
uint32 percentBlueTradeGoods;
uint32 percentPurpleTradeGoods;
uint32 percentOrangeTradeGoods;
uint32 percentYellowTradeGoods;
uint32 percentGreyItems;
uint32 percentWhiteItems;
uint32 percentGreenItems;
uint32 percentBlueItems;
uint32 percentPurpleItems;
uint32 percentOrangeItems;
uint32 percentYellowItems;
uint32 minPriceGrey;
uint32 maxPriceGrey;
uint32 minBidPriceGrey;
uint32 maxBidPriceGrey;
uint32 maxStackGrey;
uint32 minPriceWhite;
uint32 maxPriceWhite;
uint32 minBidPriceWhite;
@@ -60,27 +78,60 @@ class AHBConfig
uint32 minBidPricePurple;
uint32 maxBidPricePurple;
uint32 maxStackPurple;
uint32 minPriceOrange;
uint32 maxPriceOrange;
uint32 minBidPriceOrange;
uint32 maxBidPriceOrange;
uint32 maxStackOrange;
uint32 minPriceYellow;
uint32 maxPriceYellow;
uint32 minBidPriceYellow;
uint32 maxBidPriceYellow;
uint32 maxStackYellow;
uint32 buyerPriceGrey;
uint32 buyerPriceWhite;
uint32 buyerPriceGreen;
uint32 buyerPriceBlue;
uint32 buyerPricePurple;
uint32 buyerPriceOrange;
uint32 buyerPriceYellow;
uint32 buyerBiddingInterval;
uint32 buyerBidsPerInterval;
uint32 wtgp;
uint32 gtgp;
uint32 btgp;
uint32 ptgp;
uint32 wip;
uint32 gip;
uint32 bip;
uint32 pip;
uint32 greytgp;
uint32 whitetgp;
uint32 greentgp;
uint32 bluetgp;
uint32 purpletgp;
uint32 orangetgp;
uint32 yellowtgp;
uint32 greyip;
uint32 whiteip;
uint32 greenip;
uint32 blueip;
uint32 purpleip;
uint32 orangeip;
uint32 yellowip;
public:
AHBConfig(uint32 ahid)
{
AHID = ahid;
switch(ahid)
{
case 2:
AHFID = 55;
break;
case 6:
AHFID = 29;
break;
case 7:
AHFID = 120;
break;
default:
AHFID = 120;
break;
}
}
AHBConfig()
{
@@ -89,6 +140,10 @@ class AHBConfig
{
return AHID;
}
uint32 GetAHFID()
{
return AHFID;
}
void SetMinItems(uint32 value)
{
minItems = value;
@@ -132,9 +187,9 @@ class AHBConfig
{
return maxTime;
}
void SetPercentages(uint32 wtg, uint32 gtg, uint32 btg, uint32 ptg, uint32 wi, uint32 gi, uint32 bi, uint32 pi)
void SetPercentages(uint32 greytg, uint32 whitetg, uint32 greentg, uint32 bluetg, uint32 purpletg, uint32 orangetg, uint32 yellowtg, uint32 greyi, uint32 whitei, uint32 greeni, uint32 bluei, uint32 purplei, uint32 orangei, uint32 yellowi)
{
uint32 totalPercent = wtg + gtg + btg + ptg + wi + gi + bi + pi;
uint32 totalPercent = greytg + whitetg + greentg + bluetg + purpletg + orangetg + yellowtg + greyi + whitei + greeni + bluei + purplei + orangei + yellowi;
if (totalPercent == 0)
{
@@ -142,26 +197,35 @@ class AHBConfig
}
else if (totalPercent != 100)
{
double scale = (double) 100 / (double) totalPercent;
wtg = (uint32) (scale * (double) pi);
gtg = (uint32) (scale * (double) gtg);
btg = (uint32) (scale * (double) btg);
ptg = (uint32) (scale * (double) ptg);
wi = (uint32) (scale * (double) wi);
gi = (uint32) (scale * (double) gi);
bi = (uint32) (scale * (double) bi);
pi = 100 - wtg - gtg - btg - ptg - wi - gi - bi;
greytg = 0;
whitetg = 27;
greentg = 12;
bluetg = 10;
purpletg = 1;
orangetg = 0;
yellowtg = 0;
greyi = 0;
whitei = 10;
greeni = 30;
bluei = 8;
purplei = 2;
orangei = 0;
yellowi = 0;
}
percentWhiteTradeGoods = wtg;
percentGreenTradeGoods = gtg;
percentBlueTradeGoods = btg;
percentPurpleTradeGoods = ptg;
percentWhiteItems = wi;
percentGreenItems = gi;
percentBlueItems = bi;
percentPurpleItems = pi;
percentGreyTradeGoods = greytg;
percentWhiteTradeGoods = whitetg;
percentGreenTradeGoods = greentg;
percentBlueTradeGoods = bluetg;
percentPurpleTradeGoods = purpletg;
percentOrangeTradeGoods = orangetg;
percentYellowTradeGoods = yellowtg;
percentGreyItems = greyi;
percentWhiteItems = whitei;
percentGreenItems = greeni;
percentBlueItems = bluei;
percentPurpleItems = purplei;
percentOrangeItems = orangei;
percentYellowItems = yellowi;
CalculatePercents();
}
uint32 GetPercentages(uint32 color)
@@ -169,7 +233,7 @@ class AHBConfig
switch(color)
{
case AHB_GREY_TG:
return 0;
return percentGreyTradeGoods;
break;
case AHB_WHITE_TG:
return percentWhiteTradeGoods;
@@ -183,8 +247,14 @@ class AHBConfig
case AHB_PURPLE_TG:
return percentPurpleTradeGoods;
break;
case AHB_ORANGE_TG:
return percentOrangeTradeGoods;
break;
case AHB_YELLOW_TG:
return percentYellowTradeGoods;
break;
case AHB_GREY_I:
return 0;
return percentGreyItems;
break;
case AHB_WHITE_I:
return percentWhiteItems;
@@ -198,6 +268,12 @@ class AHBConfig
case AHB_PURPLE_I:
return percentPurpleItems;
break;
case AHB_ORANGE_I:
return percentOrangeItems;
break;
case AHB_YELLOW_I:
return percentYellowItems;
break;
default:
return 0;
break;
@@ -208,6 +284,7 @@ class AHBConfig
switch(color)
{
case AHB_GREY:
minPriceGrey = value;
break;
case AHB_WHITE:
minPriceWhite = value;
@@ -221,6 +298,12 @@ class AHBConfig
case AHB_PURPLE:
minPricePurple = value;
break;
case AHB_ORANGE:
minPriceOrange = value;
break;
case AHB_YELLOW:
minPriceYellow = value;
break;
default:
break;
}
@@ -231,7 +314,12 @@ class AHBConfig
{
case AHB_GREY:
{
return 0;
if (minPriceGrey == 0)
return 100;
else if (minPriceGrey > maxPriceGrey)
return maxPriceGrey;
else
return minPriceGrey;
break;
}
case AHB_WHITE:
@@ -274,6 +362,26 @@ class AHBConfig
return minPricePurple;
break;
}
case AHB_ORANGE:
{
if (minPriceOrange == 0)
return 400;
else if (minPriceOrange > maxPriceOrange)
return maxPriceOrange;
else
return minPriceOrange;
break;
}
case AHB_YELLOW:
{
if (minPriceYellow == 0)
return 500;
else if (minPriceYellow > maxPriceYellow)
return maxPriceYellow;
else
return minPriceYellow;
break;
}
default:
{
return 0;
@@ -286,6 +394,7 @@ class AHBConfig
switch(color)
{
case AHB_GREY:
maxPriceGrey = value;
break;
case AHB_WHITE:
maxPriceWhite = value;
@@ -299,6 +408,12 @@ class AHBConfig
case AHB_PURPLE:
maxPricePurple = value;
break;
case AHB_ORANGE:
maxPriceOrange = value;
break;
case AHB_YELLOW:
maxPriceYellow = value;
break;
default:
break;
}
@@ -309,7 +424,10 @@ class AHBConfig
{
case AHB_GREY:
{
return 0;
if (maxPriceGrey == 0)
return 150;
else
return maxPriceGrey;
break;
}
case AHB_WHITE:
@@ -344,6 +462,22 @@ class AHBConfig
return maxPricePurple;
break;
}
case AHB_ORANGE:
{
if (maxPriceOrange == 0)
return 550;
else
return maxPriceOrange;
break;
}
case AHB_YELLOW:
{
if (maxPriceYellow == 0)
return 650;
else
return maxPriceYellow;
break;
}
default:
{
return 0;
@@ -356,6 +490,7 @@ class AHBConfig
switch(color)
{
case AHB_GREY:
minBidPriceGrey = value;
break;
case AHB_WHITE:
minBidPriceWhite = value;
@@ -369,6 +504,12 @@ class AHBConfig
case AHB_PURPLE:
minBidPricePurple = value;
break;
case AHB_ORANGE:
minBidPriceOrange = value;
break;
case AHB_YELLOW:
minBidPriceYellow = value;
break;
default:
break;
}
@@ -379,7 +520,10 @@ class AHBConfig
{
case AHB_GREY:
{
return 0;
if (minBidPriceGrey > 100)
return 100;
else
return minBidPriceGrey;
break;
}
case AHB_WHITE:
@@ -414,6 +558,22 @@ class AHBConfig
return minBidPricePurple;
break;
}
case AHB_ORANGE:
{
if (minBidPriceOrange > 100)
return 100;
else
return minBidPriceOrange;
break;
}
case AHB_YELLOW:
{
if (minBidPriceYellow > 100)
return 100;
else
return minBidPriceYellow;
break;
}
default:
{
return 0;
@@ -426,6 +586,7 @@ class AHBConfig
switch(color)
{
case AHB_GREY:
maxBidPriceGrey = value;
break;
case AHB_WHITE:
maxBidPriceWhite = value;
@@ -439,6 +600,12 @@ class AHBConfig
case AHB_PURPLE:
maxBidPricePurple = value;
break;
case AHB_ORANGE:
maxBidPriceOrange = value;
break;
case AHB_YELLOW:
maxBidPriceYellow = value;
break;
default:
break;
}
@@ -449,7 +616,10 @@ class AHBConfig
{
case AHB_GREY:
{
return 0;
if (maxBidPriceGrey > 100)
return 100;
else
return maxBidPriceGrey;
break;
}
case AHB_WHITE:
@@ -484,6 +654,22 @@ class AHBConfig
return maxBidPricePurple;
break;
}
case AHB_ORANGE:
{
if (maxBidPriceOrange > 100)
return 100;
else
return maxBidPriceOrange;
break;
}
case AHB_YELLOW:
{
if (maxBidPriceYellow > 100)
return 100;
else
return maxBidPriceYellow;
break;
}
default:
{
return 0;
@@ -496,6 +682,7 @@ class AHBConfig
switch(color)
{
case AHB_GREY:
maxStackGrey = value;
break;
case AHB_WHITE:
maxStackWhite = value;
@@ -509,6 +696,12 @@ class AHBConfig
case AHB_PURPLE:
maxStackPurple = value;
break;
case AHB_ORANGE:
maxStackOrange = value;
break;
case AHB_YELLOW:
maxStackYellow = value;
break;
default:
break;
}
@@ -519,7 +712,7 @@ class AHBConfig
{
case AHB_GREY:
{
return 0;
return maxStackGrey;
break;
}
case AHB_WHITE:
@@ -542,6 +735,16 @@ class AHBConfig
return maxStackPurple;
break;
}
case AHB_ORANGE:
{
return maxStackOrange;
break;
}
case AHB_YELLOW:
{
return maxStackYellow;
break;
}
default:
{
return 0;
@@ -568,6 +771,12 @@ class AHBConfig
case AHB_PURPLE:
buyerPricePurple = value;
break;
case AHB_ORANGE:
buyerPriceOrange = value;
break;
case AHB_YELLOW:
buyerPriceYellow = value;
break;
default:
break;
}
@@ -591,6 +800,12 @@ class AHBConfig
case AHB_PURPLE:
return buyerPricePurple;
break;
case AHB_ORANGE:
return buyerPriceOrange;
break;
case AHB_YELLOW:
return buyerPriceYellow;
break;
default:
return 0;
break;
@@ -606,62 +821,79 @@ class AHBConfig
}
void CalculatePercents()
{
wtgp = (uint32) (((double)percentWhiteTradeGoods / 100.0) * maxItems);
gtgp = (uint32) (((double)percentGreenTradeGoods / 100.0) * maxItems);
btgp = (uint32) (((double)percentBlueTradeGoods / 100.0) * maxItems);
ptgp = (uint32) (((double)percentPurpleTradeGoods / 100.0) * maxItems);
wip = (uint32) (((double)percentWhiteItems / 100.0) * maxItems);
gip = (uint32) (((double)percentGreenItems / 100.0) * maxItems);
bip = (uint32) (((double)percentBlueItems / 100.0) * maxItems);
pip = (uint32) (((double)percentPurpleItems / 100.0) * maxItems);
uint32 total = wtgp + gtgp + btgp + ptgp + wip + gip + bip + pip;
if (total != maxItems)
greytgp = (uint32) (((double)percentGreyTradeGoods / 100.0) * maxItems);
whitetgp = (uint32) (((double)percentWhiteTradeGoods / 100.0) * maxItems);
greentgp = (uint32) (((double)percentGreenTradeGoods / 100.0) * maxItems);
bluetgp = (uint32) (((double)percentBlueTradeGoods / 100.0) * maxItems);
purpletgp = (uint32) (((double)percentPurpleTradeGoods / 100.0) * maxItems);
orangetgp = (uint32) (((double)percentOrangeTradeGoods / 100.0) * maxItems);
yellowtgp = (uint32) (((double)percentYellowTradeGoods / 100.0) * maxItems);
greyip = (uint32) (((double)percentGreyItems / 100.0) * maxItems);
whiteip = (uint32) (((double)percentWhiteItems / 100.0) * maxItems);
greenip = (uint32) (((double)percentGreenItems / 100.0) * maxItems);
blueip = (uint32) (((double)percentBlueItems / 100.0) * maxItems);
purpleip = (uint32) (((double)percentPurpleItems / 100.0) * maxItems);
orangeip = (uint32) (((double)percentOrangeItems / 100.0) * maxItems);
yellowip = (uint32) (((double)percentYellowItems / 100.0) * maxItems);
uint32 total = greytgp + whitetgp + greentgp + bluetgp + purpletgp + orangetgp + yellowtgp + greyip + whiteip + greenip + blueip + purpleip + orangeip + yellowip;
int32 diff = (maxItems - total);
if (diff < 0)
{
wtgp = (uint32) (maxItems * (double) wtgp);
gtgp = (uint32) (maxItems * (double) gtgp);
btgp = (uint32) (maxItems * (double) btgp);
ptgp = (uint32) (maxItems * (double) ptgp);
wip = (uint32) (maxItems * (double) wip);
gip = (uint32) (maxItems * (double) gip);
bip = (uint32) (maxItems * (double) bip);
pip = (maxItems - (wtgp + gtgp + btgp + ptgp + wip + gip + bip));
total = wtgp + gtgp + btgp + ptgp + wip + gip + bip + pip;
if ((whiteip - diff) > 0)
whiteip -= diff;
else if ((greenip - diff) > 0)
greenip -= diff;
}
else if (diff < 0)
{
whiteip += diff;
}
//sLog.outString("%u %u %u %u %u %u %u %u", wtgp, gtgp, btgp, ptgp, wip, gip, bip, pip);
}
uint32 GetPercents(uint32 color)
{
switch(color)
{
case AHB_GREY_TG:
return 0;
return greytgp;
break;
case AHB_WHITE_TG:
return wtgp;
return whitetgp;
break;
case AHB_GREEN_TG:
return gtgp;
return greentgp;
break;
case AHB_BLUE_TG:
return btgp;
return bluetgp;
break;
case AHB_PURPLE_TG:
return ptgp;
return purpletgp;
break;
case AHB_ORANGE_TG:
return orangetgp;
break;
case AHB_YELLOW_TG:
return yellowtgp;
break;
case AHB_GREY_I:
return 0;
return greyip;
break;
case AHB_WHITE_I:
return wip;
return whiteip;
break;
case AHB_GREEN_I:
return gip;
return greenip;
break;
case AHB_BLUE_I:
return bip;
return blueip;
break;
case AHB_PURPLE_I:
return pip;
return purpleip;
break;
case AHB_ORANGE_I:
return orangeip;
break;
case AHB_YELLOW_I:
return yellowip;
break;
default:
return 0;
@@ -685,4 +917,3 @@ void AuctionHouseBotInit();
void AuctionHouseBotLoadValues(AHBConfig*);
void AuctionHouseBotCommands(uint32, uint32, uint32, char*);
#endif
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
*
* Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
#include "ObjectMgr.h"
#include "Player.h"
#include "UpdateMask.h"
#include "AuctionHouseObject.h"
#include "AuctionHouseMgr.h"
#include "Util.h"
#include "AuctionHouseBot.h"
@@ -55,67 +55,19 @@ void WorldSession::HandleAuctionHelloOpcode( WorldPacket & recv_data )
SendAuctionHello(guid, unit);
}
static uint8 AuctioneerFactionToLocation(uint32 faction)
{
if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
return 7; // neutral
FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(faction);
if(!u_entry)
return 7; // neutral
if(u_entry->ourMask & FACTION_MASK_ALLIANCE)
return 2;
else if(u_entry->ourMask & FACTION_MASK_HORDE)
return 6;
else
return 7;
}
//this void causes that auction window is opened
void WorldSession::SendAuctionHello( uint64 guid, Creature* unit )
{
AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->getFaction());
if(!ahEntry)
return;
WorldPacket data( MSG_AUCTION_HELLO, 12 );
data << (uint64) guid;
data << (uint32) AuctioneerFactionToLocation(unit->getFaction());
data << (uint32) ahEntry->houseId;
SendPacket( &data );
}
//this function inserts to WorldPacket auction's data
bool WorldSession::SendAuctionInfo(WorldPacket & data, AuctionEntry* auction)
{
Item *pItem = objmgr.GetAItem(auction->item_guidlow);
if (!pItem)
{
sLog.outError("auction to item, that doesn't exist !!!!");
return false;
}
data << (uint32) auction->Id;
data << (uint32) pItem->GetEntry();
for (uint8 i = 0; i < MAX_INSPECTED_ENCHANTMENT_SLOT; i++)
{
data << (uint32) pItem->GetEnchantmentId(EnchantmentSlot(i));
data << (uint32) pItem->GetEnchantmentDuration(EnchantmentSlot(i));
data << (uint32) pItem->GetEnchantmentCharges(EnchantmentSlot(i));
}
data << (uint32) pItem->GetItemRandomPropertyId(); //random item property id
data << (uint32) pItem->GetItemSuffixFactor(); //SuffixFactor
data << (uint32) pItem->GetCount(); //item->count
data << (uint32) pItem->GetSpellCharges(); //item->charge FFFFFFF
data << (uint32) 0; //Unknown
data << (uint64) auction->owner; //Auction->owner
data << (uint32) auction->startbid; //Auction->startbid (not sure if useful)
data << (uint32) ((auction->bid)? objmgr.GetAuctionOutBid(auction->bid) : 0);
//minimal outbid
data << (uint32) auction->buyout; //auction->buyout
data << (uint32) (auction->time - time(NULL)) * 1000; //time left
data << (uint64) auction->bidder; //auction->bidder current
data << (uint32) auction->bid; //current bid
return true;
}
//call this method when player bids, creates, or deletes auction
void WorldSession::SendAuctionCommandResult(uint32 auctionId, uint32 Action, uint32 ErrorCode, uint32 bidError )
{
@@ -132,13 +84,13 @@ void WorldSession::SendAuctionCommandResult(uint32 auctionId, uint32 Action, uin
void WorldSession::SendAuctionBidderNotification( uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template)
{
WorldPacket data(SMSG_AUCTION_BIDDER_NOTIFICATION, (8*4));
data << location;
data << auctionId;
data << (uint64) bidder;
data << bidSum;
data << (uint32) diff;
data << item_template;
data << (uint32) 0;
data << uint32(location);
data << uint32(auctionId);
data << uint64(bidder);
data << uint32(bidSum);
data << uint32(diff);
data << uint32(item_template);
data << uint32(0);
SendPacket(&data);
}
@@ -173,16 +125,16 @@ void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction, uint32 newPri
msgAuctionOutbiddedSubject << auction->item_template << ":0:" << AUCTION_OUTBIDDED;
if (oldBidder && !_player)
oldBidder->GetSession()->SendAuctionBidderNotification( auction->location, auction->Id, AHBplayerGUID, newPrice, objmgr.GetAuctionOutBid(auction->bid), auction->item_template);
oldBidder->GetSession()->SendAuctionBidderNotification( auction->GetHouseId(), auction->Id, AHBplayerGUID, newPrice, auction->GetAuctionOutBid(), auction->item_template);
if (oldBidder && _player)
oldBidder->GetSession()->SendAuctionBidderNotification( auction->location, auction->Id, _player->GetGUID(), newPrice, objmgr.GetAuctionOutBid(auction->bid), auction->item_template);
oldBidder->GetSession()->SendAuctionBidderNotification( auction->GetHouseId(), auction->Id, _player->GetGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template);
WorldSession::SendMailTo(oldBidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->bidder, msgAuctionOutbiddedSubject.str(), 0, NULL, auction->bid, 0, MAIL_CHECK_MASK_NONE);
WorldSession::SendMailTo(oldBidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->bidder, msgAuctionOutbiddedSubject.str(), 0, NULL, auction->bid, 0, MAIL_CHECK_MASK_NONE);
}
}
//this function sends mail, when auction is canceled to old bidder
//this function sends mail, when auction is cancelled to old bidder
void WorldSession::SendAuctionCancelledToBidderMail( AuctionEntry* auction )
{
uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);
@@ -198,7 +150,7 @@ void WorldSession::SendAuctionCancelledToBidderMail( AuctionEntry* auction )
std::ostringstream msgAuctionCancelledSubject;
msgAuctionCancelledSubject << auction->item_template << ":0:" << AUCTION_CANCELLED_TO_BIDDER;
WorldSession::SendMailTo(bidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->bidder, msgAuctionCancelledSubject.str(), 0, NULL, auction->bid, 0, MAIL_CHECK_MASK_NONE);
WorldSession::SendMailTo(bidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->bidder, msgAuctionCancelledSubject.str(), 0, NULL, auction->bid, 0, MAIL_CHECK_MASK_NONE);
}
}
@@ -223,6 +175,14 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
return;
}
AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(pCreature->getFaction());
if(!auctionHouseEntry)
{
sLog.outDebug( "WORLD: HandleAuctionSellItem - Unit (GUID: %u) has wrong faction.", uint32(GUID_LOPART(auctioneer)) );
return;
}
// client send time in minutes, convert to common used sec time
etime *= MINUTE;
@@ -243,7 +203,7 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
Item *it = pl->GetItemByGuid( item );
//do not allow to sell already auctioned items
if(objmgr.GetAItem(GUID_LOPART(item)))
if(auctionmgr.GetAItem(GUID_LOPART(item)))
{
sLog.outError("AuctionError, player %s is sending item id: %u, but item is already in another auction", pl->GetName(), GUID_LOPART(item));
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
@@ -268,12 +228,10 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
return;
}
uint32 location = AuctioneerFactionToLocation(pCreature->getFaction());
AuctionHouseObject * mAuctions;
mAuctions = objmgr.GetAuctionsMap( location );
AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() );
//we have to take deposit :
uint32 deposit = objmgr.GetAuctionDeposit( location, etime, it );
uint32 deposit = auctionmgr.GetAuctionDeposit( auctionHouseEntry, etime, it );
if ( pl->GetMoney() < deposit )
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_NOT_ENOUGHT_MONEY);
@@ -292,7 +250,10 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
AuctionEntry *AH = new AuctionEntry;
AH->Id = objmgr.GenerateAuctionID();
AH->auctioneer = GUID_LOPART(auctioneer);
if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
AH->auctioneer = 23442;
else
AH->auctioneer = GUID_LOPART(auctioneer);
AH->item_guidlow = GUID_LOPART(item);
AH->item_template = it->GetEntry();
AH->owner = pl->GetGUIDLow();
@@ -300,22 +261,20 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
AH->bidder = 0;
AH->bid = 0;
AH->buyout = buyout;
AH->time = time(NULL) + auction_time;
AH->expire_time = time(NULL) + auction_time;
AH->deposit = deposit;
AH->location = location;
AH->auctionHouseEntry = auctionHouseEntry;
sLog.outDetail("selling item %u to auctioneer %u with initial bid %u with buyout %u and with time %u (in sec) in location: %u", GUID_LOPART(item), GUID_LOPART(auctioneer), bid, buyout, auction_time, location);
mAuctions->AddAuction(AH);
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());
auctionHouse->AddAuction(AH);
objmgr.AddAItem(it);
auctionmgr.AddAItem(it);
pl->MoveItemFromInventory( it->GetBagSlot(), it->GetSlot(), true);
CharacterDatabase.BeginTransaction();
it->DeleteFromInventoryDB();
it->SaveToDB(); // recursive and not have transaction guard into self, not in inventiory and can be save standalone
CharacterDatabase.PExecute("INSERT INTO auctionhouse (id,auctioneerguid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit,location) "
"VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '" I64FMTD "', '%u', '%u', '%u', '%u', '%u')",
AH->Id, AH->auctioneer, AH->item_guidlow, AH->item_template, AH->owner, AH->buyout, (uint64)AH->time, AH->bidder, AH->bid, AH->startbid, AH->deposit, AH->location);
AH->SaveToDB();
pl->SaveInventoryAndGoldToDB();
CharacterDatabase.CommitTransaction();
@@ -347,12 +306,9 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
uint32 location = AuctioneerFactionToLocation(pCreature->getFaction());
AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() );
AuctionHouseObject * mAuctions;
mAuctions = objmgr.GetAuctionsMap( location );
AuctionEntry *auction = mAuctions->GetAuction(auctionId);
AuctionEntry *auction = auctionHouse->GetAuction(auctionId);
Player *pl = GetPlayer();
if( !auction || auction->owner == pl->GetGUIDLow() )
@@ -377,7 +333,7 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
// price too low for next bid if not buyout
if ((price < auction->buyout || auction->buyout == 0) &&
price < auction->bid + objmgr.GetAuctionOutBid(auction->bid))
price < auction->bid + auction->GetAuctionOutBid())
{
//auction has already higher bid, client tests it!
return;
@@ -435,15 +391,15 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
auction->bidder = pl->GetGUIDLow();
auction->bid = auction->buyout;
objmgr.SendAuctionSalePendingMail( auction );
objmgr.SendAuctionSuccessfulMail( auction );
objmgr.SendAuctionWonMail( auction );
auctionmgr.SendAuctionSalePendingMail( auction );
auctionmgr.SendAuctionSuccessfulMail( auction );
auctionmgr.SendAuctionWonMail( auction );
SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK);
objmgr.RemoveAItem(auction->item_guidlow);
mAuctions->RemoveAuction(auction->Id);
CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",auction->Id);
auctionmgr.RemoveAItem(auction->item_guidlow);
auctionHouse->RemoveAuction(auction->Id);
auction->DeleteFromDB();
delete auction;
}
@@ -474,22 +430,19 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
uint32 location = AuctioneerFactionToLocation(pCreature->getFaction());
AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() );
AuctionHouseObject * mAuctions;
mAuctions = objmgr.GetAuctionsMap( location );
AuctionEntry *auction = mAuctions->GetAuction(auctionId);
AuctionEntry *auction = auctionHouse->GetAuction(auctionId);
Player *pl = GetPlayer();
if (auction && auction->owner == pl->GetGUIDLow())
{
Item *pItem = objmgr.GetAItem(auction->item_guidlow);
Item *pItem = auctionmgr.GetAItem(auction->item_guidlow);
if (pItem)
{
if (auction->bidder > 0) // If we have a bidder, we have to send him the money he paid
{
uint32 auctionCut = objmgr.GetAuctionCut( auction->location, auction->bid);
uint32 auctionCut = auction->GetAuctionCut();
if ( pl->GetMoney() < auctionCut ) //player doesn't have enough money, maybe message needed
return;
//some auctionBidderNotification would be needed, but don't know that parts..
@@ -504,7 +457,7 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
mi.AddItem(auction->item_guidlow, auction->item_template, pItem);
// item will deleted or added to received mail list
WorldSession::SendMailTo(pl, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, pl->GetGUIDLow(), msgAuctionCanceledOwner.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE);
WorldSession::SendMailTo(pl, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), pl->GetGUIDLow(), msgAuctionCanceledOwner.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE);
}
else
{
@@ -525,11 +478,11 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
SendAuctionCommandResult( auction->Id, AUCTION_CANCEL, AUCTION_OK );
// Now remove the auction
CharacterDatabase.BeginTransaction();
CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",auction->Id);
auction->DeleteFromDB();
pl->SaveInventoryAndGoldToDB();
CharacterDatabase.CommitTransaction();
objmgr.RemoveAItem( auction->item_guidlow );
mAuctions->RemoveAuction( auction->Id );
auctionmgr.RemoveAItem( auction->item_guidlow );
auctionHouse->RemoveAuction( auction->Id );
delete auction;
}
@@ -562,8 +515,7 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data )
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
uint32 location = AuctioneerFactionToLocation(pCreature->getFaction());
AuctionHouseObject* mAuctions = objmgr.GetAuctionsMap( location );
AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() );
WorldPacket data( SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4) );
Player *pl = GetPlayer();
@@ -575,23 +527,15 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data )
--outbiddedCount;
uint32 outbiddedAuctionId;
recv_data >> outbiddedAuctionId;
AuctionEntry * auction = mAuctions->GetAuction( outbiddedAuctionId );
if ( auction && SendAuctionInfo(data, auction))
AuctionEntry * auction = auctionHouse->GetAuction( outbiddedAuctionId );
if ( auction && auction->BuildAuctionInfo(data))
{
++totalcount;
++count;
}
}
for (AuctionHouseObject::AuctionEntryMap::iterator itr = mAuctions->GetAuctionsBegin();itr != mAuctions->GetAuctionsEnd();++itr)
{
AuctionEntry *Aentry = itr->second;
if( Aentry && Aentry->bidder == pl->GetGUIDLow() )
{
if (SendAuctionInfo(data, itr->second))
++count;
++totalcount;
}
}
auctionHouse->BuildListBidderItems(data,pl,count,totalcount);
data.put<uint32>( 0, count ); // add count to placeholder
data << totalcount;
data << (uint32)300; //unk 2.3.0
@@ -620,25 +564,15 @@ void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data )
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
uint32 location = AuctioneerFactionToLocation(pCreature->getFaction());
AuctionHouseObject* mAuctions = objmgr.GetAuctionsMap( location );
AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() );
WorldPacket data( SMSG_AUCTION_OWNER_LIST_RESULT, (4+4+4) );
data << (uint32) 0; // amount place holder
uint32 count = 0;
uint32 totalcount = 0;
for (AuctionHouseObject::AuctionEntryMap::iterator itr = mAuctions->GetAuctionsBegin();itr != mAuctions->GetAuctionsEnd();++itr)
{
AuctionEntry *Aentry = itr->second;
if( Aentry && Aentry->owner == _player->GetGUIDLow() )
{
if(SendAuctionInfo(data, itr->second))
++count;
++totalcount;
}
}
auctionHouse->BuildListOwnerItems(data,_player,count,totalcount);
data.put<uint32>(0, count);
data << (uint32) totalcount;
data << (uint32) 0;
@@ -650,9 +584,9 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8+4+1+1+1+4+4+4+4+1);
std::string searchedname, name;
uint8 levelmin, levelmax, usable, location;
uint32 count, totalcount, listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality;
std::string searchedname;
uint8 levelmin, levelmax, usable;
uint32 listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality;
uint64 guid;
recv_data >> guid;
@@ -677,15 +611,13 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
location = AuctioneerFactionToLocation(pCreature->getFaction());
AuctionHouseObject * mAuctions;
mAuctions = objmgr.GetAuctionsMap( location );
AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() );
//sLog.outDebug("Auctionhouse search guid: " I64FMTD ", list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u", guid, listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable);
WorldPacket data( SMSG_AUCTION_LIST_RESULT, (4+4+4) );
count = 0;
totalcount = 0;
uint32 count = 0;
uint32 totalcount = 0;
data << (uint32) 0;
// converting string that we try to find to lower case
@@ -695,62 +627,11 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
wstrToLower(wsearchedname);
for (AuctionHouseObject::AuctionEntryMap::iterator itr = mAuctions->GetAuctionsBegin();itr != mAuctions->GetAuctionsEnd();++itr)
{
AuctionEntry *Aentry = itr->second;
Item *item = objmgr.GetAItem(Aentry->item_guidlow);
if( item )
{
ItemPrototype const *proto = item->GetProto();
if( proto )
{
if( auctionMainCategory == (0xffffffff) || proto->Class == auctionMainCategory )
{
if( auctionSubCategory == (0xffffffff) || proto->SubClass == auctionSubCategory )
{
if( auctionSlotID == (0xffffffff) || proto->InventoryType == auctionSlotID )
{
if( quality == (0xffffffff) || proto->Quality == quality )
{
if( usable == (0x00) || _player->CanUseItem( item ) == EQUIP_ERR_OK )
{
if( ( levelmin == (0x00) || proto->RequiredLevel >= levelmin ) && ( levelmax == (0x00) || proto->RequiredLevel <= levelmax ) )
{
name = proto->Name1;
auctionHouse->BuildListAuctionItems(data,_player,
wsearchedname, listfrom, levelmin, levelmax, usable,
auctionSlotID, auctionMainCategory, auctionSubCategory, quality,
count,totalcount);
// local name
int loc_idx = GetSessionDbLocaleIndex();
if ( loc_idx >= 0 )
{
ItemLocale const *il = objmgr.GetItemLocale(proto->ItemId);
if (il)
{
if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
name = il->Name[loc_idx];
}
}
if(name.empty())
continue;
if( wsearchedname.empty() || Utf8FitTo(name, wsearchedname) )
{
if ((count < 50) && (totalcount >= listfrom))
{
++count;
SendAuctionInfo( data, Aentry);
}
++totalcount;
}
}
}
}
}
}
}
}
}
}
data.put<uint32>(0, count);
data << (uint32) totalcount;
data << (uint32) 300; // unk 2.3.0 const?
+685
View File
@@ -0,0 +1,685 @@
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "Common.h"
#include "Database/DatabaseEnv.h"
#include "Database/DBCStores.h"
#include "Database/SQLStorage.h"
#include "ProgressBar.h"
#include "AccountMgr.h"
#include "AuctionHouseMgr.h"
#include "Item.h"
#include "Language.h"
#include "Log.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "World.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "Policies/SingletonImp.h"
INSTANTIATE_SINGLETON_1( AuctionHouseMgr );
AuctionHouseMgr::AuctionHouseMgr()
{
}
AuctionHouseMgr::~AuctionHouseMgr()
{
for(ItemMap::iterator itr = mAitems.begin(); itr != mAitems.end(); ++itr)
delete itr->second;
}
AuctionHouseObject * AuctionHouseMgr::GetAuctionsMap( uint32 factionTemplateId )
{
if(sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
return &mNeutralAuctions;
// team have linked auction houses
FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId);
if(!u_entry)
return &mNeutralAuctions;
else if(u_entry->ourMask & FACTION_MASK_ALLIANCE)
return &mAllianceAuctions;
else if(u_entry->ourMask & FACTION_MASK_HORDE)
return &mHordeAuctions;
else
return &mNeutralAuctions;
}
uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem)
{
uint32 deposit = pItem->GetProto()->SellPrice * pItem->GetCount() * (time / MIN_AUCTION_TIME );
return uint32(deposit * entry->depositPercent * 3 * sWorld.getRate(RATE_AUCTION_DEPOSIT) / 100.0f );
}
//does not clear ram
void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction )
{
Item *pItem = GetAItem(auction->item_guidlow);
if(!pItem)
return;
uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);
Player *bidder = objmgr.GetPlayer(bidder_guid);
uint32 bidder_accId = 0;
// data for gm.log
if( sWorld.getConfig(CONFIG_GM_LOG_TRADE) )
{
uint32 bidder_security = 0;
std::string bidder_name;
if (bidder)
{
bidder_accId = bidder->GetSession()->GetAccountId();
bidder_security = bidder->GetSession()->GetSecurity();
bidder_name = bidder->GetName();
}
else
{
bidder_accId = objmgr.GetPlayerAccountIdByGUID(bidder_guid);
bidder_security = accmgr.GetSecurity(bidder_accId);
if(bidder_security > SEC_PLAYER ) // not do redundant DB requests
{
if(!objmgr.GetPlayerNameByGUID(bidder_guid,bidder_name))
bidder_name = objmgr.GetTrinityStringForDBCLocale(LANG_UNKNOWN);
}
}
if( bidder_security > SEC_PLAYER )
{
std::string owner_name;
if(!objmgr.GetPlayerNameByGUID(auction->owner,owner_name))
owner_name = objmgr.GetTrinityStringForDBCLocale(LANG_UNKNOWN);
uint32 owner_accid = objmgr.GetPlayerAccountIdByGUID(auction->owner);
sLog.outCommand(bidder_accId,"GM %s (Account: %u) won item in auction: %s (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)",
bidder_name.c_str(),bidder_accId,pItem->GetProto()->Name1,pItem->GetEntry(),pItem->GetCount(),auction->bid,owner_name.c_str(),owner_accid);
}
}
else if(!bidder)
bidder_accId = objmgr.GetPlayerAccountIdByGUID(bidder_guid);
// receiver exist
if(bidder || bidder_accId)
{
std::ostringstream msgAuctionWonSubject;
msgAuctionWonSubject << auction->item_template << ":0:" << AUCTION_WON;
std::ostringstream msgAuctionWonBody;
msgAuctionWonBody.width(16);
msgAuctionWonBody << std::right << std::hex << auction->owner;
msgAuctionWonBody << std::dec << ":" << auction->bid << ":" << auction->buyout;
sLog.outDebug( "AuctionWon body string : %s", msgAuctionWonBody.str().c_str() );
//prepare mail data... :
uint32 itemTextId = objmgr.CreateItemText( msgAuctionWonBody.str() );
// set owner to bidder (to prevent delete item with sender char deleting)
// owner in `data` will set at mail receive and item extracting
CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'",auction->bidder,pItem->GetGUIDLow());
CharacterDatabase.CommitTransaction();
MailItemsInfo mi;
mi.AddItem(auction->item_guidlow, auction->item_template, pItem);
if (bidder)
bidder->GetSession()->SendAuctionBidderNotification( auction->GetHouseId(), auction->Id, bidder_guid, 0, 0, auction->item_template);
else
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
// will delete item or place to receiver mail list
WorldSession::SendMailTo(bidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->bidder, msgAuctionWonSubject.str(), itemTextId, &mi, 0, 0, MAIL_CHECK_MASK_AUCTION);
}
// receiver not exist
else
{
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", pItem->GetGUIDLow());
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
delete pItem;
}
}
void AuctionHouseMgr::SendAuctionSalePendingMail( AuctionEntry * auction )
{
uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER);
Player *owner = objmgr.GetPlayer(owner_guid);
// owner exist (online or offline)
if(owner || objmgr.GetPlayerAccountIdByGUID(owner_guid))
{
std::ostringstream msgAuctionSalePendingSubject;
msgAuctionSalePendingSubject << auction->item_template << ":0:" << AUCTION_SALE_PENDING;
std::ostringstream msgAuctionSalePendingBody;
uint32 auctionCut = auction->GetAuctionCut();
time_t distrTime = time(NULL) + HOUR;
msgAuctionSalePendingBody.width(16);
msgAuctionSalePendingBody << std::right << std::hex << auction->bidder;
msgAuctionSalePendingBody << std::dec << ":" << auction->bid << ":" << auction->buyout;
msgAuctionSalePendingBody << ":" << auction->deposit << ":" << auctionCut << ":0:";
msgAuctionSalePendingBody << secsToTimeBitFields(distrTime);
sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str());
uint32 itemTextId = objmgr.CreateItemText( msgAuctionSalePendingBody.str() );
WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->owner, msgAuctionSalePendingSubject.str(), itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_AUCTION);
}
}
//call this method to send mail to auction owner, when auction is successful, it does not clear ram
void AuctionHouseMgr::SendAuctionSuccessfulMail( AuctionEntry * auction )
{
uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER);
Player *owner = objmgr.GetPlayer(owner_guid);
uint32 owner_accId = 0;
if(!owner)
owner_accId = objmgr.GetPlayerAccountIdByGUID(owner_guid);
// owner exist
if(owner || owner_accId)
{
std::ostringstream msgAuctionSuccessfulSubject;
msgAuctionSuccessfulSubject << auction->item_template << ":0:" << AUCTION_SUCCESSFUL;
std::ostringstream auctionSuccessfulBody;
uint32 auctionCut = auction->GetAuctionCut();
auctionSuccessfulBody.width(16);
auctionSuccessfulBody << std::right << std::hex << auction->bidder;
auctionSuccessfulBody << std::dec << ":" << auction->bid << ":" << auction->buyout;
auctionSuccessfulBody << ":" << auction->deposit << ":" << auctionCut;
sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str());
uint32 itemTextId = objmgr.CreateItemText( auctionSuccessfulBody.str() );
uint32 profit = auction->bid + auction->deposit - auctionCut;
if (owner)
{
//send auction owner notification, bidder must be current!
owner->GetSession()->SendAuctionOwnerNotification( auction );
}
WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->owner, msgAuctionSuccessfulSubject.str(), itemTextId, NULL, profit, 0, MAIL_CHECK_MASK_AUCTION, HOUR);
}
}
//does not clear ram
void AuctionHouseMgr::SendAuctionExpiredMail( AuctionEntry * auction )
{ //return an item in auction to its owner by mail
Item *pItem = GetAItem(auction->item_guidlow);
if(!pItem)
{
sLog.outError("Auction item (GUID: %u) not found, and lost.",auction->item_guidlow);
return;
}
uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER);
Player *owner = objmgr.GetPlayer(owner_guid);
uint32 owner_accId = 0;
if(!owner)
owner_accId = objmgr.GetPlayerAccountIdByGUID(owner_guid);
// owner exist
if(owner || owner_accId)
{
std::ostringstream subject;
subject << auction->item_template << ":0:" << AUCTION_EXPIRED;
if ( owner )
owner->GetSession()->SendAuctionOwnerNotification( auction );
else
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
MailItemsInfo mi;
mi.AddItem(auction->item_guidlow, auction->item_template, pItem);
// will delete item or place to receiver mail list
WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), GUID_LOPART(owner_guid), subject.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE);
}
// owner not found
else
{
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'",pItem->GetGUIDLow());
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
delete pItem;
}
}
void AuctionHouseMgr::LoadAuctionItems()
{
// data needs to be at first place for Item::LoadFromDB
QueryResult *result = CharacterDatabase.Query( "SELECT data,itemguid,item_template FROM auctionhouse JOIN item_instance ON itemguid = guid" );
if( !result )
{
barGoLink bar(1);
bar.step();
sLog.outString("");
sLog.outString(">> Loaded 0 auction items");
return;
}
barGoLink bar( result->GetRowCount() );
uint32 count = 0;
Field *fields;
do
{
bar.step();
fields = result->Fetch();
uint32 item_guid = fields[1].GetUInt32();
uint32 item_template = fields[2].GetUInt32();
ItemPrototype const *proto = objmgr.GetItemPrototype(item_template);
if(!proto)
{
sLog.outError( "ObjectMgr::LoadAuctionItems: Unknown item (GUID: %u id: #%u) in auction, skipped.", item_guid,item_template);
continue;
}
Item *item = NewItemOrBag(proto);
if(!item->LoadFromDB(item_guid,0, result))
{
delete item;
continue;
}
AddAItem(item);
++count;
}
while( result->NextRow() );
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u auction items", count );
}
void AuctionHouseMgr::LoadAuctions()
{
QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auctionhouse");
if( !result )
{
barGoLink bar(1);
bar.step();
sLog.outString("");
sLog.outString(">> Loaded 0 auctions. DB table `auctionhouse` is empty.");
return;
}
Field *fields = result->Fetch();
uint32 AuctionCount=fields[0].GetUInt32();
delete result;
if(!AuctionCount)
{
barGoLink bar(1);
bar.step();
sLog.outString("");
sLog.outString(">> Loaded 0 auctions. DB table `auctionhouse` is empty.");
return;
}
result = CharacterDatabase.Query( "SELECT id,auctioneerguid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit FROM auctionhouse" );
if( !result )
{
barGoLink bar(1);
bar.step();
sLog.outString("");
sLog.outString(">> Loaded 0 auctions. DB table `auctionhouse` is empty.");
return;
}
barGoLink bar( AuctionCount );
AuctionEntry *aItem;
do
{
fields = result->Fetch();
bar.step();
aItem = new AuctionEntry;
aItem->Id = fields[0].GetUInt32();
aItem->auctioneer = fields[1].GetUInt32();
aItem->item_guidlow = fields[2].GetUInt32();
aItem->item_template = fields[3].GetUInt32();
aItem->owner = fields[4].GetUInt32();
aItem->buyout = fields[5].GetUInt32();
aItem->expire_time = fields[6].GetUInt32();
aItem->bidder = fields[7].GetUInt32();
aItem->bid = fields[8].GetUInt32();
aItem->startbid = fields[9].GetUInt32();
aItem->deposit = fields[10].GetUInt32();
CreatureData const* auctioneerData = objmgr.GetCreatureData(aItem->auctioneer);
if(!auctioneerData)
{
aItem->DeleteFromDB();
sLog.outError("Auction %u has not a existing auctioneer (GUID : %u)", aItem->Id, aItem->auctioneer);
delete aItem;
continue;
}
CreatureInfo const* auctioneerInfo = objmgr.GetCreatureTemplate(auctioneerData->id);
if(!auctioneerInfo)
{
aItem->DeleteFromDB();
sLog.outError("Auction %u has not a existing auctioneer (GUID : %u Entry: %u)", aItem->Id, aItem->auctioneer,auctioneerData->id);
delete aItem;
continue;
}
aItem->auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(auctioneerInfo->faction_A);
if(!aItem->auctionHouseEntry)
{
aItem->DeleteFromDB();
sLog.outError("Auction %u has auctioneer (GUID : %u Entry: %u) with wrong faction %u",
aItem->Id, aItem->auctioneer,auctioneerData->id,auctioneerInfo->faction_A);
delete aItem;
continue;
}
// check if sold item exists for guid
// and item_template in fact (GetAItem will fail if problematic in result check in ObjectMgr::LoadAuctionItems)
if ( !GetAItem( aItem->item_guidlow ) )
{
aItem->DeleteFromDB();
sLog.outError("Auction %u has not a existing item : %u", aItem->Id, aItem->item_guidlow);
delete aItem;
continue;
}
GetAuctionsMap( auctioneerInfo->faction_A )->AddAuction(aItem);
} while (result->NextRow());
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u auctions", AuctionCount );
}
void AuctionHouseMgr::AddAItem( Item* it )
{
ASSERT( it );
ASSERT( mAitems.find(it->GetGUIDLow()) == mAitems.end());
mAitems[it->GetGUIDLow()] = it;
}
bool AuctionHouseMgr::RemoveAItem( uint32 id )
{
ItemMap::iterator i = mAitems.find(id);
if (i == mAitems.end())
{
return false;
}
mAitems.erase(i);
return true;
}
void AuctionHouseMgr::Update()
{
mHordeAuctions.Update();
mAllianceAuctions.Update();
mNeutralAuctions.Update();
}
AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTemplateId)
{
uint32 houseid = 7; // goblin auction house
if(!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
{
//FIXME: found way for proper auctionhouse selection by another way
// AuctionHouse.dbc have faction field with _player_ factions associated with auction house races.
// but no easy way convert creature faction to player race faction for specific city
switch(factionTemplateId)
{
case 12: houseid = 1; break; // human
case 29: houseid = 6; break; // orc, and generic for horde
case 55: houseid = 2; break; // dwarf, and generic for alliance
case 68: houseid = 4; break; // undead
case 80: houseid = 3; break; // n-elf
case 104: houseid = 5; break; // trolls
case 120: houseid = 7; break; // booty bay, neutral
case 474: houseid = 7; break; // gadgetzan, neutral
case 855: houseid = 7; break; // everlook, neutral
case 1604: houseid = 6; break; // b-elfs,
default: // for unknown case
{
FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId);
if(!u_entry)
houseid = 7; // goblin auction house
else if(u_entry->ourMask & FACTION_MASK_ALLIANCE)
houseid = 1; // human auction house
else if(u_entry->ourMask & FACTION_MASK_HORDE)
houseid = 6; // orc auction house
else
houseid = 7; // goblin auction house
break;
}
}
}
return sAuctionHouseStore.LookupEntry(houseid);
}
void AuctionHouseObject::Update()
{
time_t curTime = sWorld.GetGameTime();
///- Handle expired auctions
AuctionEntryMap::iterator next;
for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end();itr = next)
{
next = itr;
++next;
if (curTime > (itr->second->expire_time))
{
///- Either cancel the auction if there was no bidder
if (itr->second->bidder == 0)
{
auctionmgr.SendAuctionExpiredMail( itr->second );
}
///- Or perform the transaction
else
{
//we should send an "item sold" message if the seller is online
//we send the item to the winner
//we send the money to the seller
auctionmgr.SendAuctionSuccessfulMail( itr->second );
auctionmgr.SendAuctionWonMail( itr->second );
}
///- In any case clear the auction
itr->second->DeleteFromDB();
auctionmgr.RemoveAItem(itr->second->item_guidlow);
delete itr->second;
RemoveAuction(itr->first);
}
}
}
void AuctionHouseObject::BuildListBidderItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount)
{
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr)
{
AuctionEntry *Aentry = itr->second;
if( Aentry && Aentry->bidder == player->GetGUIDLow() )
{
if (itr->second->BuildAuctionInfo(data))
++count;
++totalcount;
}
}
}
void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount)
{
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr)
{
AuctionEntry *Aentry = itr->second;
if( Aentry && Aentry->owner == player->GetGUIDLow() )
{
if(Aentry->BuildAuctionInfo(data))
++count;
++totalcount;
}
}
}
void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player,
std::wstring const& wsearchedname, uint32 listfrom, uint32 levelmin, uint32 levelmax, uint32 usable,
uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality,
uint32& count, uint32& totalcount)
{
int loc_idx = player->GetSession()->GetSessionDbLocaleIndex();
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr)
{
AuctionEntry *Aentry = itr->second;
Item *item = auctionmgr.GetAItem(Aentry->item_guidlow);
if (!item)
continue;
ItemPrototype const *proto = item->GetProto();
if (itemClass != (0xffffffff) && proto->Class != itemClass)
continue;
if (itemSubClass != (0xffffffff) && proto->SubClass != itemSubClass)
continue;
if (inventoryType != (0xffffffff) && proto->InventoryType != inventoryType)
continue;
if (quality != (0xffffffff) && proto->Quality != quality)
continue;
if( levelmin != (0x00) && (proto->RequiredLevel < levelmin || levelmax != (0x00) && proto->RequiredLevel > levelmax ) )
continue;
if( usable != (0x00) && player->CanUseItem( item ) != EQUIP_ERR_OK )
continue;
std::string name = proto->Name1;
if(name.empty())
continue;
// local name
if ( loc_idx >= 0 )
{
ItemLocale const *il = objmgr.GetItemLocale(proto->ItemId);
if (il)
{
if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
name = il->Name[loc_idx];
}
}
if( !wsearchedname.empty() && !Utf8FitTo(name, wsearchedname) )
continue;
if ((count < 50) && (totalcount >= listfrom))
{
++count;
Aentry->BuildAuctionInfo(data);
}
++totalcount;
}
}
//this function inserts to WorldPacket auction's data
bool AuctionEntry::BuildAuctionInfo(WorldPacket & data) const
{
Item *pItem = auctionmgr.GetAItem(item_guidlow);
if (!pItem)
{
sLog.outError("auction to item, that doesn't exist !!!!");
return false;
}
data << (uint32) Id;
data << (uint32) pItem->GetEntry();
for (uint8 i = 0; i < MAX_INSPECTED_ENCHANTMENT_SLOT; i++)
{
data << (uint32) pItem->GetEnchantmentId(EnchantmentSlot(i));
data << (uint32) pItem->GetEnchantmentDuration(EnchantmentSlot(i));
data << (uint32) pItem->GetEnchantmentCharges(EnchantmentSlot(i));
}
data << (uint32) pItem->GetItemRandomPropertyId(); //random item property id
data << (uint32) pItem->GetItemSuffixFactor(); //SuffixFactor
data << (uint32) pItem->GetCount(); //item->count
data << (uint32) pItem->GetSpellCharges(); //item->charge FFFFFFF
data << (uint32) 0; //Unknown
data << (uint64) owner; //Auction->owner
data << (uint32) startbid; //Auction->startbid (not sure if useful)
data << (uint32) (bid ? GetAuctionOutBid() : 0);
//minimal outbid
data << (uint32) buyout; //auction->buyout
data << (uint32) (expire_time - time(NULL))* 1000; //time left
data << (uint64) bidder; //auction->bidder current
data << (uint32) bid; //current bid
return true;
}
uint32 AuctionEntry::GetAuctionCut() const
{
return uint32(auctionHouseEntry->cutPercent * bid * sWorld.getRate(RATE_AUCTION_CUT) / 100.f);
}
/// the sum of outbid is (1% from current bid)*5, if bid is very small, it is 1c
uint32 AuctionEntry::GetAuctionOutBid() const
{
uint32 outbid = (bid / 100) * 5;
if (!outbid)
outbid = 1;
return outbid;
}
void AuctionEntry::DeleteFromDB() const
{
//No SQL injection (Id is integer)
CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",Id);
}
void AuctionEntry::SaveToDB() const
{
//No SQL injection (no strings)
CharacterDatabase.PExecute("INSERT INTO auctionhouse (id,auctioneerguid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit) "
"VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '" I64FMTD "', '%u', '%u', '%u', '%u')",
Id, auctioneer, item_guidlow, item_template, owner, buyout, (uint64)expire_time, bidder, bid, startbid, deposit);
}
+170
View File
@@ -0,0 +1,170 @@
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _AUCTION_HOUSE_MGR_H
#define _AUCTION_HOUSE_MGR_H
#include "SharedDefines.h"
#include "Policies/Singleton.h"
class Item;
class Player;
class WorldPacket;
#define MIN_AUCTION_TIME (12*HOUR)
enum AuctionError
{
AUCTION_OK = 0,
AUCTION_INTERNAL_ERROR = 2,
AUCTION_NOT_ENOUGHT_MONEY = 3,
AUCTION_ITEM_NOT_FOUND = 4,
CANNOT_BID_YOUR_AUCTION_ERROR = 10
};
enum AuctionAction
{
AUCTION_SELL_ITEM = 0,
AUCTION_CANCEL = 1,
AUCTION_PLACE_BID = 2
};
struct AuctionEntry
{
uint32 Id;
uint32 auctioneer; // creature low guid
uint32 item_guidlow;
uint32 item_template;
uint32 owner;
uint32 startbid; //maybe useless
uint32 bid;
uint32 buyout;
time_t expire_time;
uint32 bidder;
uint32 deposit; //deposit can be calculated only when creating auction
AuctionHouseEntry const* auctionHouseEntry; // in AuctionHouse.dbc
// helpers
uint32 GetHouseId() const { return auctionHouseEntry->houseId; }
uint32 GetHouseFaction() const { return auctionHouseEntry->faction; }
uint32 GetAuctionCut() const;
uint32 GetAuctionOutBid() const;
bool BuildAuctionInfo(WorldPacket & data) const;
void DeleteFromDB() const;
void SaveToDB() const;
};
//this class is used as auctionhouse instance
class AuctionHouseObject
{
public:
AuctionHouseObject() {}
~AuctionHouseObject()
{
for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
delete itr->second;
}
typedef std::map<uint32, AuctionEntry*> AuctionEntryMap;
uint32 Getcount() { return AuctionsMap.size(); }
AuctionEntryMap::iterator GetAuctionsBegin() {return AuctionsMap.begin();}
AuctionEntryMap::iterator GetAuctionsEnd() {return AuctionsMap.end();}
void AddAuction(AuctionEntry *ah)
{
ASSERT( ah );
AuctionsMap[ah->Id] = ah;
}
AuctionEntry* GetAuction(uint32 id) const
{
AuctionEntryMap::const_iterator itr = AuctionsMap.find( id );
return itr != AuctionsMap.end() ? itr->second : NULL;
}
bool RemoveAuction(uint32 id)
{
return AuctionsMap.erase(id) ? true : false;
}
void Update();
void BuildListBidderItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount);
void BuildListOwnerItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount);
void BuildListAuctionItems(WorldPacket& data, Player* player,
std::wstring const& searchedname, uint32 listfrom, uint32 levelmin, uint32 levelmax, uint32 usable,
uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality,
uint32& count, uint32& totalcount);
private:
AuctionEntryMap AuctionsMap;
};
class AuctionHouseMgr
{
public:
AuctionHouseMgr();
~AuctionHouseMgr();
typedef UNORDERED_MAP<uint32, Item*> ItemMap;
AuctionHouseObject* GetAuctionsMap( uint32 factionTemplateId );
Item* GetAItem(uint32 id)
{
ItemMap::const_iterator itr = mAitems.find(id);
if (itr != mAitems.end())
{
return itr->second;
}
return NULL;
}
//auction messages
void SendAuctionWonMail( AuctionEntry * auction );
void SendAuctionSalePendingMail( AuctionEntry * auction );
void SendAuctionSuccessfulMail( AuctionEntry * auction );
void SendAuctionExpiredMail( AuctionEntry * auction );
static uint32 GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem);
static AuctionHouseEntry const* GetAuctionHouseEntry(uint32 factionTemplateId);
public:
//load first auction items, because of check if item exists, when loading
void LoadAuctionItems();
void LoadAuctions();
void AddAItem(Item* it);
bool RemoveAItem(uint32 id);
void Update();
private:
AuctionHouseObject mHordeAuctions;
AuctionHouseObject mAllianceAuctions;
AuctionHouseObject mNeutralAuctions;
ItemMap mAitems;
};
#define auctionmgr Trinity::Singleton<AuctionHouseMgr>::Instance()
#endif
-107
View File
@@ -1,107 +0,0 @@
/*
* Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
*
* Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _AUCTION_HOUSE_H
#define _AUCTION_HOUSE_H
#include "SharedDefines.h"
#define MIN_AUCTION_TIME (12*HOUR)
enum AuctionError
{
AUCTION_OK = 0,
AUCTION_INTERNAL_ERROR = 2,
AUCTION_NOT_ENOUGHT_MONEY = 3,
AUCTION_ITEM_NOT_FOUND = 4,
CANNOT_BID_YOUR_AUCTION_ERROR = 10
};
enum AuctionAction
{
AUCTION_SELL_ITEM = 0,
AUCTION_CANCEL = 1,
AUCTION_PLACE_BID = 2
};
struct AuctionEntry
{
uint32 Id;
uint32 auctioneer;
uint32 item_guidlow;
uint32 item_template;
uint32 owner;
uint32 startbid; //maybe useless
uint32 bid;
uint32 buyout;
time_t time;
uint32 bidder;
uint32 deposit; //deposit can be calculated only when creating auction
uint32 location;
};
//this class is used as auctionhouse instance
class AuctionHouseObject
{
public:
AuctionHouseObject() {}
~AuctionHouseObject()
{
for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
delete itr->second;
}
typedef std::map<uint32, AuctionEntry*> AuctionEntryMap;
uint32 Getcount() { return AuctionsMap.size(); }
AuctionEntryMap::iterator GetAuctionsBegin() {return AuctionsMap.begin();}
AuctionEntryMap::iterator GetAuctionsEnd() {return AuctionsMap.end();}
void AddAuction(AuctionEntry *ah)
{
ASSERT( ah );
AuctionsMap[ah->Id] = ah;
}
AuctionEntry* GetAuction(uint32 id) const
{
AuctionEntryMap::const_iterator itr = AuctionsMap.find( id );
if( itr != AuctionsMap.end() )
return itr->second;
return NULL;
}
bool RemoveAuction(uint32 id)
{
AuctionEntryMap::iterator i = AuctionsMap.find(id);
if (i == AuctionsMap.end())
{
return false;
}
AuctionsMap.erase(i);
return true;
}
private:
AuctionEntryMap AuctionsMap;
};
#endif
+2 -2
View File
@@ -441,7 +441,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target
}
//Alliance flag on ground(not in base) (returned or picked up again from ground!)
if(this->GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10))
if(this->GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10) && target_obj->GetGOInfo()->id == BG_OBJECT_A_FLAG_GROUND_WS_ENTRY)
{
if(Source->GetTeam() == ALLIANCE)
{
@@ -470,7 +470,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target
}
//Horde flag on ground(not in base) (returned or picked up again)
if(this->GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10))
if(this->GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10) && target_obj->GetGOInfo()->id == BG_OBJECT_H_FLAG_GROUND_WS_ENTRY)
{
if(Source->GetTeam() == HORDE)
{
+3 -1
View File
@@ -101,7 +101,9 @@ enum BG_WS_ObjectEntry
BG_OBJECT_DOOR_H_3_WS_ENTRY = 180322,
BG_OBJECT_DOOR_H_4_WS_ENTRY = 180322,
BG_OBJECT_A_FLAG_WS_ENTRY = 179830,
BG_OBJECT_H_FLAG_WS_ENTRY = 179831
BG_OBJECT_H_FLAG_WS_ENTRY = 179831,
BG_OBJECT_A_FLAG_GROUND_WS_ENTRY = 179785,
BG_OBJECT_H_FLAG_GROUND_WS_ENTRY = 179786
};
enum BG_WS_FlagState
+3 -2
View File
@@ -12,10 +12,11 @@ SET(game_STAT_SRCS
ArenaTeam.cpp
ArenaTeam.h
ArenaTeamHandler.cpp
AuctionHouse.cpp
AuctionHouseBot.cpp
AuctionHouseBot.h
AuctionHouseObject.h
AuctionHouseHandler.cpp
AuctionHouseMgr.cpp
AuctionHouseMgr.h
Bag.cpp
Bag.h
BattleGround.cpp
+1
View File
@@ -300,6 +300,7 @@ ChatCommand * ChatHandler::getCommandTable()
{ "locales_npc_text", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesNpcTextCommand, "", NULL },
{ "locales_page_text", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesPageTextCommand, "", NULL },
{ "locales_quest", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesQuestCommand, "", NULL },
{ "auctions", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAuctionsCommand, "", NULL },
{ "waypoint_scripts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadWpScriptsCommand, "", NULL },
{ "gm_tickets", SEC_ADMINISTRATOR, true, &ChatHandler::HandleGMTicketReloadCommand, "", NULL },
+1
View File
@@ -275,6 +275,7 @@ class ChatHandler
bool HandleReloadLocalesNpcTextCommand(const char* args);
bool HandleReloadLocalesPageTextCommand(const char* args);
bool HandleReloadLocalesQuestCommand(const char* args);
bool HandleReloadAuctionsCommand(const char* args);
bool HandleInstanceListBindsCommand(const char* args);
bool HandleInstanceUnbindCommand(const char* args);
+149 -40
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
#include "WorldSession.h"
#include "World.h"
#include "ObjectMgr.h"
#include "AuctionHouseMgr.h"
#include "AccountMgr.h"
#include "PlayerDump.h"
#include "SpellMgr.h"
@@ -149,28 +150,42 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
char * param6 = strtok(NULL, " ");
char * param7 = strtok(NULL, " ");
char * param8 = strtok(NULL, " ");
if ((!ahMapIdStr) || (!param1) || (!param2) || (!param3) || (!param4) || (!param5) || (!param6) || (!param7) || (!param8))
char * param9 = strtok(NULL, " ");
char * param10 = strtok(NULL, " ");
char * param11 = strtok(NULL, " ");
char * param12 = strtok(NULL, " ");
char * param13 = strtok(NULL, " ");
char * param14 = strtok(NULL, " ");
if ((!ahMapIdStr) || (!param14))
{
PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8");
PSendSysMessage("1 WhiteTradeGoods 2 GreenTradeGoods 3 BlueTradeGoods 4 PurpleTradeGoods");
PSendSysMessage("5 WhiteItems 6 GreenItems 7 BlueItems 8 PurpleItems");
PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14");
PSendSysMessage("1 GreyTradeGoods 2 WhiteTradeGoods 3 GreenTradeGoods 4 BlueTradeGoods 5 PurpleTradeGoods");
PSendSysMessage("6 OrangeTradeGoods 7 YellowTradeGoods 8 GreyItems 9 WhiteItems 10 GreenItems 11 BlueItems");
PSendSysMessage("12 PurpleItems 13 OrangeItems 14 YellowItems");
PSendSysMessage("The total must add up to 100%");
return false;
}
uint32 wtg = (uint32) strtoul(param1, NULL, 0);
uint32 gtg = (uint32) strtoul(param2, NULL, 0);
uint32 btg = (uint32) strtoul(param3, NULL, 0);
uint32 ptg = (uint32) strtoul(param4, NULL, 0);
uint32 wi = (uint32) strtoul(param5, NULL, 0);
uint32 gi = (uint32) strtoul(param6, NULL, 0);
uint32 bi = (uint32) strtoul(param7, NULL, 0);
uint32 pi = (uint32) strtoul(param8, NULL, 0);
uint32 totalPercent = wtg + gtg + btg + ptg + wi + gi + bi + pi;
uint32 greytg = (uint32) strtoul(param1, NULL, 0);
uint32 whitetg = (uint32) strtoul(param2, NULL, 0);
uint32 greentg = (uint32) strtoul(param3, NULL, 0);
uint32 bluetg = (uint32) strtoul(param3, NULL, 0);
uint32 purpletg = (uint32) strtoul(param5, NULL, 0);
uint32 orangetg = (uint32) strtoul(param6, NULL, 0);
uint32 yellowtg = (uint32) strtoul(param7, NULL, 0);
uint32 greyi = (uint32) strtoul(param8, NULL, 0);
uint32 whitei = (uint32) strtoul(param9, NULL, 0);
uint32 greeni = (uint32) strtoul(param10, NULL, 0);
uint32 bluei = (uint32) strtoul(param11, NULL, 0);
uint32 purplei = (uint32) strtoul(param12, NULL, 0);
uint32 orangei = (uint32) strtoul(param13, NULL, 0);
uint32 yellowi = (uint32) strtoul(param14, NULL, 0);
uint32 totalPercent = greytg + whitetg + greentg + bluetg + purpletg + orangetg + yellowtg + greyi + whitei + greeni + bluei + purplei + orangei + yellowi;
if ((totalPercent == 0) || (totalPercent != 100))
{
PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8");
PSendSysMessage("1 WhiteTradeGoods 2 GreenTradeGoods 3 BlueTradeGoods 4 PurpleTradeGoods");
PSendSysMessage("5 WhiteItems 6 GreenItems 7 BlueItems 8 PurpleItems");
PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14");
PSendSysMessage("1 GreyTradeGoods 2 WhiteTradeGoods 3 GreenTradeGoods 4 BlueTradeGoods 5 PurpleTradeGoods");
PSendSysMessage("6 OrangeTradeGoods 7 YellowTradeGoods 8 GreyItems 9 WhiteItems 10 GreenItems 11 BlueItems");
PSendSysMessage("12 PurpleItems 13 OrangeItems 14 YellowItems");
PSendSysMessage("The total must add up to 100%");
return false;
}
@@ -191,6 +206,18 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
strcat(param, param7);
strcat(param, " ");
strcat(param, param8);
strcat(param, " ");
strcat(param, param9);
strcat(param, " ");
strcat(param, param10);
strcat(param, " ");
strcat(param, param11);
strcat(param, " ");
strcat(param, param12);
strcat(param, " ");
strcat(param, param13);
strcat(param, " ");
strcat(param, param14);
AuctionHouseBotCommands(5, ahMapID, NULL, param);
}
else if (strncmp(opt,"minprice",l) == 0)
@@ -199,10 +226,14 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
char * param2 = strtok(NULL, " ");
if ((!ahMapIdStr) || (!param1) || (!param2))
{
PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price");
PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
return false;
}
if (strncmp(param1,"white",l) == 0)
if (strncmp(param1,"grey",l) == 0)
{
AuctionHouseBotCommands(6, ahMapID, AHB_GREY, param2);
}
else if (strncmp(param1,"white",l) == 0)
{
AuctionHouseBotCommands(6, ahMapID, AHB_WHITE, param2);
}
@@ -214,13 +245,21 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
{
AuctionHouseBotCommands(6, ahMapID, AHB_BLUE, param2);
}
else if (strncmp(param1,"purple",l) == 0)
else if (strncmp(param1,"purple",l) == 0)
{
AuctionHouseBotCommands(6, ahMapID, AHB_PURPLE, param2);
}
else if (strncmp(param1,"orange",l) == 0)
{
AuctionHouseBotCommands(6, ahMapID, AHB_ORANGE, param2);
}
else if (strncmp(param1,"yellow",l) == 0)
{
AuctionHouseBotCommands(6, ahMapID, AHB_YELLOW, param2);
}
else
{
PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price");
PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
return false;
}
}
@@ -230,10 +269,14 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
char * param2 = strtok(NULL, " ");
if ((!ahMapIdStr) || (!param1) || (!param2))
{
PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price");
PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
return false;
}
if (strncmp(param1,"white",l) == 0)
if (strncmp(param1,"grey",l) == 0)
{
AuctionHouseBotCommands(7, ahMapID, AHB_GREY, param2);
}
else if (strncmp(param1,"white",l) == 0)
{
AuctionHouseBotCommands(7, ahMapID, AHB_WHITE, param2);
}
@@ -245,13 +288,21 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
{
AuctionHouseBotCommands(7, ahMapID, AHB_BLUE, param2);
}
else if (strncmp(param1,"purple",l) == 0)
else if (strncmp(param1,"purple",l) == 0)
{
AuctionHouseBotCommands(7, ahMapID, AHB_PURPLE, param2);
}
else if (strncmp(param1,"orange",l) == 0)
{
AuctionHouseBotCommands(7, ahMapID, AHB_ORANGE, param2);
}
else if (strncmp(param1,"yellow",l) == 0)
{
AuctionHouseBotCommands(7, ahMapID, AHB_YELLOW, param2);
}
else
{
PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price");
PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
return false;
}
}
@@ -261,7 +312,7 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
char * param2 = strtok(NULL, " ");
if ((!ahMapIdStr) || (!param1) || (!param2))
{
PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price");
PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
return false;
}
uint32 minBidPrice = (uint32) strtoul(param2, NULL, 0);
@@ -270,7 +321,11 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
PSendSysMessage("The min bid price multiplier must be between 1 and 100");
return false;
}
if (strncmp(param1,"white",l) == 0)
if (strncmp(param1,"grey",l) == 0)
{
AuctionHouseBotCommands(8, ahMapID, AHB_GREY, param2);
}
else if (strncmp(param1,"white",l) == 0)
{
AuctionHouseBotCommands(8, ahMapID, AHB_WHITE, param2);
}
@@ -282,13 +337,21 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
{
AuctionHouseBotCommands(8, ahMapID, AHB_BLUE, param2);
}
else if (strncmp(param1,"purple",l) == 0)
else if (strncmp(param1,"purple",l) == 0)
{
AuctionHouseBotCommands(8, ahMapID, AHB_PURPLE, param2);
}
else if (strncmp(param1,"orange",l) == 0)
{
AuctionHouseBotCommands(8, ahMapID, AHB_ORANGE, param2);
}
else if (strncmp(param1,"yellow",l) == 0)
{
AuctionHouseBotCommands(8, ahMapID, AHB_YELLOW, param2);
}
else
{
PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price");
PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
return false;
}
}
@@ -298,7 +361,7 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
char * param2 = strtok(NULL, " ");
if ((!ahMapIdStr) || (!param1) || (!param2))
{
PSendSysMessage("Syntax is: ahbotoptions maxbidprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price");
PSendSysMessage("Syntax is: ahbotoptions maxbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
return false;
}
uint32 maxBidPrice = (uint32) strtoul(param2, NULL, 0);
@@ -307,7 +370,11 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
PSendSysMessage("The max bid price multiplier must be between 1 and 100");
return false;
}
if (strncmp(param1,"white",l) == 0)
if (strncmp(param1,"grey",l) == 0)
{
AuctionHouseBotCommands(9, ahMapID, AHB_GREY, param2);
}
else if (strncmp(param1,"white",l) == 0)
{
AuctionHouseBotCommands(9, ahMapID, AHB_WHITE, param2);
}
@@ -319,13 +386,21 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
{
AuctionHouseBotCommands(9, ahMapID, AHB_BLUE, param2);
}
else if (strncmp(param1,"purple",l) == 0)
else if (strncmp(param1,"purple",l) == 0)
{
AuctionHouseBotCommands(9, ahMapID, AHB_PURPLE, param2);
}
else if (strncmp(param1,"orange",l) == 0)
{
AuctionHouseBotCommands(9, ahMapID, AHB_ORANGE, param2);
}
else if (strncmp(param1,"yellow",l) == 0)
{
AuctionHouseBotCommands(9, ahMapID, AHB_YELLOW, param2);
}
else
{
PSendSysMessage("Syntax is: ahbotoptions max bidprice $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $price");
PSendSysMessage("Syntax is: ahbotoptions max bidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
return false;
}
}
@@ -335,7 +410,7 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
char * param2 = strtok(NULL, " ");
if ((!ahMapIdStr) || (!param1) || (!param2))
{
PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $value");
PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $value");
return false;
}
uint32 maxStack = (uint32) strtoul(param2, NULL, 0);
@@ -344,7 +419,11 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
PSendSysMessage("maxstack can't be a negative number.");
return false;
}
if (strncmp(param1,"white",l) == 0)
if (strncmp(param1,"grey",l) == 0)
{
AuctionHouseBotCommands(10, ahMapID, AHB_GREY, param2);
}
else if (strncmp(param1,"white",l) == 0)
{
AuctionHouseBotCommands(10, ahMapID, AHB_WHITE, param2);
}
@@ -356,13 +435,21 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
{
AuctionHouseBotCommands(10, ahMapID, AHB_BLUE, param2);
}
else if (strncmp(param1,"purple",l) == 0)
else if (strncmp(param1,"purple",l) == 0)
{
AuctionHouseBotCommands(10, ahMapID, AHB_PURPLE, param2);
}
else if (strncmp(param1,"orange",l) == 0)
{
AuctionHouseBotCommands(10, ahMapID, AHB_ORANGE, param2);
}
else if (strncmp(param1,"yellow",l) == 0)
{
AuctionHouseBotCommands(10, ahMapID, AHB_YELLOW, param2);
}
else
{
PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (white, green, blue or purple) $value");
PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $value");
return false;
}
}
@@ -375,7 +462,11 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
PSendSysMessage("Syntax is: ahbotoptions buyerprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue or purple) $price");
return false;
}
if (strncmp(param1,"white",l) == 0)
if (strncmp(param1,"grey",l) == 0)
{
AuctionHouseBotCommands(11, ahMapID, AHB_GREY, param2);
}
else if (strncmp(param1,"white",l) == 0)
{
AuctionHouseBotCommands(11, ahMapID, AHB_WHITE, param2);
}
@@ -387,10 +478,18 @@ bool ChatHandler::HandleAHBotOptionsCommand(const char* args)
{
AuctionHouseBotCommands(11, ahMapID, AHB_BLUE, param2);
}
else if (strncmp(param1,"purple",l) == 0)
else if (strncmp(param1,"purple",l) == 0)
{
AuctionHouseBotCommands(11, ahMapID, AHB_PURPLE, param2);
}
else if (strncmp(param1,"orange",l) == 0)
{
AuctionHouseBotCommands(11, ahMapID, AHB_ORANGE, param2);
}
else if (strncmp(param1,"yellow",l) == 0)
{
AuctionHouseBotCommands(11, ahMapID, AHB_YELLOW, param2);
}
else
{
PSendSysMessage("Syntax is: ahbotoptions buyerprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue or purple) $price");
@@ -1101,6 +1200,16 @@ bool ChatHandler::HandleLoadScriptsCommand(const char* args)
return true;
}
bool ChatHandler::HandleReloadAuctionsCommand(const char* args)
{
///- Reload dynamic data tables from the database
sLog.outString( "Re-Loading Auctions..." );
auctionmgr.LoadAuctionItems();
auctionmgr.LoadAuctions();
SendGlobalGMSysMessage("Auctions reloaded.");
return true;
}
bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args)
{
if(!*args)
+3 -2
View File
@@ -49,10 +49,11 @@ $(srcdir)/AnimalRandomMovementGenerator.h \
$(srcdir)/ArenaTeam.cpp \
$(srcdir)/ArenaTeam.h \
$(srcdir)/ArenaTeamHandler.cpp \
$(srcdir)/AuctionHouse.cpp \
$(srcdir)/AuctionHouseHandler.cpp \
$(srcdir)/AuctionHouseBot.cpp \
$(srcdir)/AuctionHouseBot.h \
$(srcdir)/AuctionHouseObject.h \
$(srcdir)/AuctionHouseMgr.cpp \
$(srcdir)/AuctionHouseMgr.h \
$(srcdir)/Bag.cpp \
$(srcdir)/Bag.h \
$(srcdir)/BattleGround.cpp \
+2 -359
View File
@@ -22,6 +22,7 @@
#include "Database/DatabaseEnv.h"
#include "Database/SQLStorage.h"
#include "Database/SQLStorageImpl.h"
#include "Policies/SingletonImp.h"
#include "Log.h"
#include "MapManager.h"
@@ -35,7 +36,6 @@
#include "ArenaTeam.h"
#include "Transports.h"
#include "ProgressBar.h"
#include "Policies/SingletonImp.h"
#include "Language.h"
#include "GameEvent.h"
#include "Spell.h"
@@ -123,9 +123,9 @@ ObjectMgr::ObjectMgr()
m_hiPetNumber = 1;
m_ItemTextId = 1;
m_mailid = 1;
m_auctionid = 1;
m_guildId = 1;
m_arenaTeamId = 1;
m_auctionid = 1;
mGuildBankTabPrice.resize(GUILD_BANK_MAX_TABS);
mGuildBankTabPrice[0] = 100;
@@ -178,9 +178,6 @@ ObjectMgr::~ObjectMgr()
for (CachePlayerInfoMap::iterator itr = m_mPlayerInfoMap.begin(); itr != m_mPlayerInfoMap.end(); ++itr)
delete itr->second;
for(ItemMap::iterator itr = mAitems.begin(); itr != mAitems.end(); ++itr)
delete itr->second;
for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr)
itr->second.Clear();
@@ -325,254 +322,6 @@ void ObjectMgr::RemoveArenaTeam(ArenaTeam* arenaTeam)
mArenaTeamMap.erase( arenaTeam->GetId() );
}
AuctionHouseObject * ObjectMgr::GetAuctionsMap( uint32 location )
{
switch ( location )
{
case 6: //horde
return & mHordeAuctions;
break;
case 2: //alliance
return & mAllianceAuctions;
break;
default: //neutral
return & mNeutralAuctions;
}
}
uint32 ObjectMgr::GetAuctionCut(uint32 location, uint32 highBid)
{
if (location == 7 && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
return (uint32) (0.15f * highBid * sWorld.getRate(RATE_AUCTION_CUT));
else
return (uint32) (0.05f * highBid * sWorld.getRate(RATE_AUCTION_CUT));
}
uint32 ObjectMgr::GetAuctionDeposit(uint32 location, uint32 time, Item *pItem)
{
float percentance; // in 0..1
if ( location == 7 && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
percentance = 0.75f;
else
percentance = 0.15f;
percentance *= sWorld.getRate(RATE_AUCTION_DEPOSIT);
return uint32( percentance * pItem->GetProto()->SellPrice * pItem->GetCount() * (time / MIN_AUCTION_TIME ) );
}
/// the sum of outbid is (1% from current bid)*5, if bid is very small, it is 1c
uint32 ObjectMgr::GetAuctionOutBid(uint32 currentBid)
{
uint32 outbid = (currentBid / 100) * 5;
if (!outbid)
outbid = 1;
return outbid;
}
//does not clear ram
void ObjectMgr::SendAuctionWonMail( AuctionEntry *auction )
{
Item *pItem = GetAItem(auction->item_guidlow);
if(!pItem)
return;
uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);
Player *bidder = GetPlayer(bidder_guid);
uint32 bidder_accId = 0;
// data for gm.log
if( sWorld.getConfig(CONFIG_GM_LOG_TRADE) )
{
uint32 bidder_security = 0;
std::string bidder_name;
if (bidder)
{
bidder_accId = bidder->GetSession()->GetAccountId();
bidder_security = bidder->GetSession()->GetSecurity();
bidder_name = bidder->GetName();
}
else
{
bidder_accId = GetPlayerAccountIdByGUID(bidder_guid);
bidder_security = accmgr.GetSecurity(bidder_accId);
if(bidder_security > SEC_PLAYER ) // not do redundant DB requests
{
if(!GetPlayerNameByGUID(bidder_guid,bidder_name))
bidder_name = GetTrinityStringForDBCLocale(LANG_UNKNOWN);
}
}
if( bidder_security > SEC_PLAYER )
{
std::string owner_name;
if(!GetPlayerNameByGUID(auction->owner,owner_name))
owner_name = GetTrinityStringForDBCLocale(LANG_UNKNOWN);
uint32 owner_accid = GetPlayerAccountIdByGUID(auction->owner);
sLog.outCommand(bidder_accId,"GM %s (Account: %u) won item in auction: %s (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)",
bidder_name.c_str(),bidder_accId,pItem->GetProto()->Name1,pItem->GetEntry(),pItem->GetCount(),auction->bid,owner_name.c_str(),owner_accid);
}
}
else if(!bidder)
bidder_accId = GetPlayerAccountIdByGUID(bidder_guid);
// receiver exist
if(bidder || bidder_accId)
{
std::ostringstream msgAuctionWonSubject;
msgAuctionWonSubject << auction->item_template << ":0:" << AUCTION_WON;
std::ostringstream msgAuctionWonBody;
msgAuctionWonBody.width(16);
msgAuctionWonBody << std::right << std::hex << auction->owner;
msgAuctionWonBody << std::dec << ":" << auction->bid << ":" << auction->buyout;
sLog.outDebug( "AuctionWon body string : %s", msgAuctionWonBody.str().c_str() );
//prepare mail data... :
uint32 itemTextId = CreateItemText( msgAuctionWonBody.str() );
// set owner to bidder (to prevent delete item with sender char deleting)
// owner in `data` will set at mail receive and item extracting
CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'",auction->bidder,pItem->GetGUIDLow());
CharacterDatabase.CommitTransaction();
MailItemsInfo mi;
mi.AddItem(auction->item_guidlow, auction->item_template, pItem);
if (bidder)
bidder->GetSession()->SendAuctionBidderNotification( auction->location, auction->Id, bidder_guid, 0, 0, auction->item_template);
else
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
// will delete item or place to receiver mail list
WorldSession::SendMailTo(bidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->bidder, msgAuctionWonSubject.str(), itemTextId, &mi, 0, 0, MAIL_CHECK_MASK_AUCTION);
}
// receiver not exist
else
{
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", pItem->GetGUIDLow());
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
delete pItem;
}
}
void ObjectMgr::SendAuctionSalePendingMail( AuctionEntry * auction )
{
uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER);
Player *owner = GetPlayer(owner_guid);
// owner exist (online or offline)
if(owner || GetPlayerAccountIdByGUID(owner_guid))
{
std::ostringstream msgAuctionSalePendingSubject;
msgAuctionSalePendingSubject << auction->item_template << ":0:" << AUCTION_SALE_PENDING;
std::ostringstream msgAuctionSalePendingBody;
uint32 auctionCut = GetAuctionCut(auction->location, auction->bid);
time_t distrTime = time(NULL) + HOUR;
msgAuctionSalePendingBody.width(16);
msgAuctionSalePendingBody << std::right << std::hex << auction->bidder;
msgAuctionSalePendingBody << std::dec << ":" << auction->bid << ":" << auction->buyout;
msgAuctionSalePendingBody << ":" << auction->deposit << ":" << auctionCut << ":0:";
msgAuctionSalePendingBody << secsToTimeBitFields(distrTime);
sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str());
uint32 itemTextId = CreateItemText( msgAuctionSalePendingBody.str() );
WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->owner, msgAuctionSalePendingSubject.str(), itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_AUCTION);
}
}
//call this method to send mail to auction owner, when auction is successful, it does not clear ram
void ObjectMgr::SendAuctionSuccessfulMail( AuctionEntry * auction )
{
uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER);
Player *owner = GetPlayer(owner_guid);
uint32 owner_accId = 0;
if(!owner)
owner_accId = GetPlayerAccountIdByGUID(owner_guid);
// owner exist
if(owner || owner_accId)
{
std::ostringstream msgAuctionSuccessfulSubject;
msgAuctionSuccessfulSubject << auction->item_template << ":0:" << AUCTION_SUCCESSFUL;
std::ostringstream auctionSuccessfulBody;
uint32 auctionCut = GetAuctionCut(auction->location, auction->bid);
auctionSuccessfulBody.width(16);
auctionSuccessfulBody << std::right << std::hex << auction->bidder;
auctionSuccessfulBody << std::dec << ":" << auction->bid << ":" << auction->buyout;
auctionSuccessfulBody << ":" << auction->deposit << ":" << auctionCut;
sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str());
uint32 itemTextId = CreateItemText( auctionSuccessfulBody.str() );
uint32 profit = auction->bid + auction->deposit - auctionCut;
if (owner)
{
//send auction owner notification, bidder must be current!
owner->GetSession()->SendAuctionOwnerNotification( auction );
}
WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->owner, msgAuctionSuccessfulSubject.str(), itemTextId, NULL, profit, 0, MAIL_CHECK_MASK_AUCTION, HOUR);
}
}
//does not clear ram
void ObjectMgr::SendAuctionExpiredMail( AuctionEntry * auction )
{ //return an item in auction to its owner by mail
Item *pItem = GetAItem(auction->item_guidlow);
if(!pItem)
{
sLog.outError("Auction item (GUID: %u) not found, and lost.",auction->item_guidlow);
return;
}
uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER);
Player *owner = GetPlayer(owner_guid);
uint32 owner_accId = 0;
if(!owner)
owner_accId = GetPlayerAccountIdByGUID(owner_guid);
// owner exist
if(owner || owner_accId)
{
std::ostringstream subject;
subject << auction->item_template << ":0:" << AUCTION_EXPIRED;
if ( owner )
owner->GetSession()->SendAuctionOwnerNotification( auction );
else
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
MailItemsInfo mi;
mi.AddItem(auction->item_guidlow, auction->item_template, pItem);
// will delete item or place to receiver mail list
WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, GUID_LOPART(owner_guid), subject.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE);
}
// owner not found
else
{
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'",pItem->GetGUIDLow());
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
delete pItem;
}
}
CreatureInfo const* ObjectMgr::GetCreatureTemplate(uint32 id)
{
return sCreatureStorage.LookupEntry<CreatureInfo>(id);
@@ -1498,65 +1247,6 @@ uint32 ObjectMgr::GetPlayerAccountIdByPlayerName(const std::string& name) const
return 0;
}
void ObjectMgr::LoadAuctions()
{
QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auctionhouse");
if( !result )
return;
Field *fields = result->Fetch();
uint32 AuctionCount=fields[0].GetUInt32();
delete result;
if(!AuctionCount)
return;
result = CharacterDatabase.Query( "SELECT id,auctioneerguid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit,location FROM auctionhouse" );
if( !result )
return;
barGoLink bar( AuctionCount );
AuctionEntry *aItem;
do
{
fields = result->Fetch();
bar.step();
aItem = new AuctionEntry;
aItem->Id = fields[0].GetUInt32();
aItem->auctioneer = fields[1].GetUInt32();
aItem->item_guidlow = fields[2].GetUInt32();
aItem->item_template = fields[3].GetUInt32();
aItem->owner = fields[4].GetUInt32();
aItem->buyout = fields[5].GetUInt32();
aItem->time = fields[6].GetUInt32();
aItem->bidder = fields[7].GetUInt32();
aItem->bid = fields[8].GetUInt32();
aItem->startbid = fields[9].GetUInt32();
aItem->deposit = fields[10].GetUInt32();
aItem->location = fields[11].GetUInt8();
//check if sold item exists
if ( GetAItem( aItem->item_guidlow ) )
{
GetAuctionsMap( aItem->location )->AddAuction(aItem);
}
else
{
CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",aItem->Id);
sLog.outError("Auction %u has not a existing item : %u", aItem->Id, aItem->item_guidlow);
delete aItem;
}
} while (result->NextRow());
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u auctions", AuctionCount );
sLog.outString();
}
void ObjectMgr::LoadItemLocales()
{
mItemLocaleMap.clear(); // need for reload case
@@ -1932,53 +1622,6 @@ void ObjectMgr::LoadItemPrototypes()
sItemStore.Clear();
}
void ObjectMgr::LoadAuctionItems()
{
QueryResult *result = CharacterDatabase.Query( "SELECT itemguid,item_template FROM auctionhouse" );
if( !result )
return;
barGoLink bar( result->GetRowCount() );
uint32 count = 0;
Field *fields;
do
{
bar.step();
fields = result->Fetch();
uint32 item_guid = fields[0].GetUInt32();
uint32 item_template = fields[1].GetUInt32();
ItemPrototype const *proto = GetItemPrototype(item_template);
if(!proto)
{
sLog.outError( "ObjectMgr::LoadAuctionItems: Unknown item (GUID: %u id: #%u) in auction, skipped.", item_guid,item_template);
continue;
}
Item *item = NewItemOrBag(proto);
if(!item->LoadFromDB(item_guid,0))
{
delete item;
continue;
}
AddAItem(item);
++count;
}
while( result->NextRow() );
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u auction items", count );
}
void ObjectMgr::LoadPetLevelInfo()
{
// Loading levels data
-45
View File
@@ -34,7 +34,6 @@
#include "ItemPrototype.h"
#include "NPCHandler.h"
#include "Database/DatabaseEnv.h"
#include "AuctionHouseObject.h"
#include "Mail.h"
#include "Map.h"
#include "ObjectAccessor.h"
@@ -368,42 +367,6 @@ class ObjectMgr
return sInstanceTemplate.LookupEntry<InstanceTemplate>(map);
}
Item* GetAItem(uint32 id)
{
ItemMap::const_iterator itr = mAitems.find(id);
if (itr != mAitems.end())
{
return itr->second;
}
return NULL;
}
void AddAItem(Item* it)
{
ASSERT( it );
ASSERT( mAitems.find(it->GetGUIDLow()) == mAitems.end());
mAitems[it->GetGUIDLow()] = it;
}
bool RemoveAItem(uint32 id)
{
ItemMap::iterator i = mAitems.find(id);
if (i == mAitems.end())
{
return false;
}
mAitems.erase(i);
return true;
}
AuctionHouseObject * GetAuctionsMap( uint32 location );
//auction messages
void SendAuctionWonMail( AuctionEntry * auction );
void SendAuctionSalePendingMail( AuctionEntry * auction );
void SendAuctionSuccessfulMail( AuctionEntry * auction );
void SendAuctionExpiredMail( AuctionEntry * auction );
static uint32 GetAuctionCut( uint32 location, uint32 highBid );
static uint32 GetAuctionDeposit(uint32 location, uint32 time, Item *pItem);
static uint32 GetAuctionOutBid(uint32 currentBid);
PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint32 level) const;
PlayerClassInfo const* GetPlayerClassInfo(uint32 class_) const
@@ -577,9 +540,6 @@ class ObjectMgr
void LoadItemTexts();
void LoadPageTexts();
//load first auction items, because of check if item exists, when loading
void LoadAuctionItems();
void LoadAuctions();
void LoadPlayerInfo();
void LoadPetLevelInfo();
void LoadExplorationBaseXP();
@@ -847,14 +807,9 @@ class ObjectMgr
ArenaTeamMap mArenaTeamMap;
ItemMap mItems;
ItemMap mAitems;
ItemTextMap mItemTexts;
AuctionHouseObject mHordeAuctions;
AuctionHouseObject mAllianceAuctions;
AuctionHouseObject mNeutralAuctions;
QuestAreaTriggerMap mQuestAreaTriggerMap;
BattleMastersMap mBattleMastersMap;
TavernAreaTriggerSet mTavernAreaTriggerSet;
-22
View File
@@ -20,28 +20,6 @@
#ifndef _PLAYER_DUMP_H
#define _PLAYER_DUMP_H
/*
#include "Log.h"
#include "Object.h"
#include "Bag.h"
#include "Creature.h"
#include "Player.h"
#include "DynamicObject.h"
#include "GameObject.h"
#include "Corpse.h"
#include "QuestDef.h"
#include "Path.h"
#include "ItemPrototype.h"
#include "NPCHandler.h"
#include "Database/DatabaseEnv.h"
#include "AuctionHouseObject.h"
#include "Mail.h"
#include "Map.h"
#include "ObjectAccessor.h"
#include "ObjectDefines.h"
#include "Policies/Singleton.h"
#include "Database/SQLStorage.h"
*/
#include <string>
#include <map>
#include <set>
+7 -53
View File
@@ -37,6 +37,7 @@
#include "SkillDiscovery.h"
#include "World.h"
#include "AccountMgr.h"
#include "AuctionHouseMgr.h"
#include "ObjectMgr.h"
#include "SpellMgr.h"
#include "Chat.h"
@@ -624,7 +625,7 @@ void World::LoadConfigSettings(bool reload)
m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Channel",false);
m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Group",false);
m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Guild",false);
m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Auction",false);
m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Auction",false);
m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Mail",false);
m_configs[CONFIG_ALLOW_TWO_SIDE_WHO_LIST] = sConfig.GetBoolDefault("AllowTwoSide.WhoList", false);
m_configs[CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND] = sConfig.GetBoolDefault("AllowTwoSide.AddFriend", false);
@@ -1268,8 +1269,8 @@ void World::SetInitialWorldSettings()
///- Load dynamic data tables from the database
sLog.outString( "Loading Auctions..." );
objmgr.LoadAuctionItems();
objmgr.LoadAuctions();
auctionmgr.LoadAuctionItems();
auctionmgr.LoadAuctions();
sLog.outString( "Loading Guilds..." );
objmgr.LoadGuilds();
@@ -1513,7 +1514,7 @@ void World::Update(time_t diff)
if (m_timers[WUPDATE_AUCTIONS].Passed())
{
AuctionHouseBot();
m_timers[WUPDATE_AUCTIONS].Reset();
m_timers[WUPDATE_AUCTIONS].Reset();
///- Update mails (return old mails with item, or delete them)
//(tested... works on win)
@@ -1522,55 +1523,8 @@ void World::Update(time_t diff)
mail_timer = 0;
objmgr.ReturnOrDeleteOldMails(true);
}
AuctionHouseObject* AuctionMap;
for (int i = 0; i < 3; i++)
{
switch (i)
{
case 0:
AuctionMap = objmgr.GetAuctionsMap( 6 );//horde
break;
case 1:
AuctionMap = objmgr.GetAuctionsMap( 2 );//alliance
break;
case 2:
AuctionMap = objmgr.GetAuctionsMap( 7 );//neutral
break;
}
///- Handle expired auctions
AuctionHouseObject::AuctionEntryMap::iterator itr,next;
for (itr = AuctionMap->GetAuctionsBegin(); itr != AuctionMap->GetAuctionsEnd();itr = next)
{
next = itr;
++next;
if (m_gameTime > (itr->second->time))
{
///- Either cancel the auction if there was no bidder
if (itr->second->bidder == 0)
{
objmgr.SendAuctionExpiredMail( itr->second );
}
///- Or perform the transaction
else
{
//we should send an "item sold" message if the seller is online
//we send the item to the winner
//we send the money to the seller
objmgr.SendAuctionSuccessfulMail( itr->second );
objmgr.SendAuctionWonMail( itr->second );
}
///- In any case clear the auction
//No SQL injection (Id is integer)
CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",itr->second->Id);
objmgr.RemoveAItem(itr->second->item_guidlow);
delete itr->second;
AuctionMap->RemoveAuction(itr->first);
}
}
}
///-Handle expired auctions
auctionmgr.Update();
}
RecordTimeDiff(NULL);
-1
View File
@@ -164,7 +164,6 @@ class TRINITY_DLL_SPEC WorldSession
void SendAuctionCommandResult( uint32 auctionId, uint32 Action, uint32 ErrorCode, uint32 bidError = 0);
void SendAuctionBidderNotification( uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template);
void SendAuctionOwnerNotification( AuctionEntry * auction );
bool SendAuctionInfo(WorldPacket & data, AuctionEntry* auction);
void SendAuctionOutbiddedMail( AuctionEntry * auction, uint32 newPrice );
void SendAuctionCancelledToBidderMail( AuctionEntry* auction );
+3 -1
View File
@@ -36,6 +36,7 @@ static AreaFlagByAreaID sAreaFlagByAreaID;
static AreaFlagByMapID sAreaFlagByMapID; // for instances without generated *.map files
DBCStorage <AreaTriggerEntry> sAreaTriggerStore(AreaTriggerEntryfmt);
DBCStorage <AuctionHouseEntry> sAuctionHouseStore(AuctionHouseEntryfmt);
DBCStorage <BankBagSlotPricesEntry> sBankBagSlotPricesStore(BankBagSlotPricesEntryfmt);
DBCStorage <BattlemasterListEntry> sBattlemasterListStore(BattlemasterListEntryfmt);
DBCStorage <CharStartOutfitEntry> sCharStartOutfitStore(CharStartOutfitEntryfmt);
@@ -178,7 +179,7 @@ void LoadDBCStores(const std::string& dataPath)
{
std::string dbcPath = dataPath+"dbc/";
const uint32 DBCFilesCount = 56;
const uint32 DBCFilesCount = 57;
barGoLink bar( DBCFilesCount );
@@ -202,6 +203,7 @@ void LoadDBCStores(const std::string& dataPath)
}
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAreaTriggerStore, dbcPath,"AreaTrigger.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAuctionHouseStore, dbcPath,"AuctionHouse.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBankBagSlotPricesStore, dbcPath,"BankBagSlotPrices.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBattlemasterListStore, dbcPath,"BattlemasterList.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCharStartOutfitStore, dbcPath,"CharStartOutfit.dbc");
+1
View File
@@ -134,6 +134,7 @@ class DBCStorage
extern DBCStorage <AreaTableEntry> sAreaStore;// recommend access using functions
extern DBCStorage <AreaTriggerEntry> sAreaTriggerStore;
extern DBCStorage <AuctionHouseEntry> sAuctionHouseStore;
extern DBCStorage <BankBagSlotPricesEntry> sBankBagSlotPricesStore;
extern DBCStorage <BattlemasterListEntry> sBattlemasterListStore;
//extern DBCStorage <ChatChannelsEntry> sChatChannelsStore; -- accessed using function, no usable index
+10
View File
@@ -65,6 +65,16 @@ struct AreaTriggerEntry
float box_orientation; // 9 extent rotation by about z axis
};
struct AuctionHouseEntry
{
uint32 houseId; // 0 index
uint32 faction; // 1 id of faction.dbc for player factions associated with city
uint32 depositPercent; // 2 1/3 from real
uint32 cutPercent; // 3
//char* name[16]; // 4-19
// 20 string flag, unused
};
struct BankBagSlotPricesEntry
{
uint32 ID;
+1
View File
@@ -19,6 +19,7 @@
*/
const char AreaTableEntryfmt[]="iiinixxxxxissssssssssssssssxixxxxxx";
const char AuctionHouseEntryfmt[]="niiixxxxxxxxxxxxxxxxx";
const char AreaTriggerEntryfmt[]="niffffffff";
const char BankBagSlotPricesEntryfmt[]="ni";
const char BattlemasterListEntryfmt[]="niiixxxxxiiiixxssssssssssssssssxx";
+12 -14
View File
@@ -130,10 +130,6 @@
<Filter
Name="World/Others"
>
<File
RelativePath="..\..\src\game\AuctionHouse.cpp"
>
</File>
<File
RelativePath="..\..\src\game\Channel.cpp"
>
@@ -220,16 +216,6 @@
RelativePath="..\..\src\game\ArenaTeam.h"
>
</File>
<File
RelativePath="..\..\src\game\AuctionHouseObject.h"
>
</File>
<File
RelativePath="..\..\src\game\AuctionHouseBot.cpp">
</File>
<File
RelativePath="..\..\src\game\AuctionHouseBot.h">
</File>
<File
RelativePath="..\..\src\game\Bag.cpp"
>
@@ -1086,6 +1072,10 @@
RelativePath="..\..\src\game\ArenaTeamHandler.cpp"
>
</File>
<File
RelativePath="..\..\src\game\AuctionHouseHandler.cpp"
>
</File>
<File
RelativePath="..\..\src\game\ChannelHandler.cpp"
>
@@ -1194,6 +1184,14 @@
RelativePath="..\..\src\game\AccountMgr.h"
>
</File>
<File
RelativePath="..\..\src\game\AuctionHouseMgr.cpp"
>
</File>
<File
RelativePath="..\..\src\game\AuctionHouseMgr.h"
>
</File>
<File
RelativePath="..\..\src\game\ChannelMgr.h"
>
+12 -14
View File
@@ -350,10 +350,6 @@
<Filter
Name="World/Others"
>
<File
RelativePath="..\..\src\game\AuctionHouse.cpp"
>
</File>
<File
RelativePath="..\..\src\game\Channel.cpp"
>
@@ -440,16 +436,6 @@
RelativePath="..\..\src\game\ArenaTeam.h"
>
</File>
<File
RelativePath="..\..\src\game\AuctionHouseBot.cpp">
</File>
<File
RelativePath="..\..\src\game\AuctionHouseBot.h">
</File>
<File
RelativePath="..\..\src\game\AuctionHouseObject.h"
>
</File>
<File
RelativePath="..\..\src\game\Bag.cpp"
>
@@ -1306,6 +1292,10 @@
RelativePath="..\..\src\game\ArenaTeamHandler.cpp"
>
</File>
<File
RelativePath="..\..\src\game\AuctionHouseHandler.cpp"
>
</File>
<File
RelativePath="..\..\src\game\ChannelHandler.cpp"
>
@@ -1414,6 +1404,14 @@
RelativePath="..\..\src\game\AccountMgr.h"
>
</File>
<File
RelativePath="..\..\src\game\AuctionHouseMgr.cpp"
>
</File>
<File
RelativePath="..\..\src\game\AuctionHouseMgr.h"
>
</File>
<File
RelativePath="..\..\src\game\ChannelMgr.h"
>
+12 -8
View File
@@ -355,10 +355,6 @@
<Filter
Name="World/Others"
>
<File
RelativePath="..\..\src\game\AuctionHouse.cpp"
>
</File>
<File
RelativePath="..\..\src\game\Channel.cpp"
>
@@ -445,10 +441,6 @@
RelativePath="..\..\src\game\ArenaTeam.h"
>
</File>
<File
RelativePath="..\..\src\game\AuctionHouseObject.h"
>
</File>
<File
RelativePath="..\..\src\game\Bag.cpp"
>
@@ -1305,6 +1297,10 @@
RelativePath="..\..\src\game\ArenaTeamHandler.cpp"
>
</File>
<File
RelativePath="..\..\src\game\AuctionHouseHandler.cpp"
>
</File>
<File
RelativePath="..\..\src\game\ChannelHandler.cpp"
>
@@ -1413,6 +1409,14 @@
RelativePath="..\..\src\game\AccountMgr.h"
>
</File>
<File
RelativePath="..\..\src\game\AuctionHouseMgr.cpp"
>
</File>
<File
RelativePath="..\..\src\game\AuctionHouseMgr.h"
>
</File>
<File
RelativePath="..\..\src\game\ChannelMgr.h"
>