Bug - Fixed Failure to equip an item can result in inventory screwup

Veracity

Developer
Staff member
When you get an item in the Relay Browser, KoLmafia gives you a "use" link, which takes you to inv_equip.php. If you don't have the stats to equip it, the equip fails, but KoLmafia apparently tries to put it in the appropriate equipment slot (as seen on the Gear Changer) and removes it from inventory.

"refresh" calls api.php which fixes the Gear Changer.
"refresh inv" refreshes inventory and the item is seen to be back in inventory (where it never left).

My debug log shows this:

Code:
Requesting: http://www.kingdomofloathing.com/inv_equip.php?which=2&action=equip&whichitem=2069&pwd&ajax=1
Retrieved: http://www.kingdomofloathing.com/inv_equip.php?which=2&action=equip&whichitem=2069&pwd&ajax=1
ResponseText has 507 characters.
<script type="text/javascript">top.charpane.location.href="charpane.php";</script>
<script type="text/javascript">if (window.updateInv) updateInv([])</script>
<center><table  width=95%  cellspacing=0 cellpadding=0><tr><td style="color: white;" align=center bgcolor=blue><b>Results:</b></td></tr><tr><td style="padding: 5px; border: 1px solid blue;"><center><table><tr><td>You must have at least 70 base Moxie to equip that item.</td></tr></table></center></td></tr><tr><td height=4></td></tr></table></center>
Processing results...
Requesting: http://www.kingdomofloathing.com/charpane.php
Retrieved: http://www.kingdomofloathing.com/charpane.php
Note that if we had done that with an EquipmentRequest, we would not have even tried, since we new the stats were inadequate, but if we had tried, that javascript invocation of charpane.php would have induced us to get api.php.

I expect this is reproducible without a "use" link by doing visit_url( "inv_equip.php?which=2&action=equip&whichitem=2069&pwd&ajax=1" ).
I expect the bug is in EquipmentRequest.parseEquipmentChange().
 

Darzil

Developer
Doesn't even need a stats failure. You also get it when you have a two handed weapon and click on a use link for an offhand. Spooky little girl on Spaaaace quest is where I see it most often.
 

Veracity

Developer
Staff member
There was absolutely no checking for failure to equip or unequip in parseEquipment.

If the call to inv_equip came through an EquipmentRequest, processResults checked for failure and didn't try to change things if it didn't get a success message, but through the Relay Browser (or any other external reguest, such as via visit_url), parseEquipment was called to process the response without any such pre-testing.

Revision 13028 makes parseEquipment check that the equipment change actually happened before it moves equipment between inventory and equipped slots.
 
Top