[10250] Select auction store by house id only.

After this commit auction auctioneer guid used only for select auction house in packet or loading.
Next task replace it in DB by houseid, dependence DB data from creature guid isn't good.
This commit is contained in:
VladimirMangos 2010-07-23 11:38:58 +04:00
parent 02532a469a
commit 9350c9990d
8 changed files with 150 additions and 128 deletions

View file

@ -35,13 +35,13 @@
// void called when player click on auctioneer npc // void called when player click on auctioneer npc
void WorldSession::HandleAuctionHelloOpcode( WorldPacket & recv_data ) void WorldSession::HandleAuctionHelloOpcode( WorldPacket & recv_data )
{ {
uint64 guid; // NPC guid ObjectGuid auctioneerGuid; // NPC guid
recv_data >> guid; recv_data >> auctioneerGuid;
Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_AUCTIONEER); Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(auctioneerGuid, UNIT_NPC_FLAG_AUCTIONEER);
if (!unit) if (!unit)
{ {
DEBUG_LOG( "WORLD: HandleAuctionHelloOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); DEBUG_LOG("WORLD: HandleAuctionHelloOpcode - %s not found or you can't interact with him.", auctioneerGuid.GetString().c_str());
return; return;
} }
@ -49,18 +49,17 @@ void WorldSession::HandleAuctionHelloOpcode( WorldPacket & recv_data )
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
SendAuctionHello(guid, unit); SendAuctionHello(unit);
} }
// this void causes that auction window is opened // this void causes that auction window is opened
void WorldSession::SendAuctionHello( uint64 guid, Creature* unit ) void WorldSession::SendAuctionHello(Creature* unit)
{ {
// always return pointer
AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->getFaction()); AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->getFaction());
if(!ahEntry)
return;
WorldPacket data( MSG_AUCTION_HELLO, 12 ); WorldPacket data( MSG_AUCTION_HELLO, 12 );
data << uint64(guid); data << unit->GetObjectGuid();
data << uint32(ahEntry->houseId); data << uint32(ahEntry->houseId);
data << uint8(1); // 3.3.3: 1 - AH enabled, 0 - AH disabled data << uint8(1); // 3.3.3: 1 - AH enabled, 0 - AH disabled
SendPacket(&data); SendPacket(&data);
@ -153,12 +152,28 @@ void WorldSession::SendAuctionCancelledToBidderMail( AuctionEntry* auction )
} }
} }
AuctionHouseEntry const* WorldSession::GetCheckedAuctionHouseForAuctioneer(ObjectGuid guid)
{
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_AUCTIONEER);
if (!pCreature)
{
DEBUG_LOG("Auctioneeer %s accessed in cheating way.", guid.GetString().c_str());
return NULL;
}
// always return pointer
return AuctionHouseMgr::GetAuctionHouseEntry(pCreature->getFaction());
}
// this void creates new auction and adds auction to some auctionhouse // this void creates new auction and adds auction to some auctionhouse
void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data ) void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
{ {
uint64 auctioneer, item; DEBUG_LOG("WORLD: HandleAuctionSellItem");
ObjectGuid auctioneerGuid;
uint64 item;
uint32 etime, bid, buyout; uint32 etime, bid, buyout;
recv_data >> auctioneer; recv_data >> auctioneerGuid;
recv_data.read_skip<uint32>(); // const 1? recv_data.read_skip<uint32>(); // const 1?
recv_data >> item; recv_data >> item;
recv_data.read_skip<uint32>(); // stack size recv_data.read_skip<uint32>(); // stack size
@ -166,24 +181,17 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
recv_data >> buyout; recv_data >> buyout;
recv_data >> etime; recv_data >> etime;
Player *pl = GetPlayer();
if (!item || !bid || !etime) if (!item || !bid || !etime)
return; // check for cheaters return; // check for cheaters
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer, UNIT_NPC_FLAG_AUCTIONEER); Player *pl = GetPlayer();
if (!pCreature)
{
DEBUG_LOG( "WORLD: HandleAuctionSellItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)) );
return;
}
AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(pCreature->getFaction()); AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
if (!auctionHouseEntry) if (!auctionHouseEntry)
{
DEBUG_LOG( "WORLD: HandleAuctionSellItem - Unit (GUID: %u) has wrong faction.", uint32(GUID_LOPART(auctioneer)) );
return; return;
}
// always return pointer
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
// client send time in minutes, convert to common used sec time // client send time in minutes, convert to common used sec time
etime *= MINUTE; etime *= MINUTE;
@ -230,8 +238,6 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
return; return;
} }
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap( pCreature->getFaction() );
//we have to take deposit : //we have to take deposit :
uint32 deposit = AuctionHouseMgr::GetAuctionDeposit( auctionHouseEntry, etime, it ); uint32 deposit = AuctionHouseMgr::GetAuctionDeposit( auctionHouseEntry, etime, it );
if ( pl->GetMoney() < deposit ) if ( pl->GetMoney() < deposit )
@ -252,7 +258,7 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
AuctionEntry *AH = new AuctionEntry; AuctionEntry *AH = new AuctionEntry;
AH->Id = sObjectMgr.GenerateAuctionID(); AH->Id = sObjectMgr.GenerateAuctionID();
AH->auctioneer = GUID_LOPART(auctioneer); AH->auctioneer = auctioneerGuid.GetCounter();
AH->item_guidlow = GUID_LOPART(item); AH->item_guidlow = GUID_LOPART(item);
AH->item_template = it->GetEntry(); AH->item_template = it->GetEntry();
AH->owner = pl->GetGUIDLow(); AH->owner = pl->GetGUIDLow();
@ -264,7 +270,8 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
AH->deposit = deposit; AH->deposit = deposit;
AH->auctionHouseEntry = auctionHouseEntry; AH->auctionHouseEntry = auctionHouseEntry;
DETAIL_LOG("selling item %u to auctioneer %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u", GUID_LOPART(item), GUID_LOPART(auctioneer), bid, buyout, auction_time, AH->GetHouseId()); DETAIL_LOG("selling item %u to auctioneer %s with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u",
GUID_LOPART(item), auctioneerGuid.GetString().c_str(), bid, buyout, auction_time, AH->GetHouseId());
auctionHouse->AddAuction(AH); auctionHouse->AddAuction(AH);
sAuctionMgr.AddAItem(it); sAuctionMgr.AddAItem(it);
@ -285,27 +292,28 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
// this function is called when client bids or buys out auction // this function is called when client bids or buys out auction
void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data ) void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
{ {
uint64 auctioneer; DEBUG_LOG("WORLD: HandleAuctionPlaceBid");
ObjectGuid auctioneerGuid;
uint32 auctionId; uint32 auctionId;
uint32 price; uint32 price;
recv_data >> auctioneer; recv_data >> auctioneerGuid;
recv_data >> auctionId >> price; recv_data >> auctionId >> price;
if (!auctionId || !price) if (!auctionId || !price)
return; // check for cheaters return; // check for cheaters
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer,UNIT_NPC_FLAG_AUCTIONEER); AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
if (!pCreature) if (!auctionHouseEntry)
{
DEBUG_LOG( "WORLD: HandleAuctionPlaceBid - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)) );
return; return;
}
// always return pointer
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap( pCreature->getFaction() );
AuctionEntry *auction = auctionHouse->GetAuction(auctionId); AuctionEntry *auction = auctionHouse->GetAuction(auctionId);
Player *pl = GetPlayer(); Player *pl = GetPlayer();
@ -412,25 +420,25 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
// this void is called when auction_owner cancels his auction // this void is called when auction_owner cancels his auction
void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data ) void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
{ {
uint64 auctioneer; DEBUG_LOG("WORLD: HandleAuctionRemoveItem");
ObjectGuid auctioneerGuid;
uint32 auctionId; uint32 auctionId;
recv_data >> auctioneer; recv_data >> auctioneerGuid;
recv_data >> auctionId; recv_data >> auctionId;
//DEBUG_LOG( "Cancel AUCTION AuctionID: %u", auctionId); //DEBUG_LOG( "Cancel AUCTION AuctionID: %u", auctionId);
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer, UNIT_NPC_FLAG_AUCTIONEER); AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
if (!pCreature) if (!auctionHouseEntry)
{
DEBUG_LOG( "WORLD: HandleAuctionRemoveItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)) );
return; return;
}
// always return pointer
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap( pCreature->getFaction() );
AuctionEntry *auction = auctionHouse->GetAuction(auctionId); AuctionEntry *auction = auctionHouse->GetAuction(auctionId);
Player *pl = GetPlayer(); Player *pl = GetPlayer();
@ -487,11 +495,13 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
//called when player lists his bids //called when player lists his bids
void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data ) void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data )
{ {
uint64 guid; // NPC guid DEBUG_LOG("WORLD: HandleAuctionListBidderItems");
ObjectGuid auctioneerGuid; // NPC guid
uint32 listfrom; // page of auctions uint32 listfrom; // page of auctions
uint32 outbiddedCount; // count of outbidded auctions uint32 outbiddedCount; // count of outbidded auctions
recv_data >> guid; recv_data >> auctioneerGuid;
recv_data >> listfrom; // not used in fact (this list not have page control in client) recv_data >> listfrom; // not used in fact (this list not have page control in client)
recv_data >> outbiddedCount; recv_data >> outbiddedCount;
if (recv_data.size() != (16 + outbiddedCount * 4 )) if (recv_data.size() != (16 + outbiddedCount * 4 ))
@ -500,19 +510,17 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data )
outbiddedCount = 0; outbiddedCount = 0;
} }
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_AUCTIONEER); AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
if (!pCreature) if (!auctionHouseEntry)
{
DEBUG_LOG( "WORLD: HandleAuctionListBidderItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
return; return;
}
// always return pointer
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap( pCreature->getFaction() );
WorldPacket data( SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4) ); WorldPacket data( SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4) );
Player *pl = GetPlayer(); Player *pl = GetPlayer();
data << uint32(0); // add 0 as count data << uint32(0); // add 0 as count
@ -541,25 +549,25 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data )
// this void sends player info about his auctions // this void sends player info about his auctions
void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data ) void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data )
{ {
uint32 listfrom; DEBUG_LOG("WORLD: HandleAuctionListOwnerItems");
uint64 guid;
recv_data >> guid; ObjectGuid auctioneerGuid;
uint32 listfrom;
recv_data >> auctioneerGuid;
recv_data >> listfrom; // not used in fact (this list not have page control in client) recv_data >> listfrom; // not used in fact (this list not have page control in client)
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_AUCTIONEER); AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
if (!pCreature) if (!auctionHouseEntry)
{
DEBUG_LOG( "WORLD: HandleAuctionListOwnerItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
return; return;
}
// always return pointer
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap( pCreature->getFaction() );
WorldPacket data( SMSG_AUCTION_OWNER_LIST_RESULT, (4+4+4) ); WorldPacket data( SMSG_AUCTION_OWNER_LIST_RESULT, (4+4+4) );
data << (uint32) 0; // amount place holder data << (uint32) 0; // amount place holder
@ -576,12 +584,14 @@ void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data )
//this void is called when player clicks on search button //this void is called when player clicks on search button
void WorldSession::HandleAuctionListItems( WorldPacket & recv_data ) void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
{ {
DEBUG_LOG("WORLD: HandleAuctionListItems");
ObjectGuid auctioneerGuid;
std::string searchedname; std::string searchedname;
uint8 levelmin, levelmax, usable; uint8 levelmin, levelmax, usable;
uint32 listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality; uint32 listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality;
uint64 guid;
recv_data >> guid; recv_data >> auctioneerGuid;
recv_data >> listfrom; // start, used for page control listing by 50 elements recv_data >> listfrom; // start, used for page control listing by 50 elements
recv_data >> searchedname; recv_data >> searchedname;
@ -591,19 +601,17 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
recv_data.read_skip(16); // unknown 16 bytes: 00 07 01 00 00 01 05 00 06 00 09 01 08 00 03 00 recv_data.read_skip(16); // unknown 16 bytes: 00 07 01 00 00 01 05 00 06 00 09 01 08 00 03 00
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_AUCTIONEER); AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
if (!pCreature) if (!auctionHouseEntry)
{
DEBUG_LOG( "WORLD: HandleAuctionListItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
return; return;
}
// always return pointer
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap( pCreature->getFaction() );
//DEBUG_LOG("Auctionhouse search (GUID: %u TypeId: %u)", , list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u", //DEBUG_LOG("Auctionhouse search (GUID: %u TypeId: %u)", , list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u",
// GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid)), listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable); // GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid)), listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable);
@ -634,7 +642,13 @@ void WorldSession::HandleAuctionListPendingSales( WorldPacket & recv_data )
{ {
DEBUG_LOG("CMSG_AUCTION_LIST_PENDING_SALES"); DEBUG_LOG("CMSG_AUCTION_LIST_PENDING_SALES");
recv_data.read_skip<uint64>(); // auctioneer guid ObjectGuid auctioneerGuid;
recv_data >> auctioneerGuid; // auctioneer guid
AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
if (!auctionHouseEntry)
return;
uint32 count = 0; uint32 count = 0;

View file

@ -49,21 +49,18 @@ AuctionHouseMgr::~AuctionHouseMgr()
delete itr->second; delete itr->second;
} }
AuctionHouseObject * AuctionHouseMgr::GetAuctionsMap( uint32 factionTemplateId ) AuctionHouseObject * AuctionHouseMgr::GetAuctionsMap(AuctionHouseEntry const* house)
{ {
if(sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) if(sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
return &mNeutralAuctions; return &mNeutralAuctions;
// team have linked auction houses // team have linked auction houses
FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId); switch(GetAuctionHouseTeam(house))
if(!u_entry) {
return &mNeutralAuctions; case ALLIANCE: return &mAllianceAuctions;
else if(u_entry->ourMask & FACTION_MASK_ALLIANCE) case HORDE: return &mHordeAuctions;
return &mAllianceAuctions; default: return &mNeutralAuctions;
else if(u_entry->ourMask & FACTION_MASK_HORDE) }
return &mHordeAuctions;
else
return &mNeutralAuctions;
} }
uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem) uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem)
@ -407,43 +404,23 @@ void AuctionHouseMgr::LoadAuctions()
continue; continue;
} }
bool success = true;
CreatureData const* auctioneerData = sObjectMgr.GetCreatureData(auction->auctioneer); CreatureData const* auctioneerData = sObjectMgr.GetCreatureData(auction->auctioneer);
if(!auctioneerData) if(!auctioneerData)
{ {
success = false;
sLog.outError("Auction %u has not a existing auctioneer (GUID : %u), will mail to owner (GUID: %u)", sLog.outError("Auction %u has not a existing auctioneer (GUID : %u), will mail to owner (GUID: %u)",
auction->Id, auction->auctioneer, auction->owner); auction->Id, auction->auctioneer, auction->owner);
} }
CreatureInfo const* auctioneerInfo; CreatureInfo const* auctioneerInfo = auctioneerData ? ObjectMgr::GetCreatureTemplate(auctioneerData->id) : NULL;
if (success) if(auctioneerData && !auctioneerInfo)
{ {
auctioneerInfo = ObjectMgr::GetCreatureTemplate(auctioneerData->id);
if(!auctioneerInfo)
{
success = false;
sLog.outError("Auction %u has not a existing auctioneer (GUID : %u Entry: %u), will mail to owner (GUID: %u)", sLog.outError("Auction %u has not a existing auctioneer (GUID : %u Entry: %u), will mail to owner (GUID: %u)",
auction->Id, auction->auctioneer,auctioneerData->id, auction->owner); auction->Id, auction->auctioneer,auctioneerData->id, auction->owner);
} }
}
if (success) if (!auctioneerInfo)
{
auction->auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(auctioneerInfo->faction_A);
if(!auction->auctionHouseEntry)
{
success = false;
sLog.outError("Auction %u has auctioneer (GUID : %u Entry: %u) with wrong faction %u, will mail to owner (GUID: %u)",
auction->Id, auction->auctioneer, auctioneerData->id, auctioneerInfo->faction_A, auction->owner);
}
}
if(!success)
{ {
// need for send mail, use goblin auctionhouse // need for send mail, use goblin auctionhouse
if (!auction->auctionHouseEntry)
auction->auctionHouseEntry = sAuctionHouseStore.LookupEntry(7); auction->auctionHouseEntry = sAuctionHouseStore.LookupEntry(7);
// Attempt send item back to owner // Attempt send item back to owner
@ -458,10 +435,14 @@ void AuctionHouseMgr::LoadAuctions()
RemoveAItem(auction->item_guidlow); RemoveAItem(auction->item_guidlow);
auction->DeleteFromDB(); auction->DeleteFromDB();
delete auction; delete auction;
continue; continue;
} }
GetAuctionsMap( auctioneerInfo->faction_A )->AddAuction(auction); // always return pointer
auction->auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(auctioneerInfo->faction_A);
GetAuctionsMap(auction->auctionHouseEntry)->AddAuction(auction);
} while (result->NextRow()); } while (result->NextRow());
delete result; delete result;
@ -495,6 +476,23 @@ void AuctionHouseMgr::Update()
mNeutralAuctions.Update(); mNeutralAuctions.Update();
} }
uint32 AuctionHouseMgr::GetAuctionHouseTeam(AuctionHouseEntry const* house)
{
// auction houses have faction field pointing to PLAYER,* factions,
// but player factions not have filled team field, and hard go from faction value to faction_template value,
// so more easy just sort by auction house ids
switch(house->houseId)
{
case 1: case 2: case 3:
return ALLIANCE;
case 4: case 5: case 6:
return HORDE;
case 7:
default:
return 0; // neutral
}
}
AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTemplateId) AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTemplateId)
{ {
uint32 houseid = 1; // dwarf auction house (used for normal cut/etc percents) uint32 houseid = 1; // dwarf auction house (used for normal cut/etc percents)
@ -508,14 +506,16 @@ AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTem
{ {
case 12: houseid = 1; break; // human case 12: houseid = 1; break; // human
case 29: houseid = 6; break; // orc, and generic for horde case 29: houseid = 6; break; // orc, and generic for horde
case 55: houseid = 2; break; // dwarf, and generic for alliance case 55: houseid = 2; break; // dwarf/gnome, and generic for alliance
case 68: houseid = 4; break; // undead case 68: houseid = 4; break; // undead
case 80: houseid = 3; break; // n-elf case 80: houseid = 3; break; // n-elf
case 104: houseid = 5; break; // trolls case 104: houseid = 5; break; // trolls
case 120: houseid = 7; break; // booty bay, neutral case 120: houseid = 7; break; // booty bay, neutral
case 474: houseid = 7; break; // gadgetzan, neutral case 474: houseid = 7; break; // gadgetzan, neutral
case 534: houseid = 2; break; // Alliance Generic
case 855: houseid = 7; break; // everlook, neutral case 855: houseid = 7; break; // everlook, neutral
case 1604: houseid = 6; break; // b-elfs, case 1604: houseid = 6; break; // b-elfs,
case 1638: houseid = 2; break; // exodar, alliance
default: // for unknown case default: // for unknown case
{ {
FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId); FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId);

View file

@ -122,7 +122,7 @@ class AuctionHouseMgr
typedef UNORDERED_MAP<uint32, Item*> ItemMap; typedef UNORDERED_MAP<uint32, Item*> ItemMap;
AuctionHouseObject* GetAuctionsMap( uint32 factionTemplateId ); AuctionHouseObject* GetAuctionsMap(AuctionHouseEntry const* house);
Item* GetAItem(uint32 id) Item* GetAItem(uint32 id)
{ {
@ -140,6 +140,8 @@ class AuctionHouseMgr
void SendAuctionSuccessfulMail( AuctionEntry * auction ); void SendAuctionSuccessfulMail( AuctionEntry * auction );
void SendAuctionExpiredMail( AuctionEntry * auction ); void SendAuctionExpiredMail( AuctionEntry * auction );
static uint32 GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem); static uint32 GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem);
static uint32 GetAuctionHouseTeam(AuctionHouseEntry const* house);
static AuctionHouseEntry const* GetAuctionHouseEntry(uint32 factionTemplateId); static AuctionHouseEntry const* GetAuctionHouseEntry(uint32 factionTemplateId);
public: public:

View file

@ -700,7 +700,7 @@ void WorldSession::HandleSaveGuildEmblemOpcode(WorldPacket& recvPacket)
{ {
DEBUG_LOG("WORLD: Received MSG_SAVE_GUILD_EMBLEM"); DEBUG_LOG("WORLD: Received MSG_SAVE_GUILD_EMBLEM");
uint64 vendorGuid; ObjectGuid vendorGuid;
uint32 EmblemStyle, EmblemColor, BorderStyle, BorderColor, BackgroundColor; uint32 EmblemStyle, EmblemColor, BorderStyle, BorderColor, BackgroundColor;
recvPacket >> vendorGuid; recvPacket >> vendorGuid;
@ -711,7 +711,7 @@ void WorldSession::HandleSaveGuildEmblemOpcode(WorldPacket& recvPacket)
{ {
//"That's not an emblem vendor!" //"That's not an emblem vendor!"
SendSaveGuildEmblem(ERR_GUILDEMBLEM_INVALIDVENDOR); SendSaveGuildEmblem(ERR_GUILDEMBLEM_INVALIDVENDOR);
DEBUG_LOG("WORLD: HandleSaveGuildEmblemOpcode - Unit (GUID: %u) not found or you can't interact with him.", GUID_LOPART(vendorGuid)); DEBUG_LOG("WORLD: HandleSaveGuildEmblemOpcode - %s not found or you can't interact with him.", vendorGuid.GetString().c_str());
return; return;
} }

View file

@ -487,18 +487,22 @@ void WorldSession::HandlePageQuerySkippedOpcode( WorldPacket & recv_data )
void WorldSession::HandleSellItemOpcode( WorldPacket & recv_data ) void WorldSession::HandleSellItemOpcode( WorldPacket & recv_data )
{ {
DEBUG_LOG( "WORLD: Received CMSG_SELL_ITEM" ); DEBUG_LOG( "WORLD: Received CMSG_SELL_ITEM" );
uint64 vendorguid, itemguid;
ObjectGuid vendorGuid;
uint64 itemguid;
uint32 count; uint32 count;
recv_data >> vendorguid >> itemguid >> count; recv_data >> vendorGuid;
recv_data >> itemguid;
recv_data >> count;
if(!itemguid) if(!itemguid)
return; return;
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR); Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_VENDOR);
if (!pCreature) if (!pCreature)
{ {
DEBUG_LOG( "WORLD: HandleSellItemOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(vendorguid)) ); DEBUG_LOG("WORLD: HandleSellItemOpcode - %s not found or you can't interact with him.", vendorGuid.GetString().c_str());
_player->SendSellError( SELL_ERR_CANT_FIND_VENDOR, NULL, itemguid, 0); _player->SendSellError( SELL_ERR_CANT_FIND_VENDOR, NULL, itemguid, 0);
return; return;
} }
@ -596,15 +600,15 @@ void WorldSession::HandleSellItemOpcode( WorldPacket & recv_data )
void WorldSession::HandleBuybackItem(WorldPacket & recv_data) void WorldSession::HandleBuybackItem(WorldPacket & recv_data)
{ {
DEBUG_LOG( "WORLD: Received CMSG_BUYBACK_ITEM" ); DEBUG_LOG( "WORLD: Received CMSG_BUYBACK_ITEM" );
uint64 vendorguid; ObjectGuid vendorGuid;
uint32 slot; uint32 slot;
recv_data >> vendorguid >> slot; recv_data >> vendorGuid >> slot;
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR); Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_VENDOR);
if (!pCreature) if (!pCreature)
{ {
DEBUG_LOG( "WORLD: HandleBuybackItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(vendorguid)) ); DEBUG_LOG("WORLD: HandleBuybackItem - %s not found or you can't interact with him.", vendorGuid.GetString().c_str());
_player->SendSellError( SELL_ERR_CANT_FIND_VENDOR, NULL, 0, 0); _player->SendSellError( SELL_ERR_CANT_FIND_VENDOR, NULL, 0, 0);
return; return;
} }

View file

@ -12957,7 +12957,7 @@ void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 me
GetSession()->SendTabardVendorActivate(guid); GetSession()->SendTabardVendorActivate(guid);
break; break;
case GOSSIP_OPTION_AUCTIONEER: case GOSSIP_OPTION_AUCTIONEER:
GetSession()->SendAuctionHello(guid, ((Creature*)pSource)); GetSession()->SendAuctionHello(((Creature*)pSource));
break; break;
case GOSSIP_OPTION_SPIRITGUIDE: case GOSSIP_OPTION_SPIRITGUIDE:
PrepareGossipMenu(pSource); PrepareGossipMenu(pSource);

View file

@ -28,6 +28,7 @@
struct ItemPrototype; struct ItemPrototype;
struct AuctionEntry; struct AuctionEntry;
struct AuctionHouseEntry;
struct DeclinedName; struct DeclinedName;
class ObjectGuid; class ObjectGuid;
@ -263,12 +264,13 @@ class MANGOS_DLL_SPEC WorldSession
bool SendItemInfo( uint32 itemid, WorldPacket data ); bool SendItemInfo( uint32 itemid, WorldPacket data );
//auction //auction
void SendAuctionHello( uint64 guid, Creature * unit ); void SendAuctionHello(Creature * unit);
void SendAuctionCommandResult( uint32 auctionId, uint32 Action, uint32 ErrorCode, uint32 bidError = 0); 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 SendAuctionBidderNotification( uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template);
void SendAuctionOwnerNotification( AuctionEntry * auction ); void SendAuctionOwnerNotification( AuctionEntry * auction );
void SendAuctionOutbiddedMail( AuctionEntry * auction, uint32 newPrice ); void SendAuctionOutbiddedMail( AuctionEntry * auction, uint32 newPrice );
void SendAuctionCancelledToBidderMail( AuctionEntry* auction ); void SendAuctionCancelledToBidderMail( AuctionEntry* auction );
AuctionHouseEntry const* GetCheckedAuctionHouseForAuctioneer(ObjectGuid guid);
//Item Enchantment //Item Enchantment
void SendEnchantmentLog(uint64 Target, uint64 Caster,uint32 ItemID,uint32 SpellID); void SendEnchantmentLog(uint64 Target, uint64 Caster,uint32 ItemID,uint32 SpellID);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10249" #define REVISION_NR "10250"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__