Bug - Fixed historical_price gets confused with items with the same name

Cool12309

Member
Code:
> ash historical_price($item[8042])

Returned: 990

> ash mall_price($item[8042])

Returned: 0

> ash historical_price($item[8042])

Returned: 990

I am attempting to get the mall price for the spelunky rock (item ID 8042), but historical_price is changing that to the price of the old Crimbo rock (2108). mall_price doesn't seem to have that issue, for whatever reason.
 

lostcalpolydude

Developer
Staff member
> ash historical_price( $item[8042] )

Returned: 0

> ash historical_price( $item[2108] )

Returned: 990
I have no idea how to get what you're seeing. I see that mallprices.txt stores historical prices by itemid, and the internal array also uses itemid, so there shouldn't be any issue.
 

Bale

Minion
Something is definitely screwy. Check this out:

Code:
[COLOR="#808000"]> ash historical_price($item[8042])[/COLOR]

Returned: 0

[COLOR="#808000"]> ash mall_price($item[8042])[/COLOR]

Returned: 0

[COLOR="#808000"]> ash mall_price($item[2108])[/COLOR]

Searching for "rock"...
Search complete.
Returned: 999

[COLOR="#808000"]> ash mall_price($item[8042])[/COLOR]

Returned: 0

[COLOR="#808000"]> ash historical_price($item[8042])[/COLOR]

Returned: 999
 

lostcalpolydude

Developer
Staff member
So the issue is that the mall search is parsing item name rather than itemid (which seems to be available, though refactoring MallSearchRequest is likely nontrivial). The problem isn't with historical_price(), it's actually with mall_price() (and other mall-searching functions).
 

heeheehee

Developer
Staff member
For what it's worth, the item ID is available in the same part of the soup wherein we extract the item name in the first place. Example:
HTML:
<tr class="blackabove" id="item_3621"><td width=30 height=30 align=center valign=center><img style='vertical-align: middle' class=hand src='/images/itemimages/clawpair.gif' onclick='descitem(933179859)' alt="pair of twitching claws" title="pair of twitching claws"></td><td><b><a href="/mall.php?justitems=0&pudnuggler=%22pair+of+twitching+claws%22">pair of twitching claws</a>
 

lostcalpolydude

Developer
Staff member
I think we actually just use the search string that we submit rather than parsing the page for item names. I didn't look too closely at the code though.
 

Veracity

Developer
Staff member
Well, when we submit a MallSearchRequest, the processResults method calls searchMall. That looks at every item returned in the result and pulls out the itemId.

However, that is not the method that updates the historical price. I see the following in the run() method:

Code:
		// If an exact match, we can think about updating mall_price().
		if ( this.searchString != null && this.searchString.startsWith( "\"" ) )
		{
			String name = this.getFormField( "pudnuggler" );
			StoreManager.maybeUpdateMallPrice( AdventureResult.pseudoItem( name ), new ArrayList<PurchaseRequest>( results ) );
		}
Notice that it passes in an ArrayList of the results it got back - which are PurchaseRequests, which include the itemId.

It looks like StoreManager.maybeUpdateMallPrice is passed AdventureResult item - but the only thing it cares about is item.getItemId(). It also seems like it could get the itemId from the first PurchaseRequest it is given.

Or, perhaps, MallSearchRequest could do something like this:

Code:
		if ( this.searchString != null && this.results.size() > 0 && this.searchString.startsWith( "\"" ) )
		{
			AdventureResult item = this.results.get(0).getItem();
			StoreManager.maybeUpdateMallPrice( item, new ArrayList<PurchaseRequest>( this.results ) );
		}

instead of what I cited above.
 

Veracity

Developer
Staff member
With my patch:

Code:
[color=green]> ash historical_price($item[8042])[/color]

Returned: 0

[color=green]> ash mall_price($item[8042])[/color]

Returned: 0

[color=green]> ash mall_price($item[2108])[/color]

Searching for "rock"...
Search complete.
Returned: 999

[color=green]> ash mall_price($item[8042])[/color]

Returned: 0

[color=green]> ash historical_price($item[8042])[/color]

Returned: 0

[color=green]> ash historical_price($item[2108])[/color]

Returned: 999
Try revision 16253
 
Top