FindItemCount doesnt seem to be working correctly.

A forum for reporting bugs NOT related to custom plugins.

Moderator: MacroQuest Developers

Lacky
a hill giant
a hill giant
Posts: 174
Joined: Mon Nov 22, 2004 4:02 pm

FindItemCount doesnt seem to be working correctly.

Post by Lacky » Sun Dec 19, 2004 10:40 pm

When i do for instance:

/echo ${FindItemCount[Plains Pebble]}

It returns 1..... And I have a stack of 16 in one of my bags.
When I take one of them and put it in a seperate slot it returns 2.
So I am wrong, Sue me.

devNull
a ghoul
a ghoul
Posts: 121
Joined: Sat Mar 06, 2004 3:57 am

Post by devNull » Sun Dec 19, 2004 11:16 pm

Having a similar problem. It looks like items in containers (at least on characters, haven't tried bank, etc.) aren't being recognized correctly. Items put directly in InvSlots 22-29 seem to be ok. But, if they contain containers, then items inside are not being found.

I think problem is here

Code: Select all

/*0x1a0*/ struct _ITEMSPELLS Clicky; 
/*0x1a8*/ struct _ITEMSPELLS Proc; 
/*0x1b0*/ struct _ITEMSPELLS Worn; 
/*0x1a8*/ struct _ITEMSPELLS Focus; 
/*0x1c0*/ struct _ITEMSPELLS Scroll; 
- /*0x1c4*/ DWORD Unknown0x1c4;
/*0x1c8*/ DWORD Unknown0x1c8;
1a0 + 8 = 1a8
1a8 + 8 = 1b0
1b0 + 8 = 1b8 (typo in comment)
1b8 + 8 = 1c0
1c0 + 8 = 1c8 (Unknown0x1c4 not needed)

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Mon Dec 20, 2004 12:09 am

yeah, Ama made a small goof. I believe it's fixed in the latest zip.

Amadeus
The Maestro
The Maestro
Posts: 2036
Joined: Sat Jun 29, 2002 3:51 pm

Post by Amadeus » Mon Dec 20, 2004 1:48 am

It really irritates me when people post here without checking for a new zip file. Seriously, before you post, go to the Announcements section and make sure there isn't a new zip file posted since you last did a download.


Is there some new bug that I should know about, or is the struct thing the only thing at fault here?

Lacky
a hill giant
a hill giant
Posts: 174
Joined: Mon Nov 22, 2004 4:02 pm

Whoops

Post by Lacky » Mon Dec 20, 2004 2:43 am

Thought I had updated to the latest Downloaded this evening. Will retry.


Edit-
I updated to latest to make sure. It is still returning 1 when I have a full stack inside a container, will try right now with a stack outside a container.... And its also returning 1 for full stacks outside of a container...
It returns 2 when I have a stack of 19 and a single....

Just to make sure I am not being a moron I will redownload and re compile.

Edit #2-
Ok double checked and I was running the latest version(also started with clean install ie. deleted all but my macros and a new mqmake folder) still does it.

Is there any other info I can give you? I am still trying to fumble my way through learning how to do this. Thank you for your work and sorry for making you irritable Ama.
So I am wrong, Sue me.

insanitywiz
a hill giant
a hill giant
Posts: 250
Joined: Mon Jul 08, 2002 7:50 am

Post by insanitywiz » Mon Dec 20, 2004 9:45 am

Doesn't itemcount work based off of stackable? And isn't that still borked?

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Mon Dec 20, 2004 9:57 am

Looking into it

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Mon Dec 20, 2004 10:22 am

Stackable is in fact borked in ITEMINFO, guess I get to dive back into that struct I love so so much :)

edit: Looks like they may have just reversed the value of this field, making it NotStackable. Dirty fuckers. Doing a bit more testing before I post fixes.

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Mon Dec 20, 2004 11:15 am

WHAT A PAIN IN THE ASS!!!

Ok, in EQData.h, ITEMINFO struct should now have

Code: Select all

/*0x204*/ DWORD UnStackable; // Careful, packs/containers are marked stackable
MQ2DataTypes.cpp now reads

Code: Select all

	case Stack:
		if ((pItem->Item->Type != ITEMTYPE_NORMAL) || pItem->Item->UnStackable)
			Dest.DWord=1;
		else
			Dest.DWord=pItem->StackCount;
		Dest.Type=pIntType;
		return true;
