Bug - Fixed Mafia double-counts certain meat expenditures

zarqon

Well-known member
I have the following alias:

Code:
stashmeat => ash if (contains_text(visit_url("clan_stash.php?pwd&action=contribute&howmuch=%%"),"You contributed")) print(%%+" meat added to the stash."); else print("There was a problem adding meat to the Clan Coffer.","red");

Whenever I add meat to the stash using this command, mafia shows my meat decreasing twice, in rapid succession. Refreshing the charpane restores the correct meat value. I think once I actually showed negative meat!

Small bug, but a bug nonetheless. I seem to recall this also happened with sending meat in kmails when I sent them using visit_url().
 

slyz

Developer
I have seen 2x more meat than needed substracted when buying ailment ointment from Doc Galactic or other NPC stores, but the value was immediately corrected. I saw it show negative meat too.

I'll try to get a debug log today.
 

zarqon

Well-known member
Closeting meat seems to work fine:

> ash my_meat()

Returned: 29399

> closet put 100 meat

Placing meat into closet...
Requests complete.

> ash my_meat()

Returned: 29299

However, using the above posted alias, the problem still occurs:

> ash my_meat()

Returned: 143454

> stashmeat 100

100 meat added to the stash.
Returned: true

> ash my_meat()

Returned: 143254
 

roippi

Developer
So, using your alias, I am able to replicate this bug. But oddly, it only happens the first time I stash some meat; subsequent stashings are properly single-deducted for the most part; perhaps 1 in 20 are double-deducted. Still looking into that.

Amusingly, this testing uncovered a different bug: the responseText "you gain n Clan Karma" causes mafia to temporarily interpret that as gaining n MP. Mafia quickly corrects this when it subsequently parses the charpane.
 

Theraze

Active member
Mafia double-subtracts meat for certain urls

Originally reported here in connection with learning guild skills using the get_skill script. Bale mentioned that the same issue happens with mushroom plots and visit_url.
 

Veracity

Developer
Staff member
I cannot reproduce this for buying skills in the guild.

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
 

Veracity

Developer
Staff member
I cannot reproduce this for buying a mushroom plot.

In session tally:

Meat Gained: 0

In CLI:

> ashq visit_url( "knoll_mushrooms.php?action=buyplot" )

Buying a mushroom plot

In session tally:

Meat Gained: -5,000
 

Theraze

Active member
Well, I briefly (until the refresh all) had negative nine-hundred some meat. I'll try to do this with debugging on next time... this has happened for me every time I use the get_skill script, which just does the same visit_url that you did.
 

Bale

Minion
Bale mentioned that the same issue happens with mushroom plots and visit_url.
I cannot reproduce this for buying a mushroom plot.

Nobody can reproduce it with mushroom plots! That was fixed by r9736 many moons ago. I haven't encountered that problem since.

Theraze shouldn't have dragged up my comment from September. I didn't specifically point out that my problem was fixed by the revision, but it was marked fixed and I was happy, so there didn't seem a reason to point it out.
 

Theraze

Active member
Sorry, I mentioned it only because you'd mentioned it on the thread as another double-counted meat issue that, well:
Obviously this doesn't cause much trouble, but it's probably the same bug, so I'm throwing it out there.
Wasn't trying to cause trouble, just noticed it still happened for me today buying skills with 10365 this morning, and the bug thread on the parsing was closed when the other bug got fixed, so... posted my bug, which got merged into this semi-related fixed bug. :)
 

roippi

Developer
Original bug in OP is not fixed.

here's the output of a scriptlet that I wrote to test this. Basically uses visit_url to donate 4 meat to the clan stash, over and over.

Code:
	int loopcount = 0;
	int iterloops = 50;
	int meatbefore;
	int meatafter;
	while ( loopcount < iterloops ) {
		meatbefore = my_meat();
		if (contains_text(visit_url("clan_stash.php?pwd&action=contribute&howmuch=4"),"You contributed")) { 
		print("4 meat added to the stash."); }
		meatafter = my_meat();
		print("mafia thinks we contributed " + ( meatbefore - meatafter ) + " meat to the stash.");
		iterloops += 1;	}

Code:
> testmeat

You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 8 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.
You gain 2 Clan Karma
4 meat added to the stash.
mafia thinks we contributed 4 meat to the stash.

Notice that only the first one is doubled.
 

Theraze

Active member
Here's my debug log for buying armorcraftiness on a different character. My meat was indeed 2500 low and a refresh all brought it back, but I don't think you want an extra 889kb debug log with the refresh info, since all that shows is that the returned data was for 8325 meat, not 5825, what the GUI was displaying.
 

Attachments

  • DEBUG_20120202.txt
    384.7 KB · Views: 49

Veracity

Developer
Staff member
In your log, I see:

Processing result: Meat Gained: -2,500
You learned a new skill: Armorcraftiness

That is exactly what I expect to see. What did your session tally say on the "Meat gained:" row? I assume it said "-2,500"

I also see a Charpane refresh with 8,325 Meat in it.

So, I am confused. You talk about "what the GUI was displaying". Where, exactly is the "display" of the "GUI" that you are talking about?
 

Theraze

Active member
The "Meat:" below HP/MP and above Adv on the left side of the GUI window displayed 5825 after purchasing armorcraftiness when I had 10825 meat. I then ran a refresh all and the "Meat" display updated to show 8325, the correct amount.
 

Veracity

Developer
Staff member
OK, I see what happened. You did a visit_url, which executed the command in a GenericRequest. It works like this:

visit_url
--> GenericRequest.run()
--> GenericRequest.processResults() --> nothing
--> CharPaneRequest.run()
--> parse charpane and set meat
do an "external update"
--> GuildRequest decrements meat

I will change it to do this:

visit_url
--> GenericRequest.run()
--> GenericRequest.processResults()
----> do an "external update"
----> GuildRequest decrements meat
--> CharPaneRequest.run()
--> parse charpane and set meat

All that "external update" stuff used to be done automatically for a RelayRequest, and then only on demand for other requests -- AFTER the normal result processing happened and the CharPaneRequest was executed. Now, it will do it for any GenericRequest - and for any other request which does not override processResults.

This is a simple change with a potential wide impact. Let's see how it works. :)
 
Top