mirror of
https://github.com/NathanHandley/mod-ah-bot-plus.git
synced 2026-01-13 09:17:21 +00:00
ObjectGuid - Part I. (#35)
Co-authored-by: UltraNix <ultranix@gmail.com>
This commit is contained in:
@@ -170,26 +170,7 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
|
||||
|
||||
if (debug_Out) sLog->outString("AHSeller: Adding %u Auctions", items);
|
||||
|
||||
uint32 AuctioneerGUID = 0;
|
||||
|
||||
switch (config->GetAHID())
|
||||
{
|
||||
case 2:
|
||||
AuctioneerGUID = 79707; //Human in stormwind.
|
||||
break;
|
||||
case 6:
|
||||
AuctioneerGUID = 4656; //orc in Orgrimmar
|
||||
break;
|
||||
case 7:
|
||||
AuctioneerGUID = 23442; //goblin in GZ
|
||||
break;
|
||||
default:
|
||||
if (debug_Out) sLog->outError( "AHSeller: GetAHID() - Default switch reached");
|
||||
AuctioneerGUID = 23442; //default to neutral 7
|
||||
break;
|
||||
}
|
||||
|
||||
if (debug_Out) sLog->outError( "AHSeller: Current Auctineer GUID is %u", AuctioneerGUID);
|
||||
if (debug_Out) sLog->outError( "AHSeller: Current house id is %u", config->GetAHID());
|
||||
|
||||
uint32 greyTGcount = config->GetPercents(AHB_GREY_TG);
|
||||
uint32 whiteTGcount = config->GetPercents(AHB_WHITE_TG);
|
||||
@@ -424,14 +405,13 @@ void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
AuctionEntry* auctionEntry = new AuctionEntry();
|
||||
auctionEntry->Id = sObjectMgr->GenerateAuctionID();
|
||||
auctionEntry->auctioneer = AuctioneerGUID;
|
||||
auctionEntry->item_guidlow = item->GetGUIDLow();
|
||||
auctionEntry->houseId = config->GetAHID();
|
||||
auctionEntry->item_guid = item->GetGUID();
|
||||
auctionEntry->item_template = item->GetEntry();
|
||||
auctionEntry->itemCount = item->GetCount();
|
||||
auctionEntry->owner = AHBplayer->GetGUIDLow();
|
||||
auctionEntry->owner = AHBplayer->GetGUID();
|
||||
auctionEntry->startbid = bidPrice * stackCount;
|
||||
auctionEntry->buyout = buyoutPrice * stackCount;
|
||||
auctionEntry->bidder = 0;
|
||||
auctionEntry->bid = 0;
|
||||
auctionEntry->deposit = dep;
|
||||
auctionEntry->expire_time = (time_t) etime + time(NULL);
|
||||
@@ -544,10 +524,10 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
|
||||
continue;
|
||||
|
||||
// get exact item information
|
||||
Item *pItem = sAuctionMgr->GetAItem(auction->item_guidlow);
|
||||
Item *pItem = sAuctionMgr->GetAItem(auction->item_guid);
|
||||
if (!pItem)
|
||||
{
|
||||
if (debug_Out) sLog->outError( "AHBuyer: Item %u doesn't exist, perhaps bought already?", auction->item_guidlow);
|
||||
if (debug_Out) sLog->outError( "AHBuyer: Item %s doesn't exist, perhaps bought already?", auction->item_guid.ToString().c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -626,9 +606,8 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
|
||||
sLog->outString("-------------------------------------------------");
|
||||
sLog->outString("AHBuyer: Info for Auction #%u:", auction->Id);
|
||||
sLog->outString("AHBuyer: AuctionHouse: %u", auction->GetHouseId());
|
||||
sLog->outString("AHBuyer: Auctioneer: %u", auction->auctioneer);
|
||||
sLog->outString("AHBuyer: Owner: %u", auction->owner);
|
||||
sLog->outString("AHBuyer: Bidder: %u", auction->bidder);
|
||||
sLog->outString("AHBuyer: Owner: %s", auction->owner.ToString().c_str());
|
||||
sLog->outString("AHBuyer: Bidder: %s", auction->bidder.ToString().c_str());
|
||||
sLog->outString("AHBuyer: Starting Bid: %u", auction->startbid);
|
||||
sLog->outString("AHBuyer: Current Bid: %u", currentprice);
|
||||
sLog->outString("AHBuyer: Buyout: %u", auction->buyout);
|
||||
@@ -638,7 +617,7 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
|
||||
sLog->outString("AHBuyer: Bid Max: %Lf", bidMax);
|
||||
sLog->outString("AHBuyer: Bid Value: %Lf", bidvalue);
|
||||
sLog->outString("AHBuyer: Bid Price: %u", bidprice);
|
||||
sLog->outString("AHBuyer: Item GUID: %u", auction->item_guidlow);
|
||||
sLog->outString("AHBuyer: Item GUID: %s", auction->item_guid.ToString().c_str());
|
||||
sLog->outString("AHBuyer: Item Template: %u", auction->item_template);
|
||||
sLog->outString("AHBuyer: Item Info:");
|
||||
sLog->outString("AHBuyer: Item ID: %u", prototype->ItemId);
|
||||
@@ -654,10 +633,9 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
|
||||
// Check whether we do normal bid, or buyout
|
||||
if ((bidprice < auction->buyout) || (auction->buyout == 0))
|
||||
{
|
||||
|
||||
if (auction->bidder > 0)
|
||||
if (auction->bidder)
|
||||
{
|
||||
if (auction->bidder == AHBplayer->GetGUIDLow())
|
||||
if (auction->bidder == AHBplayer->GetGUID())
|
||||
{
|
||||
//pl->ModifyMoney(-int32(price - auction->bid));
|
||||
}
|
||||
@@ -671,21 +649,21 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
|
||||
}
|
||||
}
|
||||
|
||||
auction->bidder = AHBplayer->GetGUIDLow();
|
||||
auction->bidder = AHBplayer->GetGUID();
|
||||
auction->bid = bidprice;
|
||||
|
||||
// Saving auction into database
|
||||
CharacterDatabase.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);
|
||||
CharacterDatabase.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder.GetCounter(), auction->bid, auction->Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
//buyout
|
||||
if ((auction->bidder) && (AHBplayer->GetGUIDLow() != auction->bidder))
|
||||
if ((auction->bidder) && (AHBplayer->GetGUID() != auction->bidder))
|
||||
{
|
||||
sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, session->GetPlayer(), trans);
|
||||
}
|
||||
auction->bidder = AHBplayer->GetGUIDLow();
|
||||
auction->bidder = AHBplayer->GetGUID();
|
||||
auction->bid = auction->buyout;
|
||||
|
||||
// Send mails to buyer & seller
|
||||
@@ -694,7 +672,7 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
|
||||
sAuctionMgr->SendAuctionWonMail(auction, trans);
|
||||
auction->DeleteFromDB( trans);
|
||||
|
||||
sAuctionMgr->RemoveAItem(auction->item_guidlow);
|
||||
sAuctionMgr->RemoveAItem(auction->item_guid);
|
||||
auctionHouse->RemoveAuction(auction);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
@@ -710,7 +688,7 @@ void AuctionHouseBot::Update()
|
||||
WorldSession _session(AHBplayerAccount, NULL, SEC_PLAYER, sWorld->getIntConfig(CONFIG_EXPANSION), 0, LOCALE_zhCN,0,false,false,0);
|
||||
Player _AHBplayer(&_session);
|
||||
_AHBplayer.Initialize(AHBplayerGUID);
|
||||
sObjectAccessor->AddObject(&_AHBplayer);
|
||||
ObjectAccessor::AddObject(&_AHBplayer);
|
||||
|
||||
// Add New Bids
|
||||
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
|
||||
@@ -742,7 +720,7 @@ void AuctionHouseBot::Update()
|
||||
addNewAuctionBuyerBotBid(&_AHBplayer, &NeutralConfig, &_session);
|
||||
_lastrun_n = _newrun;
|
||||
}
|
||||
sObjectAccessor->RemoveObject(&_AHBplayer);
|
||||
ObjectAccessor::RemoveObject(&_AHBplayer);
|
||||
}
|
||||
|
||||
void AuctionHouseBot::Initialize()
|
||||
@@ -1392,10 +1370,10 @@ void AuctionHouseBot::IncrementItemCounts(AuctionEntry* ah)
|
||||
// from auctionhousehandler.cpp, creates auction pointer & player pointer
|
||||
|
||||
// get exact item information
|
||||
Item *pItem = sAuctionMgr->GetAItem(ah->item_guidlow);
|
||||
Item *pItem = sAuctionMgr->GetAItem(ah->item_guid);
|
||||
if (!pItem)
|
||||
{
|
||||
if (debug_Out) sLog->outError( "AHBot: Item %u doesn't exist, perhaps bought already?", ah->item_guidlow);
|
||||
if (debug_Out) sLog->outError( "AHBot: Item %s doesn't exist, perhaps bought already?", ah->item_guid.ToString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1404,25 +1382,25 @@ void AuctionHouseBot::IncrementItemCounts(AuctionEntry* ah)
|
||||
|
||||
AHBConfig *config;
|
||||
|
||||
FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(ah->GetHouseFaction());
|
||||
if (!u_entry)
|
||||
AuctionHouseEntry const* ahEntry = sAuctionHouseStore.LookupEntry(ah->GetHouseId());
|
||||
if (!ahEntry)
|
||||
{
|
||||
if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Neutral", ah->GetHouseFaction());
|
||||
if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Neutral", ah->GetHouseId());
|
||||
config = &NeutralConfig;
|
||||
}
|
||||
else if (u_entry->ourMask & FACTION_MASK_ALLIANCE)
|
||||
else if (ahEntry->houseId == AUCTIONHOUSE_ALLIANCE)
|
||||
{
|
||||
if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Alliance", ah->GetHouseFaction());
|
||||
if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Alliance", ah->GetHouseId());
|
||||
config = &AllianceConfig;
|
||||
}
|
||||
else if (u_entry->ourMask & FACTION_MASK_HORDE)
|
||||
else if (ahEntry->houseId == AUCTIONHOUSE_HORDE)
|
||||
{
|
||||
if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Horde", ah->GetHouseFaction());
|
||||
if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Horde", ah->GetHouseId());
|
||||
config = &HordeConfig;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Neutral", ah->GetHouseFaction());
|
||||
if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Neutral", ah->GetHouseId());
|
||||
config = &NeutralConfig;
|
||||
}
|
||||
|
||||
@@ -1436,25 +1414,25 @@ void AuctionHouseBot::DecrementItemCounts(AuctionEntry* ah, uint32 itemEntry)
|
||||
|
||||
AHBConfig *config;
|
||||
|
||||
FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(ah->GetHouseFaction());
|
||||
if (!u_entry)
|
||||
AuctionHouseEntry const* ahEntry = sAuctionHouseStore.LookupEntry(ah->GetHouseId());
|
||||
if (!ahEntry)
|
||||
{
|
||||
if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Neutral", ah->GetHouseFaction());
|
||||
if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Neutral", ah->GetHouseId());
|
||||
config = &NeutralConfig;
|
||||
}
|
||||
else if (u_entry->ourMask & FACTION_MASK_ALLIANCE)
|
||||
else if (ahEntry->houseId == AUCTIONHOUSE_ALLIANCE)
|
||||
{
|
||||
if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Alliance", ah->GetHouseFaction());
|
||||
if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Alliance", ah->GetHouseId());
|
||||
config = &AllianceConfig;
|
||||
}
|
||||
else if (u_entry->ourMask & FACTION_MASK_HORDE)
|
||||
else if (ahEntry->houseId == AUCTIONHOUSE_HORDE)
|
||||
{
|
||||
if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Horde", ah->GetHouseFaction());
|
||||
if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Horde", ah->GetHouseId());
|
||||
config = &HordeConfig;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Neutral", ah->GetHouseFaction());
|
||||
if (debug_Out) sLog->outError( "AHBot: %u returned as House Faction. Neutral", ah->GetHouseId());
|
||||
config = &NeutralConfig;
|
||||
}
|
||||
|
||||
@@ -1514,7 +1492,7 @@ void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char*
|
||||
|
||||
while (itr != auctionHouse->GetAuctionsEnd())
|
||||
{
|
||||
if (itr->second->owner == AHBplayerGUID)
|
||||
if (itr->second->owner.GetCounter() == AHBplayerGUID)
|
||||
{
|
||||
itr->second->expire_time = sWorld->GetGameTime();
|
||||
uint32 id = itr->second->Id;
|
||||
@@ -1793,7 +1771,7 @@ void AuctionHouseBot::LoadValues(AHBConfig *config)
|
||||
for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin(); itr != auctionHouse->GetAuctionsEnd(); ++itr)
|
||||
{
|
||||
AuctionEntry *Aentry = itr->second;
|
||||
Item *item = sAuctionMgr->GetAItem(Aentry->item_guidlow);
|
||||
Item *item = sAuctionMgr->GetAItem(Aentry->item_guid);
|
||||
if (item)
|
||||
{
|
||||
ItemTemplate const *prototype = item->GetTemplate();
|
||||
|
||||
Reference in New Issue
Block a user