• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

CashIventory & Uniqueid

Newbie Spellweaver
Joined
Mar 7, 2011
Messages
62
Reaction score
0
Recently I created a topic, where Eric helped me solve my problem with my cashinventory. But now I have another problem ... when I transfer my item to the cash inventory, it returns me null.
I did a little analysis and noticed that the error starts here:

Code:
 IItem item = mi.findByCashId (cashId);

When it does this search, it returns me a null item, so would my findByCashId?

Code:
public IItem findByCashId(int cashId) {
	      for (IItem item : inventory.values()) {
	           if ((item.getPetId() > -1 ? item.getPetId() : item.getCashId()) == cashId)
	                return item;
	           }

	      return null;
	}

GetCashId function:
Code:
    @Override
       public int getCashId() {
	 if (cashId == 0)
	      cashId = new Random().nextInt(Integer.MAX_VALUE) + 1;
	 /* This is not really unique but the chance to have 2 items
	 * with the same Cash Id is so low that we just don't care.
	 */

	 return cashId;
	}

Is the getCashId function responsible for returning a value equal to the cashId generated by the client?
This is my question, or in this case I need to create a uniqueid system (same I saw in some sources)?

Code im CashOperation:

Code:
		int cashId = slea.readInt();
			slea.skip(4);
			MapleInventory mi = chr.getInventory(MapleInventoryType.getByType(slea.readByte()));
			IItem item = mi.findByCashId(cashId);

			if (item == null)
				return;

			cs.addToInventory(item);
			mi.removeSlot(item.getPosition());
			c.getSession().write(MaplePacketCreator.putIntoCashInventory(item, c.getAccID()));
 
Back
Top