-
Notifications
You must be signed in to change notification settings - Fork 0
/
enable_debug_mode_ze2.sh
executable file
·83 lines (72 loc) · 2.43 KB
/
enable_debug_mode_ze2.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
#!/bin/bash
# Patch VLR main scripts to enable debug mode and replace them in the BinDot file.
# Copyright (C) 2023 KerJoe.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
if [ -z "$1" ]; then
echo "File path to ze2_data_en_us.bin required"
exit 1
fi
BINDOT=$(realpath "$1")
if [ -z "$2" ]; then
echo "Path to lua 5.1 x86 compiler required"
exit 1
fi
if [ $(which $2) ]; then
LUAC=$(which $2)
else
LUAC=$(realpath $2)
fi
if [[ ! $(${LUAC} -v | grep "Lua 5.1") ]]; then
echo "Bad version of lua compiler, expected 5.1"
exit 1
fi
if [[ ! $(file ${LUAC} | grep "Intel 80386") ]]; then
echo "Bad architecture of lua compiler, expected x86"
exit 1
fi
# Go to script directory
DIR="$(dirname -- "${BASH_SOURCE[0]}")"
DIR="$(realpath -e -- "$DIR")"
cd ${DIR}
source .venv/bin/activate
mkdir workdir
mkdir workdir/script_bin
mkdir workdir/script_bin/ae
patch -p1 -d workdir/script_txt < file_analysis/debug_mode.diff
for FILE in "workdir/script_txt/"*.lua; do
if [[ $FILE == "script_txt/*.lua" ]]; then break; fi
FILE_BASE=$(basename $FILE)
echo Converting: ${FILE_BASE}
${LUAC} -o /tmp/$FILE_BASE $FILE
python lua/luac2vlr.py /tmp/$FILE_BASE workdir/script_bin/$FILE_BASE
done
for FILE in "workdir/script_txt/ae/"*.lua; do
if [[ $FILE == "script_txt/ae/*.lua" ]]; then break; fi
FILE_BASE=$(basename $FILE)
echo Converting: ae/${FILE_BASE}
${LUAC} -o /tmp/$FILE_BASE $FILE
python lua/luac2vlr.py /tmp/$FILE_BASE workdir/script_bin/ae/$FILE_BASE
done
rm workdir/script.zip
7z a workdir/script.zip workdir/script_bin
7z rn workdir/script.zip workdir/script_bin script
echo
echo "The \"${BINDOT}\" file will be modified. Are you sure you want to continue?"
select yn in "Yes" "No"; do
case $yn in
Yes ) bindot/patch.py ${BINDOT} workdir/script.zip 2119833045; break ;;
No ) exit 0 ;;
esac
done