Bug lastDesertUnlock improperly set

katyarn

Member
After completing Community Service, the desert beach is closed unless you've made a meatcar or any of the other substitutes. Mafia improperly sets the lastDesertUnlock to your current ascension number upon completing this challenge path.

Edit: more info below in post #10
 
Last edited:

katyarn

Member
Here's a simple patch that should resolve the issue for Community Service.
 

Attachments

  • lastDesertUnlock.patch
    797 bytes · Views: 5

MCroft

Developer
Staff member
The update you wrote certainly works, but there's a comment a few lines up that makes me think we might have intended to fix this some other way.

To be fair, that's a comment from 2014. But is this something for which there is a more correct way of addressing the issue?

Java:
// Temporary code to allow Mafia to catch up with the fact that unlock is a flag
if ( Preferences.getInteger( "lastDesertUnlock" ) != KoLCharacter.getAscensions() )
     {
     if ( KoLConstants.inventory.contains( ItemPool.get( ItemPool.BITCHIN_MEATCAR, 1 ) ) ||
         KoLConstants.inventory.contains( ItemPool.get( ItemPool.DESERT_BUS_PASS, 1 ) ) ||
         KoLConstants.inventory.contains( ItemPool.get( ItemPool.PUMPKIN_CARRIAGE, 1 ) ) ||
         KoLConstants.inventory.contains( ItemPool.get( ItemPool.TIN_LIZZIE, 1 ) ) ||
         Preferences.getString( "peteMotorbikeGasTank" ).equals( "Large Capacity Tank" ) ||
         Preferences.getString( "questG01Meatcar" ).equals( "finished" ) ||
         KoLCharacter.kingLiberated() || KoLCharacter.isEd() )
     {
         Preferences.setInteger( "lastDesertUnlock", KoLCharacter.getAscensions() );
     }
 }
 return Preferences.getInteger( "lastDesertUnlock" ) == KoLCharacter.getAscensions() &&
            !Limitmode.limitZone( "Beach" );
 

heeheehee

Developer
Staff member
That block is unconditionally setting lastDesertUnlock if kingLiberated() is true.

Is that logic correct? Can players automatically access the beach at the conclusion of an Ed run? Pete? Exploathing?

There's likely no reason to continue tracking this explicitly in a preference -- meatcar is no longer untinkerable, and all of its equivalents are marked as quest items that can't be discarded, so once you have access in an ascension, you'll always have access.
 

katyarn

Member
It would likely cause a lot of problems for various scripts to stop updating this property, canadv, for instance, relies on it.

I posed the question about other paths opening the desert beach in the title because I don't remember at all.
 

MCroft

Developer
Staff member
Ed yes, pete, idk, Exploathing, looks like that's taken care of.

The full fn shows the Exploathing exemption. Ed has access from turn 1.
Java:
public static final boolean desertBeachAccessible()
    {
         if ( KoLCharacter.isKingdomOfExploathing() )
         {
             return false;
         }
 
         // Temporary code to allow Mafia to catch up with the fact that unlock is a flag
         if ( Preferences.getInteger( "lastDesertUnlock" ) != KoLCharacter.getAscensions() )
         {
             if ( KoLConstants.inventory.contains( ItemPool.get( ItemPool.BITCHIN_MEATCAR, 1 ) ) ||
                  KoLConstants.inventory.contains( ItemPool.get( ItemPool.DESERT_BUS_PASS, 1 ) ) ||
                  KoLConstants.inventory.contains( ItemPool.get( ItemPool.PUMPKIN_CARRIAGE, 1 ) ) ||
                  KoLConstants.inventory.contains( ItemPool.get( ItemPool.TIN_LIZZIE, 1 ) ) ||
                  Preferences.getString( "peteMotorbikeGasTank" ).equals( "Large Capacity Tank" ) ||
                  Preferences.getString( "questG01Meatcar" ).equals( "finished" ) ||
                  KoLCharacter.kingLiberated() || KoLCharacter.isEd() )
             {
                 Preferences.setInteger( "lastDesertUnlock", KoLCharacter.getAscensions() );
             }
         }
         return Preferences.getInteger( "lastDesertUnlock" ) == KoLCharacter.getAscensions() &&
                 !Limitmode.limitZone( "Beach" );
     }
 

heeheehee

Developer
Staff member
Well, my question is if those paths keep access after freeing the king, or if they need to make a meatcar afterwards.

I expect that the underlying KoL code is unchanged from when the beach (well, probably shore, actually) was first introduced, in that it is actually a once-per-ascension unlock, in that someone probably has an ancient never-ascended character that untinkered the meatcar years ago and still has beach access. So keeping it as a preference is probably still correct. (In addition to the backwards-compatibility angle that katyarn pointed out.)

Either way, I don't think kingLiberated() is the correct thing to check here. Worst-case scenario, we should be able to auto-detect beach access either from main.php or from topmenu.php (or awesomemenu.php or whatever the revamped topmenu was called).
 

MCroft

Developer
Staff member
The function assumes there is no reversion. It’s true if the current ascension is the same as the last ascension where it was ever true when this fn was called and beach is not in the limitZone.

I don’t know if this is still a valid assumption.

I also don’t know when limitmode.limitZone gets added to the mix
 

katyarn

Member
In investigating this further, it turns out Autoscend has been special-casing KoE because Mafia incorrectly reports the desert beach as closed.

I think the correct answer for this is to update lastDesertUnlock if:
1) You own Bitchin' Meatcar, Desert Bus Pass, Pumpkin Carriage or Tin Lizzie
2) You have the large capacity tank for Sneaky Pete
3) Your current challenge path is Ed or KoE. These will remain open after completing the paths as well.

The last one might pose challenges because you might begin using Mafia in aftercore and it won't be clear why the desert beach is unlocked without knowing which path was just completed. Does Mafia have a concept of the path prior to freeing the king?
 
Top