Feature - Implemented charpane.php hit after item use

slyz

Developer
I seem to recall visiting the charpane after using something was part of the logic that detected new content
You're thinking of the "detect new adventuring locations" logic in CharpaneRequest.checkNewLocation(). We just need to add ApiRequest.checkNewLocation() and check the "link" JSON entry.
 

lostcalpolydude

Developer
Staff member
As far as skipping loading the charpane completely (including skipping api), there are weird cases like eating with both Glorious Lunch and milk active where KoL doesn't bother to mention that you lose milk. Anti-anti-antidotes say that they unpoison you without listing the effects they remove. I'm sure there are other cases that aren't worth adding special code to account for.

Doing an ApiRequest instead seems like it should be fine though.
 

Catch-22

Active member
Switching to ApiRequest is a step in the right direction. I still think that if KoLmafia can accurately predict the outcome of item/skill/uneffect use, we should forfeit the hit (I was never suggesting we remove the charpane hit for all cases).

If slyz ends up committing the ApiRequest patch, I guess this can be closed. The bug description would no longer accurate anyway. Given that Veracity has thought/tinkered with this issue on her own, I'd say more careful consideration wouldn't be a bad idea, although it sounds like refactoring the UseItemRequest should be done first.
 

Veracity

Developer
Staff member
I'm going to bump this, if only to remind us to consider switching to api.php rather than charpane.php for internally generated refreshes.
 

Veracity

Developer
Staff member
Revision 12585 now goes to api.php?what=status instead of charpane.php, when the response to an internal request says to load charpane.php.

This should be interesting.
 

Fluxxdog

