Bug - Fixed Mafia get ouf of sync with familiar items during aborted combat.

Crowther

Active member
What I did was aborted during combat, then forced mafia to try and take a familiar item from another familiar. KoLmafia does not notice the failure and gets out of sync with KoL.
Code:
> familiar hound

Putting silence the Hobo Monkey back into terrarium...
Taking Teh King the Jumpsuited Hound Dog out of terrarium...
plastic pumpkin bucket is better than (none). Switching items...
Stealing plastic pumpkin bucket from silence the Hobo Monkey...
Putting on plastic pumpkin bucket...
Equipment changed.

> equip snow suit

Putting on Snow Suit...
Equipment changed.

> familiar hobo

Putting Teh King the Jumpsuited Hound Dog back into terrarium...
Taking silence the Hobo Monkey out of terrarium...
plastic pumpkin bucket is better than (none). Switching items...
Putting on plastic pumpkin bucket...
Equipment changed.

> equip

Hat: Hodgman's porkpie hat
Weapon: bottle-rocket crossbow
Off-hand: Hodgman's metal detector
Shirt: flaming pink shirt
Pants: Hodgman's lobsterskin pants
Container: Camp Scout backpack

Acc. 1: Mr. Accessory Jr.
Acc. 2: Hodgman's lucky sock
Acc. 3: Hodgman's bow tie

Pet: Hobo Monkey (45 lbs)
Item: plastic pumpkin bucket

Sticker 1: scratch 'n' sniff wrestler sticker (0)
Sticker 2: scratch 'n' sniff wrestler sticker (0)
Sticker 3: scratch 'n' sniff wrestler sticker (0)

> ccs abort

CCS set to abort

> adv 1 top floor

Casting Leash of Linguini 1 times...
You acquire an effect: Leash of Linguini (duration: 10 Adventures)
Leash of Linguini was successfully cast.
Using 1 Knob Goblin pet-buffing spray...
You acquire an effect: Heavy Petting (duration: 10 Adventures)
Finished using 1 Knob Goblin pet-buffing spray.
Changing "Form of...Bird" to "Form of...Bird!" would get rid of this message (Universal_recovery.ash, line 580)
Changing "slime tube" to "The Slime Tube" would get rid of this message (Universal_recovery.ash, line 835)
Changing "Form of...Bird" to "Form of...Bird!" would get rid of this message (Universal_recovery.ash, line 886)
Changing "Form of...Bird" to "Form of...Bird!" would get rid of this message (Universal_recovery.ash, line 911)
Changing "Form of...Bird" to "Form of...Bird!" would get rid of this message (Universal_recovery.ash, line 968)
Changing "Form of...Bird" to "Form of...Bird!" would get rid of this message (Universal_recovery.ash, line 1126)
Changing "Form of...Bird" to "Form of...Bird!" would get rid of this message (Universal_recovery.ash, line 1171)
Changing "Form of...Bird" to "Form of...Bird!" would get rid of this message (Universal_recovery.ash, line 1207)
Changing "Knob Shaft (mining)" to "The Knob Shaft (Mining)" would get rid of this message (Universal_recovery.ash, line 1457)
Changing "Form of...Bird" to "Form of...Bird!" would get rid of this message (Universal_recovery.ash, line 1473)
Restoring HP! Currently at 9586 of 28342 HP, 152 of 41798 MP, current meat: 60995834 ... Target HP = 26925.
Purchasing magical mystery juice (19 @ 100)...
You acquire magical mystery juice (19)
You spent 1,900 Meat
Purchases complete.
Using 19 magical mystery juice...
You gain 3,476 Mojo Points
Finished using 19 magical mystery juice.
Using 1 scroll of drastic healing...
Finished using 1 scroll of drastic healing.

Visit to Beanstalk: The Castle in the Clouds in the Sky (Top Floor) in progress...

