From 37cd8599d6c49c3afd987ab85e72b7af49e6af49 Mon Sep 17 00:00:00 2001 From: Axel Cocat Date: Sun, 2 Apr 2023 19:13:55 +0200 Subject: [PATCH 1/2] fix: fix GetItemLink crash and name --- src/LuaEngine/ItemMethods.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/LuaEngine/ItemMethods.h b/src/LuaEngine/ItemMethods.h index 336dcd6229..016815de20 100644 --- a/src/LuaEngine/ItemMethods.h +++ b/src/LuaEngine/ItemMethods.h @@ -265,8 +265,10 @@ namespace LuaItem const ItemTemplate* temp = item->GetTemplate(); 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(locale), name); + }*/ #ifndef CLASSIC if (int32 itemRandPropId = item->GetItemRandomPropertyId()) @@ -302,16 +304,18 @@ namespace LuaItem } if (suffix) { - name += ' '; #if TRINITY || AZEROTHCORE - name += (*suffix)[(name != temp->Name1) ? locale : uint8(DEFAULT_LOCALE)]; + const char* suffixName = (*suffix)[(name != temp->Name1) ? locale : uint8(DEFAULT_LOCALE)]; #else - name += suffix[(name != temp->Name1) ? locale : uint8(DEFAULT_LOCALE)]; + const char* suffixName = suffix[(name != temp->Name1) ? locale : uint8(DEFAULT_LOCALE)]; #endif + name += ' '; + name += suffixName; } } #endif + Player* owner = item->GetOwner(); std::ostringstream oss; oss << "|c" << std::hex << ItemQualityColors[temp->Quality] << std::dec << "|Hitem:" << temp->ItemId << ":" << @@ -323,11 +327,7 @@ namespace LuaItem item->GetEnchantmentId(BONUS_ENCHANTMENT_SLOT) << ":" << #endif item->GetItemRandomPropertyId() << ":" << item->GetItemSuffixFactor() << ":" << -#ifdef TRINITY - (uint32)item->GetOwner()->GetLevel() << "|h[" << name << "]|h|r"; -#else - (uint32)item->GetOwner()->getLevel() << "|h[" << name << "]|h|r"; -#endif + (uint32)(owner ? owner->GetLevel() : 0) << "|h[" << name << "]|h|r"; Eluna::Push(L, oss.str()); return 1; From a62e35bb349b68eb81ab31c99b009a642451d0fb Mon Sep 17 00:00:00 2001 From: Axel Cocat Date: Sun, 2 Apr 2023 21:43:20 +0200 Subject: [PATCH 2/2] uncomment locale --- src/LuaEngine/ItemMethods.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/LuaEngine/ItemMethods.h b/src/LuaEngine/ItemMethods.h index 016815de20..cdafc7e8a0 100644 --- a/src/LuaEngine/ItemMethods.h +++ b/src/LuaEngine/ItemMethods.h @@ -265,10 +265,10 @@ namespace LuaItem const ItemTemplate* temp = item->GetTemplate(); 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(locale), name); - }*/ + } #ifndef CLASSIC if (int32 itemRandPropId = item->GetItemRandomPropertyId()) @@ -286,21 +286,25 @@ namespace LuaItem { const ItemRandomSuffixEntry* itemRandEntry = sItemRandomSuffixStore.LookupEntry(-item->GetItemRandomPropertyId()); if (itemRandEntry) + { #if TRINITY || AZEROTHCORE suffix = &itemRandEntry->Name; #else suffix = itemRandEntry->nameSuffix; #endif + } } else { const ItemRandomPropertiesEntry* itemRandEntry = sItemRandomPropertiesStore.LookupEntry(item->GetItemRandomPropertyId()); if (itemRandEntry) + { #if TRINITY || AZEROTHCORE suffix = &itemRandEntry->Name; #else suffix = itemRandEntry->nameSuffix; #endif + } } if (suffix) { @@ -309,8 +313,11 @@ namespace LuaItem #else const char* suffixName = suffix[(name != temp->Name1) ? locale : uint8(DEFAULT_LOCALE)]; #endif - name += ' '; - name += suffixName; + if (strcmp(suffixName, "") != 0) + { + name += ' '; + name += suffixName; + } } } #endif