Skip to content

Instantly share code, notes, and snippets.

@apocalyptech
Created May 19, 2022 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apocalyptech/7254e26a4931589fd68266509a5b7460 to your computer and use it in GitHub Desktop.
Save apocalyptech/7254e26a4931589fd68266509a5b7460 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# vim: set expandtab tabstop=4 shiftwidth=4:
import os
import io
import subprocess
# Generate the v2 protobufs
subprocess.run(['./protodec', '/home/pez/bl3_steam_root/OakGame/Binaries/Win64/Borderlands3.exe'])
for filename in sorted(os.listdir('.')):
if filename.startswith('Oak') and filename.endswith('.proto'):
print('Post-processing {}'.format(filename))
# Grab the v2 protobuf
with open(filename) as df:
contents = io.StringIO(df.read())
contents.seek(0)
# Now convert to v3
with open(filename, 'w') as df:
print('syntax = "proto3";', file=df)
for line in contents:
line = line.replace('optional ', '')
line = line.replace('.OakSave.', '')
line = line.replace('.OakProfile.', '')
line = line.replace('.OakShared.', '')
line = line.replace('Profile.', '')
line = line.replace('MissionStatusPlayerSaveGameData.', '')
line = line.replace('Character.', '')
df.write(line.replace("\t", ' '))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment