From 3d36288fbd35f2b7caaed975a9bb67f78b65f655 Mon Sep 17 00:00:00 2001 From: oldnapalm <38410858+oldnapalm@users.noreply.github.com> Date: Mon, 14 Sep 2020 10:11:29 -0300 Subject: [PATCH] Use start lines by default --- README.md | 4 ++-- standalone.py | 10 +++++++--- standalone.spec | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a88551a..ab4bf36 100644 --- a/README.md +++ b/README.md @@ -213,8 +213,8 @@ To obtain your current profile: * Create a file called "enable_ghosts.txt" inside zoffline's storage directory * When you save an activity the ghost will be saved in ``storage//ghosts//`` * Files from previous version will be organized in subdirectories. -* If you want the ghosts to spawn in the start line, copy the file [start_lines.csv](https://github.com/zoffline/zwift-offline/blob/master/start_lines.csv) to the storage directory. - * Move up "Road to Sky" and "Ven-Top" start lines to enable them. +* Next time you ride the same route, the ghost will be loaded. +* Edit the file start_lines.csv to enable optional start lines ("Jungle Circuit", "Road to Sky" and "Ven-Top"). ## Dependencies diff --git a/standalone.py b/standalone.py index c2aba1c..06e9297 100755 --- a/standalone.py +++ b/standalone.py @@ -8,6 +8,7 @@ import threading import time import csv from datetime import datetime +from shutil import copyfile if sys.version_info[0] > 2: import socketserver from http.server import SimpleHTTPRequestHandler @@ -25,10 +26,14 @@ if getattr(sys, 'frozen', False): # If we're running as a pyinstaller bundle CDN_DIR = "%s/cdn" % sys._MEIPASS STORAGE_DIR = "%s/storage" % os.path.dirname(sys.executable) + START_LINES_FILE = '%s/start_lines.csv' % STORAGE_DIR + if not os.path.isfile(START_LINES_FILE): + copyfile('%s/start_lines.csv' % sys._MEIPASS, START_LINES_FILE) else: SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) CDN_DIR = "%s/cdn" % SCRIPT_DIR STORAGE_DIR = "%s/storage" % SCRIPT_DIR + START_LINES_FILE = '%s/start_lines.csv' % SCRIPT_DIR PROXYPASS_FILE = "%s/cdn-proxy.txt" % STORAGE_DIR SERVER_IP_FILE = "%s/server-ip.txt" % STORAGE_DIR @@ -112,9 +117,8 @@ def loadGhosts(player_id, state): s.append(g.states[0].roadTime) start_road = roadID(state) start_rt = 0 - sl_file = '%s/start_lines.csv' % STORAGE_DIR - if os.path.isfile(sl_file): - with open(sl_file, 'r') as fd: + if os.path.isfile(START_LINES_FILE): + with open(START_LINES_FILE, 'r') as fd: sl = [tuple(line) for line in csv.reader(fd)] rt = [t for t in sl if t[0] == str(course(state)) and t[1] == str(roadID(state)) and (boolean(t[2]) == isForward(state) or not t[2])] if rt: diff --git a/standalone.spec b/standalone.spec index 6491042..83df137 100644 --- a/standalone.spec +++ b/standalone.spec @@ -8,7 +8,7 @@ sys.modules['FixTk'] = None a = Analysis(['standalone.py'], pathex=['/home/alexvh/Code/zoffline'], binaries=[], - datas=[('ssl/*', 'ssl'), ('initialize_db.sql', '.')], + datas=[('ssl/*', 'ssl'), ('initialize_db.sql', '.'), ('start_lines.csv', '.')], hiddenimports=[], hookspath=[], runtime_hooks=[],