• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

TrinityCore WotLK Eluna GetIcon() problem

Eleinder

BETA Tester
I have been trying to get an icon using the Eluna api to get the item icon. I have already done all the necessary changes in the core and compiled without problems. Just in case, let me put the code:

DataStores\DBCStructure.h

Code:
struct ItemDisplayInfoEntry
{
    uint32      ID;                                         // 0        m_ID
                                                            // 1        m_modelName[2]
                                                            // 2        m_modelTexture[2]
    char*       inventoryIcon;                  			// 3        m_inventoryIcon
                                                            // 4        m_geosetGroup[3]
                                                            // 5        m_flags
                                                            // 6        m_spellVisualID
                                                            // 7        m_groupSoundIndex
                                                            // 8        m_helmetGeosetVis[2]
                                                            // 9        m_texture[2]
                                                            // 10       m_itemVisual[8]
                                                            // 11       m_particleColorID
};

DataStores\DBCStores.h

I added:
Code:
DBCStorage <ItemDisplayInfoEntry> sItemDisplayInfoStore(ItemDisplayTemplateEntryfmt);

DataStores\DBCfmt.h

I added
Code:
char const ItemDisplayTemplateEntryfmt[] = "nxxxxsxxxxxxxxxxxxxxxxxxx";

DataStores\DBCStores.h

Code:
TC_GAME_API extern DBCStorage <ItemDisplayInfoEntry>         sItemDisplayInfoStore;

LuaEngine\ItemMethods.h

Code:
int GetIcon(Eluna* /*E*/, lua_State* L, Item* item)
	{
		std::ostringstream iconText;
		float w = Eluna::CHECKVAL<float >(L, 2);
		float h = Eluna::CHECKVAL<float >(L, 3);
		float x = Eluna::CHECKVAL<float >(L, 4,0);
		float y = Eluna::CHECKVAL<float >(L, 5,0);

		const ItemDisplayInfoEntry* dispInfo = sItemDisplayInfoStore.LookupEntry(item->GetTemplate()->DisplayInfoID);

		iconText << "Interface";
		if (dispInfo)
		{
			iconText << "/ICONS/" << dispInfo->inventoryIcon;
		}
		else
		{
			iconText << "/InventoryItems/WoWUnknownItem01";
		}
		//iconText << ":" << w << ":" << h << ":" << x << ":" << y << "|t";
		Eluna::Push(L, iconText.str());
		return 1;
	}

LuaEngine\GlobalMethods.h

Code:
int GetIcon(Eluna* /*E*/, lua_State* L)
	{
		Item* item = Eluna::CHECKOBJ<Item>(L, 1, false);
		const ItemDisplayInfoEntry* dispInfo;
        if (!item)
        {
			uint32 entry = Eluna::CHECKVAL<uint32 >(L, 1);
			const ItemTemplate* temp = eObjectMgr->GetItemTemplate(entry);
			dispInfo = sItemDisplayInfoStore.LookupEntry(temp->DisplayInfoID);
        }
		else
		{
			dispInfo = sItemDisplayInfoStore.LookupEntry(item->GetTemplate()->DisplayInfoID);
		}

		std::ostringstream iconText;
		
		float w = Eluna::CHECKVAL<float >(L, 2);
		float h = Eluna::CHECKVAL<float >(L, 3);
		float x = Eluna::CHECKVAL<float >(L, 4,0);
		float y = Eluna::CHECKVAL<float >(L, 5,0);

		iconText << "Interface";
		if (dispInfo)
		{
			iconText << "/ICONS/" << dispInfo->inventoryIcon;
		}
		else
		{
			iconText << "/InventoryItems/WoWUnknownItem01";
		}
		//iconText << ":" << w << ":" << h << ":" << x << ":" << y << "|t";
		Eluna::Push(L, iconText.str());
		return 1;
	}

LuaEngine\LuaFunctions.cpp

Code:
ElunaGlobal::ElunaRegister GlobalMethods[] =
{
      ......
      // Getters
      { "GetLuaEngine", &LuaGlobalFunctions::GetLuaEngine },
      { "GetIcon", &LuaGlobalFunctions::GetIcon },
      ......
}

Code:
ElunaRegister<Item> ItemMethods[] =
{
    // Getters
	{ "GetIcon", &LuaItem::GetIcon },                             // :GetIcon(high,width,x,y)
    { "GetOwnerGUID", &LuaItem::GetOwnerGUID },
     ........
}


I compiled and all was working properly.

Just to test I made a simple script in Eluna to return the icon path of the item. The part of the script which involves the icon capture and display is:

Code:
........ code without interest here.........
iconW1 = GetIcon(31174, 40, 40)
print(""..iconW1.."")

and the output:

Worldserver Icon Output


So my question is:

What's wrong here?
Maybe Eluna has changed something and the API is not working anymore?
Or maybe is my problem and I dont understand how its working.

Seems to ItemDisplayInfo.dbc cannot be read properly or something, but Im using a Blizz (non edited) one in Source/dbc

Thanks for reading.
Eleinder
 
Last edited:

Rochet2

Moderator / Eluna Dev
Maybe you missed this?
"LoadDBC(availableDbcLocales, bad_dbc_files, sItemDisplayInfoStore, dbcPath, "ItemDisplayInfo.dbc");"

The data doesnt magically load itself you know. :)

Btw you have a possible crash here if you give a nonexisting item entry to the function as temp is nullptr and you try to access DisplayInfoID from it.
const ItemTemplate* temp = eObjectMgr->GetItemTemplate(entry);
dispInfo = sItemDisplayInfoStore.LookupEntry(temp->DisplayInfoID);

aand tommy was first : |
 
Top