New Content - Implemented Recently expired effect list + familiar below effects generates debug logs

heeheehee

Developer
Staff member
The recent interface change that brought uparrows also added an interface option to display recently expired effects (default: 0).

Sample HTML of the table in question:
Code:
<table cellpadding=1 cellspacing=0><tr><td colspan='3' style='color:#666' align='center'><font size=2><b>Recently Expired Effects:</b></font></td></tr><tr><td></td><td valign='middle'><img src="http://images.kingdomofloathing.com/itemimages/buttrock.gif" width=30 height=30  onClick='eff("04bc18fe47f495a894774fa1bbb9713d");'></td><td valign=center><font size=2 color='#666'>Butt-Rock Hair (0)</font><br></td></tr><tr><td></td><td valign='middle'><img src="http://images.kingdomofloathing.com/itemimages/strboost.gif" width=30 height=30  onClick='eff("943ba3b11499412f041807f8a7835d75");'></td><td valign=center><font size=2 color='#666'>Go Get 'Em, Tiger! (0)</font><br></td></tr><tr><td></td><td valign='middle'><img src="http://images.kingdomofloathing.com/itemimages/beatenup.gif" width=30 height=30  onClick='eff("acf143c704afaf7504ac07375084f79e");'></td><td valign=center><font size=2 color='#666'>Beaten Up (0)</font><br></td></tr></table>

Debug log snippet:
Code:
Unexpected error, debug log printed.
class java.lang.StringIndexOutOfBoundsException: String index out of range: -96
java.lang.StringIndexOutOfBoundsException: String index out of range: -96
        at java.lang.String.substring(String.java:1911)
        at net.sourceforge.kolmafia.request.CharPaneRequest.extractEffect(CharPaneRequest.java:651)
        at net.sourceforge.kolmafia.request.CharPaneRequest.refreshEffects(CharPaneRequest.java:722)
        at net.sourceforge.kolmafia.request.CharPaneRequest.processResults(CharPaneRequest.java:211)
        at net.sourceforge.kolmafia.request.GenericRequest.processResponse(GenericRequest.java:2164)

CharPaneRequest.java:651 (with context):
Code:
                        int startIndex = responseText.indexOf( "<font size=2>", searchIndex ) + 13;
                        durationIndex = responseText.indexOf( "</font", startIndex );
                        durationIndex = responseText.lastIndexOf( "(", durationIndex ) + 1;
                        effectName = responseText.substring( startIndex, durationIndex - 1 ).trim();

I think CharPaneRequest.refreshEffect is matching the onClick of one of the expired effects, but extractEffect is only working with the text of the title, but that's just a guess.

(aside: I was not aware that lastIndexOf could return an index to indicate a position prior to the specified start index)
 

lostcalpolydude

Developer
Staff member
I've had that KoL feature enabled since it was released (currently set to 3 effects), though the effect of it has been hidden from using ChIT. I am not getting debug logs from having it enabled. I just disabled ChIT (by renaming it) and tried changing a bunch of charpane display settings and I could not get a debug log out of it.
 

heeheehee

Developer
Staff member
Hm. It seems to be the "Show familiar below effects" option in conjunction with "Display recently expired effects".
 

lostcalpolydude

Developer
Staff member
I can't figure out the issue. The table of Recently Expired Effects has identical HTML regardless of familiar placement. effectName should be set to a valid name if extractEffect() is applied to those effect listings, from what I can see.
 

Bale

Minion
I've had that KoL feature enabled since it was released (currently set to 3 effects), though the effect of it has been hidden from using ChIT. I am not getting debug logs from having it enabled. I just disabled ChIT (by renaming it) and tried changing a bunch of charpane display settings and I could not get a debug log out of it.

Huh. I didn't even notice the option exists 'till now. Why didn't someone tell me that ChIT was lacking support for something? It's low priority and my mind is on other things so I'll be a while, but at least I know now.
 

antimarty

Member
Display recently expired effects option in native interface causes errors

If I choose the native KoL interface option to display a non-zero number of recently expired effects, I get lots of "Unexpected error, debug log printed" messages using the relay browser. The important part of those looks like:

Code:
class java.lang.StringIndexOutOfBoundsException: String index out of range: -96
java.lang.StringIndexOutOfBoundsException: String index out of range: -96
	at java.lang.String.substring(Unknown Source)
	at net.sourceforge.kolmafia.request.CharPaneRequest.extractEffect(CharPaneRequest.java:651)
	at net.sourceforge.kolmafia.request.CharPaneRequest.refreshEffects(CharPaneRequest.java:722)
	at net.sourceforge.kolmafia.request.CharPaneRequest.processResults(CharPaneRequest.java:211)

