diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..306f58e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Current File", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal", + "justMyCode": true + } + ] +} \ No newline at end of file diff --git a/game.py b/game.py index 6eca5d8..fe7601b 100644 --- a/game.py +++ b/game.py @@ -46,6 +46,7 @@ def load(logDir): latest_file = max(log_files, key=os.path.getmtime) log("Opening log file " + str(latest_file), "load") res = [] + i = 0 with open(latest_file) as f: for line in f: line = line.strip() # Remove leading/trailing whitespace @@ -53,10 +54,12 @@ def load(logDir): try: data = json.loads(line) res.append(data) + i = i +1 except json.JSONDecodeError: log(f"Skipping line: {line}", "load") + log("Log file parsed, " + str(i) + " lines found", "load") res.reverse() # so that it will stop when at the latest event it recognizes - return res, len(res) + return res def getCMDR(logs): @@ -121,7 +124,7 @@ def getStation(logs): -def eventHandler(event, logLineNum): +def eventHandler(event, logLineNum=0): """ Event handler for journal events. Run once per line. diff --git a/main.py b/main.py index e422741..eda81bf 100644 --- a/main.py +++ b/main.py @@ -72,6 +72,7 @@ def updatePrecense(presence, state, start_time, cmdr): client_id = "1170388114498392095" def mainGameLoop(): + time.sleep(1) currently = "Loading EDDP..." log("Starting game loop", "mainGameLoop") currently = " " @@ -93,7 +94,7 @@ def mainGameLoop(): j = 0 while j < len(logs): logLineNow = logs[j] - now, logLineCount = eventHandler(logLineNow["event"], j) + now = eventHandler(logLineNow["event"], j) log("Event: " + str(now) + " No: " + str(j), "mainGameLoop") j += 1 if now != 1: @@ -114,4 +115,5 @@ def mainGameLoop(): # Start the thread icon_thread.start() + #mainGameLoop() awaitGame() \ No newline at end of file