This commit is contained in:
luis
2026-09-04 15:22:17 -03:00
parent 82439e1f89
commit 6b3f807127
+114 -114
View File
@@ -97,8 +97,8 @@ namespace
}
CollectionMgr::CollectionMgr(WorldSession* owner) : _owner(owner),
_appearances(std::make_unique<boost::dynamic_bitset<uint32>>()),
_transmogIllusions(std::make_unique<boost::dynamic_bitset<uint32>>())
_appearances(std::make_unique<boost::dynamic_bitset<uint32>>()),
_transmogIllusions(std::make_unique<boost::dynamic_bitset<uint32>>())
{
}
@@ -193,7 +193,7 @@ void CollectionMgr::ToyClearFanfare(uint32 itemId)
if (itr == _toys.end())
return;
itr->second &= ~ ToyFlags::HasFanfare;
itr->second &= ~ToyFlags::HasFanfare;
}
void CollectionMgr::OnItemAdded(Item* item)
@@ -481,7 +481,7 @@ struct DynamicBitsetBlockOutputIterator
using pointer = void;
using reference = void;
explicit DynamicBitsetBlockOutputIterator(OutputAction const& action) : _action(&action) { }
explicit DynamicBitsetBlockOutputIterator(OutputAction const& action) : _action(&action) {}
DynamicBitsetBlockOutputIterator& operator=(uint32 value)
{
@@ -501,9 +501,9 @@ void CollectionMgr::LoadItemAppearances()
{
Player* owner = _owner->GetPlayer();
boost::to_block_range(*_appearances, DynamicBitsetBlockOutputIterator([owner](uint32 blockValue)
{
owner->AddTransmogBlock(blockValue);
}));
{
owner->AddTransmogBlock(blockValue);
}));
for (auto const& [itemModifiedAppearanceId, _] : _temporaryAppearances)
owner->AddConditionalTransmog(itemModifiedAppearanceId);
@@ -567,43 +567,43 @@ void CollectionMgr::SaveAccountItemAppearances(LoginDatabaseTransaction trans)
{
uint16 blockIndex = 0;
boost::to_block_range(*_appearances, DynamicBitsetBlockOutputIterator([this, &blockIndex, trans = trans.get()](uint32 blockValue)
{
if (blockValue) // this table is only appended/bits are set (never cleared) so don't save empty blocks
{
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_BNET_ITEM_APPEARANCES);
stmt->setUInt32(0, _owner->GetBattlenetAccountId());
stmt->setUInt16(1, blockIndex);
stmt->setUInt32(2, blockValue);
trans->Append(stmt);
}
if (blockValue) // this table is only appended/bits are set (never cleared) so don't save empty blocks
{
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_BNET_ITEM_APPEARANCES);
stmt->setUInt32(0, _owner->GetBattlenetAccountId());
stmt->setUInt16(1, blockIndex);
stmt->setUInt32(2, blockValue);
trans->Append(stmt);
}
++blockIndex;
}));
++blockIndex;
}));
LoginDatabasePreparedStatement* stmt;
for (auto itr = _favoriteAppearances.begin(); itr != _favoriteAppearances.end();)
{
switch (itr->second)
{
case CollectionItemState::New:
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_BNET_ITEM_FAVORITE_APPEARANCE);
stmt->setUInt32(0, _owner->GetBattlenetAccountId());
stmt->setUInt32(1, itr->first);
trans->Append(stmt);
itr->second = CollectionItemState::Unchanged;
++itr;
break;
case CollectionItemState::Removed:
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_BNET_ITEM_FAVORITE_APPEARANCE);
stmt->setUInt32(0, _owner->GetBattlenetAccountId());
stmt->setUInt32(1, itr->first);
trans->Append(stmt);
itr = _favoriteAppearances.erase(itr);
break;
case CollectionItemState::Unchanged:
case CollectionItemState::Changed:
++itr;
break;
case CollectionItemState::New:
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_BNET_ITEM_FAVORITE_APPEARANCE);
stmt->setUInt32(0, _owner->GetBattlenetAccountId());
stmt->setUInt32(1, itr->first);
trans->Append(stmt);
itr->second = CollectionItemState::Unchanged;
++itr;
break;
case CollectionItemState::Removed:
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_BNET_ITEM_FAVORITE_APPEARANCE);
stmt->setUInt32(0, _owner->GetBattlenetAccountId());
stmt->setUInt32(1, itr->first);
trans->Append(stmt);
itr = _favoriteAppearances.erase(itr);
break;
case CollectionItemState::Unchanged:
case CollectionItemState::Changed:
++itr;
break;
}
}
}
@@ -697,46 +697,46 @@ bool CollectionMgr::CanAddAppearance(ItemModifiedAppearanceEntry const* itemModi
switch (itemTemplate->GetClass())
{
case ITEM_CLASS_WEAPON:
case ITEM_CLASS_WEAPON:
{
if (itemTemplate->GetSubClass() == ITEM_SUBCLASS_WEAPON_EXOTIC ||
itemTemplate->GetSubClass() == ITEM_SUBCLASS_WEAPON_EXOTIC2 ||
itemTemplate->GetSubClass() == ITEM_SUBCLASS_WEAPON_MISCELLANEOUS ||
itemTemplate->GetSubClass() == ITEM_SUBCLASS_WEAPON_THROWN ||
itemTemplate->GetSubClass() == ITEM_SUBCLASS_WEAPON_SPEAR ||
itemTemplate->GetSubClass() == ITEM_SUBCLASS_WEAPON_FISHING_POLE)
return false;
break;
}
case ITEM_CLASS_ARMOR:
{
switch (itemTemplate->GetInventoryType())
{
if (itemTemplate->GetSubClass() == ITEM_SUBCLASS_WEAPON_EXOTIC ||
itemTemplate->GetSubClass() == ITEM_SUBCLASS_WEAPON_EXOTIC2 ||
itemTemplate->GetSubClass() == ITEM_SUBCLASS_WEAPON_MISCELLANEOUS ||
itemTemplate->GetSubClass() == ITEM_SUBCLASS_WEAPON_THROWN ||
itemTemplate->GetSubClass() == ITEM_SUBCLASS_WEAPON_SPEAR ||
itemTemplate->GetSubClass() == ITEM_SUBCLASS_WEAPON_FISHING_POLE)
case INVTYPE_BODY:
case INVTYPE_SHIELD:
case INVTYPE_CLOAK:
case INVTYPE_TABARD:
case INVTYPE_HOLDABLE:
break;
case INVTYPE_HEAD:
case INVTYPE_SHOULDERS:
case INVTYPE_CHEST:
case INVTYPE_WAIST:
case INVTYPE_LEGS:
case INVTYPE_FEET:
case INVTYPE_WRISTS:
case INVTYPE_HANDS:
case INVTYPE_ROBE:
if (itemTemplate->GetSubClass() == ITEM_SUBCLASS_ARMOR_MISCELLANEOUS)
return false;
break;
}
case ITEM_CLASS_ARMOR:
{
switch (itemTemplate->GetInventoryType())
{
case INVTYPE_BODY:
case INVTYPE_SHIELD:
case INVTYPE_CLOAK:
case INVTYPE_TABARD:
case INVTYPE_HOLDABLE:
break;
case INVTYPE_HEAD:
case INVTYPE_SHOULDERS:
case INVTYPE_CHEST:
case INVTYPE_WAIST:
case INVTYPE_LEGS:
case INVTYPE_FEET:
case INVTYPE_WRISTS:
case INVTYPE_HANDS:
case INVTYPE_ROBE:
if (itemTemplate->GetSubClass() == ITEM_SUBCLASS_ARMOR_MISCELLANEOUS)
return false;
break;
default:
return false;
}
break;
}
default:
return false;
}
break;
}
default:
return false;
}
if (itemModifiedAppearance->ID < _appearances->size() && _appearances->test(itemModifiedAppearance->ID))
@@ -895,9 +895,9 @@ void CollectionMgr::LoadTransmogIllusions()
{
Player* owner = _owner->GetPlayer();
boost::to_block_range(*_transmogIllusions, DynamicBitsetBlockOutputIterator([owner](uint32 blockValue)
{
owner->AddIllusionBlock(blockValue);
}));
{
owner->AddIllusionBlock(blockValue);
}));
}
void CollectionMgr::LoadAccountTransmogIllusions(PreparedQueryResult knownTransmogIllusions)
@@ -946,17 +946,17 @@ void CollectionMgr::SaveAccountTransmogIllusions(LoginDatabaseTransaction trans)
uint16 blockIndex = 0;
boost::to_block_range(*_transmogIllusions, DynamicBitsetBlockOutputIterator([this, &blockIndex, trans = trans.get()](uint32 blockValue)
{
if (blockValue) // this table is only appended/bits are set (never cleared) so don't save empty blocks
{
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_BNET_TRANSMOG_ILLUSIONS);
stmt->setUInt32(0, _owner->GetBattlenetAccountId());
stmt->setUInt16(1, blockIndex);
stmt->setUInt32(2, blockValue);
trans->Append(stmt);
}
++blockIndex;
}));
if (blockValue) // this table is only appended/bits are set (never cleared) so don't save empty blocks
{
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_BNET_TRANSMOG_ILLUSIONS);
stmt->setUInt32(0, _owner->GetBattlenetAccountId());
stmt->setUInt16(1, blockIndex);
stmt->setUInt32(2, blockValue);
trans->Append(stmt);
}
++blockIndex;
}));
}
void CollectionMgr::AddTransmogIllusion(uint32 transmogIllusionId)
@@ -1079,36 +1079,36 @@ void CollectionMgr::SaveAccountWarbandScenes(LoginDatabaseTransaction trans)
auto& [warbandSceneId, data] = *itr;
switch (data.State)
{
case CollectionItemState::New:
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_BNET_WARBAND_SCENE);
stmt->setUInt32(0, _owner->GetBattlenetAccountId());
stmt->setUInt32(1, warbandSceneId);
stmt->setBool(2, data.Flags.HasFlag(WarbandSceneCollectionFlags::Favorite));
stmt->setBool(3, data.Flags.HasFlag(WarbandSceneCollectionFlags::HasFanfare));
trans->Append(stmt);
data.State = CollectionItemState::Unchanged;
++itr;
break;
case CollectionItemState::Changed:
stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_WARBAND_SCENE);
stmt->setBool(0, data.Flags.HasFlag(WarbandSceneCollectionFlags::Favorite));
stmt->setBool(1, data.Flags.HasFlag(WarbandSceneCollectionFlags::HasFanfare));
stmt->setUInt32(2, _owner->GetBattlenetAccountId());
stmt->setUInt32(3, warbandSceneId);
trans->Append(stmt);
data.State = CollectionItemState::Unchanged;
++itr;
break;
case CollectionItemState::Removed:
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_BNET_WARBAND_SCENE);
stmt->setUInt32(0, _owner->GetBattlenetAccountId());
stmt->setUInt32(1, warbandSceneId);
trans->Append(stmt);
itr = _warbandScenes.erase(itr);
break;
default:
++itr;
break;
case CollectionItemState::New:
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_BNET_WARBAND_SCENE);
stmt->setUInt32(0, _owner->GetBattlenetAccountId());
stmt->setUInt32(1, warbandSceneId);
stmt->setBool(2, data.Flags.HasFlag(WarbandSceneCollectionFlags::Favorite));
stmt->setBool(3, data.Flags.HasFlag(WarbandSceneCollectionFlags::HasFanfare));
trans->Append(stmt);
data.State = CollectionItemState::Unchanged;
++itr;
break;
case CollectionItemState::Changed:
stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_WARBAND_SCENE);
stmt->setBool(0, data.Flags.HasFlag(WarbandSceneCollectionFlags::Favorite));
stmt->setBool(1, data.Flags.HasFlag(WarbandSceneCollectionFlags::HasFanfare));
stmt->setUInt32(2, _owner->GetBattlenetAccountId());
stmt->setUInt32(3, warbandSceneId);
trans->Append(stmt);
data.State = CollectionItemState::Unchanged;
++itr;
break;
case CollectionItemState::Removed:
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_BNET_WARBAND_SCENE);
stmt->setUInt32(0, _owner->GetBattlenetAccountId());
stmt->setUInt32(1, warbandSceneId);
trans->Append(stmt);
itr = _warbandScenes.erase(itr);
break;
default:
++itr;
break;
}
}
}