Page 2 of 2 FirstFirst 1 2
Results 11 to 20 of 20

Thread: Mafia being left open through dayroll without clicking anything until dayroll over

  1. #11
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,311

    Default

    Thank you for explaining. I assumed it was being done via a date and time check (adjusted to your timezone).
    Originally Posted by taltamir View Post
    Depending on your system clock to have a value which (even adjusting for timezone) is comparable to times that are used by the KoL servers themselves is a huge squirming bag of worms.
    If you are using some sort of network time protocol to set your system clock at boot (or periodically, or whatever) and your hardware clock is accurate enough to keep you closely in-synch between updates and (any number of other assumptions) ...

    The method I mentioned uses nothing but time values that KoL itself sends us and requires nothing of the accuracy of your local time. KoL itself tells us when rollover has passed and a new day has begun.

    I just stayed logged in for (more than) thirty minutes after rollover had presumably finished. I clicked the "refresh" button on the inventory page, which does api.php?which=inventory.

    Code:
    Updating inventory...
    Installing default certificate validation...
    Sending login request...
    *** slot acc1: KoL has (none) but KoLmafia has Draftsman's driving gloves
    Loading character status...
    Synchronizing moon data...
    2 days until Festival of Jarlsberg, Moxie bonus tomorrow (not today)
    It submitted that api.php request, got redirected to login.php, did the timin, detected that rollover had happened, reset counters and did a few more requests, and then resubmitted the inventory refresh.

    Which is what I expected.

    I'll sleep on it and look more tomorrow and see what it would take to make it like the first full login of the day. EVen without counting breakfast (which I do not run automatically) and SVN update (ditto), it needs to look at garden progress, and who knows how much else.
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

  2. #12
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,311

    Default

    As for what my logout script does.
    it uses up my remaining fortune teller asks, puts my pvp stealable expensive items in my closet, and runs breakfast. Which does a bunch of daily actions which could be a problem if you just broke prism to liberate the king (thus making a bunch of iotms with daily limits that were unavailable become available).
    Originally Posted by taltamir View Post
    So, near as I can tell, your logout script is coded with the assumption that you will only ever log out once a day.
    Huh.

    Well, since I may log in, do stuff, log out, log in later, do more stuff, log out, log in yet again, finish doing stuff, log out, I wouldn't do that.
    In fact, I can't think of anything I would want to be doing every single time I log out.
    But, we do give you the opportunity to write such a script.
    I think it's up to you to make it work correctly every time, whether or not you have used it earlier today and whether or not you might log in and out later and it will run again.
    I don't think it is up to KoLmafia to decide the "one true way" a logout script is intended to work and make that way - and only that way - work correctly, possibly at the expense of other ways to write such a script.

    What does zarqon's logout script do?
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

  3. #13
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,798

    Default

    My logout script basically attempts to use all the multifarious daily-limited resources I have remaining, under the same assumption that I am done playing for the day. It does things like use up remaining free craftings and minings, record songs, burn MP until daily-limited MP restoratives are used up (like nuns, free rests, and magical sausages), faxputty a desirable monster, improve spirits, get any un-got daily buffs, comb the remaining free beach, Solve the Detective, and use remaining daily zaps. There's more, but you get the picture. It attempts to pretty comprehensively wrap up my day by using any daily thing I didn't use already in that day's adventuring. You can probably see where I would only want that to run when I actually finish playing a character for the day.

    A logout script seemed the most sensible place to put all this stuff since that will guarantee I "remember" to use everything.

    I could extend the nightcap check to apply to the whole script -- so the script would do nothing unless I had spent enough turns and filled enough stomach and liver -- but I have had no need to thus far. If I leave a KoLmafia instance open and rollover happens (quite common for me), when I come back to my computer I close KoLmafia rapidly before it has a chance to execute my logout script (two ALT+F4s in quick succession on my Windows machine), then restart it. This is old, learned behavior; I have an ancient memory of my logout script firing up in these cases and doing stuff I didn't want to do yet, which I also couldn't see clearly because I was looking at the login window rather than the CLI. I guess that's what I meant by "errors". I can't recall if there were script-generated errors in addition to unwanted behavior, so my word choice was perhaps the real error here.

    If I'm understanding correctly, the present behavior is:

    • When rollover is detected as ongoing, abort any actions and print a red message to the CLI.
    • When rollover is detected as having happened in the past, partially update mafia's information.

    This latter bit leaves mafia in a state of dubious usefulness. To avoid said dubious state, it seems best to either 1) exit to the login screen (without calling a logout script; at this point you are in a situation practically identical to not having logged in at all) or b) re-login (as though we had just logged in from the login window). It looks like perhaps choice b) is better now since the login-out-in thing is awkward.

    Might also be worth considering having mafia kick you back to the login screen if it detects rollover is ongoing. Would prevent you from ever being in this "login limbo".

    I seem to have accidentally registered a horse in this race. I am fine with the way things are, honestly, but I do think eliminating that half-useful state would be an improvement.
    Sig by JakAtk
    My scripts: Prefref Plus | Skillref Plus | One-Click Woss | Om****est (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mercenary Mood | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | Drag-n-Drop Inventories | CanAdv | Script Registry | Map Manager
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

  4. #14
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,311

    Default

    Well, I have a commit ready which does this:

    - When we redirect to maint.php (i.e. you submit a request during rollover) we continue to clear the session variables - session ID, password hash, etc. - since you are logged out. We don't kick you back to the login frame. You might not even be running with a GUI. But if you exit the program (closing windows, exit command, etc.) we will notice that there is no session ID and will not call your logout script.

    That should solve the "errors from your logout script" issue. I assume those were all a result of every attempted request being redirected to maint.php.

    - When we timein, it submits login.php (which is what it was redirected to when you tried to submit a request). The first thing it does after that is to get api.php and see if rollover has happened.

    If not, it saves and reloads preferences, closes and reopens the session log (because it used to do those things. These may be unnecessary), and then learns the new password hash (since it changes every login) and visits main.php (since some things don't reset correctly in KoL if you don't do that.) And that's it. Everything else is assumed to be in the same state as when you left it. properties will not have changed. Inventory will not have changed. (Modulo PVP and kmail - but that's always the case; those can happen at any time even while you are activly doing other things.)

    I tested this case. Timein worked just as before with a couple fewer server calls.

    - If api.php says we have timed in on the other side of a rollover, it treats this login just like it was the first login of the day from the Login Frame: It reloads every, resets properties, refreshes session log, runs breakfast (if configured) checks SVN (if configured) and so on. I think that is what you people want - and it seems right; the purpose of timein is to allow you to continue today's session, having walked away from your computer for 15 minutes, say, just as if there had been no interruption. But as a new day, this timein is really starting a new session.

    I will test this tonight after rollover. I will be checking that it correctly opens a new session log...

  5. #15
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,311

    Default

    OK, that worked

    Code:
    > debug on
    
    > vsg status
    
    Installing default certificate validation...
    Sending login request...
    Loading character status...
    *** slot acc1: KoL has (none) but KoLmafia has Draftsman's driving gloves
    Initializing session for Veracity...
    Loading character status...
    Refreshing session data...
    Synchronizing moon data...
    Loading character status...
    Retrieving character data...
    Updating inventory...
    Examining Meat in closet...
    Updating closet...
    Retrieving quest data...
    Retrieving familiar data...
    Familiar data retrieved.
    Retrieving campground data...
    Examining Meat and pulls in storage...
    Updating storage...
    Visiting The Horsery
    You are currently a member of Hardcore Oxygenation
    Visiting Crimbo Tree in clan VIP lounge
    Visiting Hot Dog Stand in clan VIP lounge
    Visiting Speakeasy in clan VIP lounge
    Visiting Floundry in clan VIP lounge
    Session data refreshed.
    Festival of Jarlsberg tomorrow, Moxie bonus today and tomorrow.
    Already updated from https://kolmafia.us/scripts/updateprices.php?action=getmap in this session.
    06/05/20 05:06 PM - Now pledging your allegiance to Bonus Adventures from Hell.
    06/05/20 05:07 PM - Now pledging your allegiance to Hardcore Oxygenation.
    06/05/20 05:07 PM - New message received from CheeseFax
    06/05/20 05:07 PM - New message received from CheeseFax
    06/05/20 05:07 PM - New message received from CheeseFax
    06/06/20 12:00:45 AM - New message received from Your Pen Pal.
    
    Visiting the Spacegate Terminal
    You haven't activated the Spacegate today
    
    > debug off
    It timed me in at midnight - at least 20 minutes after rollover had completed - and recognized it was a new day, so it turned it into a regular login.

    Try revision 20149.

  6. #16
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,798

    Default

    That sounds perfect. Thanks for yet another thoughtful and forward-thinking solution. I hadn't considered the non-GUI people.

    Visiting main.php on timein might have solved another issue I was getting ready to report, too. Sometimes I'd run a script after my session had expired and that script would auto-adventure as its first server-hitting act, which would result in an infinite loop of "Unhandled redirect to main.php". If I encounter that again I'll make a bug report, but I'm hoping this fixes it.
    Sig by JakAtk
    My scripts: Prefref Plus | Skillref Plus | One-Click Woss | Om****est (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mercenary Mood | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | Drag-n-Drop Inventories | CanAdv | Script Registry | Map Manager
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

  7. #17
    Senior Member
    Join Date
    Oct 2017
    Posts
    596

    Default

    Thank you for the fix. I will test it with the new version too.

  8. #18
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,311

    Default

    By the way - I was curious about what you did in your logout script, because I've considered, for example, doing this:

    login script - save a timestamp in a property
    logout script - read time stamp, get a new one, calculate difference, and increment another property.

    Net result would be a property tracking how much time I was spending logged in via KoLmafia.

    Notice that no requests are involved. Just properties.

    With the new "if you are kicked out by rollover, and then exit KoLmafia, no logout script is run", such a scheme would not work.

    Perhaps I need a "kicked out by rollover script".

    That would be super niche.

    But, obviously, my idea of what a "login script" or a "logout script" is good for differs from yours. There is no "one true way".

  9. #19
    Senior Member
    Join Date
    Oct 2017
    Posts
    596

    Default

    I forgot to report that testing shows it works fine now.

    Also in regards to your suggestion. My logout script assumes I am completely done for that day. while my login script checks the current state (so with the new rollover handling will work just fine for what i want to do on a new day).
    So I personally do not have a need for a kicked by rollover script slot.

    What is your logout script doing that would necessitate it?

  10. #20
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,311

    Default

    I don't have a logout script.

    Read the post just before yours which talks about a proposed login/logout script which would, using properties, accumulate the total time you have spent logged in to KoL via KoLmafia.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •