Bug - Fixed Jabanero Pepper obtained from Mall not Hermit ?

roippi

Developer
Two major issues with your patch:

1) It adds a bunch of useless server hits. Putting

Code:
int mallPrice = StoreManager.getMallPrice( item, 7.0f );

where you did means that every item that gets to that point in retrieveItem will have its mall price retrieved. There's no reason to do it there since you could have just put it at the end of the if() statement. Java uses short-circuiting Boolean operations so putting it there will protect it from being run on non-hermit items.

retrieveItem gets called a LOT so you have to be extra vigilant about not doing bad things there even when making small changes.

2) Your Travoltan math is bad.

Code:
	public static int currentWorthlessItemCost()
	{			
		AdventureResult trousers = new AdventureResult(ItemPool.TRAVOLTAN_TROUSERS, 0);
		int travoltanModifier = KoLConstants.inventory.contains( trousers) ? 95 : 100;
		int x = InventoryManager.getStarterItemCount();
		return (int) Math.ceil( 12.5 *(travoltanModifier/100)* ( 17 - x ) );
	}

In java, this-

Code:
int x = 95;
int y = 100;

return (x/y);

returns 0.
 
Thanks!

Amazingly, in my day job, I never use anything other than integers.... Sadly... So I didn't trigger on that. (Yes, I knew it.. but unused info goes stale :)

As for the other, yeah I am still learning the structure of Mafia... I appreciate the feedback.

This patch, should handle the discount properly... ( I stepped through it.)

It is also uses short circuiting to have the mall check happen only when dealing with mall items.
 

Attachments

  • notint.patch
    2 KB · Views: 21
Top