Page 1 of 2

FindItemCount doesnt seem to be working correctly.

Posted: Sun Dec 19, 2004 10:40 pm
by Lacky
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.

Posted: Sun Dec 19, 2004 11:16 pm
by devNull
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)

Posted: Mon Dec 20, 2004 12:09 am
by Cr4zyb4rd
yeah, Ama made a small goof. I believe it's fixed in the latest zip.

Posted: Mon Dec 20, 2004 1:48 am
by Amadeus
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?

Whoops

Posted: Mon Dec 20, 2004 2:43 am
by Lacky
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.

Posted: Mon Dec 20, 2004 9:45 am
by insanitywiz
Doesn't itemcount work based off of stackable? And isn't that still borked?

Posted: Mon Dec 20, 2004 9:57 am
by Cr4zyb4rd
Looking into it

Posted: Mon Dec 20, 2004 10:22 am
by Cr4zyb4rd
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.

Posted: Mon Dec 20, 2004 11:15 am
by Cr4zyb4rd
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.

Stackable

Posted: Mon Dec 20, 2004 11:15 am
by Lacky
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.

Posted: Mon Dec 20, 2004 11:33 am
by Cr4zyb4rd
This still isn't quite right, but it's closer.

Posted: Mon Dec 20, 2004 11:41 am
by A_Druid_00
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?

Posted: Mon Dec 20, 2004 12:01 pm
by Cr4zyb4rd
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.

Posted: Mon Dec 20, 2004 12:54 pm
by A_Druid_00
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.

Posted: Mon Dec 20, 2004 2:14 pm
by Cr4zyb4rd
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.