Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 11.05.24 #350

Merged
merged 6 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sql/base/characters_database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3749,7 +3749,8 @@ INSERT INTO `updates` VALUES
('2024_08_26_00_characters.sql','68EEBE1D639D59B24F5121008C2D103CA67FFC9A','ARCHIVED','2024-08-26 00:49:08',0),
('2024_09_03_00_characters.sql','71ECC73A3F324EB64DA19B0CC4DF72A85E022BDC','ARCHIVED','2024-09-03 00:47:42',0),
('2024_09_23_00_characters.sql','D8491BCEE728F40D55D47E3A4BC5A5F083EBD02E','ARCHIVED','2024-09-23 22:48:10',0),
('2024_10_03_00_characters.sql','408249A6992999A36EB94089D184972E8E0767A3','RELEASED','2024-10-03 11:10:18',0);
('2024_10_03_00_characters.sql','408249A6992999A36EB94089D184972E8E0767A3','RELEASED','2024-10-03 11:10:18',0),
('2024_11_04_00_characters.sql','F7980E0CEE728FF866703693690F76F932E7C764','RELEASED','2024-11-04 17:14:03',0);
/*!40000 ALTER TABLE `updates` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down
1 change: 1 addition & 0 deletions sql/updates/characters/master/2024_11_04_00_characters.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELETE FROM `character_spell` WHERE `disabled`=1;
3 changes: 3 additions & 0 deletions sql/updates/world/master/2024_11_03_00_world.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DELETE FROM `spell_script_names` WHERE `ScriptName` = 'spell_warl_demonbolt';
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(264178, 'spell_warl_demonbolt');
80 changes: 49 additions & 31 deletions src/server/game/AuctionHouse/AuctionHouseMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,7 @@ void AuctionHouseMgr::LoadAuctions()
void AuctionHouseMgr::AddAItem(Item* item)
{
ASSERT(item);
ASSERT(_itemsByGuid.count(item->GetGUID()) == 0);
_itemsByGuid[item->GetGUID()] = item;
ASSERT_WITH_SIDE_EFFECTS(_itemsByGuid.emplace(item->GetGUID(), item).second);
}

bool AuctionHouseMgr::RemoveAItem(ObjectGuid itemGuid, bool deleteItem /*= false*/, CharacterDatabaseTransaction* trans /*= nullptr*/)
Expand Down Expand Up @@ -928,12 +927,10 @@ void AuctionHouseObject::AddAuction(CharacterDatabaseTransaction trans, AuctionP

if (ItemModifiedAppearanceEntry const* itemModifiedAppearance = auction.Items[0]->GetItemModifiedAppearance())
{
auto itr = std::find_if(bucket->ItemModifiedAppearanceId.begin(), bucket->ItemModifiedAppearanceId.end(),
[itemModifiedAppearance](std::pair<uint32, uint32> const& appearance) { return appearance.first == itemModifiedAppearance->ID; });
auto itr = std::ranges::find(bucket->ItemModifiedAppearanceId, itemModifiedAppearance->ID, &std::pair<uint32, uint32>::first);

if (itr == bucket->ItemModifiedAppearanceId.end())
itr = std::find_if(bucket->ItemModifiedAppearanceId.begin(), bucket->ItemModifiedAppearanceId.end(),
[](std::pair<uint32, uint32> const& appearance) { return appearance.first == 0; });
itr = std::ranges::find(bucket->ItemModifiedAppearanceId, 0u, &std::pair<uint32, uint32>::first);

if (itr != bucket->ItemModifiedAppearanceId.end())
{
Expand Down Expand Up @@ -964,7 +961,7 @@ void AuctionHouseObject::AddAuction(CharacterDatabaseTransaction trans, AuctionP
}
}

bucket->QualityMask |= static_cast<AuctionHouseFilterMask>(1 << (quality + 4));
bucket->QualityMask |= static_cast<AuctionHouseFilterMask>(AsUnderlyingType(AuctionHouseFilterMask::PoorQuality) << quality);
++bucket->QualityCounts[quality];

if (trans)
Expand Down Expand Up @@ -1004,16 +1001,17 @@ void AuctionHouseObject::AddAuction(CharacterDatabaseTransaction trans, AuctionP

WorldPackets::AuctionHouse::AuctionSortDef priceSort{ AuctionHouseSortOrder::Price, false };
AuctionPosting::Sorter insertSorter(LOCALE_enUS, std::span(&priceSort, 1));
bucket->Auctions.insert(std::lower_bound(bucket->Auctions.begin(), bucket->Auctions.end(), addedAuction, std::cref(insertSorter)), addedAuction);
bucket->Auctions.insert(std::ranges::lower_bound(bucket->Auctions, addedAuction, std::cref(insertSorter)), addedAuction);

sScriptMgr->OnAuctionAdd(this, addedAuction);
}

void AuctionHouseObject::RemoveAuction(CharacterDatabaseTransaction trans, AuctionPosting* auction, std::map<uint32, AuctionPosting>::iterator* auctionItr /*= nullptr*/)
std::map<uint32, AuctionPosting>::node_type AuctionHouseObject::RemoveAuction(CharacterDatabaseTransaction trans, AuctionPosting* auction,
std::map<uint32, AuctionPosting>::iterator* auctionItr /*= nullptr*/)
{
AuctionsBucketData* bucket = auction->Bucket;

bucket->Auctions.erase(std::remove(bucket->Auctions.begin(), bucket->Auctions.end(), auction), bucket->Auctions.end());
std::erase(bucket->Auctions, auction);
if (!bucket->Auctions.empty())
{
// update cache fields
Expand Down Expand Up @@ -1065,10 +1063,13 @@ void AuctionHouseObject::RemoveAuction(CharacterDatabaseTransaction trans, Aucti
}

if (!--bucket->QualityCounts[quality])
bucket->QualityMask &= static_cast<AuctionHouseFilterMask>(~(1 << (quality + 4)));
bucket->QualityMask &= static_cast<AuctionHouseFilterMask>(AsUnderlyingType(AuctionHouseFilterMask::PoorQuality) << quality);
}
else
{
auction->Bucket = nullptr;
_buckets.erase(bucket->Key);
}

CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_AUCTION);
stmt->setUInt32(0, auction->Id);
Expand All @@ -1084,9 +1085,9 @@ void AuctionHouseObject::RemoveAuction(CharacterDatabaseTransaction trans, Aucti
Trinity::Containers::MultimapErasePair(_playerBidderAuctions, bidder, auction->Id);

if (auctionItr)
*auctionItr = _itemsByAuctionId.erase(*auctionItr);
return _itemsByAuctionId.extract((*auctionItr)++);
else
_itemsByAuctionId.erase(auction->Id);
return _itemsByAuctionId.extract(auction->Id);
}

void AuctionHouseObject::Update()
Expand Down Expand Up @@ -1127,29 +1128,24 @@ void AuctionHouseObject::Update()
continue;
}

std::map<uint32, AuctionPosting>::node_type removedAuctionNode = RemoveAuction(trans, auction, &it);
auction = &removedAuctionNode.mapped();

///- Either cancel the auction if there was no bidder
if (auction->Bidder.IsEmpty())
{
SendAuctionExpired(auction, trans);
sScriptMgr->OnAuctionExpire(this, auction);

RemoveAuction(trans, auction, &it);
SendAuctionExpired(auction, trans);
}
///- Or perform the transaction
else
{
// Copy data before freeing AuctionPosting in auctionHouse->RemoveAuction
// Because auctionHouse->SendAuctionWon can unload items if bidder is offline
// we need to RemoveAuction before sending mails
AuctionPosting copy = *auction;
RemoveAuction(trans, auction, &it);

sScriptMgr->OnAuctionSuccessful(this, auction);
//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
SendAuctionSold(&copy, nullptr, trans);
SendAuctionWon(&copy, nullptr, trans);
sScriptMgr->OnAuctionSuccessful(this, auction);
SendAuctionSold(auction, nullptr, trans);
SendAuctionWon(auction, nullptr, trans);
}
}

