Bug - Fixed "You've already explored that spot." when exploring next unexplored square.

xKiv

Active member
Today I have finally managed to capture this elusive beast (as soon as I put my debugging printouts in mafia code, it stopped happening for several runs).
What happens:
- I go to tavern cellar
- click the first square manually
- then go to each new square using mafia's 'explore next unexplored'
- eventually mafia will try to explore an already explored square

In this case ...
Code:
...
[30] The Typical Tavern Cellar (row 2, col 1)
Encounter: Those Who Came Before You
You acquire an item: Ben-Gal™ Balm
You acquire an item: shiny ring

[31] The Typical Tavern Cellar (row 3, col 1)
Encounter: A Rat's Home...

[31] The Typical Tavern Cellar (row 4, col 1)
Encounter: drunken rat
This last drunken rat resulted from hitting cellar.php?action=explore&whichspot=16 , which redirected to fight.php?ireallymeanit=1461982269
No change to tavernLayout happened during or after that.
I would see something in stdout if postTavernVisit went through the fight.php branch or kept going until the end. (also I was healthy, with adventures left, and not drunk)
TavernRequest.postTavernVisit then calls parseCellarMap and quits without any futher modification of tavernLayout
TavernRequest.parseCellarMap did NOT change tavernLayout
 

lostcalpolydude

Developer
Staff member
I see this happen occasionally, but I don't know why it happens or how to reproduce it. I gave up trying to track down this bug a while ago.
 

xKiv

Active member
I guess I will just put *even more logging* in those methods to see what's happening.

(I now suspect something reset isRatQuest to false)
 
Last edited:

xKiv

Active member
OK, it happened again.

Best as I can tell:

1) I click on the "explore next square" link
this is cellar.php?action=explore&whichspot=16, and isRatQuest==true
2) newchatmessages.php?j=1&lasttime=1422872939 happens and sets isRatQuest=false (in GenericRequest.processResponse, where it calls TavernRequest.postTavernVisit)
3) my original click is redirected to fight.php?ireallymeanit=1462502390, but isRatQuest is already false, so mafia doesn't process the response as "tavern square visit results in a fight"
 

xKiv

Active member
Probably because coding it to copy through a chain of forwarded requests was too complicated?
 

heeheehee

Developer
Staff member
Sounds plausible.

There are two types of requests that are relevant here: relay requests, and Mafia-initiated requests. These handle requests separately -- Mafia-initiated requests automatically follow redirect chains within the context of a single request, while relay requests rely on the browser to follow redirects, generating a new request for each link in the chain. The former would be automatically resolved by making isRatQuest non-static, but the latter seems nontrivial to handle in general (Referer header doesn't seem to help with tracking redirect source without some tracking, e.g. a cookie, although it might help in this particular case).
 

heeheehee

Developer
Staff member
That is one part of a fix! Quest requests should also probably not flip isRatRequest off, since they can also be accessed at any point.
 

Veracity

Developer
Staff member
Looking at GenericRequest.processResponse():

Code:
		if ( !this.isChatRequest && !this.isDescRequest && !this.isQuestLogRequest )
		{
			EventManager.checkForNewEvents( this.responseText );
		}
Seems like way earlier in the method we could have:

Code:
		if ( this.isChatRequest || this.isDescRequest || this.isQuestLogRequest )
		{
			return;
		}
Since essentially nothing in the method past logging the response to the DEBUG log is necessary (or correct) for those kinds of requests.
 

Veracity

Developer
Staff member
Well... Actually this.processResults() does do something for the questlog and desc_ requests.
I will experiment.
 

Veracity

Developer
Staff member
Something like this after updating the DEBUG log.

Code:
		if ( this.isChatRequest )
		{
			return;
		}

		if ( this.isDescRequest || this.isQuestLogRequest )
		{
			ResponseTextParser.externalUpdate( this.getURLString(), this.responseText )();
			return;
		}
I'll try it some time after rollover.
 
Top