diff --git a/storage/2462261/profile.bin b/pace_partners/2462261/profile.bin similarity index 100% rename from storage/2462261/profile.bin rename to pace_partners/2462261/profile.bin diff --git a/pace_partners/2462261/route.bin b/pace_partners/2462261/route.bin new file mode 100644 index 0000000..6f2c591 Binary files /dev/null and b/pace_partners/2462261/route.bin differ diff --git a/storage/2466327/profile.bin b/pace_partners/2466327/profile.bin similarity index 100% rename from storage/2466327/profile.bin rename to pace_partners/2466327/profile.bin diff --git a/pace_partners/2466327/route.bin b/pace_partners/2466327/route.bin new file mode 100644 index 0000000..4428e30 Binary files /dev/null and b/pace_partners/2466327/route.bin differ diff --git a/storage/2466331/profile.bin b/pace_partners/2466331/profile.bin similarity index 100% rename from storage/2466331/profile.bin rename to pace_partners/2466331/profile.bin diff --git a/pace_partners/2466331/route.bin b/pace_partners/2466331/route.bin new file mode 100644 index 0000000..5e9aced Binary files /dev/null and b/pace_partners/2466331/route.bin differ diff --git a/storage/2466341/profile.bin b/pace_partners/2466341/profile.bin similarity index 100% rename from storage/2466341/profile.bin rename to pace_partners/2466341/profile.bin diff --git a/pace_partners/2466341/route.bin b/pace_partners/2466341/route.bin new file mode 100644 index 0000000..73b9e2b Binary files /dev/null and b/pace_partners/2466341/route.bin differ diff --git a/standalone.py b/standalone.py index 182bb82..674a94a 100755 --- a/standalone.py +++ b/standalone.py @@ -30,17 +30,20 @@ if getattr(sys, 'frozen', False): 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) + PACE_PARTNERS_DIR = '%s/pace_partners' % sys._MEIPASS 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 + PACE_PARTNERS_DIR = '%s/pace_partners' % SCRIPT_DIR PROXYPASS_FILE = "%s/cdn-proxy.txt" % STORAGE_DIR SERVER_IP_FILE = "%s/server-ip.txt" % STORAGE_DIR MAP_OVERRIDE = deque(maxlen=16) -update_freq = 3 +ghost_update_freq = 3 +pacer_update_freq = 1 last_pp_updates = {} global_ghosts = {} ghosts_enabled = {} @@ -350,12 +353,11 @@ class PacePartnerVariables: position = 0 def load_pace_partners(): - folder = '%s/pace_partners' % STORAGE_DIR - if not os.path.isdir(folder): return - for (root, dirs, files) in os.walk(folder): + if not os.path.isdir(PACE_PARTNERS_DIR): return + for (root, dirs, files) in os.walk(PACE_PARTNERS_DIR): for pp_id in dirs: p_id = int(pp_id) - route = '%s/%s/route.bin' % (folder, pp_id) + route = '%s/%s/route.bin' % (PACE_PARTNERS_DIR, pp_id) if os.path.isfile(route): with open(route, 'rb') as fd: global_pace_partners[p_id] = PacePartnerVariables() @@ -375,7 +377,7 @@ def play_pace_partners(): state.id = pp_id state.watchingRiderId = pp_id state.worldTime = zwift_offline.world_time() - ppthreadevent.wait(timeout=update_freq) + ppthreadevent.wait(timeout=pacer_update_freq) def get_empty_message(player_id): message = udp_node_msgs_pb2.ServerToClient() @@ -442,7 +444,7 @@ class UDPHandler(socketserver.BaseRequestHandler): ghosts.loaded = True load_ghosts(player_id, state, ghosts) if state.roadTime and ghosts.last_rt and state.roadTime != ghosts.last_rt: - if t >= ghosts.last_rec + update_freq: + if t >= ghosts.last_rec + ghost_update_freq: s = ghosts.rec.states.add() s.CopyFrom(state) ghosts.last_rec = t @@ -474,7 +476,7 @@ class UDPHandler(socketserver.BaseRequestHandler): for p_id in remove_players: global_ghosts.pop(p_id) - if ghosts.started and t >= ghosts.last_play + update_freq: + if ghosts.started and t >= ghosts.last_play + ghost_update_freq: message = get_empty_message(player_id) active_ghosts = 0 for g in ghosts.play.ghosts: @@ -513,7 +515,7 @@ class UDPHandler(socketserver.BaseRequestHandler): #Check if players are close in world if zwift_offline.is_nearby(nearby_state, player): nearby.append(p_id) - if t >= last_pp_update + update_freq: + if t >= last_pp_update + pacer_update_freq: last_pp_updates[player_id] = t for p_id in global_pace_partners.keys(): pace_partner_variables = global_pace_partners[p_id] diff --git a/standalone.spec b/standalone.spec index f2f35d7..c1fd479 100644 --- a/standalone.spec +++ b/standalone.spec @@ -18,6 +18,7 @@ a = Analysis(['standalone.py'], cipher=block_cipher, noarchive=False) a.datas += Tree('cdn', prefix='cdn') +a.datas += Tree('pace_partners', prefix='pace_partners') pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) exe = EXE(pyz, diff --git a/storage/pace_partners/2462261/route.bin b/storage/pace_partners/2462261/route.bin deleted file mode 100644 index d594062..0000000 Binary files a/storage/pace_partners/2462261/route.bin and /dev/null differ diff --git a/storage/pace_partners/2466327/route.bin b/storage/pace_partners/2466327/route.bin deleted file mode 100644 index 4026389..0000000 Binary files a/storage/pace_partners/2466327/route.bin and /dev/null differ diff --git a/storage/pace_partners/2466331/route.bin b/storage/pace_partners/2466331/route.bin deleted file mode 100644 index 21303ee..0000000 Binary files a/storage/pace_partners/2466331/route.bin and /dev/null differ diff --git a/storage/pace_partners/2466341/route.bin b/storage/pace_partners/2466341/route.bin deleted file mode 100644 index b096601..0000000 Binary files a/storage/pace_partners/2466341/route.bin and /dev/null differ diff --git a/zwift_offline.py b/zwift_offline.py index 1bd6822..720c1e5 100644 --- a/zwift_offline.py +++ b/zwift_offline.py @@ -55,9 +55,11 @@ if getattr(sys, 'frozen', False): # If we're running as a pyinstaller bundle SCRIPT_DIR = sys._MEIPASS STORAGE_DIR = "%s/storage" % os.path.dirname(sys.executable) + PACE_PARTNERS_DIR = '%s/pace_partners' % sys._MEIPASS else: SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) STORAGE_DIR = "%s/storage" % SCRIPT_DIR + PACE_PARTNERS_DIR = '%s/pace_partners' % SCRIPT_DIR try: # Ensure storage dir exists @@ -196,7 +198,10 @@ def get_online(): def get_partial_profile(player_id): if not player_id in player_partial_profiles: #Read from disk - profile_file = '%s/%s/profile.bin' % (STORAGE_DIR, player_id) + if player_id in [2462261, 2466327, 2466331, 2466341]: + profile_file = '%s/%s/profile.bin' % (PACE_PARTNERS_DIR, player_id) + else: + profile_file = '%s/%s/profile.bin' % (STORAGE_DIR, player_id) if os.path.isfile(profile_file): try: with open(profile_file, 'rb') as fd: @@ -722,12 +727,15 @@ def api_profiles(): p.country_code = 0 else: profile = profile_pb2.Profile() - profile_file = '%s/%s/profile.bin' % (STORAGE_DIR, i) + if i in ['2462261', '2466327', '2466331', '2466341']: + profile_file = '%s/%s/profile.bin' % (PACE_PARTNERS_DIR, i) + else: + profile_file = '%s/%s/profile.bin' % (STORAGE_DIR, i) if os.path.isfile(profile_file): with open(profile_file, 'rb') as fd: profile.ParseFromString(fd.read()) - p = profiles.profiles.add() - p.CopyFrom(profile) + p = profiles.profiles.add() + p.CopyFrom(profile) return profiles.SerializeToString(), 200