*Use correct indent for aubot.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-05-06 09:32:24 -05:00
parent 280a2ac54e
commit 6ff7d30004
+24 -54
View File
@@ -504,27 +504,20 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World
} }
uint32 bids = config->GetBidsPerInterval(); uint32 bids = config->GetBidsPerInterval();
for (uint32 count = 1;count <= bids;count++) for (uint32 count = 0; count < bids; ++count)
{ {
// Do we have anything to bid? If not, stop here. // Do we have anything to bid? If not, stop here.
if(possibleBids.empty()) if(possibleBids.empty())
{
count = bids + 1;
return; return;
}
// Choose random auction from possible auctions // Choose random auction from possible auctions
uint32 vectorPos = urand(0, possibleBids.size() - 1); uint32 vectorPos = urand(0, possibleBids.size() - 1);
uint32 auctionID = possibleBids[vectorPos];
// Erase the auction from the vector to prevent bidding on item in next itteration.
vector<uint32>::iterator iter = possibleBids.begin(); vector<uint32>::iterator iter = possibleBids.begin();
advance(iter, vectorPos); advance(iter, vectorPos);
possibleBids.erase(iter);
// from auctionhousehandler.cpp, creates auction pointer & player pointer // from auctionhousehandler.cpp, creates auction pointer & player pointer
AuctionEntry* auction = auctionHouse->GetAuction(auctionID); AuctionEntry* auction = auctionHouse->GetAuction(*iter);
// Erase the auction from the vector to prevent bidding on item in next itteration.
possibleBids.erase(iter);
// get exact item information // get exact item information
Item *pItem = auctionmgr.GetAItem(auction->item_guidlow); Item *pItem = auctionmgr.GetAItem(auction->item_guidlow);
@@ -546,6 +539,7 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World
sLog.outError("Sell Price: %u", prototype->SellPrice); sLog.outError("Sell Price: %u", prototype->SellPrice);
sLog.outError("Quality: %u", prototype->Quality); sLog.outError("Quality: %u", prototype->Quality);
} }
uint32 currentprice; uint32 currentprice;
if(auction->bid) if(auction->bid)
{ {
@@ -559,129 +553,104 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World
if(debug_Out) if(debug_Out)
{sLog.outError("Current Price: %u", auction->startbid);} {sLog.outError("Current Price: %u", auction->startbid);}
} }
uint32 bidprice;
// Prepare portion from maximum bid // Prepare portion from maximum bid
uint32 tmprate2 = urand(0, 100); uint32 tmprate2 = urand(0, 100);
double tmprate = static_cast<double>(tmprate2); double tmprate = static_cast<double>(tmprate2);
if(debug_Out)
{sLog.outError("tmprate: %f", tmprate);}
double bidrate = tmprate / 100; double bidrate = tmprate / 100;
if(debug_Out)
{sLog.outError("bidrate: %f", bidrate);}
long double bidMax = 0; long double bidMax = 0;
if(debug_Out)
{
sLog.outError("tmprate: %f", tmprate);
sLog.outError("bidrate: %f", bidrate);
}
// check that bid has acceptable value and take bid based on vendorprice, stacksize and quality // check that bid has acceptable value and take bid based on vendorprice, stacksize and quality
switch (BuyMethod) switch (BuyMethod)
{ {
case 0: case 0:
{
switch (prototype->Quality) switch (prototype->Quality)
{ {
case 0: case 0:
if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY)) if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY))
{
bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY); bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY);
}
break; break;
case 1: case 1:
if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE)) if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE))
{
bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE); bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE);
}
break; break;
case 2: case 2:
if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN)) if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN))
{
bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN); bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN);
}
break; break;
case 3: case 3:
if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE)) if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE))
{
bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE); bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE);
}
break; break;
case 4: case 4:
if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE)) if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE))
{
bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE); bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE);
}
case 5: case 5:
if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE)) if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE))
{
bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE); bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE);
}
case 6: case 6:
if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW)) if(currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW))
{
bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW); bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW);
}
break; break;
default: default:
// quality is something it shouldn't be, let's get out of here // quality is something it shouldn't be, let's get out of here
if(debug_Out) if(debug_Out)
{sLog.outError("bidMax(fail): %f", bidMax);} sLog.outError("bidMax(fail): %f", bidMax);
return; return;
break;
} }
break; break;
}
case 1: case 1:
{
switch (prototype->Quality) switch (prototype->Quality)
{ {
case 0: case 0:
if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY)) if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY))
{
bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY); bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREY);
}
break; break;
case 1: case 1:
if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE)) if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE))
{
bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE); bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_WHITE);
}
break; break;
case 2: case 2:
if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN)) if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN))
{
bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN); bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_GREEN);
}
break; break;
case 3: case 3:
if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE)) if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE))
{
bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE); bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_BLUE);
}
break; break;
case 4: case 4:
if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE)) if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE))
{
bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE); bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_PURPLE);
}
case 5: case 5:
if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE)) if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE))
{
bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE); bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_ORANGE);
}
case 6: case 6:
if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW)) if(currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW))
{
bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW); bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(AHB_YELLOW);
}
break; break;
default: default:
// quality is something it shouldn't be, let's get out of here // quality is something it shouldn't be, let's get out of here
if(debug_Out) if(debug_Out)
{sLog.outError("bidMax(fail): %f", bidMax);} sLog.outError("bidMax(fail): %f", bidMax);
return; return;
break;
} }
break; break;
}
default: default:
bidMax = 0; bidMax = 0;
break; break;
} }
if(debug_Out) if(debug_Out)
{sLog.outError("bidMax(succeed): %f", bidMax);} sLog.outError("bidMax(succeed): %f", bidMax);
// check some special items, and do recalculating to their prices // check some special items, and do recalculating to their prices
switch (prototype->Class) switch (prototype->Class)
@@ -702,19 +671,20 @@ static void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, World
// Calculate our bid // Calculate our bid
long double bidvalue = currentprice + ( (bidMax - currentprice) * bidrate); long double bidvalue = currentprice + ( (bidMax - currentprice) * bidrate);
if(debug_Out)
{sLog.outError("bidvalue: %f", bidvalue);}
// Convert to uint32 // Convert to uint32
bidprice = static_cast<uint32>(bidvalue); uint32 bidprice = static_cast<uint32>(bidvalue);
if(debug_Out) if(debug_Out)
{sLog.outError("bidprice: %u", bidprice);} {
sLog.outError("bidprice: %u", bidprice);
sLog.outError("bidvalue: %f", bidvalue);
}
// Check our bid is high enough to be valid. If not, correct it to minimum. // Check our bid is high enough to be valid. If not, correct it to minimum.
if((currentprice + auction->GetAuctionOutBid()) > bidprice) if((currentprice + auction->GetAuctionOutBid()) > bidprice)
{ {
bidprice = currentprice + auction->GetAuctionOutBid(); bidprice = currentprice + auction->GetAuctionOutBid();
if(debug_Out) if(debug_Out)
{sLog.outError("bidprice(>): %u", bidprice);} sLog.outError("bidprice(>): %u", bidprice);
} }
// Check wether we do normal bid, or buyout // Check wether we do normal bid, or buyout