mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-16 10:30:27 +00:00
feat(Core/Common): delete old Tokenizer (#10121)
This commit is contained in:
@@ -84,6 +84,8 @@
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#include "Tokenize.h"
|
||||
#include "StringConvert.h"
|
||||
|
||||
// TODO: this import is not necessary for compilation and marked as unused by the IDE
|
||||
// however, for some reasons removing it would cause a damn linking issue
|
||||
@@ -1204,33 +1206,68 @@ bool Player::BuildEnumData(PreparedQueryResult result, WorldPacket* data)
|
||||
*data << uint32(petLevel);
|
||||
*data << uint32(petFamily);
|
||||
|
||||
Tokenizer equipment(fields[22].GetString(), ' ');
|
||||
std::vector<std::string_view> equipment = Acore::Tokenize(fields[22].GetStringView(), ' ', false);
|
||||
for (uint8 slot = 0; slot < INVENTORY_SLOT_BAG_END; ++slot)
|
||||
{
|
||||
uint32 visualBase = slot * 2;
|
||||
uint32 itemId = GetUInt32ValueFromArray(equipment, visualBase);
|
||||
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId);
|
||||
uint32 const visualBase = slot * 2;
|
||||
Optional<uint32> itemId;
|
||||
|
||||
if (visualBase < equipment.size())
|
||||
{
|
||||
itemId = Acore::StringTo<uint32>(equipment[visualBase]);
|
||||
}
|
||||
|
||||
ItemTemplate const* proto = nullptr;
|
||||
if (itemId)
|
||||
{
|
||||
proto = sObjectMgr->GetItemTemplate(*itemId);
|
||||
}
|
||||
|
||||
if (!proto)
|
||||
{
|
||||
if (!itemId || *itemId)
|
||||
{
|
||||
FMT_LOG_WARN("entities.player.loading", "Player {} has invalid equipment '{}' in `equipmentcache` at index {}. Skipped.",
|
||||
guid.ToString(), (visualBase < equipment.size()) ? equipment[visualBase] : "<none>", visualBase);
|
||||
}
|
||||
|
||||
*data << uint32(0);
|
||||
*data << uint8(0);
|
||||
*data << uint32(0);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
SpellItemEnchantmentEntry const* enchant = nullptr;
|
||||
|
||||
uint32 enchants = GetUInt32ValueFromArray(equipment, visualBase + 1);
|
||||
Optional<uint32> enchants = {};
|
||||
if ((visualBase + 1) < equipment.size())
|
||||
{
|
||||
enchants = Acore::StringTo<uint32>(equipment[visualBase + 1]);
|
||||
}
|
||||
|
||||
if (!enchants)
|
||||
{
|
||||
FMT_LOG_WARN("entities.player.loading", "Player {} has invalid enchantment info '{}' in `equipmentcache` at index {}. Skipped.",
|
||||
guid.ToString(), ((visualBase + 1) < equipment.size()) ? equipment[visualBase + 1] : "<none>", visualBase + 1);
|
||||
|
||||
enchants = 0;
|
||||
}
|
||||
|
||||
for (uint8 enchantSlot = PERM_ENCHANTMENT_SLOT; enchantSlot <= TEMP_ENCHANTMENT_SLOT; ++enchantSlot)
|
||||
{
|
||||
// values stored in 2 uint16
|
||||
uint32 enchantId = 0x0000FFFF & (enchants >> enchantSlot * 16);
|
||||
uint32 enchantId = 0x0000FFFF & ((*enchants) >> enchantSlot * 16);
|
||||
if (!enchantId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId);
|
||||
if (enchant)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*data << uint32(proto->DisplayInfoID);
|
||||
|
||||
Reference in New Issue
Block a user