Bug - Fixed hiddenCityLayout not being updated when redirected to a fight

slyz

Developer
Here is some gCLI output from my current run, obtained while I was adventuring in the Relay Browser, to follow up on a previous report:
Code:
> get hiddenCityLayout

EEWAE00000000000000000000

[603] Hidden City (Square 6)
Encounter: pygmy assault squad
Round 0: slyz wins initiative!
Round 1: slyz casts ENTANGLING NOODLES!
KoLmafia thinks it is round 3 but KoL thinks it is round 2

> get hiddenCityLayout

EEWAE00000000000000000000
Round 3: slyz casts CANNELLONI CANNON!
KoLmafia thinks it is round 4 but KoL thinks it is round 3
Round 4: pygmy assault squad takes 380 damage.
Round 4: slyz wins the fight!
You gain 159 Meat
You acquire an item: bottle of alcohol
After Battle: Ieva gorges himself on candy from his bag. And hey, look, he dropped some!
You acquire an item: BitterSweetTarts
You gain 10 Fortitude
You gain 26 Enchantedness
You gain 13 Sarcasm

The "Explore Some Unexplored Ruins" link at the end of the fight points to the square I had just adventured in.

I think HiddenCityRequest.recordToSession() should take care of registering the square, but it seems like something isn't happening as it should, and I didn't find it yet.

Attached is a debug log resulting from clicking a square (hiddencity.php?which=7) in the hidden city (one that lead to a fight).

I was posting this mainly because I am curious to see what is going on. Using the "Explore Next Square" link works perfectly, so this is by no means urgent.
 

Attachments

  • DEBUG_20110430.txt
    72.4 KB · Views: 637

Veracity

Developer
Staff member
It sure doesn't behave that way for me. You should have three links at the end of a fight:

Explore Some Unexplored Ruins
Adventure Again in These Ruins
Back to Hidden City (or whatever the standard KoL link is).

If you use KoLmafia stationary buttons, the "again" button goes to the first link it finds. I.e., "Explore" (if you have unexplored squares) or "Adventure Again" (if you have explored the whole city.)

I clicked my way through the Hidden City yesterday, using the "again" button and it took me to an unexplored square every single time. Here is my setting:

hiddenCityLayout=EEEEEEFDNDLEEDEWEATDEEEDE

I don't know what you mean when you say 'Using the "Explore Next Square" link works perfectly' (since KoLmafia doesn't put in that link) whereas 'The "Explore Some Unexplored Ruins" link at the end of the fight points to the square I had just adventured in.' Do you REALLY have both links? Do you have some sort of Greasemonkey script adding such a link?

I'll look at your debug log, by and by.
 

slyz

Developer
That's embarrassing, apparently the "Explore Next Square" link was added by the Mr. Script greasemonkey script, and not by KoLMafia (I thought it had been introduced at the same time as the "Explore Some Unexplored Ruins" link).

If hiddenCityLayout is correctly updated when you enter the fight, I wonder why it isn't behaving the same way for me. I need to visit the Hidden City map to get an updated hiddenCityLayout.

Next time around I'll try with a different browser (I'm currently using Firefox 3.6), maybe that could change the way redirects are handled? I'm saying this because I clicked the link "hiddencity.php?which=7" on the hidden City map, and the debug log mentions this line several times:
Code:
Referer: http://127.0.0.1:60080/hiddencity.php?which=6
Could this have confused Mafia?

In any case, I'll mark this as "Bug - Waiting for Info" since it seems to work for other people.
 

lostcalpolydude

Developer
Staff member
I have the same issue, sporadically, every ascension. In addition to hiddenCityLayout not being updated, hiddenCitySquare is also not updated. I'm not using Mr. Script or any other script that should affect any involved page. It really stands out when "Explore some unexplored ruins" and "Adventure again in these ruins" have the same URL. And that confuses me even more, because the only updating of lastSquare I see is based on the value of square (both in HiddenCityRequest). Debug log attached from me clicking on the fifth square (which=4), and hiddenCitySquare not updating from 4 to 5.
 

