-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathNMS-Decompressinator.sh
166 lines (141 loc) · 4.75 KB
/
NMS-Decompressinator.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/bash
# No Man's Sky Decompressinator Script by CheatFreak
# See https://github.com/cheatfreak47/NMSDecompressinator for details.
# It requires:
# PSARC by Sony Computer Entertainment LLC from any PlayStation SDK that includes it. (Bundled copy is from PsArcTool)
# NMSResign 1.0.2 by stk25/emoose/CheatFreak from https://github.com/cheatfreak47/NMSResign
# Initialize argument variables
noBackup=false
force=false
flatpak=false
# Check for arguments
for arg in "$@"; do
case $arg in
-no-backup)
noBackup=true
;;
-force)
force=true
;;
-flatpak)
flatpak=true
;;
esac
done
# Store the original directory
original_dir=$(pwd)
# Create working directory
working_dir="$HOME/nms_working_folder"
mkdir -p "$working_dir"
# Check if psarc.exe and NMSResign.exe exist in the current directory
if [ ! -f psarc.exe ] || [ ! -f NMSResign.exe ]; then
echo "Error: psarc.exe or NMSResign.exe not found in the current directory."
echo "Please put this script, psarc.exe, and NMSResign.exe in the No Man's Sky/GAMEDATA/PCBANKS folder."
echo "Press any key to exit."
read -n 1 -s
exit 1
fi
wine_command=wine
if [ "$flatpak" = true ]; then
echo "Running via flatpak wine. Make sure to use flatseal to allow executing of wine in the home directory"
wine_command="flatpak run org.winehq.Wine"
fi
# Move psarc.exe and NMSResign.exe to working directory
mv psarc.exe NMSResign.exe "$working_dir/"
# Move .pak files to working directory
pak_files=(*.pak)
if [ ${#pak_files[@]} -eq 0 ]; then
echo "Error: No .pak files found in the current directory."
echo "Please put this script in the No Man's Sky/GAMEDATA/PCBANKS folder."
echo "Press any key to exit."
read -n 1 -s
exit 1
fi
mv *.pak "$working_dir/"
# Move BankSignatures.bin and timestamp.txt if they exist
[ -f BankSignatures.bin ] && mv BankSignatures.bin "$working_dir/"
[ -f timestamp.txt ] && mv timestamp.txt "$working_dir/"
# Change to working directory
cd "$working_dir" || exit 1
# Start Message
echo "NMS Decompressinator v2.0.1 by CheatFreak"
echo "-----------------------------------------"
echo "it uses...."
echo " psarc by Sony Computer Entertainment LLC"
echo " (From any PlayStation SDK)"
echo " NMSResign Fork by CheatFreak"
echo " (Original NMSResign by emoose/stk25.)"
echo "-----------------------------------------"
echo "Note: "
echo " It may seem at some points like it has"
echo " stopped and isn't continuing..."
echo " Don't worry, it's fine. Just patiently"
echo " wait for it to finish. It takes time."
echo "-----------------------------------------"
echo "Beginning in..."
sleep 1
echo "5..."
sleep 1
echo "4..."
sleep 1
echo "3..."
sleep 1
echo "2..."
sleep 1
echo "1..."
sleep 1
# Check if timestamp file exists and read it into a variable
if [ -f timestamp.txt ]; then
lastTimestamp=$(cat timestamp.txt)
else
lastTimestamp="1970-01-01 00:00:00"
fi
# Check if PackedFileBackup directory exists
if [ "$noBackup" = false ]; then
mkdir -p PackedFileBackup
fi
# Loop over the files
for f in *.pak; do
# Get the last write time of the current file
fileTime=$(date -r "$f" "+%Y-%m-%d %H:%M:%S")
# Compare the file time with the last timestamp
isFileNewer=$(date -d "$fileTime" +%s)
lastTimestampSeconds=$(date -d "$lastTimestamp" +%s)
if [ "$force" = true ] || [ $isFileNewer -gt $lastTimestampSeconds ]; then
$wine_command psarc.exe extract "$f" --to="${f%.pak}"
if [ "$noBackup" = true ]; then
rm -f "$f"
else
mv -f "$f" PackedFileBackup/
fi
$wine_command psarc.exe create -i "${f%.pak}" -N -y -o "$f" -s ".*?${f%.pak}"
rm -rf "${f%.pak}"
else
echo "Skipping $f. Seems to be already unpacked, based on timestamp."
fi
done
# Backup BankSignatures
if [ -f "BankSignatures.bin" ] && [ "$noBackup" = false ]; then
echo "Backing up BankSignatures.bin"
cp -f "BankSignatures.bin" PackedFileBackup/
fi
# Make New BankSignatures
$wine_command NMSResign.exe -createbin
# Write the current timestamp to the file
date "+%Y-%m-%d %H:%M:%S" > timestamp.txt
# Move processed files back to original directory
mv -f * "$original_dir/"
# Change back to original directory
cd "$original_dir"
# Clean up working directory
rm -rf "$working_dir"
# Exit Message
echo "Process complete!"
echo "-----------------------------------------"
echo "Enjoy a slightly less laggy No Man's Sky!"
echo "-----------------------------------------"
echo "After No Man's Sky updates, it is likely you will get a 'File Tampering' warning on launch."
echo "To fix this, just run the script again and it will decompress the updated files and resign."
echo "See ya next time..."
echo "Press any key to exit."
read -n 1 -s