Пример #1
0
int countAllItemsOfType(int objectId, bool includeSlots)
{
	CMemReader& reader = CMemReader::getMemReader();
	
	int contNr;
	int ret         = 0;
	int openContNr  = 0;
	int openContMax = reader.readOpenContainerCount();
	for (contNr = 0; contNr < reader.m_memMaxContainers && openContNr < openContMax; contNr++)
	{
		CTibiaContainer *cont = reader.readContainer(contNr);

		if (cont->flagOnOff)
		{
			openContNr++;
			ret += cont->countItemsOfType(objectId);
		}
		delete cont;
	}
	if (includeSlots)
	{
		
		for (int slotNr = 0; slotNr < 10; slotNr++)   // Loops through all 10 inventory slots(backwards)
		{
			CTibiaItem *item = reader.readItem(reader.m_memAddressSlotArrow + slotNr * reader.m_memLengthItem);
			if (item->objectId == objectId)
				ret += item->quantity ? item->quantity : 1;
			delete item;
		}
	}
	return ret;
}
Пример #2
0
int countAllItemsOfType(int objectId,bool includeSlots) {
	CMemReaderProxy reader;
	CMemConstData memConstData = reader.getMemConstData();
	int contNr;
	int ret=0;
	for (contNr = 0; contNr < memConstData.m_memMaxContainers; contNr++) {
		CTibiaContainer *cont = reader.readContainer(contNr);
		
		if (cont->flagOnOff)
			ret+=cont->countItemsOfType(objectId);
		delete cont;
	}
	if (includeSlots){
		CMemConstData memConstData = reader.getMemConstData();
		for (int slotNr = 0; slotNr < 10; slotNr++) { // Loops through all 10 inventory slots(backwards)
			CTibiaItem *item = reader.readItem(memConstData.m_memAddressSlotArrow-slotNr*memConstData.m_memLengthItem);
			if (item->objectId==objectId)
				ret += item->quantity?item->quantity:1;
			delete item;
		}
	}
	return ret;
}