Active member
Think I found a side effect. CLI from 12588:
Code:
Putting on eerie fetish...
Adding new location: Fernswarthy's Basement - adventure.php?snarfblat=1005
Equipment changed.
Putting on spark plug earring...
Adding new location: Fernswarthy's Basement - adventure.php?snarfblat=1005
Equipment changed.
Putting on hardened slime belt...
Adding new location: Fernswarthy's Basement - adventure.php?snarfblat=1005
Equipment changed.
Holding Rain-Doh green lantern...
Adding new location: Fernswarthy's Basement - adventure.php?snarfblat=1005
Equipment changed.
Putting on hardened slime pants...
Adding new location: Fernswarthy's Basement - adventure.php?snarfblat=1005
Equipment changed.
Here's my api.php?status=what&for=me for that:
Code:
{"playerid":"2014321","name":"Fluxxdog","hardcore":"0","ascensions":"40","path":"0","sign":"Mongoose","roninleft":"0","casual":"0","drunk":"19","full":"15","turnsplayed":"369551","familiar":"174","hp":"1110","mp":"63","meat":"1862299","adventures":"324","level":"33","rawmuscle":"1091694","rawmysticality":"493022","rawmoxie":"514118","basemuscle":"1044","basemysticality":"702","basemoxie":"717","familiarexp":400,"class":"1","lastadv":{"id":"1005","name":"Fernswarthy's Basement","link":"basement.php","container":"fernruin.php"},"title":"33","pvpfights":"100","maxhp":2956,"maxmp":1706,"spleen":"15","muscle":1686,"mysticality":1124,"moxie":1076,"famlevel":58,"locked":false,"daysthisrun":"52","equipment":{"hat":"4127","shirt":"3143","pants":"4128","weapon":"5340","offhand":"5559","acc1":"6515","acc2":"2513","acc3":"4129","container":"2611","familiarequip":"6150","fakehands":0,"cardsleeve":0},"stickers":[0,0,0],"eleronkey":"768f67ea7a71f2e13a09f9f131731a70","flag_config":{"lazyinventory":"1","compactfights":0,"poppvpsearch":0,"questtracker":0,"charpanepvp":"1","fffights":"1","compactchar":0,"noframesize":0,"fullnesscounter":"1","nodevdebug":0,"noquestnudge":"1","nocalendar":0,"alwaystag":"1","clanlogins":"1","quickskills":0,"hprestorers":"1","hidejacko":0,"anchorshelf":"1","showoutfit":"1","wowbar":"1","swapfam":0,"invimages":0,"showhandedness":0,"acclinks":"1","invadvancedsort":"1","powersort":"1","autodiscard":0,"unfamequip":"1","invclose":"1","sellstuffugly":"1","oneclickcraft":0,"dontscroll":0,"multisume":"1","threecolinv":"1","profanity":"1","tc_updatetitle":0,"tc_alwayswho":"1","tc_times":"1","tc_combineallpublic":0,"tc_eventsactive":0,"tc_hidebadges":0,"tc_colortabs":"1","tc_modifierkey":0,"tc_tabsonbottom":0,"chatversion":"1","aabosses":0,"compacteffects":"1","slimhpmpdisplay":"1","ignorezonewarnings":"1","whichpenpal":"1","compactmanuel":"1","hideefarrows":"1","autoattack":0,"topmenu":0},"recalledskills":1,"freedralph":1,"mcd":0,"pwd":"xxx","rollover":1378697400,"turnsthisrun":16213,"familiar_wellfed":0,"intrinsics":{"1f53c39b96204181351b24031c0c8c62":["Iron Palms","palmtree","1f53c39b96204181351b24031c0c8c62","709"]},"familiarpic":"miniadv6","pathname":"","effects":{"2d6d3ab04b40e1523aa9c716a04b3aab":["Leash of Linguini",588,"string","skill:3010","16"],"ac32e95f470a7e0999863fa0db58d808":["Empathy",33882,"empathy","skill:2009","50"],"c26a911b8ec2c57f7eef57f9ff5fdc24":["Polka of Plenty",16945,"plenty","skill:6006","63"],"63e73adb3ecfb0cbf544db435eeeaf00":["Fat Leon's Phat Loot Lyric",16960,"fatleons","skill:6010","67"],"e6b783e02fa92072ca81c7585912ba37":["Egg-headedness",2,"eggplain","","125"],"5c8d3b5b4a6d403f95f27f5d29528c59":["Rage of the Reindeer",574,"reindeer","skill:1015","131"],"2968e9397d3aa977b8cb3e9817ad8cdd":["Snarl of the Timberwolf",577,"wolfmask","skill:1020","222"],"e6c9baf78893e9329a337033947946a5":["Mo' Hobo",13,"hobohead",null,"1029"],"a7ddbf83786e02654337f5ee97e9844e":["Beastly Flavor",8,"beastflavor","item:5199",884],"1fdbb456f7aec1f73e9d936d999bc0ff":["Oily Flavor",8,"sprocket","item:5200",885],"181b95fae78466c869735b85dfebb6a9":["Greasy Flavor",8,"blankoutglob","item:5202",887],"68a5038ad5d6fefba6982173b7e84d57":["Rainbow Bright",8,"prismwad","item:3440",541],"0d0f83e49e119df106d45167bad6f9f3":["Frio Como Helado",9,"ma4buff1",null,1285]}}
Another problem I'm noticing is a slow down. I'm not sure if it's being caused by this change, but I decided to equip a mayfly bait neckalace, use a bottle of cyclops eyedrops, and use a Polka Pop.Attached is the debug log. Hopefully everything seems right, because with only 459 people online, I don't think lag would be an issue.
UPDATE: The above and debug log was with r12588. I rolled back and tested 12584 and 12585, the lag gets more pronounced the more I played with 12585 through the relay browser.
 

Attachments

  • DEBUG_20130908.zip
    222.6 KB · Views: 44
Last edited:

Darzil

Developer
Had a play in wireshark, looking at what html was being passed. Everything looked pretty slick at an underlying level, so not much server lag on building responses. Most of the time lag was my 200ms ping to server due to distance.

In terms of the communication, I looked at fights. In relay browser, clicking on adventure link, then script button to kill.

Old version was:
GET adventure.php
GET fight,php
GET charpane.php
POST fight.php
GET charpane.php

New version is :
GET adventure.php
GET fight.php
GET charpane.php
POST fight.php
POST api.php
GET charpane.php

This appears to be an extra hit, and only once per fight, compared to the two of charpane.php. Often the charpane did not get displayed, either remaining blank or showing a refresh link with "refresh after cutscene". Clicking refresh link doesn't help. Only ways I've found to refresh it was to click on refresh button in Mafia, or to fight again and win. If you hit a choice adventure and leave, it doesn't update it.

Choice adventure : (same on old and new)
GET adventure.php
GET choice.php
GET charpane.php
POST choice.php
GET charpane.php

Note - on all these, sometimes the first charpane.php request sometimes doesn't appear until after POST fight.php or POST choice.php. I guess they are in parallel threads.