[726181] The Castle in the Clouds in the Sky (Top Floor)
Encounter: Steampunk Giant
Strategy: /home/scottk/.kolmafia/ccs/abort.ccs [default]
Round 0: WhimOrClutters wins initiative!
Round 1: WhimOrClutters executes a macro!
KoLmafia thinks it is round 2 but KoL thinks it is round 1
You're on your own, partner.
Click here to continue in the relay browser.


> equip snow suit

Stealing Snow Suit from Teh King the Jumpsuited Hound Dog...
KoLmafia thinks it is round 3 but KoL thinks it is round 1
Putting on Snow Suit...
Equipment changed.

> equip

Hat: Hodgman's porkpie hat
Weapon: bottle-rocket crossbow
Off-hand: Hodgman's metal detector
Shirt: flaming pink shirt
Pants: Hodgman's lobsterskin pants
Container: Camp Scout backpack

Acc. 1: Mr. Accessory Jr.
Acc. 2: Hodgman's lucky sock
Acc. 3: Hodgman's bow tie

Pet: Hobo Monkey (55 lbs)
Item: Snow Suit

Sticker 1: scratch 'n' sniff wrestler sticker (0)
Sticker 2: scratch 'n' sniff wrestler sticker (0)
Sticker 3: scratch 'n' sniff wrestler sticker (0)

> adv 1 top floor

Round 3: WhimOrClutters executes a macro!

[726181] The Castle in the Clouds in the Sky (Top Floor)
KoLmafia thinks it is round 4 but KoL thinks it is round 1
You're on your own, partner.
Click here to continue in the relay browser.


> ccs Destroy

CCS set to Destroy

> adv 1 top floor

Changing "boss bat's lair" to "The Boss Bat's Lair" would get rid of this message (zlib.ash, line 603)
Changing "can of ghuol-b-gone" to "can of Ghuol-B-Gone™" would get rid of this message (WHAM.ash, line 1172)
Changing "olfaction" to "Transcendent Olfaction" would get rid of this message (WHAM.ash, line 1199)
Changing "olfaction" to "Transcendent Olfaction" would get rid of this message (WHAM.ash, line 1203)
Changing "olfaction" to "Transcendent Olfaction" would get rid of this message (WHAM.ash, line 1207)
Changing "olfaction" to "Transcendent Olfaction" would get rid of this message (WHAM.ash, line 1211)
Changing "olfaction" to "Transcendent Olfaction" would get rid of this message (WHAM.ash, line 1215)
Changing "olfaction" to "Transcendent Olfaction" would get rid of this message (WHAM.ash, line 1219)
Changing "olfaction" to "Transcendent Olfaction" would get rid of this message (WHAM.ash, line 1223)
Changing "olfaction" to "Transcendent Olfaction" would get rid of this message (WHAM.ash, line 1227)
Changing "olfaction" to "Transcendent Olfaction" would get rid of this message (WHAM.ash, line 1231)
Changing "olfaction" to "Transcendent Olfaction" would get rid of this message (WHAM.ash, line 1243)
ATT: 173 (6% × 8.89, death in 28342)
DEF: 169 (97.73% × 49,652.84 (25), win in 1)
HP: 180, Value: 981.05 μ, RES: 0
WHAM: Monster HP is 180.0.
WHAM: Running SmartStasis
Profit per round: ActionProfitDamageOtherbase; Hobo Monkey (75μ)75μ--
Round 4: WhimOrClutters executes a macro!

