Bug - Fixed Learning a skill sometimes 'learns' twice

Theraze

Active member
Noticed this when clicking on the drink link on the steel margarita.
Visiting Azazel's Temple in Pandamonium
You acquire an item: steel margarita
You gain 5 Drunkenness
You learned a new skill: Liver of Steel
You learned a new skill: Liver of Steel

Guessing that something similar to this is also why learning a skill using visit_url subtracts the meat twice. If I run
visit_url("guild.php?action=buyskill&skillid=3");
as a Turtle Tamer, mafia subtracts 500 meat, not the 250 that Headbutt actually costs. Running refresh char after will fix this, but... still weird.
 

Bale

Minion
Related, but inconsequential example. Buying a mushroom plot via visit_url() deducts the meat twice. Briefly mafia believes that I cannot afford to plant a single mushroom. :)

Obviously this doesn't cause much trouble, but it's probably the same bug, so I'm throwing it out there.
 

Theraze

Active member
Wonder if some of these double meat deductions might be where mafia knows that certain actions cost meat and deducts them, and then deducts again when it parses the text of the loaded page. Not sure, but the thought just came to me and I figured I'd throw it out there as a potential fail-point.
 

roippi

Developer
"double meat deduction" would be a sweet band name.

Edit: okay, adding some content to my post. Though I know everyone enjoys my jokes.

StaticEntity.externalUpdate calls a bunch of parseResponse methods:

Code:
		else if ( location.startsWith( "cave.php" ) )
		{
			NemesisRequest.parseResponse( location, responseText );
		}

		else if ( location.startsWith( "charsheet.php" ) &&
			location.indexOf( "ajax=1" ) == -1 )
		{
			CharSheetRequest.parseStatus( responseText );
		}

etc. etc. At the bottom of externalUpdate, I see this:

Code:
		// You can learn a skill on many pages.
		StaticEntity.learnSkill( location, responseText );

		// Currently, required recipes can only be learned via using an
		// item, but that's probably not guaranteed to be true forever.
		// Update: you can now learn them from the April Shower
		StaticEntity.learnRecipe( responseText );

And then in learnSkill, it checks if you're using something from inventory:

Code:
// Don't parse skill acquisition via item use here, since
		// UseItemRequest will detect it.

		if ( location.startsWith( "inv_use.php" ) )
		{
			return;
		}

I suspect that the in-line use location doesn't start with inv_use.php? Or something along those lines.
 
Last edited:

roippi

Developer
I suspect that the in-line use location doesn't start with inv_use.php? Or something along those lines.

yep. The [drink] URL is http://127.0.0.1:60080/inv_booze.php?which=1&whichitem=2743&pwd=<snip>

Of course, that isn't limited to the in-line link added by the decorator; all [drink] links have a location of inv_booze.php. Likewise for steel stomach, the location would be inv_eat.php.
 

Theraze

Active member
inv_spleen for that one as well?

Which doesn't help the double meat deduction on visit_url for the guild, but fixing the steel organ would make a good start. :)
 

roippi

Developer
Spleen is just inv_use, so that one never got double-learned. I think the visit_url double bug is separate - marking this one fixed. I think hola may have an idea on what the other one is?

r9736
 

Veracity

Developer
Staff member
Guessing that something similar to this is also why learning a skill using visit_url subtracts the meat twice. If I run

visit_url("guild.php?action=buyskill&skillid=3");

as a Turtle Tamer, mafia subtracts 500 meat, not the 250 that Headbutt actually costs. Running refresh char after will fix this, but... still weird.
I cannot reproduce this.

In session tally:

Meat Gained: 0

In CLI:

> ashq visit_url( "guild.php?action=buyskill&skillid=9" )

You learned a new skill: Lasagna Bandages

In session tally:

Meat Gained: -1,000
 
Last edited:

Theraze

Active member
It's back to double learning from items again. Don't think it affects much, but...
Visiting Azazel's Temple in Pandamonium
You acquire an item: steel margarita
Drinking 1 steel margarita...
You gain 5 Drunkenness
You learned a new skill: Liver of Steel
You learned a new skill: Liver of Steel
Finished drinking 1 steel margarita.
 

GValko

Member
I had it happen to me w/ Liver just the other day. Using a skillbook doesn't seem to trigger it, so I can't reproduce it until I ascend.
 

Theraze

Active member
I'll try to get a debug log... not sure if I have anyone who hasn't gotten their liver again, but I'll keep my eye out...
 

Veracity

Developer
Staff member
Try revision 10382. If using the steel consumable redirects to inventory.php, then my recent change will learn the skill from that and the additional hardcoded learning of the skill is unnecessary. I'm sure that eating and drinking redirects. I am not so sure about spleen items.
 

Veracity

Developer
Staff member
Actually, experimentation with using spleen items makes me think that that one will NOT redirect. Revision 10383 therefor restores the code to learn that skill.

I am marking this fixed until somebody proves otherwise. :)
 

Theraze

Active member
Looks like food and drink items need it too, at least when used in-line.
Visiting Azazel's Temple in Pandamonium
You acquire an item: steel margarita
You gain 5 Drunkenness

> my_inebriety

Returned: 19

> inebriety_limit

Returned: 14
Debug log attached. Just to be clear, I clicked on this link in the relay browser, since I was doing this manually:
inv_booze.php?which=1&whichitem=2743&pwd&ajax=1
 

Attachments

  • DEBUG_20120203.txt
    9.6 KB · Views: 42

Veracity

Developer
Staff member
OK, I'm going to just restore it, then.

It would be helpful if you would explain what you did the first time when it "double learned", since you obviously did NOT do that one in the Relay Browser.
 

Theraze

Active member
I just did (in ash) use(1, $item). I'll try to get you a debug log from that next, but I'm temporarily out of characters... Hopefully another 3-4 days.
 
Top