Automating turns seems to work out ok, other than leaving the relay browser in a state where the charpane is blank.

Old version:
POST adventure.php
POST fight.php
GET charpane.php
POST fight.php
GET charpane.php

New version:
POST adventure.php
POST fight.php
POST api.php
POST fight.php
POST api.php

api.php is considerably smaller, so if we could rebuild charpane locally based on api.php and not request charpane.php at all, there may be performance advantages to gain. api.php is about twice as fast as charpane.php for me. Of course, for a slow computer closer to the server, that advantage may be reversed.
 

Bale

Minion
api.php is considerably smaller, so if we could rebuild charpane locally based on api.php and not request charpane.php at all, there may be performance advantages to gain. api.php is about twice as fast as charpane.php for me. Of course, for a slow computer closer to the server, that advantage may be reversed.

Sounds good in theory. In practice: extreme meter, Old Man's Bathtub Adventure, zombie horde, axel lotl...

And that's not even considering the fact Jick might purposefully change the charpane. If we're gonna do that, we'd be able to save even more time/server access by rebuilding inventory instead of hitting the actual inventory page.
 

Darzil

Developer
Sounds good in theory. In practice: extreme meter, Old Man's Bathtub Adventure, zombie horde, axel lotl...

And that's not even considering the fact Jick might purposefully change the charpane. If we're gonna do that, we'd be able to save even more time/server access by rebuilding inventory instead of hitting the actual inventory page.

I agree. The flip side is if we don't (and we probably shouldn't), then hitting api.php as well as charpane.php is adding server hits and slowing things down when in relay browser.
 

Veracity

Developer
Staff member
Old version was:
GET adventure.php
GET fight,php
GET charpane.php
POST fight.php
GET charpane.php

New version is :
GET adventure.php
GET fight.php
GET charpane.php
POST fight.php
POST api.php
GET charpane.php

This appears to be an extra hit, and only once per fight, compared to the two of charpane.php.
This is interesting. When we relay requests from the browser, we don't do any api.php stuff; we figure the browser will request charpane.php when KoL tells it to and we look at the response. When automating, we look at the response and, if KoL says get charpane.php, we get api.php instead.

When you hit the "script" button, you are automating, and we run the fight with calls to api.php - and then on the last round, we pass the final page down to the browser, which refreshes charpane.php.

That explains the extra call to api.php at the end of the fight. I'll have to see about not doing that in that case.

Often the charpane did not get displayed, either remaining blank or showing a refresh link with "refresh after cutscene". Clicking refresh link doesn't help. Only ways I've found to refresh it was to click on refresh button in Mafia, or to fight again and win. If you hit a choice adventure and leave, it doesn't update it.
Fixed in 12589. The browser requested a charpane and we got one back from KoL which - based on variables we saved from earlier charpane of api requests - looked to be obsolete, based on the "turnsthisrun" variable in the script part of the charpane. If it's obsolete, we return a 404 - page not found - for the charpane.

I think it's fine to not process the charpane, but I'm not sure passing back the 404 is right. I've seen blank charpanes in the past - presumably for this reason - and I can't even request a refresh, since there is no refresh link on the blank charpane!

In any case, the "obsolete" check fired because the new api parsing set the variables differently than the old charpane parsing, and revision 12589 fixes this.

Choice adventure : (same on old and new)
GET adventure.php
GET choice.php
GET charpane.php
POST choice.php
GET charpane.php

Note - on all these, sometimes the first charpane.php request sometimes doesn't appear until after POST fight.php or POST choice.php. I guess they are in parallel threads.
If these are relay requests, it's entirely up to the browser to decide when to submit the charpane request relative to following the redirect.

api.php is considerably smaller, so if we could rebuild charpane locally based on api.php and not request charpane.php at all, there may be performance advantages to gain. api.php is about twice as fast as charpane.php for me. Of course, for a slow computer closer to the server, that advantage may be reversed.
There is absolutely no way that we are going to hand-craft the charpane and serve it to the browser. Aside from the fact that there are way too many complicated KoL options about how to show the info on it, there are things that we cannot reconstruct - KoL's uparrows, for example, only appear on effects that KoL itself has remembered a "refresh" method for.
 

Veracity

Developer
Staff member
I agree. The flip side is if we don't (and we probably shouldn't), then hitting api.php as well as charpane.php is adding server hits and slowing things down when in relay browser.
As I explained, we hit api.php ONLY for automation. In the Relay Browser, we let the browser hit charpane.php.

The issue is when you request automation via the relay browser - the "script" button, for example - we add the extra api.php call at the end of automation when we are about to hand control back to the browser.

I am sure we can fix that.
 

Veracity

Developer
Staff member
The browser requested a charpane and we got one back from KoL which - based on variables we saved from earlier charpane of api requests - looked to be obsolete, based on the "turnsthisrun" variable in the script part of the charpane. If it's obsolete, we return a 404 - page not found - for the charpane.
Interestingly enough, the obsolete check attempts to return "304 Not Modified", but we morph it into a "404 Not Found". RelayRequest.java:

Code:
		if ( this.responseCode == 302 )
		{
			this.pseudoResponse( "HTTP/1.1 302 Found", this.redirectLocation );
		}
		else if ( this.responseCode != 200 )
		{
			this.sendNotFound();
		}
		else if ( wasAdventure )
		{
			RelayRequest.executeAfterAdventureScript();
		}
Considering the we generate a 304 ourself - GenericRequest.java:

Code:
			if ( !CharPaneRequest.processResults( responseTimestamp, this.responseText ) )
			{
				this.responseCode = 304;
			}
We should presumably handle that better.
 

Darzil

Developer
Yeah, looking much better in 12589, other than the script firing extra api.php, which is only around 0.4 seconds extra for me, but the previous patch was a lot slower. Refresh of character pane after automation fine, and automation will be faster with charpane.php replaced by api.php.
 

Darzil

Developer
Am getting carried away now, fun with wireshark, looked at what it did whilst making/consuming booze from Item Manager (because that's the only way I ever do it).

Drink 4 Neuromancer :

Network communications:

craft.php?action=craft&mode=cocktail&ajax=1&a=247&b=2726&qty=2
api.php
guild.php?action=stillbooze&whichitem=237&quantity=4
api.php
mall.php?category=allitems&consumable_byme=0&weaponattribute=3&wearable_byme=0&nolimits=0&max_price=0&sortresultsby=price&justitems=0&x_cheapest=10&pudnuggler=%22olive%22
store.php?whichitem=245&whichstore=h&buying=1&ajax=1&howmany=4
api.php
guild.php?action=stillfruit&whichitem=245&quantity=4
api.php
craft.php?action=craft&mode=cocktail&ajax=1&a=1553&b=1560&qty=4
api.php
craft.php?action=craft&mode=cocktail&ajax=1&a=1570&b=1007&qty=4
api.php
inv_booze.php?whichitem=1582&ajax=1&quantity=4
api.php

What these actions do :

Combine 2 fermenting powder + juniper berries
Distill bottle of gin
Get mall price on olive
Buy olive at store as cheaper
Distill olive
Combine bottle of Calcutta Emerald + cocktail onion
Combine gibson + coconut shell
Drink 4 Neuromancer

It strikes me that probably only purchase and drink actually change api.php result (plus the last two combines if not crafting adventure free)? So maybe the rest can be cut, improving performance further? I haven't tested with the old one, but if all those api.php's were charpane.php's, that'd certainly explain why this was MUCH faster to craft than in previous versions.

Probably not a trivial project though!
 

lostcalpolydude

Developer
Staff member
It makes sense for KoL to request a refresh after crafting since it can take turns, and I guess after the guild visit since the guild can give meat? I think trying to cut out refreshes that KoL requests will lead to issues somehow.
 

Veracity

Developer
Staff member
I agree. If KoL thinks you need a charpane request, the browser will do one - and, if we are automating, we will do an api request instead.

The trick is to not ADD an api request when there will be a charpane request coming from the browser as a result of the thing we just did, not eliminate refreshes that KoL tells us we need.
 

infopowerbroker

New member
Fixed in 12589. The browser requested a charpane and we got one back from KoL which - based on variables we saved from earlier charpane of api requests - looked to be obsolete, based on the "turnsthisrun" variable in the script part of the charpane. If it's obsolete, we return a 404 - page not found - for the charpane.

Thanks :D I was running into a bug for a few days where the CharPane would go blank after "Louvre It or Leave It" goal automation.

The most recent build fixed it (I had been using 12588, so I assume it was 12589 that did the trick).
 
Top