Skip to content

Commit

Permalink
Merge branch 'zoffline:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnapalm authored Nov 26, 2024
2 parents b673719 + 184d075 commit c360334
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ zoffline can be installed on the same machine as Zwift or another local machine.
- 3025:3025
restart: unless-stopped
```
* In the ``volumes`` tag replace ``./storage/`` before the ``:`` with the directory path you want to use as your local zoffline data store.
* If you are not running zoffline on the same PC that Zwift is running: create a ``server-ip.txt`` file in the ``storage`` directory containing the IP address of the PC running zoffline.
* Start zoffline with:
``docker-compose up -d ``
Expand Down Expand Up @@ -392,6 +393,14 @@ To enable support for multiple users perform the steps below:
* To unlock all equipment, create a file ``unlock_all_equipment.txt`` instead.
</details>

### Upload activities to Intervals.icu

<details><summary>Expand</summary>

* To upload activities to Intervals.icu, use the "Settings - Intervals" button in the launcher window to enter your credentials (if using Android, access https://secure.zwift.com/intervals/zoffline/).
* Copy "Athlete ID" and "API Key" from https://intervals.icu/settings under "Developer Settings".
</details>

## Community Discord server and Strava club

Please join the community supported [Discord](https://discord.gg/GMdn8F8) server and [Strava](https://www.strava.com/clubs/zoffline) club.
Expand Down
14 changes: 13 additions & 1 deletion protobuf/user_storage.proto
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
syntax = "proto2";

message UserStorage {
optional Attributes attributes = 2;
repeated Attributes attributes = 2;
}

message Attributes {
optional GameSettings game_settings = 22;
optional GarageItemLastSelected garage_last_selected = 23;
optional SpecialEventSeen special_event_seen = 25;
}

message GameSettings {
Expand All @@ -16,3 +18,13 @@ message GameSettings {
optional int32 power_meter_slot2 = 6;
optional int32 power_meter_slot3 = 7;
}

message GarageItemLastSelected {
optional string signature = 1;
optional uint64 time = 2;
}

message SpecialEventSeen {
optional string signature = 1;
optional uint64 time = 2;
}
14 changes: 9 additions & 5 deletions protobuf/user_storage_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions zwift_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3683,16 +3683,22 @@ def api_player_profile_user_game_storage_attributes():
if request.method == 'POST':
new = user_storage_pb2.UserStorage()
new.ParseFromString(request.stream.read())
user_storage.MergeFrom(new)
for n in new.attributes:
for f in n.DESCRIPTOR.fields_by_name:
if n.HasField(f):
for a in list(user_storage.attributes):
if a.HasField(f) and (not 'signature' in getattr(a, f).DESCRIPTOR.fields_by_name \
or getattr(a, f).signature == getattr(n, f).signature):
user_storage.attributes.remove(a)
user_storage.attributes.add().CopyFrom(n)
with open(user_storage_file, 'wb') as f:
f.write(user_storage.SerializeToString())
return '', 202
ret = user_storage_pb2.UserStorage()
n = int(request.args.get('n'))
if n in user_storage.attributes.DESCRIPTOR.fields_by_number:
field = user_storage.attributes.DESCRIPTOR.fields_by_number[n].name
if user_storage.attributes.HasField(field):
getattr(ret.attributes, field).CopyFrom(getattr(user_storage.attributes, field))
for n in request.args.getlist('n'):
for a in user_storage.attributes:
if int(n) in a.DESCRIPTOR.fields_by_number and a.HasField(a.DESCRIPTOR.fields_by_number[int(n)].name):
ret.attributes.add().CopyFrom(a)
return ret.SerializeToString(), 200


Expand Down

0 comments on commit c360334

Please sign in to comment.