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 Sep 7, 2024
2 parents 1c3151b + 4e49bd0 commit d94ee32
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 10 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ zoffline can be installed on the same machine as Zwift or another local machine.
<details><summary>Windows Instructions</summary>

* Install Zwift
* If your Zwift version is 1.0.134990, you're all set.
* If your Zwift version is 1.0.135093, you're all set.
* If Zwift is not installed, install it before installing zoffline.
* If your Zwift version is newer than 1.0.134990 and zoffline is running from source: copy ``C:\Program Files (x86)\Zwift\Zwift_ver_cur.xml`` to zoffline's ``cdn/gameassets/Zwift_Updates_Root/`` overwriting the existing file.
* If your Zwift version is newer than 1.0.134990 and zoffline is not running from source: wait for zoffline to be updated.
* If your Zwift version is newer than 1.0.135093 and zoffline is running from source: copy ``C:\Program Files (x86)\Zwift\Zwift_ver_cur.xml`` to zoffline's ``cdn/gameassets/Zwift_Updates_Root/`` overwriting the existing file.
* If your Zwift version is newer than 1.0.135093 and zoffline is not running from source: wait for zoffline to be updated.
* __NOTE:__ instead of performing the steps below you can instead just run the __configure_client__ script from https://github.com/oldnapalm/zoffline-helper/releases/latest
* On your Windows machine running Zwift, copy the following files in this repo to a known location:
* [ssl/cert-zwift-com.p12](https://github.com/zoffline/zwift-offline/raw/master/ssl/cert-zwift-com.p12)
Expand All @@ -124,9 +124,9 @@ to generate your own certificates and do the same.
<details><summary>macOS Instructions</summary>

* Install Zwift
* If your Zwift version is 1.0.134990, you're all set.
* If your Zwift version is 1.0.135093, you're all set.
* If Zwift is not installed, install it before installing zoffline.
* If your Zwift version is newer than 1.0.134990: copy ``~/Library/Application Support/Zwift/ZwiftMac_ver_cur.xml`` to zoffline's ``cdn/gameassets/Zwift_Updates_Root/`` overwriting the existing file.
* If your Zwift version is newer than 1.0.135093: copy ``~/Library/Application Support/Zwift/ZwiftMac_ver_cur.xml`` to zoffline's ``cdn/gameassets/Zwift_Updates_Root/`` overwriting the existing file.
* On your Mac machine running Zwift, copy the file [ssl/cert-zwift-com.pem](https://github.com/zoffline/zwift-offline/raw/master/ssl/cert-zwift-com.pem) in this repo to a known location.
* Open Keychain Access, select "System" under "Keychains", select "Certificates" under "Category"
* Click "File - Import Items..." and import cert-zwift-com.pem
Expand Down
2 changes: 1 addition & 1 deletion cdn/gameassets/Zwift_Updates_Root/ZwiftMac_ver_cur.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<Zwift version="1.0.134990" sversion="1.73.0 (134990)" gbranch="rc/1.73.0" gcommit="1ac48732c3ec8a63983a2fbdad68a1d00701ed5b" GAME_URL="https://us-or-rly101.zwift.com" manifest="ZwiftMac_1.0.134990_b74574d6_manifest.xml" manifest_checksum="883637182" ver_cur_checksum="-661828331"/>
<Zwift version="1.0.135093" sversion="1.73.2 (135093)" gbranch="rc/1.73.2" gcommit="283b33867cec38fd33e5528841fc9777fd2ba74b" GAME_URL="https://us-or-rly101.zwift.com" manifest="ZwiftMac_1.0.135093_99217986_manifest.xml" manifest_checksum="940942822" ver_cur_checksum="-1495877667"/>
2 changes: 1 addition & 1 deletion cdn/gameassets/Zwift_Updates_Root/Zwift_ver_cur.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<Zwift version="1.0.134990" sversion="1.73.0 (134990)" gbranch="rc/1.73.0" gcommit="1ac48732c3ec8a63983a2fbdad68a1d00701ed5b" GAME_URL="https://us-or-rly101.zwift.com" manifest="Zwift_1.0.134990_b74574d6_manifest.xml" manifest_checksum="-1175175416" ver_cur_checksum="1466249619"/>
<Zwift version="1.0.135093" sversion="1.73.2 (135093)" gbranch="rc/1.73.2" gcommit="283b33867cec38fd33e5528841fc9777fd2ba74b" GAME_URL="https://us-or-rly101.zwift.com" manifest="Zwift_1.0.135093_99217986_manifest.xml" manifest_checksum="232213262" ver_cur_checksum="-1874785425"/>
5 changes: 5 additions & 0 deletions data/variants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,7 @@
},
{
"name": "game_ClassyJazzFlute",
"value": true,
"values": {}
},
{
Expand Down Expand Up @@ -1527,6 +1528,9 @@
"average_power_from_bike_computer": {
"boolValue": true
},
"calculate_road_position_by_dist_fix": {
"varintValue": "0"
},
"dark_mode_color_scheme": {
"boolValue": true
},
Expand Down Expand Up @@ -1700,6 +1704,7 @@
},
{
"name": "gn_deferred_lighting",
"value": true,
"values": {}
},
{
Expand Down
1 change: 1 addition & 0 deletions protobuf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ all:
protoc --python_out=. variants.proto
protoc --python_out=. playback.proto
protoc --python_out=. route-result.proto
protoc --python_out=. user_storage.proto

clean:
rm -f *_pb2.py *_pb2.pyc
1 change: 1 addition & 0 deletions protobuf/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ protoc --python_out=. events.proto
protoc --python_out=. variants.proto
protoc --python_out=. playback.proto
protoc --python_out=. route-result.proto
protoc --python_out=. user_storage.proto

pause
18 changes: 18 additions & 0 deletions protobuf/user_storage.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto2";

message UserStorage {
optional GameSettings game_settings = 2;
}

message GameSettings {
optional Attributes f22 = 22;
}

message Attributes {
optional float f2 = 2;
optional int32 f3 = 3;
optional int32 f4 = 4;
optional int32 f5 = 5;
optional int32 f6 = 6;
optional int32 f7 = 7;
}
29 changes: 29 additions & 0 deletions protobuf/user_storage_pb2.py

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

4 changes: 3 additions & 1 deletion scripts/configure_client.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ TITLE configure_client
ECHO Configuring Zwift client to use zoffline
ECHO.

NET SESSION >nul 2>&1 || ( PowerShell start -verb runas '%~0' & EXIT /B )
NET SESSION >nul 2>&1 || ( PowerShell start -verb runas '"%~0"' & EXIT /B )

CD /D "%~dp0"

SET HOSTS="%WINDIR%\system32\drivers\etc\hosts"
COPY %HOSTS% %HOSTS%.bak >nul
Expand Down
2 changes: 1 addition & 1 deletion scripts/disable_zoffline.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@ECHO OFF
TITLE disable_zoffline

NET SESSION >nul 2>&1 || ( PowerShell start -verb runas '%~0' & EXIT /B )
NET SESSION >nul 2>&1 || ( PowerShell start -verb runas '"%~0"' & EXIT /B )

SET HOSTS="%WINDIR%\system32\drivers\etc\hosts"
COPY %HOSTS% %HOSTS%.bak >nul
Expand Down
27 changes: 26 additions & 1 deletion zwift_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import events_pb2
import variants_pb2
import playback_pb2
import user_storage_pb2
import online_sync

logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
Expand Down Expand Up @@ -1311,7 +1312,6 @@ def api_clubs_club_my_clubs_summary():
@app.route('/api/game-asset-patching-service/manifest', methods=['GET'])
@app.route('/api/race-results', methods=['POST'])
@app.route('/api/workout/progress', methods=['POST'])
@app.route('/api/player-profile/user-game-storage/attributes', methods=['GET', 'POST']) # will load from prefs.xml
def api_proto_empty():
return '', 200

Expand Down Expand Up @@ -3642,6 +3642,31 @@ def api_power_curve_best(option):
return power_curves.SerializeToString(), 200


@app.route('/api/player-profile/user-game-storage/attributes', methods=['GET', 'POST'])
@jwt_to_session_cookie
@login_required
def api_player_profile_user_game_storage_attributes():
user_storage = user_storage_pb2.UserStorage()
user_storage_file = os.path.join(STORAGE_DIR, str(current_user.player_id), 'user_storage.bin')
if os.path.isfile(user_storage_file):
with open(user_storage_file, 'rb') as f:
user_storage.ParseFromString(f.read())
if request.method == 'POST':
new = user_storage_pb2.UserStorage()
new.ParseFromString(request.stream.read())
user_storage.MergeFrom(new)
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.game_settings.DESCRIPTOR.fields_by_number:
field = user_storage.game_settings.DESCRIPTOR.fields_by_number[n].name
if user_storage.game_settings.HasField(field):
getattr(ret.game_settings, field).CopyFrom(getattr(user_storage.game_settings, field))
return ret.SerializeToString(), 200


@app.teardown_request
def teardown_request(exception):
db.session.close()
Expand Down

0 comments on commit d94ee32

Please sign in to comment.