Bug Global _underline preferences aren't initialized at first login

Bale

Minion
I'm pretty sure that the problem is that _underline preferences aren't reset at first login of the day. I might be mistaken.

At any rate, I did not see the new pop-up window today, telling me that there is going to be a Twitch event. (The new feature that performed so nicely yesterday.) Also, I think that script manager only reloads the remote repository if I manually tell it to do so.

Both those things could be connected since they both use an _underline preference of global scope.
 

lostcalpolydude

Developer
Staff member
I wrote some code to reset global _ settings, and it seems to work fine. However, it triggers after the code that shows login page announcements, leading to weird results there (it will only show up the first time you log in on a day if you didn't log in a second time the previous day, assuming there was an announcement to show both days). That's still good enough that people will see the announcement, and should work fine for the other global daily settings. I'll think on it.
 

xKiv

Active member
How about workaround using dates/timestamps?
(don't show popup/don't udpate svnrepo IF the property is set to today or less than 12 hours ago)
 

fronobulax

Developer
Staff member
How about workaround using dates/timestamps?
(don't show popup/don't udpate svnrepo IF the property is set to today or less than 12 hours ago)

Do we have a good idea of which timestamp to use if we were going to do this?

Since I don't recall the problem existing before the announcement popup, perhaps a better solution would be to revisit that work? Perhaps the announcement data is always fetched on login but the decision to display, or not, is made later? Perhaps the announcement is fetched, or not, based on the nonvolatile preference but displayed, or not, based on the daily preference?
 

lostcalpolydude

Developer
Staff member
Actually, global _underline preferences have never been reset daily. Apparently when the first one was added, this was noticed and a workaround was added (which reset it more than daily). When the second one was added that was overlooked, and now the announcements are a third setting.
 

lostcalpolydude

Developer
Staff member
14105 adds code to reset global _ settings. The results won't be perfect because of the timing of stuff (so I'm leaving this report open) for both SVN and announcements, but it's a big improvement over having nothing.
 

fronobulax

Developer
Staff member
For this particular thing, it would be "when did we last show it". But hopefuly such hack won't be needed.

I guess my question was more how we would get and use the timestamp. Over the years people have used local time, GMT, GMT adjusted to Arizona, and faux time from within KoL, etc. and each one of them had minor issues because users changed computers or developers were in different timezones or conversion routines were buggy or... Getting times right in a system like this has not always been as easy as people think.

IMO, YMMV because we know I remember things that did not happen.
 

Cool12309

Member
I guess my question was more how we would get and use the timestamp. Over the years people have used local time, GMT, GMT adjusted to Arizona, and faux time from within KoL, etc. and each one of them had minor issues because users changed computers or developers were in different timezones or conversion routines were buggy or... Getting times right in a system like this has not always been as easy as people think.

IMO, YMMV because we know I remember things that did not happen.

Why not unix time? That should be universal and doesn't change according to time zones.
 

Theraze

Active member
But unix time adjusted to what? What will actually display once per rollover and not miss more or less depending on computer/synchronization variances?
 

fronobulax

Developer
Staff member
Why not unix time? That should be universal and doesn't change according to time zones.

*snicker*

With respect to KoLmafia, since there are players who use multiple computers, and in the same day, any time that is based on the local computer's clock is potentially going to give the wrong answer if the clocks do not agree. So a local call to get the time in milliseconds since whenever is not going to work all of the time. A better answer is to always use the same clock, which means using the time as reported by the KoL server or a time server. Synchronizing with an external server is a solved problem, but like cryptography, home brew solutions can fail miserably and in unexpected ways and using someone elses solution seems excessive for KoLmafia. Using the KoL time involves some kind of conversion. Again how to do the conversion should be easy but in practice that has not always been the case. So solving a KoLmafia problem with time and doing it right involves a lot of work and the question should be asked if there are better solutions that involve less work. In this case based on past experience I think the answer is yes - there should be other ways to deal with the issue.
 

Bale

Minion
For some reason, when I logged in just now, KoLmafia did not show the announcements for me today.

Code:
[COLOR="olive"]> prefref announcement[/COLOR]

_announcementShown (global: false)
showAnnouncements (global: true)

What other information can I give to help figure out why it wasn't shown?
 