and

Code: Select all

	case Stackable:
		Dest.DWord=(pItem->Item->Type!=ITEMTYPE_PACK && !pItem->Item->UnStackable);
		Dest.Type=pBoolType;
		return true;
then MQ2Data.cpp

Code: Select all

BOOL dataFindItemBankCount(PCHAR szIndex, MQ2TYPEVAR &Ret)
{
	if (!szIndex[0])
		return false;
	DWORD N=1;
	PCHAR pName=&szIndex[0];
	BOOL bExact=false;

	if (*pName=='=')
	{
		bExact=true;
		pName++;
	}
	CHAR Name[MAX_STRING]={0};
	CHAR Temp[MAX_STRING]={0};
	strlwr(strcpy(Name,pName));
	PCHARINFO pCharInfo=GetCharInfo();

	unsigned long Count=0;

	for (unsigned long nPack=0 ; nPack < NUM_BANK_SLOTS ; nPack++)
	{
		PCHARINFO pCharInfo=GetCharInfo();
		if (PCONTENTS pPack=pCharInfo->Bank[nPack])
		{
			if (bExact)
			{
				if (!stricmp(Name,pPack->Item->Name))
				{
                    if ((pPack->Item->Type != ITEMTYPE_NORMAL) ||
                        (!pPack->Item->UnStackable))
						Count++;
                    else
                        Count+=pPack->StackCount;
				}
			}
			else 
			{
				if(strstr(strlwr(strcpy(Temp,pPack->Item->Name)),Name))
				{
                    if ((pPack->Item->Type != ITEMTYPE_NORMAL) ||
                        (!pPack->Item->UnStackable))
						Count++;
                    else
                        Count+=pPack->StackCount;
				}
			}
			if (pPack->Item->Type==ITEMTYPE_PACK)
			{
				for (unsigned long nItem=0 ; nItem < pPack->Item->Slots ; nItem++)
				{
					if (PCONTENTS pItem=pPack->Contents[nItem])
					{
						if (bExact)
						{
							if (!stricmp(Name,pItem->Item->Name))
							{
                                if ((pItem->Item->Type != ITEMTYPE_NORMAL) ||
                                    (!pItem->Item->UnStackable))
								    Count++;
                                else
                                    Count+=pItem->StackCount;
							}
						}
						else 
						{
							if(strstr(strlwr(strcpy(Temp,pItem->Item->Name)),Name))
							{
                                if ((pItem->Item->Type != ITEMTYPE_NORMAL) ||
                                    (!pItem->Item->UnStackable))
								    Count++;
                                else
                                    Count+=pItem->StackCount;
							}
						}
					}
				}
			}
		}
	}

	Ret.DWord=Count;
	Ret.Type=pIntType;

	return true;
}
and

Code: Select all

BOOL dataFindItemCount(PCHAR szIndex, MQ2TYPEVAR &Ret)
{
	if (!szIndex[0])
		return false;
	DWORD N=1;
	PCHAR pName=&szIndex[0];
	BOOL bExact=false;

	if (*pName=='=')
	{
		bExact=true;
		pName++;
	}
	CHAR Name[MAX_STRING]={0};
	CHAR Temp[MAX_STRING]={0};
	strlwr(strcpy(Name,pName));
	PCHARINFO pCharInfo=GetCharInfo();

	unsigned long Count=0;

	for (unsigned long nSlot=0 ; nSlot < 0x1E ; nSlot++)
	{
		if (PCONTENTS pItem=pCharInfo->InventoryArray[nSlot])
		{
			if (bExact)
			{
				if (!stricmp(Name,pItem->Item->Name))
				{
                    if ((pItem->Item->Type != ITEMTYPE_NORMAL) ||
                        (!pItem->Item->UnStackable))
						Count++;
                    else
                        Count+=pItem->StackCount;
				}
			}
			else 
			{
				if(strstr(strlwr(strcpy(Temp,pItem->Item->Name)),Name))
				{

					if ((pItem->Item->Type != ITEMTYPE_NORMAL) ||
                        (!pItem->Item->UnStackable))
						Count++;
                    else
                        Count+=pItem->StackCount;
				}
			}
		}
	}

	for (unsigned long nPack=0 ; nPack < 8 ; nPack++)
	{
		if (PCONTENTS pPack=pCharInfo->Inventory.Pack[nPack])
		{
			if (pPack->Item->Type==ITEMTYPE_PACK)
			{
				for (unsigned long nItem=0 ; nItem < pPack->Item->Slots ; nItem++)
				{
					if (PCONTENTS pItem=pPack->Contents[nItem])
					{
						if (bExact)
						{
							if (!stricmp(Name,pItem->Item->Name))
							{
                                if ((pItem->Item->Type != ITEMTYPE_NORMAL) ||
                                    (!pItem->Item->UnStackable))
								    Count++;
                                else
                                    Count+=pItem->StackCount;
							}
						}
						else 
						{
							if(strstr(strlwr(strcpy(Temp,pItem->Item->Name)),Name))
							{
                                if ((pItem->Item->Type != ITEMTYPE_NORMAL) ||
                                    (!pItem->Item->UnStackable))
								    Count++;
                                else
                                    Count+=pItem->StackCount;
							}
						}
					}
				}
			}
		}
	}

	Ret.DWord=Count;
	Ret.Type=pIntType;

	return true;
}
lastly MQ2Commands.cpp in the code for the /identify command (near the end of the function) change to