Expand Down Expand Up @@ -1227,7 +1223,7 @@ void AuctionHouseObject::BuildListBuckets(WorldPackets::AuctionHouse::AuctionLis
{
if (ItemModifiedAppearanceEntry const* itemModifiedAppearance = sItemModifiedAppearanceStore.LookupEntry(bucketAppearance.first))
{
if (knownAppearanceIds.find(itemModifiedAppearance->ItemAppearanceID) == knownAppearanceIds.end())
if (!knownAppearanceIds.contains(itemModifiedAppearance->ItemAppearanceID))
{
hasAll = false;
break;
Expand Down Expand Up @@ -1281,6 +1277,13 @@ void AuctionHouseObject::BuildListBuckets(WorldPackets::AuctionHouse::AuctionLis
continue;
}

if (filters.HasFlag(AuctionHouseFilterMask::CurrentExpansionOnly))
{
ItemTemplate const* itemTemplate = ASSERT_NOTNULL(sObjectMgr->GetItemTemplate(bucket.first.ItemId));
if (itemTemplate->GetRequiredExpansion() != sWorld->getIntConfig(CONFIG_EXPANSION))
continue;
}

// TODO: this one needs to access loot history to know highest item level for every inventory type
//if (filters.HasFlag(AuctionHouseFilterMask::UpgradesOnly))
//{
Expand Down Expand Up @@ -1313,7 +1316,7 @@ void AuctionHouseObject::BuildListBuckets(WorldPackets::AuctionHouse::AuctionLis
}

AuctionsBucketData::Sorter sorter(player->GetSession()->GetSessionDbcLocale(), sorts);
std::sort(buckets.begin(), buckets.end(), std::cref(sorter));
std::ranges::sort(buckets, std::cref(sorter));

for (AuctionsBucketData const* resultBucket : buckets)
{
Expand All @@ -1335,7 +1338,7 @@ void AuctionHouseObject::BuildListBiddedItems(WorldPackets::AuctionHouse::Auctio
auctions.push_back(auction);

AuctionPosting::Sorter sorter(player->GetSession()->GetSessionDbcLocale(), sorts);
std::sort(auctions.begin(), auctions.end(), std::cref(sorter));
std::ranges::sort(auctions, std::cref(sorter));

for (AuctionPosting const* resultAuction : auctions)
{
Expand Down Expand Up @@ -1414,7 +1417,7 @@ void AuctionHouseObject::BuildListOwnedItems(WorldPackets::AuctionHouse::Auction
auctions.push_back(auction);

AuctionPosting::Sorter sorter(player->GetSession()->GetSessionDbcLocale(), sorts);
std::sort(auctions.begin(), auctions.end(), std::cref(sorter));
std::ranges::sort(auctions, std::cref(sorter));

for (AuctionPosting const* resultAuction : auctions)
{
Expand Down Expand Up @@ -1486,6 +1489,9 @@ CommodityQuote const* AuctionHouseObject::CreateCommodityQuote(Player const* pla
uint32 remainingQuantity = quantity;
for (AuctionPosting const* auction : bucketItr->second.Auctions)
{
if (auction->Owner == player->GetGUID() || auction->OwnerAccount == player->GetSession()->GetAccountGUID())
continue;

for (Item* auctionItem : auction->Items)
{
if (auctionItem->GetCount() >= remainingQuantity)
Expand Down Expand Up @@ -1545,6 +1551,9 @@ bool AuctionHouseObject::BuyCommodity(CharacterDatabaseTransaction trans, Player
for (auto auctionItr = bucketItr->second.Auctions.begin(); auctionItr != bucketItr->second.Auctions.end();)
{
AuctionPosting* auction = *auctionItr++;
if (auction->Owner == player->GetGUID() || auction->OwnerAccount == player->GetSession()->GetAccountGUID())
continue;

auctions.push_back(auction);
for (Item* auctionItem : auction->Items)
{
Expand Down Expand Up @@ -1611,6 +1620,9 @@ bool AuctionHouseObject::BuyCommodity(CharacterDatabaseTransaction trans, Player
for (auto auctionItr = bucketItr->second.Auctions.begin(); auctionItr != bucketItr->second.Auctions.end();)
{
AuctionPosting* auction = *auctionItr++;
if (auction->Owner == player->GetGUID() || auction->OwnerAccount == player->GetSession()->GetAccountGUID())
continue;

if (!uniqueSeller)
uniqueSeller = auction->Owner;
else if (*uniqueSeller != auction->Owner)
Expand Down Expand Up @@ -1823,7 +1835,10 @@ void AuctionHouseObject::SendAuctionWon(AuctionPosting const* auction, Player* b
{
// bidder doesn't exist, delete the item
for (Item* item : auction->Items)
sAuctionMgr->RemoveAItem(item->GetGUID(), true, &trans);
{
item->FSetState(ITEM_REMOVED);
item->SaveToDB(trans);
}
}
}

Expand Down Expand Up @@ -1879,7 +1894,10 @@ void AuctionHouseObject::SendAuctionExpired(AuctionPosting const* auction, Chara
{
// owner doesn't exist, delete the item
for (Item* item : auction->Items)
sAuctionMgr->RemoveAItem(item->GetGUID(), true, &trans);
{
item->FSetState(ITEM_REMOVED);
item->SaveToDB(trans);
}
}
}

Expand Down
30 changes: 16 additions & 14 deletions src/server/game/AuctionHouse/AuctionHouseMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,20 @@ constexpr std::size_t MAX_FAVORITE_AUCTIONS = 100;

enum class AuctionHouseFilterMask : uint32
{
None = 0x0,
UncollectedOnly = 0x1,
UsableOnly = 0x2,
UpgradesOnly = 0x4,
ExactMatch = 0x8,
PoorQuality = 0x10,
CommonQuality = 0x20,
UncommonQuality = 0x40,
RareQuality = 0x80,
EpicQuality = 0x100,
LegendaryQuality = 0x200,
ArtifactQuality = 0x400,
LegendaryCraftedItemOnly = 0x800,
None = 0x0000,
UncollectedOnly = 0x0002,
UsableOnly = 0x0004,
CurrentExpansionOnly = 0x0008,
UpgradesOnly = 0x0010,
ExactMatch = 0x0020,
PoorQuality = 0x0040,
CommonQuality = 0x0080,
UncommonQuality = 0x0100,
RareQuality = 0x0200,
EpicQuality = 0x0400,
LegendaryQuality = 0x0800,
ArtifactQuality = 0x1000,
LegendaryCraftedItemOnly = 0x2000,
};

DEFINE_ENUM_FLAG(AuctionHouseFilterMask);
Expand Down Expand Up @@ -291,7 +292,8 @@ class TC_GAME_API AuctionHouseObject

void AddAuction(CharacterDatabaseTransaction trans, AuctionPosting auction);

void RemoveAuction(CharacterDatabaseTransaction trans, AuctionPosting* auction, std::map<uint32, AuctionPosting>::iterator* auctionItr = nullptr);
std::map<uint32, AuctionPosting>::node_type RemoveAuction(CharacterDatabaseTransaction trans, AuctionPosting* auction,
std::map<uint32, AuctionPosting>::iterator* auctionItr = nullptr);

void Update();

Expand Down
8 changes: 4 additions & 4 deletions src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,12 @@ void AuctionBotBuyer::BuyEntry(AuctionPosting* auction, AuctionHouseObject* auct
// Copy data before freeing AuctionPosting in auctionHouse->RemoveAuction
// Because auctionHouse->SendAuctionWon can unload items if bidder is offline
// we need to RemoveAuction before sending mails
AuctionPosting copy = *auction;
auctionHouse->RemoveAuction(trans, auction);
std::map<uint32, AuctionPosting>::node_type removedAuctionNode = auctionHouse->RemoveAuction(trans, auction);
auction = &removedAuctionNode.mapped();

// Mails must be under transaction control too to prevent data loss
auctionHouse->SendAuctionSold(&copy, nullptr, trans);
auctionHouse->SendAuctionWon(&copy, nullptr, trans);
auctionHouse->SendAuctionSold(auction, nullptr, trans);
auctionHouse->SendAuctionWon(auction, nullptr, trans);

// Run SQLs
CharacterDatabase.CommitTransaction(trans);
Expand Down
20 changes: 10 additions & 10 deletions src/server/game/Entities/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2714,12 +2714,12 @@ void Player::RemoveTalent(TalentEntry const* talent)
if (!spellInfo)
return;

RemoveSpell(talent->SpellID, true);
RemoveSpell(talent->SpellID);

// search for spells that the talent teaches and unlearn them
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
if (spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL) && spellEffectInfo.TriggerSpell > 0)
RemoveSpell(spellEffectInfo.TriggerSpell, true);
RemoveSpell(spellEffectInfo.TriggerSpell);

if (talent->OverridesSpellID)
RemoveOverrideSpell(talent->OverridesSpellID, talent->SpellID);
Expand Down Expand Up @@ -27214,7 +27214,7 @@ void Player::RemovePvpTalent(PvpTalentEntry const* talent, uint8 activeTalentGro
if (!spellInfo)
return;

RemoveSpell(talent->SpellID, true);
RemoveSpell(talent->SpellID);

// Move this to toggle ?
if (talent->OverridesSpellID)
Expand All @@ -27235,15 +27235,15 @@ void Player::TogglePvpTalents(bool enable)
{
if (enable)
{
LearnSpell(pvpTalentInfo->SpellID, false);
LearnSpell(pvpTalentInfo->SpellID, true);
if (pvpTalentInfo->OverridesSpellID)
AddOverrideSpell(pvpTalentInfo->OverridesSpellID, pvpTalentInfo->SpellID);
}
else
{
if (pvpTalentInfo->OverridesSpellID)
RemoveOverrideSpell(pvpTalentInfo->OverridesSpellID, pvpTalentInfo->SpellID);
RemoveSpell(pvpTalentInfo->SpellID, true);
RemoveSpell(pvpTalentInfo->SpellID);
}
}
}
Expand Down Expand Up @@ -28226,12 +28226,12 @@ void Player::ActivateTalentGroup(ChrSpecializationEntry const* spec)
if (!spellInfo)
continue;

RemoveSpell(talentInfo->SpellID, true);
RemoveSpell(talentInfo->SpellID);

// search for spells that the talent teaches and unlearn them
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
if (spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL) && spellEffectInfo.TriggerSpell > 0)
RemoveSpell(spellEffectInfo.TriggerSpell, true);
RemoveSpell(spellEffectInfo.TriggerSpell);

if (talentInfo->OverridesSpellID)
RemoveOverrideSpell(talentInfo->OverridesSpellID, talentInfo->SpellID);
Expand All @@ -28247,12 +28247,12 @@ void Player::ActivateTalentGroup(ChrSpecializationEntry const* spec)
if (!spellInfo)
continue;

RemoveSpell(talentInfo->SpellID, true);
RemoveSpell(talentInfo->SpellID);

// search for spells that the talent teaches and unlearn them
for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects())
if (spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL) && spellEffectInfo.TriggerSpell > 0)
RemoveSpell(spellEffectInfo.TriggerSpell, true);
RemoveSpell(spellEffectInfo.TriggerSpell);

if (talentInfo->OverridesSpellID)
RemoveOverrideSpell(talentInfo->OverridesSpellID, talentInfo->SpellID);
Expand Down Expand Up @@ -30078,7 +30078,7 @@ void Player::RemoveSpecializationSpells()
for (size_t j = 0; j < specSpells->size(); ++j)
{
SpecializationSpellsEntry const* specSpell = (*specSpells)[j];
RemoveSpell(specSpell->SpellID, true);
RemoveSpell(specSpell->SpellID);
if (specSpell->OverridesSpellID)
RemoveOverrideSpell(specSpell->OverridesSpellID, specSpell->SpellID);
}
Expand Down
6 changes: 3 additions & 3 deletions src/server/game/Handlers/AuctionHouseHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,10 @@ void WorldSession::HandleAuctionPlaceBid(WorldPackets::AuctionHouse::AuctionPlac
if (canBuyout && placeBid.BidAmount == auction->BuyoutOrUnitPrice)
{
// buyout
auctionHouse->SendAuctionSold(auction, nullptr, trans);
auctionHouse->SendAuctionWon(auction, player, trans);
std::map<uint32, AuctionPosting>::node_type removedAuctionNode = auctionHouse->RemoveAuction(trans, auction);

auctionHouse->RemoveAuction(trans, auction);
auctionHouse->SendAuctionSold(&removedAuctionNode.mapped(), nullptr, trans);
auctionHouse->SendAuctionWon(&removedAuctionNode.mapped(), player, trans);
}
else
{
Expand Down
Loading
Loading