mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 08:28:32 +01:00
Auction house changes:
- Stop storing guid for auctioneer. - Store instead house ID - No separate ID for various houses. Only Horde, Alliance and Neutral. - Removed non-needed faction checks. - Use enum for auction house IDs NOTE: This will expire all current auctions and return item to player (or award to high bidder) in order to prepare database for the changes.
This commit is contained in:
@@ -190,7 +190,7 @@ DROP TABLE IF EXISTS `auctionhouse`;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `auctionhouse` (
|
||||
`id` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`auctioneerguid` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`houseid` tinyint(3) unsigned NOT NULL DEFAULT '7',
|
||||
`itemguid` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`itemowner` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`buyoutprice` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
@@ -2509,7 +2509,7 @@ CREATE TABLE `updates` (
|
||||
|
||||
LOCK TABLES `updates` WRITE;
|
||||
/*!40000 ALTER TABLE `updates` DISABLE KEYS */;
|
||||
INSERT INTO `updates` VALUES ('2015_03_20_00_characters.sql','B761760804EA73BD297F296C5C1919687DF7191C','ARCHIVED','2015-03-21 21:44:15',0),('2015_03_20_01_characters.sql','894F08B70449A5481FFAF394EE5571D7FC4D8A3A','ARCHIVED','2015-03-21 21:44:15',0),('2015_03_20_02_characters.sql','97D7BE0CAADC79F3F11B9FD296B8C6CD40FE593B','ARCHIVED','2015-03-21 21:44:51',0),('2015_06_26_00_characters_335.sql','C2CC6E50AFA1ACCBEBF77CC519AAEB09F3BBAEBC','ARCHIVED','2015-07-13 23:49:22',0);
|
||||
INSERT INTO `updates` VALUES ('2015_03_20_00_characters.sql','B761760804EA73BD297F296C5C1919687DF7191C','ARCHIVED','2015-03-21 21:44:15',0),('2015_03_20_01_characters.sql','894F08B70449A5481FFAF394EE5571D7FC4D8A3A','ARCHIVED','2015-03-21 21:44:15',0),('2015_03_20_02_characters.sql','97D7BE0CAADC79F3F11B9FD296B8C6CD40FE593B','ARCHIVED','2015-03-21 21:44:51',0),('2015_06_26_00_characters_335.sql','C2CC6E50AFA1ACCBEBF77CC519AAEB09F3BBAEBC','ARCHIVED','2015-07-13 23:49:22',0),('2015_09_28_00_characters_335.sql','F8682A431D50E54BDC4AC0E7DBED21AE8AAB6AD4','ARCHIVED','2015-09-28 21:00:00',0);
|
||||
/*!40000 ALTER TABLE `updates` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
|
||||
5
sql/updates/characters/2015_09_28_00_characters_335.sql
Normal file
5
sql/updates/characters/2015_09_28_00_characters_335.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
UPDATE `auctionhouse`
|
||||
SET `time` = 0, `auctioneerguid` = 7;
|
||||
|
||||
ALTER TABLE `auctionhouse`
|
||||
CHANGE COLUMN `auctioneerguid` `houseid` TINYINT(3) UNSIGNED NOT NULL DEFAULT '7' AFTER `id`;
|
||||
@@ -127,8 +127,8 @@ void CharacterDatabaseConnection::DoPrepareStatements()
|
||||
PrepareStatement(CHAR_SEL_CHARACTER_ACTIONS_SPEC, "SELECT button, action, type FROM character_action WHERE guid = ? AND spec = ? ORDER BY button", CONNECTION_SYNCH);
|
||||
PrepareStatement(CHAR_SEL_MAILITEMS, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, item_guid, itemEntry, owner_guid FROM mail_items mi JOIN item_instance ii ON mi.item_guid = ii.guid WHERE mail_id = ?", CONNECTION_SYNCH);
|
||||
PrepareStatement(CHAR_SEL_AUCTION_ITEMS, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, itemguid, itemEntry FROM auctionhouse ah JOIN item_instance ii ON ah.itemguid = ii.guid", CONNECTION_SYNCH);
|
||||
PrepareStatement(CHAR_SEL_AUCTIONS, "SELECT id, auctioneerguid, itemguid, itemEntry, count, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit FROM auctionhouse ah INNER JOIN item_instance ii ON ii.guid = ah.itemguid", CONNECTION_SYNCH);
|
||||
PrepareStatement(CHAR_INS_AUCTION, "INSERT INTO auctionhouse (id, auctioneerguid, itemguid, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_SEL_AUCTIONS, "SELECT id, houseid, itemguid, itemEntry, count, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit FROM auctionhouse ah INNER JOIN item_instance ii ON ii.guid = ah.itemguid", CONNECTION_SYNCH);
|
||||
PrepareStatement(CHAR_INS_AUCTION, "INSERT INTO auctionhouse (id, houseid, itemguid, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_DEL_AUCTION, "DELETE FROM auctionhouse WHERE id = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_UPD_AUCTION_BID, "UPDATE auctionhouse SET buyguid = ?, lastbid = ? WHERE id = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_INS_MAIL, "INSERT INTO mail(id, messageType, stationery, mailTemplateId, sender, receiver, subject, body, has_items, expire_time, deliver_time, money, cod, checked) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
|
||||
@@ -61,6 +61,19 @@ AuctionHouseObject* AuctionHouseMgr::GetAuctionsMap(uint32 factionTemplateId)
|
||||
return &mNeutralAuctions;
|
||||
}
|
||||
|
||||
AuctionHouseObject* AuctionHouseMgr::GetAuctionsMapByHouseId(uint8 auctionHouseId)
|
||||
{
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
|
||||
return &mNeutralAuctions;
|
||||
|
||||
switch(auctionHouseId)
|
||||
{
|
||||
case AUCTIONHOUSE_ALLIANCE : return &mAllianceAuctions;
|
||||
case AUCTIONHOUSE_HORDE : return &mHordeAuctions;
|
||||
default : return &mNeutralAuctions;
|
||||
}
|
||||
}
|
||||
|
||||
uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item* pItem, uint32 count)
|
||||
{
|
||||
uint32 MSV = pItem->GetTemplate()->SellPrice;
|
||||
@@ -342,7 +355,7 @@ void AuctionHouseMgr::LoadAuctions()
|
||||
continue;
|
||||
}
|
||||
|
||||
GetAuctionsMap(aItem->factionTemplateId)->AddAuction(aItem);
|
||||
GetAuctionsMapByHouseId(aItem->houseId)->AddAuction(aItem);
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
@@ -385,44 +398,32 @@ void AuctionHouseMgr::Update()
|
||||
|
||||
AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTemplateId)
|
||||
{
|
||||
uint32 houseid = 7; // goblin auction house
|
||||
uint32 houseid = AUCTIONHOUSE_NEUTRAL; // goblin auction house
|
||||
|
||||
if (!sWorld->getBoolConfig(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;
|
||||
}
|
||||
}
|
||||
FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId);
|
||||
if (!u_entry)
|
||||
houseid = AUCTIONHOUSE_NEUTRAL; // goblin auction house
|
||||
else if (u_entry->ourMask & FACTION_MASK_ALLIANCE)
|
||||
houseid = AUCTIONHOUSE_ALLIANCE; // human auction house
|
||||
else if (u_entry->ourMask & FACTION_MASK_HORDE)
|
||||
houseid = AUCTIONHOUSE_HORDE; // orc auction house
|
||||
else
|
||||
houseid = AUCTIONHOUSE_NEUTRAL; // goblin auction house
|
||||
}
|
||||
|
||||
return sAuctionHouseStore.LookupEntry(houseid);
|
||||
}
|
||||
|
||||
AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntryFromHouse(uint8 houseId)
|
||||
{
|
||||
return (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) ? sAuctionHouseStore.LookupEntry(AUCTIONHOUSE_NEUTRAL) : sAuctionHouseStore.LookupEntry(houseId);
|
||||
}
|
||||
|
||||
void AuctionHouseObject::AddAuction(AuctionEntry* auction)
|
||||
{
|
||||
ASSERT(auction);
|
||||
@@ -687,7 +688,7 @@ void AuctionEntry::SaveToDB(SQLTransaction& trans) const
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_AUCTION);
|
||||
stmt->setUInt32(0, Id);
|
||||
stmt->setUInt32(1, auctioneer);
|
||||
stmt->setUInt8(1, houseId);
|
||||
stmt->setUInt32(2, itemGUIDLow);
|
||||
stmt->setUInt32(3, owner);
|
||||
stmt->setUInt32(4, buyout);
|
||||
@@ -702,7 +703,7 @@ void AuctionEntry::SaveToDB(SQLTransaction& trans) const
|
||||
bool AuctionEntry::LoadFromDB(Field* fields)
|
||||
{
|
||||
Id = fields[0].GetUInt32();
|
||||
auctioneer = fields[1].GetUInt32();
|
||||
houseId = fields[1].GetUInt8();
|
||||
itemGUIDLow = fields[2].GetUInt32();
|
||||
itemEntry = fields[3].GetUInt32();
|
||||
itemCount = fields[4].GetUInt32();
|
||||
@@ -714,25 +715,10 @@ bool AuctionEntry::LoadFromDB(Field* fields)
|
||||
startbid = fields[10].GetUInt32();
|
||||
deposit = fields[11].GetUInt32();
|
||||
|
||||
CreatureData const* auctioneerData = sObjectMgr->GetCreatureData(auctioneer);
|
||||
if (!auctioneerData)
|
||||
{
|
||||
TC_LOG_ERROR("misc", "Auction %u has not a existing auctioneer (GUID : %u)", Id, auctioneer);
|
||||
return false;
|
||||
}
|
||||
|
||||
CreatureTemplate const* auctioneerInfo = sObjectMgr->GetCreatureTemplate(auctioneerData->id);
|
||||
if (!auctioneerInfo)
|
||||
{
|
||||
TC_LOG_ERROR("misc", "Auction %u has not a existing auctioneer (GUID : %u Entry: %u)", Id, auctioneer, auctioneerData->id);
|
||||
return false;
|
||||
}
|
||||
|
||||
factionTemplateId = auctioneerInfo->faction;
|
||||
auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(factionTemplateId);
|
||||
auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntryFromHouse(houseId);
|
||||
if (!auctionHouseEntry)
|
||||
{
|
||||
TC_LOG_ERROR("misc", "Auction %u has auctioneer (GUID : %u Entry: %u) with wrong faction %u", Id, auctioneer, auctioneerData->id, factionTemplateId);
|
||||
TC_LOG_ERROR("misc", "Auction %u has invalid house id %u", Id, houseId);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,10 +61,17 @@ enum MailAuctionAnswers
|
||||
AUCTION_SALE_PENDING = 6
|
||||
};
|
||||
|
||||
enum AuctionHouses
|
||||
{
|
||||
AUCTIONHOUSE_ALLIANCE = 2,
|
||||
AUCTIONHOUSE_HORDE = 6,
|
||||
AUCTIONHOUSE_NEUTRAL = 7
|
||||
};
|
||||
|
||||
struct AuctionEntry
|
||||
{
|
||||
uint32 Id;
|
||||
uint32 auctioneer; // creature low guid
|
||||
uint8 houseId;
|
||||
uint32 itemGUIDLow;
|
||||
uint32 itemEntry;
|
||||
uint32 itemCount;
|
||||
@@ -76,11 +83,9 @@ struct AuctionEntry
|
||||
uint32 bidder;
|
||||
uint32 deposit; //deposit can be calculated only when creating auction
|
||||
AuctionHouseEntry const* auctionHouseEntry; // in AuctionHouse.dbc
|
||||
uint32 factionTemplateId;
|
||||
|
||||
// helpers
|
||||
uint32 GetHouseId() const { return auctionHouseEntry->houseId; }
|
||||
uint32 GetHouseFaction() const { return auctionHouseEntry->faction; }
|
||||
uint8 GetHouseId() const { return houseId; }
|
||||
uint32 GetAuctionCut() const;
|
||||
uint32 GetAuctionOutBid() const;
|
||||
bool BuildAuctionInfo(WorldPacket & data) const;
|
||||
@@ -148,6 +153,7 @@ class AuctionHouseMgr
|
||||
typedef std::unordered_map<uint32, Item*> ItemMap;
|
||||
|
||||
AuctionHouseObject* GetAuctionsMap(uint32 factionTemplateId);
|
||||
AuctionHouseObject* GetAuctionsMapByHouseId(uint8 auctionHouseId);
|
||||
AuctionHouseObject* GetBidsMap(uint32 factionTemplateId);
|
||||
|
||||
Item* GetAItem(uint32 id)
|
||||
@@ -169,7 +175,7 @@ class AuctionHouseMgr
|
||||
|
||||
static uint32 GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item* pItem, uint32 count);
|
||||
static AuctionHouseEntry const* GetAuctionHouseEntry(uint32 factionTemplateId);
|
||||
|
||||
static AuctionHouseEntry const* GetAuctionHouseEntryFromHouse(uint8 houseId);
|
||||
public:
|
||||
|
||||
//load first auction items, because of check if item exists, when loading
|
||||
|
||||
@@ -906,15 +906,17 @@ void AuctionBotSeller::AddNewAuctions(SellerConfiguration& config)
|
||||
items = sAuctionBotConfig->GetItemPerCycleNormal();
|
||||
|
||||
uint32 houseid = 0;
|
||||
uint32 auctioneer = 0;
|
||||
switch (config.GetHouseType())
|
||||
{
|
||||
case AUCTION_HOUSE_ALLIANCE:
|
||||
houseid = 1; auctioneer = 79707; break;
|
||||
houseid = AUCTIONHOUSE_ALLIANCE;
|
||||
break;
|
||||
case AUCTION_HOUSE_HORDE:
|
||||
houseid = 6; auctioneer = 4656; break;
|
||||
houseid = AUCTIONHOUSE_HORDE;
|
||||
break;
|
||||
default:
|
||||
houseid = 7; auctioneer = 23442; break;
|
||||
houseid = AUCTIONHOUSE_NEUTRAL;
|
||||
break;
|
||||
}
|
||||
|
||||
AuctionHouseEntry const* ahEntry = sAuctionHouseStore.LookupEntry(houseid);
|
||||
@@ -995,7 +997,7 @@ void AuctionBotSeller::AddNewAuctions(SellerConfiguration& config)
|
||||
auctionEntry->itemEntry = item->GetEntry();
|
||||
auctionEntry->startbid = bidPrice;
|
||||
auctionEntry->buyout = buyoutPrice;
|
||||
auctionEntry->auctioneer = auctioneer;
|
||||
auctionEntry->houseId = houseid;
|
||||
auctionEntry->bidder = 0;
|
||||
auctionEntry->bid = 0;
|
||||
auctionEntry->deposit = sAuctionMgr->GetAuctionDeposit(ahEntry, etime, item, stackCount);
|
||||
|
||||
@@ -154,7 +154,6 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer, UNIT_NPC_FLAG_AUCTIONEER);
|
||||
if (!creature)
|
||||
{
|
||||
@@ -259,9 +258,26 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
|
||||
AuctionEntry* AH = new AuctionEntry();
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
|
||||
AH->auctioneer = 23442; ///@TODO - HARDCODED DB GUID, BAD BAD BAD
|
||||
AH->houseId = AUCTIONHOUSE_NEUTRAL;
|
||||
else
|
||||
AH->auctioneer = auctioneer.GetCounter();
|
||||
{
|
||||
CreatureData const* auctioneerData = sObjectMgr->GetCreatureData(creature->GetSpawnId());
|
||||
if (!auctioneerData)
|
||||
{
|
||||
TC_LOG_ERROR("misc", "Data for auctioneer not found (%s)", auctioneer.ToString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
CreatureTemplate const* auctioneerInfo = sObjectMgr->GetCreatureTemplate(auctioneerData->id);
|
||||
if (!auctioneerInfo)
|
||||
{
|
||||
TC_LOG_ERROR("misc", "Non existing auctioneer (%s)", auctioneer.ToString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
const AuctionHouseEntry* AHEntry = sAuctionMgr->GetAuctionHouseEntry(auctioneerInfo->faction);
|
||||
AH->houseId = AHEntry->houseId;
|
||||
}
|
||||
|
||||
// Required stack size of auction matches to current item stack size, just move item to auctionhouse
|
||||
if (itemsCount == 1 && item->GetCount() == count[0])
|
||||
@@ -285,8 +301,8 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
|
||||
AH->deposit = deposit;
|
||||
AH->auctionHouseEntry = auctionHouseEntry;
|
||||
|
||||
TC_LOG_INFO("network", "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) to auctioneer %u with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u",
|
||||
_player->GetName().c_str(), _player->GetGUID().GetCounter(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetGUID().GetCounter(), AH->auctioneer, item->GetCount(), bid, buyout, auctionTime, AH->GetHouseId());
|
||||
TC_LOG_INFO("network", "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u",
|
||||
_player->GetName().c_str(), _player->GetGUID().GetCounter(), item->GetTemplate()->Name1.c_str(), item->GetEntry(), item->GetGUID().GetCounter(), item->GetCount(), bid, buyout, auctionTime, AH->GetHouseId());
|
||||
sAuctionMgr->AddAItem(item);
|
||||
auctionHouse->AddAuction(AH);
|
||||
|
||||
@@ -333,8 +349,8 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
|
||||
AH->deposit = deposit;
|
||||
AH->auctionHouseEntry = auctionHouseEntry;
|
||||
|
||||
TC_LOG_INFO("network", "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) to auctioneer %u with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u",
|
||||
_player->GetName().c_str(), _player->GetGUID().GetCounter(), newItem->GetTemplate()->Name1.c_str(), newItem->GetEntry(), newItem->GetGUID().GetCounter(), AH->auctioneer, newItem->GetCount(), bid, buyout, auctionTime, AH->GetHouseId());
|
||||
TC_LOG_INFO("network", "CMSG_AUCTION_SELL_ITEM: Player %s (guid %d) is selling item %s entry %u (guid %d) with count %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u",
|
||||
_player->GetName().c_str(), _player->GetGUID().GetCounter(), newItem->GetTemplate()->Name1.c_str(), newItem->GetEntry(), newItem->GetGUID().GetCounter(), newItem->GetCount(), bid, buyout, auctionTime, AH->GetHouseId());
|
||||
sAuctionMgr->AddAItem(newItem);
|
||||
auctionHouse->AddAuction(AH);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user