mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
fix: GetItemLink crash (#114)
This commit is contained in:
@@ -266,7 +266,9 @@ namespace LuaItem
|
|||||||
const ItemTemplate* temp = item->GetTemplate();
|
const ItemTemplate* temp = item->GetTemplate();
|
||||||
std::string name = temp->Name1;
|
std::string name = temp->Name1;
|
||||||
if (ItemLocale const* il = eObjectMgr->GetItemLocale(temp->ItemId))
|
if (ItemLocale const* il = eObjectMgr->GetItemLocale(temp->ItemId))
|
||||||
|
{
|
||||||
ObjectMgr::GetLocaleString(il->Name, static_cast<LocaleConstant>(locale), name);
|
ObjectMgr::GetLocaleString(il->Name, static_cast<LocaleConstant>(locale), name);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef CLASSIC
|
#ifndef CLASSIC
|
||||||
if (int32 itemRandPropId = item->GetItemRandomPropertyId())
|
if (int32 itemRandPropId = item->GetItemRandomPropertyId())
|
||||||
@@ -284,34 +286,43 @@ namespace LuaItem
|
|||||||
{
|
{
|
||||||
const ItemRandomSuffixEntry* itemRandEntry = sItemRandomSuffixStore.LookupEntry(-item->GetItemRandomPropertyId());
|
const ItemRandomSuffixEntry* itemRandEntry = sItemRandomSuffixStore.LookupEntry(-item->GetItemRandomPropertyId());
|
||||||
if (itemRandEntry)
|
if (itemRandEntry)
|
||||||
|
{
|
||||||
#if TRINITY || AZEROTHCORE
|
#if TRINITY || AZEROTHCORE
|
||||||
suffix = &itemRandEntry->Name;
|
suffix = &itemRandEntry->Name;
|
||||||
#else
|
#else
|
||||||
suffix = itemRandEntry->nameSuffix;
|
suffix = itemRandEntry->nameSuffix;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const ItemRandomPropertiesEntry* itemRandEntry = sItemRandomPropertiesStore.LookupEntry(item->GetItemRandomPropertyId());
|
const ItemRandomPropertiesEntry* itemRandEntry = sItemRandomPropertiesStore.LookupEntry(item->GetItemRandomPropertyId());
|
||||||
if (itemRandEntry)
|
if (itemRandEntry)
|
||||||
|
{
|
||||||
#if TRINITY || AZEROTHCORE
|
#if TRINITY || AZEROTHCORE
|
||||||
suffix = &itemRandEntry->Name;
|
suffix = &itemRandEntry->Name;
|
||||||
#else
|
#else
|
||||||
suffix = itemRandEntry->nameSuffix;
|
suffix = itemRandEntry->nameSuffix;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (suffix)
|
if (suffix)
|
||||||
{
|
{
|
||||||
name += ' ';
|
|
||||||
#if TRINITY || AZEROTHCORE
|
#if TRINITY || AZEROTHCORE
|
||||||
name += (*suffix)[(name != temp->Name1) ? locale : uint8(DEFAULT_LOCALE)];
|
const char* suffixName = (*suffix)[(name != temp->Name1) ? locale : uint8(DEFAULT_LOCALE)];
|
||||||
#else
|
#else
|
||||||
name += suffix[(name != temp->Name1) ? locale : uint8(DEFAULT_LOCALE)];
|
const char* suffixName = suffix[(name != temp->Name1) ? locale : uint8(DEFAULT_LOCALE)];
|
||||||
#endif
|
#endif
|
||||||
|
if (strcmp(suffixName, "") != 0)
|
||||||
|
{
|
||||||
|
name += ' ';
|
||||||
|
name += suffixName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Player* owner = item->GetOwner();
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "|c" << std::hex << ItemQualityColors[temp->Quality] << std::dec <<
|
oss << "|c" << std::hex << ItemQualityColors[temp->Quality] << std::dec <<
|
||||||
"|Hitem:" << temp->ItemId << ":" <<
|
"|Hitem:" << temp->ItemId << ":" <<
|
||||||
@@ -323,11 +334,7 @@ namespace LuaItem
|
|||||||
item->GetEnchantmentId(BONUS_ENCHANTMENT_SLOT) << ":" <<
|
item->GetEnchantmentId(BONUS_ENCHANTMENT_SLOT) << ":" <<
|
||||||
#endif
|
#endif
|
||||||
item->GetItemRandomPropertyId() << ":" << item->GetItemSuffixFactor() << ":" <<
|
item->GetItemRandomPropertyId() << ":" << item->GetItemSuffixFactor() << ":" <<
|
||||||
#ifdef TRINITY
|
(uint32)(owner ? owner->GetLevel() : 0) << "|h[" << name << "]|h|r";
|
||||||
(uint32)item->GetOwner()->GetLevel() << "|h[" << name << "]|h|r";
|
|
||||||
#else
|
|
||||||
(uint32)item->GetOwner()->getLevel() << "|h[" << name << "]|h|r";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Eluna::Push(L, oss.str());
|
Eluna::Push(L, oss.str());
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user