Xeno-Strike-Force / LiveSplit_files_for_AX

LiveSplit files for Anti-Xeno speedrunning in Elite:Dangerous
1 stars 1 forks source link

Race condition between `init` and the game creating journal/netlog #4

Closed alterNERDtive closed 2 years ago

alterNERDtive commented 3 years ago

So … as soon as the process pops up, LiveSplit runs init. If you start LiveSplit first, then Elite, the correct journal and netlog files have not been written yet at that point.

To fix that quick & dirty, we could simply add a delay to init. That would mean you’d have to wait for this delay to pass needlessly if you run Elite first, LiveSplit second (and whenever LiveSplit reloads the splitter).

To fix that properly we have to watch the journal and netlog directories for new files to pop up, then change to the correct one. No idea if ASL allows to have a file system watcher in the background, otherwise that would have to happen from probably update every cycle 😬

Astyrrean commented 3 years ago

I agree. The most "sophisticated" version I can think of looks at the latest timestamp in a file - if it is "current" (close enough to system time) then the game is likely running - use that file; if it isn't, then the game likely isn't running - introduce the wait on init.

alterNERDtive commented 3 years ago

The fix by just sleeping locks up the entirety of LiveSplit, btw. Every time you start Elite or the splitter is reloaded while Elite is running. IDK why it’s not living in a separate process, but that’s what we have to work with.

Not ideal, but … you know …

Astyrrean commented 3 years ago

Yes, I noticed, but I also agree it's the lesser of evils for now. I also does shift focus back to Livesplit when done (which is MORE annoying but eh...)