Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion go-hub-game-master-decompiler/gamemaster-decompile.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
#!/bin/bash

# Parse command line arguments
OUTPUT_FILE=""
JSON_OUTPUT=false
while [[ $# -gt 0 ]]; do
case $1 in
-o|--output) OUTPUT_FILE="$2"; shift 2 ;;
-j|--json) JSON_OUTPUT=true; shift ;;
*) shift ;;
esac
done

pogo_protos_path="./dependencies/POGOProtos-master/src/"
pogo_protos_target="POGOProtos.Networking.Responses.DownloadItemTemplatesResponse"
pogo_protos_template="./dependencies/POGOProtos-master/src/POGOProtos/Networking/Responses/DownloadItemTemplatesResponse.proto"
pogo_gamemaster_dir="./game-master-files/"
pogo_gamemaster_name=$(ls -t "$pogo_gamemaster_dir" | head -n1)
pogo_gamemaster=$pogo_gamemaster_dir$(ls -t "$pogo_gamemaster_dir" | head -n1)

./dependencies/protoc-3.2.0-osx-x86_64/bin/protoc --proto_path="$pogo_protos_path" --decode="$pogo_protos_target" "$pogo_protos_template" < "$pogo_gamemaster" >> "$pogo_gamemaster_name"_output.txt
if [ -z "$OUTPUT_FILE" ]; then
OUTPUT_FILE="$pogo_gamemaster_name"_output.txt
fi

if [ "$JSON_OUTPUT" = true ]; then
./dependencies/protoc-3.2.0-osx-x86_64/bin/protoc --proto_path="$pogo_protos_path" --decode="$pogo_protos_target" "$pogo_protos_template" < "$pogo_gamemaster" | python3 -c "
import sys, re, json
data = re.sub(r'\s+', ' ', sys.stdin.read())
data = re.sub(r'(\w+):(?=\s*\w)', r'\"\1\": ', data)
data = re.sub(r':\s+([a-zA-Z_]\w*)', r': \"\1', data)
data = re.sub(r'(?<=\w)(\s+)(?=\w)', r'\", \"', data)
data = re.sub(r'(?<=\"\w)\s*$', '\"', data)
data = re.sub(r'(\w):\s*([a-zA-Z_]\w*)\s*$', r'\"\1\": \"\2\"', data)
print(json.dumps(json.loads(data)))
" > "$OUTPUT_FILE"
else
./dependencies/protoc-3.2.0-osx-x86_64/bin/protoc --proto_path="$pogo_protos_path" --decode="$pogo_protos_target" "$pogo_protos_template" < "$pogo_gamemaster" > "$OUTPUT_FILE"
fi

echo "****************************************************"
echo "* *"
Expand Down