CanAdv -- check whether you can adventure at a given location

Theraze

Active member
And those are tracked in mafia using which preferences, or if not directly tracked in mafia, those are found on which pages with which text or images?
 

Lxndr

Member
Doing some random stabs with prefref, I can't find any preferences that track that. Since I'm in the middle of another run, and have no idea how to do Hobopolis, I have no opportunity to figure out the proper information, but it looks like that the right page is:

clan_hobopolis.php (gotten from the game)

and the potentially correct image is:

deeper.gif (gotten from the wiki)

that's just the gate to the hobopolis zones in general.
It looks like however many normal hobos you kill or something. And I can't help with that. :(

Maybe we need to request Mafia preferences?

ETA: I found this script: https://github.com/twistedmage/assorted-kol-scripts/blob/master/scripts/hobopolis.ash Which apparently tracks the unlock conditions for the various hobo zones. I hope this helps?
 
Last edited:
Sadly, Hobopolis progress doesn't have any tracking preferences. Hobopolis progress can be tracked much like the War can approximately by image: otherimages/hobopolis/townsquare1.gif (freshly minted) through 25.gif (boss up) and 26.gif (closed). Same goes for the side areas, which have 12 images: 0 is no progress, 1-9 10% to 90% progress, 10 is boss up, 11 is closed. The sewers have a series of images as well, but these don't track progress directly, instead corresponding to grates and valves opened. There's also no single image for "completed sewer", but the presence of "deeper.gif" can be used in its place.
 

Darzil

Developer
The issue with tracking it in Mafia is that other than by server hits there is no way to know the current status of Clan Dungeons, only the state they were in when you last looked at them. They can change without your character being aware.
 

Lxndr

Member
Using SeRa as the litmus test for this.. looks like it still thinks the following zones are still being reported as accessible:

*The Purple Light District
*Burnbarrel Blvd.
*Exposure Esplanade
*The Ancient Hobo Burial Ground
*The Heap
 

lostcalpolydude

Developer
Staff member
The missing thing in that code is recognizing when visiting a side area redirects you to the sewer tunnels because you haven't cleared them. A single initial server hit could recognize the redirect to the sewer tunnels and save checking all the other locations, but since another script can only call this with a location as a parameter, SeRa is going to trigger 7 server hits for Hobopolis whenever it runs. Which I guess isn't too often, so not a big deal.
 

Lxndr

Member
Couldn't we gate the Hobo checks behind a sewer check? I mean, if deeper.gif isn't there, don't bother checking anything else.
 

lostcalpolydude

Developer
Staff member
Couldn't we gate the Hobo checks behind a sewer check? I mean, if deeper.gif isn't there, don't bother checking anything else.

SeRa (and other scripts) can only ask about one location at a time. CanAdv returns true or false, and then forgets all of what it used to get that result. The only way to cut server hits with this setup would be to completely restructure CanAdv to accept an array of locations, and then refactor a bunch of stuff to save some server hits along the way.
 

Theraze

Active member
It's already gated on a hobopolis zone check, but that's two hits to validate that the zone is unlocked first, per location.
Code:
      case "Hobopolis": return contains_text(visit_url("town_clan.php"), "clanbasement.gif") && !contains_text(visit_url("clan_basement.php?fromabove=1"), "not allowed");
Guess if we're already doing 3 hits and not being accurate, we can probably throw a fourth into there and validate that deeper is available. That'll be r85 coming soon.
 

lostcalpolydude

Developer
Staff member
That can all be reduced to 1 server hit per location. Return true for "Hobopolis" (or maybe get_clan_name() != ""), you can drop the more general clan_hobopolis.php check, and jump straight to the place=X checks for imagename0 through imagename9. Slightly more complicated code, but always 1 server hit.
 

Theraze

Active member
And 25 checks for town square?

What's the new check for the sewers? What does it look like when it isn't deeper?
 

lostcalpolydude

Developer
Staff member
Probably a regex on those image names and checking for the number being in a range would be best.

There's sewer1.gif through sewer8.gif, but only sewer1 has the text for it taking a turn so I'm not sure what the others are.
 

Lxndr

Member
Got r85. Speaking as the squeaky wheel... (using SeRa as a tester). I'm still seeing all the Hobo side-zones in SeRa's list (with no hobopolis unlocked)
Are we tossing the ball back to SeRa, maybe?

Or is there a better way for me to test?
 
Last edited:

Theraze

Active member
If they say they're not unlocked, and SeRa says they're unlocked, then yes. If CA still says they're available, then we need to fix that.

If we get something more clear as to how to avoid extra server hits and still be accurate, we'll change it up and someone will need to validate whether it still works. But that'll take more specific information.
 

zarqon

Well-known member
Splendid! The Hobopolis zones are a bit of a pain to check for -- a pain to our not-wanting-to-hit-the-server consciences. Glad that they're finally getting handled.

I had a bit of an idea -- using static variables, we can make a time-sensitive visit_url() that will use a cached value until it expires. So, here's a CanAdv with a new function timed_url(). It works like the single-parameter visit_url(), except it allows you to specify the expiry time (in milliseconds). If that much time has passed since the page was last cached, it reloads. This allows us to specify the expiry time variably per function call. And using a static variable means that the cache will persist across script instances as well (necessary since I believe SeRa and Factroid both hit CanAdv via AJAX once per location rather than in a single script instance). This ought to significantly reduce server hits for checking Hobopolis zones.

While I was at it, I took out the old regex tongs and converted your excellent new hobocheck to use a regex, reducing the repeated code.

Several other changes are included as well, some of which are simply preference but some of which I believe to be actual fixes. :)
 

Attachments

  • cango.ash
    47.6 KB · Views: 20

Theraze

Active member
Implemented. This also added support for the Telegram Office, which apparently nobody had reported yet. Yay.
 
Top