From 9e79815fbaa4ae944fa0b8a43e3edc48d8ef70e5 Mon Sep 17 00:00:00 2001 From: norohind <60548839+norohind@users.noreply.github.com> Date: Fri, 8 Apr 2022 23:22:38 +0300 Subject: [PATCH] Workaround for missing CarrierJump event --- load.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/load.py b/load.py index 9ae22f4..d02375b 100644 --- a/load.py +++ b/load.py @@ -285,6 +285,31 @@ def plugin_start3(plugin_dir): return 'FC tracker' +def journal_entry_decorator(func: callable) -> callable: + """ + The decorator aimed to solve problem with missing CarrierJump event. + """ + + @functools.wraps(func) + def decorated(cmdr, is_beta, system, station, entry, state): + event: str = entry['event'] + if event == 'Music' and entry.get('MusicTrack') == 'NoInGameMusic': + this.music_flag_1 = True + + elif event == 'Location' and this.music_flag_1: + entry['event'] = 'CarrierJump' + this.music_flag_1 = False + logger.info(f'Generating synthetic CarrierJump') + + elif event.lower() == 'shutdown' or event in ('Location', 'LoadGame', 'CarrierJump'): + this.music_flag_1 = False + + return func(cmdr, is_beta, system, station, entry, state) + + return decorated + + +@journal_entry_decorator def journal_entry(cmdr, is_beta, system, station, entry, state): event = entry["event"]