[726181] The Castle in the Clouds in the Sky (Top Floor)
Round 4: WhimOrClutters casts FIRE ORANGE BOTTLE-ROCKET!
KoLmafia thinks it is round 5 but KoL thinks it is round 2
Round 5: steampunk giant takes 50 damage.
Adjusting familiar weight by -15 pounds
Round 5: WhimOrClutters executes a macro!
Round 5: WhimOrClutters uses the fat stacks of cash!
KoLmafia thinks it is round 6 but KoL thinks it is round 3
You gain 84 Meat.
Round 6: steampunk giant takes 28 damage.
WHAM: Starting evaluation and performing of attack
WHAM: We are going to 1-shot with attack with your weapon.
Round 6: WhimOrClutters executes a macro!
Round 6: WhimOrClutters attacks!
KoLmafia thinks it is round 7 but KoL thinks it is round 4
Round 7: steampunk giant takes 49729 damage.
Round 7: WhimOrClutters wins the fight!
You gain 11 hit points
You gain 9 Mojo Points
You gain 5 hit points
You gain 4 Mojo Points
You gain 360 Meat
You acquire an item: brass gear
You gain 9 Strengthliness
You gain 11 Enchantedness
You gain 29 Chutzpah
Adjusting familiar weight by -15 pounds
Look! You found 1 brass gear (55μ)!

> familiar lime

Putting silence the Hobo Monkey back into terrarium...
Taking Gorg the Sabre-Toothed Lime out of terrarium...
Requests complete.

> equip snow suit

Stealing Snow Suit from silence the Hobo Monkey...
Round 0: WhimOrClutters
Putting on Snow Suit...
You don't have the item you're trying to equip.
 

Veracity

Developer
Staff member
This is FamiliarRequest updating internal state when the request is submitted - registerRequest - rather than looking at the responseText after it is done. The current behavior is how all requests used to be coded, but we've been switching over to the new, robust, correct, method over the years.

We could also do something like this in FightRequest

Code:
	public static final boolean inFight()
	{
		return FightRequest.currentRound != 0;
	}

	public static final boolean abortIfInFight()
	{
		if (FightRequest.currentRound != 0 )
		{
			KoLmafia.updateDisplay( MafiaState.ERROR, "You are currently in battle." );
			return true;
		}
		return false;
	}
and add the following code to appropriate request run() methods:

Code:
		if ( FightRequest.abortIfInBattle() )
		{
			return;
		}
to not even try to submit a request if you are in the middle of a fight - which saves a server hit. We should do the former anyway, since scripts can use visit_url() to submit what they want, regardless of whether you are in battle - and a browser user can for any URL they want by typing in the location bar of the browser - which will submit it - and KoLmafia has to recognize what was submitted and what the response was.
 

Veracity

Developer
Staff member
Revision 12294 adds GenericRequest.abortIfInFightOrChoice() method. The run() method of EquipmentRequest (changing equipment), FamiliarRequest (changing familiars), UseItemRequest (using stuff), and CreateItemRequest (making stuff) calls this.

This will prevent KoLmafia from attempting those actions via GUI, CLI, or ASH - except via raw visit_url() calls.

That's good, but it doesn't address the whole problem reported.

- If you attempt to change equipment via the Gear Changer, the request will be aborted, but the Gear Changer will still show the supposed change until you refresh status (which goes to api.php and resets equipment). Note that KoLmafia knows that the equipment has not changed, so this is a display error in the GUI.
- If you do use visit_url() - or a raw URL in your browser - KoLmafia will still change your familiar equipment in its internal state when the URL is submitted, rather than checking for success after KoL rejects it.
- There are undoubtedly many other pages that you cannot visit during a fight or choice - mall searches & purchases, for example, I assume - which would also benefit from calling GenericRequest.abortIfInFightOrChoice().

But this will stop a lot of "getting out of sync" of the sort reported in the original bug report.
 

Veracity

Developer
Staff member
OK, revision 13329 changes FamiliarRequest to only update our data model when a successful response comes back from Familiar requests, rather than when we submit the URL.

The only thing that is not handled correctly is changing the familiar item for the current familiar from the terrarium page. That redirects to inv_equip.php with terrarium=1 which then redirects to familiar.php&action=message with the response. That was too tricky for me to handle, in the time I felt like devoting to this right now, but it won't affect this bug report, since you can't get to the terrarium while you are in the middle of a fight.

Therefore, I think this revision finishes the issue reported here.
 
Top