Code: Select all

			if (!pCharInfo->Cursor->Item->UnStackable) {
				sprintf(szTmp,"Stack size = %d ",pCharInfo->Cursor->StackCount);
                strcat(szMsg,szTmp);
            }
Then beat your head against the keyboard 6 times, rinse, repeat.

Lacky
a hill giant
a hill giant
Posts: 174
Joined: Mon Nov 22, 2004 4:02 pm

Stackable

Post by Lacky » Mon Dec 20, 2004 11:15 am

Thank you Cr4zy. You rock the socks. I dont wanna go to work damnit!


PS I am sorry for any confusion, I was not aware that the stackable field is what let it count the number there.
So I am wrong, Sue me.

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Mon Dec 20, 2004 11:33 am

This still isn't quite right, but it's closer.

A_Druid_00
Macro Maker Extraordinaire
Posts: 2378
Joined: Tue Jul 13, 2004 12:45 pm
Location: Rolling on the Lawn Farting

Post by A_Druid_00 » Mon Dec 20, 2004 11:41 am

Cr4zyb4rd wrote:Ok, in EQData.h, ITEMINFO struct should now have

Code: Select all

/*0x204*/ DWORD UnStackable; // Careful, packs/containers are marked stackable
Just for clarification, does this replace Stackable in ITEMINFO, or is it just added to the union already there with MaxCharges?
[quote]<DigitalMocking> man, A_Druid_00 really does love those long ass if statements
<dont_know_at_all> i don't use his macro because i'm frightened of it[/quote]
[quote][12:45] <dont_know_at_all> never use a macro when you can really fuck up things with a plugin[/quote]

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Mon Dec 20, 2004 12:01 pm

It replaces the old Stackable (or you can leave it there, if you're so inclined)

This is far from perfect...Intricate Wooden Figurine (to name just one example) will be reported by MQ2 as a Stackable item (by ${Item[foo].Stackable}) with ZERO items in the stack ${Item[foo].Stack} Not ideal, but something you can at least test for. I'm pretty sure that Item.Stack and FindItemCount, etc will always work.

A_Druid_00
Macro Maker Extraordinaire
Posts: 2378
Joined: Tue Jul 13, 2004 12:45 pm
Location: Rolling on the Lawn Farting

Post by A_Druid_00 » Mon Dec 20, 2004 12:54 pm

One other thing I noticed while I was home on my lunch break is that item counting still returns the # of stacks and not the actual item count. So my bazaar dude is trying to buy 1000 stacks of celestial essences. It is recognizing that the items are stackable though, as I'm no longer buying them one at a time like I was yesterday.
[quote]<DigitalMocking> man, A_Druid_00 really does love those long ass if statements
<dont_know_at_all> i don't use his macro because i'm frightened of it[/quote]
[quote][12:45] <dont_know_at_all> never use a macro when you can really fuck up things with a plugin[/quote]

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Mon Dec 20, 2004 2:14 pm

With the code above to MQ2Data.cpp counting still broken? Geh, I swear I tested it.

At any rate, most of this is going away. We're going to just use the offset eqgame itself uses to test if an item's stackable. That fix will be posted soon.