fronobulax

Developer
Staff member
Twice now I have noticed that I don't see the announcement with the first character of the day, but I do see it once with the second and (as expected) not with the third. I normally run the characters in the same order so there could be something character specific going on. Just reporting as a FYI.
 

lostcalpolydude

Developer
Staff member
That is exactly what I said you would see, and the reason this report isn't closed. The settings are reset to default after the first login of the day (and the settings are used before each login).
 

fronobulax

Developer
Staff member
That is exactly what I said you would see, and the reason this report isn't closed. The settings are reset to default after the first login of the day (and the settings are used before each login).

I'm confused but apologize for mentioning it if it is a work in progress.

My expectation, which may not be your goal or which may be your goal and you are not there yet is that:

If it is a new day, and
if the display is allowed by a character and
if it has not previously been displayed on the new day for any character using the same settings directory
then the display will occur.
 

Theraze

Active member
Correct. That is what lost is describing as the desired behaviour. The issue is that global daily preferences reset AFTER the first login, not before. Which means that the global daily preference of "have you seen today's announcements yet?" doesn't get reset until AFTER your first character logs in.

On your first character, it checks and decides that you've seen today's announcements, and then it resets the GDP to say that you haven't seen them yet. On your second character, it checks and decides that you've not seen today's announcements yet, displays them, and marks the announcement GDP as seen. On your third character, it checks and decides that you've seen today's announcements, and moves on without changing anything.

The trick is making mafia reset the GDP when it initializes rather than on initial character login. But... changes.
 

Bale

Minion
That is exactly what I said you would see, and the reason this report isn't closed. The settings are reset to default after the first login of the day (and the settings are used before each login).

You said "the results won't be perfect because of the timing of stuff" which isn't exactly clear. I didn't really know what that meant until now. I'm glad to know that the issue is understood, even though the solution is complicated. This works well enough.
 

DaveK

New member
14105 adds code to reset global _ settings. The results won't be perfect because of the timing of stuff (so I'm leaving this report open) for both SVN and announcements, but it's a big improvement over having nothing.

I stumbled into a bit of a bug in this area:

public static void refreshSession()
{
KoLmafia.setIsRefreshing( true );

KoLmafia.refreshSessionData();

AdventureFrame.updateFromPreferences();

// It would be nice to not have to do this
IslandManager.ensureUpdatedBigIsland();

boolean shouldResetCounters = Preferences.getInteger( "lastCounterDay" ) != HolidayDatabase.getPhaseStep();
boolean shouldResetGlobalCounters = Preferences.getInteger( "lastGlobalCounterDay" ) != HolidayDatabase.getPhaseStep();
I just fired up mafia for the first time in a while. Turns out that 'a while' exactly matched the length of the moon cycle, meaning HolidayDatabase.getPhaseStep() returned the same value as it had been last time I fired up mafia. Result? No breakfast etc. for me today!

I guess this could be fixed by checking the real date as well as the phase, and noticing if it's been >= 16 days since last time. Or can we track the in-game kol calendar date somehow? I'm not much familiar with mafia internals, so don't know what would be best.
 

xKiv

Active member
I guess my question was more how we would get and use the timestamp. Over the years people have used local time, GMT, GMT adjusted to Arizona, and faux time from within KoL, etc. and each one of them had minor issues because users changed computers or developers were in different timezones or conversion routines were buggy or... Getting times right in a system like this has not always been as easy as people think.

IMO, YMMV because we know I remember things that did not happen.

How badly do you thing would clocks on different computers disagree?
My idea was simply: if it's been 12 hours since last login, then remind me.
I chose 12 hours (of unix time, I suppose) because
1) that's significantly less than the time I usually have between logins
2) it's short enough that it should trigger every day for me
3) it's long enough that it (mostly) wouldn't trigger on repeated logins (in case of crashes, switching characters, switching computers, ...)
4) it's many times more than the usual difference between computers' clocks (and if your computer's clock is several hours off, you have problems)
5) it's long enough that seconds or minutes of error won't really matter
6) it's long enough that I have probably already forgotten and need a reminder

"Set to today" is a much worse concept, in general. In this concrete, today=kol-today, so handle it like (or even with) a daily _property?
 
Top