Setting it to display zero expired effects makes the errors go away.

I'm using r12481 with Firefox on Windows.
 

wertperch

Member
String index out of range: -96 - continual

I have been getting this error almost continually, whether adventuring or not. To begin with I thought it might be associated with MafiaCHiT, but now I'm doubting that.

Any thoughts?

Code:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
         KoLmafia v16.0 r12515, Windows 7, Java 1.6.0_18
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Please note: do not post this log in the KoLmafia thread. If you
 would like the dev team to look at it, please write a bug report
 at kolmafia.us. Include specific information about what you were 
 doing when you made this and include the log as an attachment.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Timestamp: Thu Aug 29 22:15:46 PDT 2013
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Unexpected error, debug log printed.
class java.lang.StringIndexOutOfBoundsException: String index out of range: -96
java.lang.StringIndexOutOfBoundsException: String index out of range: -96
	at java.lang.String.substring(Unknown Source)
	at net.sourceforge.kolmafia.request.CharPaneRequest.extractEffect(CharPaneRequest.java:651)
	at net.sourceforge.kolmafia.request.CharPaneRequest.refreshEffects(CharPaneRequest.java:722)
	at net.sourceforge.kolmafia.request.CharPaneRequest.processResults(CharPaneRequest.java:211)
	at net.sourceforge.kolmafia.request.GenericRequest.processResponse(GenericRequest.java:2171)
	at net.sourceforge.kolmafia.request.GenericRequest.retrieveServerReply(GenericRequest.java:2136)
	at net.sourceforge.kolmafia.request.GenericRequest.retrieveServerReply(GenericRequest.java:1793)
	at net.sourceforge.kolmafia.request.GenericRequest.execute(GenericRequest.java:1479)
	at net.sourceforge.kolmafia.request.GenericRequest.run(GenericRequest.java:1372)
	at net.sourceforge.kolmafia.request.RelayRequest.run(RelayRequest.java:2072)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:222)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:185)
	at net.sourceforge.kolmafia.textui.RuntimeLibrary.visit_url(RuntimeLibrary.java:1876)
	at sun.reflect.GeneratedMethodAccessor99.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.sourceforge.kolmafia.textui.parsetree.LibraryFunction.execute(LibraryFunction.java:106)
	at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:154)
	at net.sourceforge.kolmafia.textui.parsetree.Variable.getValue(Variable.java:88)
	at net.sourceforge.kolmafia.textui.parsetree.VariableReference.execute(VariableReference.java:85)
	at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:105)
	at net.sourceforge.kolmafia.textui.parsetree.Variable.getValue(Variable.java:88)
	at net.sourceforge.kolmafia.textui.parsetree.VariableReference.execute(VariableReference.java:85)
	at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:105)
	at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:465)
	at net.sourceforge.kolmafia.textui.parsetree.UserDefinedFunction.execute(UserDefinedFunction.java:152)
	at net.sourceforge.kolmafia.textui.Interpreter.executeScope(Interpreter.java:375)
	at net.sourceforge.kolmafia.textui.Interpreter.execute(Interpreter.java:299)
	at net.sourceforge.kolmafia.textui.Interpreter.execute(Interpreter.java:292)
	at net.sourceforge.kolmafia.KoLmafiaASH.getClientHTML(KoLmafiaASH.java:109)
	at net.sourceforge.kolmafia.KoLmafiaASH.getClientHTML(KoLmafiaASH.java:91)
	at net.sourceforge.kolmafia.request.RelayRequest.run(RelayRequest.java:1955)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:222)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:185)
	at net.sourceforge.kolmafia.webui.RelayAgent.readServerResponse(RelayAgent.java:526)
	at net.sourceforge.kolmafia.webui.RelayAgent.performRelay(RelayAgent.java:158)
	at net.sourceforge.kolmafia.webui.RelayAgent.run(RelayAgent.java:131)
 

Veracity

Developer
Staff member
Merged, and I still have no idea why that combination of settings causes a problem.
We iterate over the char pane searching for effects. We extract them by looking what's between "<font size=2>" and "</font>". Expired effects actually have "<font size=2 color='#666'>" to start, which we do not recognize. If you have familiars below effects, the familiar name is inside "<font size=2>", however, and we try to parse it as an effect name. It takes the exception looking for the (xxx) duration backwards from the </font>.

I'll fix it.
 
Top