Attachments

  • DEBUG_20110527.txt
    472.2 KB · Views: 40

slyz

Developer
I managed to catch something interesting this time. I added a little bit of debug logging in KoLAdventure.recordToSession( urlString, responseText ), to check what URLs where being passed to HiddenCityRequest.recordToSession():
PHP:
RequestLogger.printLine( "location = " + location );
RequestLogger.printLine( "old URL = " + lastURL );
RequestLogger.printLine( "new URL = " + urlString );
This is what I got in the gCLI

First, clicking on a square in the Hidden City map:
Code:
location = Hidden City (Square 23)
old URL = hiddencity.php?which=22
new URL = fight.php?ireallymeanit=1306669210

[682] Hidden City (Square 23)
Encounter: bee thoven
Round 0: slyz wins initiative!
Round 0: slyz casts ENTANGLING NOODLES! (auto-attack)

> get hiddenCityLayout

DEWEEELENDEEEADDETEDEEE00
Round 2: slyz casts WAVE OF SAUCE!
(...)
The square was correctly recognized and marked as E in hiddenCityLayout.

Next, I clicked on the "Explore Some Unexplored Ruins" link:
Code:
location = Hidden City (Square 24)
old URL = hiddencity.php?which=23
new URL = newchatmessages.php?lasttime=1277878786

[683] Hidden City (Square 24)
Encounter: boaraffe
Round 0: slyz wins initiative!
Round 0: slyz casts ENTANGLING NOODLES! (auto-attack)
Round 2: Yuk leaps on your opponent, sliming it for 18 damage. It's inspiring!
Round 2: boaraffe takes 18 damage.
You gain 18 Mana Points

> get hiddenCityLayout

DEWEEELENDEEEADDETEDEEE00
Round 2: slyz executes a macro!
(...)
The location is properly recognized from the "old URL", but apparently KoLAdventure is fooled by a new chat message, and thinks it was redirected to newchatmessages.php instead of fight.php or adventure.php?snarfblat=118.

The result was that the square wasn't marked as E in hiddenCityLayout, and the "Explore Some Unexplored Ruins" link pointed to the same location.

I'm not really sure how to fix this, though.
 
Last edited:

slyz

Developer
Would changing line 431 of AdventureRequest.java:
PHP:
if ( GenericRequest.itemMonster == null && !KoLAdventure.recordToSession( urlString, responseText ) )
to
PHP:
if ( !request.isChatRequest && GenericRequest.itemMonster == null && !KoLAdventure.recordToSession( urlString, responseText ) )
solve the problem?

I'll try to adventure with the debug logging I added tomorrow to see if I see more "new URL = newchatmessages.php" messages. I didn't only get those messages in the Hidden City:
Code:
location = The Middle Chamber
old URL = adventure.php?snarfblat=125
new URL = choice.php

[695] The Middle Chamber
Encounter: Wheel in the Pyramid, Keep on Turning
location = The Middle Chamber
old URL = adventure.php?snarfblat=125
new URL = newchatmessages.php?lasttime=1277879646

[696] The Middle Chamber
Encounter: tomb bat
Round 0: slyz wins initiative!
(...)
 

Raijinili

Member
I was also experiencing problems with the "Explore Unexplored Ruins" link the past week (it was pointing to the same square as "Explore these ruins some more" or whatever), but when I look at the settings now, it says
hiddenCityLayout=ENDEATEEEDFEEEDEEWDDEELEE

Does clearing the City for anyone else fix it, or was I experiencing something else?

I do not have Greasemonkey on, and am using Firefox 3.6.17

Edit:
To anyone still ready to experience the "not updating" bug, and with knowledge to compile Mafia from source, try making this change.
In HiddenCityRequest.java, in method "identifySquare( final String location, final String responseText )", add a final "else" at the end with a debug message to see if it's falling through. Possibly with a dump of responseText.

Veracity, would it be possible to have a default in there that will throw an error (or whatever) so that it would be easy to detect KoL changes in the future?
 
Last edited:

slyz

Developer
r9372 applies the change in AdventureRequest.java. I'm marking this as fixed until proven otherwise.
 
Top