Rev 333 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 333 | Rev 375 | ||
---|---|---|---|
1 | #!/bin/sh |
1 | #!/bin/sh |
2 | 2 | ||
3 | # Duke Nukem 3D High Resolution Pack Extractor v0.3 2012-03-24 |
3 | # Duke Nukem 3D High Resolution Pack Extractor v0.3 2012-03-24 |
4 | # |
4 | # |
5 | # Author: LeoD |
5 | # Author: LeoD |
6 | # License: ISC license : http://opensource.org/licenses/isc-license.txt |
6 | # License: ISC license : http://opensource.org/licenses/isc-license.txt |
7 | # |
7 | # |
8 | # This script extracts a PolyMER or PolyMOST only HRP from your working copy |
8 | # This script extracts a PolyMER or PolyMOST only HRP from your working copy |
9 | # of the Duke Nukem 3D High Resolution Pack's Subversion repository. |
9 | # of the Duke Nukem 3D High Resolution Pack's Subversion repository. |
10 | # On Windows you might want MSYS' zip to create package files. |
10 | # On Windows you might want MSYS' zip to create package files. |
11 | # ("mingw-get install msys-zip") |
11 | # ("mingw-get install msys-zip") |
12 | # MinGW/MSYS performance is horrible, better go Linux. Even my virtual Debian |
12 | # MinGW/MSYS performance is horrible, better go Linux. Even my virtual Debian |
13 | # machine accessing the Windows drive is 5 to 10 times faster. |
13 | # machine accessing the Windows drive is 5 to 10 times faster. |
14 | # But it still sucks. This needs to become a Perl script one day. |
14 | # But it still sucks. This needs to become a Perl script one day. |
15 | # Or maybe MSYS' bash gets finally updated to 4.* and I'll use its regex engine. |
15 | # Or maybe MSYS' bash gets finally updated to 4.* and I'll use its regex engine. |
16 | 16 | ||
17 | DEF_TOP=UNDEFINED |
17 | DEF_TOP=UNDEFINED |
18 | SET_VERSION=YES # [YES|NO] |
18 | SET_VERSION=YES # [YES|NO] |
19 | EXTRACT_COMMENTED_FILES=NO # [YES|NO] |
19 | EXTRACT_COMMENTED_FILES=NO # [YES|NO] |
20 | DUKEPLUS_POLYMOST_COMPATIBILTY_APPROACH=none # [none|polymost|polymer|mixed] |
20 | DUKEPLUS_POLYMOST_COMPATIBILTY_APPROACH=none # [none|polymost|polymer|mixed] |
21 | 21 | ||
22 | ask() |
22 | ask() |
23 | { |
23 | { |
24 | echo -n "$@" '[y/N] ' ; read ans |
24 | echo -n "$@" '[y/N] ' ; read ans |
25 | case "$ans" in |
25 | case "$ans" in |
26 | y*|Y*) return 0 ;; |
26 | y*|Y*) return 0 ;; |
27 | *) return 1 ;; |
27 | *) return 1 ;; |
28 | esac |
28 | esac |
29 | } # ask |
29 | } # ask |
30 | 30 | ||
31 | 31 | ||
32 | copy_folders() |
32 | copy_folders() |
33 | { |
33 | { |
34 | mkdir ${EXTRACTDIR} |
34 | mkdir ${EXTRACTDIR} |
35 | for HRPDIR in . ; do |
35 | for HRPDIR in . ; do |
36 | if [ -d "${HRPDIR}" ] ; then |
36 | if [ -d "${HRPDIR}" ] ; then |
37 | DIRLIST=./HRP_DIRECTORIES.lst |
37 | DIRLIST=./HRP_DIRECTORIES.lst |
38 | find "${HRPDIR}" -type d > ${DIRLIST} |
38 | find "${HRPDIR}" -type d > ${DIRLIST} |
39 | cat ${DIRLIST} | while read DIR; do |
39 | cat ${DIRLIST} | while read DIR; do |
40 | if [ ! -d "${EXTRACTDIR}/${DIR}" ] ; then |
40 | if [ ! -d "${EXTRACTDIR}/${DIR}" ] ; then |
41 | mkdir "${EXTRACTDIR}/${DIR}" |
41 | mkdir "${EXTRACTDIR}/${DIR}" |
42 | fi |
42 | fi |
43 | done |
43 | done |
44 | rm ${DIRLIST} |
44 | rm ${DIRLIST} |
45 | else |
45 | else |
46 | echo "${HRPDIR} : no HRP." |
46 | echo "${HRPDIR} : no HRP." |
47 | fi |
47 | fi |
48 | done |
48 | done |
49 | } # copy_folders() |
49 | } # copy_folders() |
50 | 50 | ||
51 | 51 | ||
52 | copy_set_version() |
52 | copy_set_version() |
53 | { |
53 | { |
54 | VER_FILE="$1" |
54 | VER_FILE="$1" |
55 | TARGET_FILE="$2" |
55 | TARGET_FILE="$2" |
56 | V_DATE=`date +%F` |
56 | V_DATE=`date +%F` |
57 | if [ "${VERSION}" = "" ] ; then |
57 | if [ "${VERSION}" = "" ] ; then |
58 | if [ -f VERSION ] ; then |
58 | if [ -f VERSION ] ; then |
59 | VERSION=`grep -owE "[0-9\\.]*" VERSION` |
59 | VERSION=`grep -owE "[0-9\\.]*" VERSION` |
60 | fi |
60 | fi |
61 | fi |
61 | fi |
62 | 62 | ||
63 | echo "copy_set_version ${VER_FILE} -> ${TARGET_FILE}" |
63 | echo "copy_set_version ${VER_FILE} -> ${TARGET_FILE}" |
64 | 64 | ||
65 | case "${VER_FILE}" in |
65 | case "${VER_FILE}" in |
66 | hrp_readme.txt) |
66 | hrp_readme.txt) |
67 | cat "${VER_FILE}" | sed -r --posix \ |
67 | cat "${VER_FILE}" | sed -r --posix \ |
68 | s/\(Version\ *\)\([0-9\.]*\)\(.*\)\(\\\)\)\(.*\)/\\1${VERSION}\ \(${V_DATE}\)\ \ \\5/ \ |
68 | s/\(Version\ *\)\([0-9\.]*\)\(.*\)\(\\\)\)\(.*\)/\\1${VERSION}\ \(${V_DATE}\)\ \ \\5/ \ |
69 | >> "${TARGET_FILE}" |
69 | >> "${TARGET_FILE}" |
70 | ;; |
70 | ;; |
71 | duke3d_hrp.def) |
71 | duke3d_hrp.def) |
72 | if [ "${HRPTYPE}" = "polymer" ] ; then |
72 | if [ "${HRPTYPE}" = "polymer" ] ; then |
73 | cat "${VER_FILE}" | sed -r --posix \ |
73 | cat "${VER_FILE}" | sed -r --posix \ |
74 | s/\(Version\ *\)\([0-9\.]*\)\(.*\)/\\1${VERSION}\ Polymer\\3/ \ |
74 | s/\(Version\ *\)\([0-9\.]*\)\(.*\)/\\1${VERSION}\ Polymer\\3/ \ |
75 | >> "${TARGET_FILE}" |
75 | >> "${TARGET_FILE}" |
76 | else |
76 | else |
77 | cat "${VER_FILE}" | sed -r --posix \ |
77 | cat "${VER_FILE}" | sed -r --posix \ |
78 | s/\(Version\ *\)\([0-9\.]*\)\(.*\)/\\1${VERSION}\\3/ \ |
78 | s/\(Version\ *\)\([0-9\.]*\)\(.*\)/\\1${VERSION}\\3/ \ |
79 | >> "${TARGET_FILE}" |
79 | >> "${TARGET_FILE}" |
80 | fi |
80 | fi |
81 | ;; |
81 | ;; |
82 | duke3d_hrp_polymost.def) |
82 | duke3d_hrp_polymost.def) |
83 | if [ "${HRPTYPE}" = "polymost_override" ] ; then |
83 | if [ "${HRPTYPE}" = "polymost_override" ] ; then |
84 | cat "${VER_FILE}" | sed -r --posix \ |
84 | cat "${VER_FILE}" | sed -r --posix \ |
85 | s/\(Version\ *\)\([0-9\.]*\)\(\ Polymost\)/\\1${VERSION}\ Polymost\ Override/ \ |
85 | s/\(Version\ *\)\([0-9\.]*\)\(\ Polymost\)/\\1${VERSION}\ Polymost\ Override/ \ |
86 | >> "${TARGET_FILE}" |
86 | >> "${TARGET_FILE}" |
87 | else |
87 | else |
88 | cat "${VER_FILE}" | sed -r --posix \ |
88 | cat "${VER_FILE}" | sed -r --posix \ |
89 | s/\(Version\ *\)\([0-9\.]*\)\(.*\)/\\1${VERSION}\\3/ \ |
89 | s/\(Version\ *\)\([0-9\.]*\)\(.*\)/\\1${VERSION}\\3/ \ |
90 | >> "${TARGET_FILE}" |
90 | >> "${TARGET_FILE}" |
91 | fi |
91 | fi |
92 | ;; |
92 | ;; |
93 | *) |
93 | *) |
94 | echo "###ERROR: copy_set_version() - BAD FILE: ${VER_FILE}" |
94 | echo "###ERROR: copy_set_version() - BAD FILE: ${VER_FILE}" |
95 | exit 1 |
95 | exit 1 |
96 | ;; |
96 | ;; |
97 | esac |
97 | esac |
98 | } |
98 | } |
99 | 99 | ||
100 | tar_copy_dir() |
100 | tar_copy_dir() |
101 | { |
101 | { |
102 | (cd ${1}; tar cf - . ) | (cd ${2}; tar xf -) |
102 | (cd ${1}; tar cf - . ) | (cd ${2}; tar xf -) |
103 | } |
103 | } |
104 | 104 | ||
105 | copy_known_files() |
105 | copy_known_files() |
106 | { |
106 | { |
107 | if [ "${SET_VERSION}" = "YES" ] ; then |
107 | if [ "${SET_VERSION}" = "YES" ] ; then |
108 | copy_set_version hrp_readme.txt "${EXTRACTDIR}/hrp_readme.txt" |
108 | copy_set_version hrp_readme.txt "${EXTRACTDIR}/hrp_readme.txt" |
109 | else |
109 | else |
110 | cp -pv hrp_readme.txt "${EXTRACTDIR}" |
110 | cp -pv hrp_readme.txt "${EXTRACTDIR}" |
111 | fi |
111 | fi |
112 | cp -pv hrp_art_license.txt "${EXTRACTDIR}" |
112 | cp -pv hrp_art_license.txt "${EXTRACTDIR}" |
113 | 113 | ||
114 | if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "polymost_override" ] ; then |
114 | if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "polymost_override" ] ; then |
115 | if [ "${SET_VERSION}" = "YES" ] ; then |
115 | if [ "${SET_VERSION}" = "YES" ] ; then |
116 | copy_set_version duke3d_hrp_polymost.def "${EXTRACTDIR}/duke3d_hrp.def" |
116 | copy_set_version duke3d_hrp_polymost.def "${EXTRACTDIR}/duke3d_hrp.def" |
117 | else |
117 | else |
118 | cp -pv duke3d_hrp_polymost.def "${EXTRACTDIR}/duke3d_hrp.def" |
118 | cp -pv duke3d_hrp_polymost.def "${EXTRACTDIR}/duke3d_hrp.def" |
119 | fi |
119 | fi |
120 | fi |
120 | fi |
121 | 121 | ||
122 | if [ "${HRPTYPE}" = "polymost" ] ; then |
122 | if [ "${HRPTYPE}" = "polymost" ] ; then |
123 | cp -pv duke3d.def "${EXTRACTDIR}" |
123 | cp -pv duke3d.def "${EXTRACTDIR}" |
124 | #cp -pv duke3d_hrp_polymost.def "${EXTRACTDIR}" |
124 | #cp -pv duke3d_hrp_polymost.def "${EXTRACTDIR}" |
125 | #cp -pv highres/screen/menu/2492_polymost.png "${EXTRACTDIR}/highres/screen/menu" |
125 | #cp -pv highres/screen/menu/2492_polymost.png "${EXTRACTDIR}/highres/screen/menu" |
126 | fi |
126 | fi |
127 | 127 | ||
128 | if [ "${HRPTYPE}" = "full" ] ; then |
128 | if [ "${HRPTYPE}" = "full" ] ; then |
129 | if [ "${SET_VERSION}" = "YES" ] ; then |
129 | if [ "${SET_VERSION}" = "YES" ] ; then |
130 | copy_set_version duke3d_hrp_polymost.def "${EXTRACTDIR}/duke3d_hrp_polymost.def" |
130 | copy_set_version duke3d_hrp_polymost.def "${EXTRACTDIR}/duke3d_hrp_polymost.def" |
131 | else |
131 | else |
132 | cp -pv duke3d_hrp_polymost.def "${EXTRACTDIR}" |
132 | cp -pv duke3d_hrp_polymost.def "${EXTRACTDIR}" |
133 | fi |
133 | fi |
134 | fi |
134 | fi |
135 | 135 | ||
136 | if [ "${HRPTYPE}" = "polymost_override" ] || [ "${HRPTYPE}" = "full" ] ; then |
136 | if [ "${HRPTYPE}" = "polymost_override" ] || [ "${HRPTYPE}" = "full" ] ; then |
137 | cp -pv highres/screen/menu/2492_ver_polymost.png "${EXTRACTDIR}/highres/screen/menu" |
137 | cp -pv highres/screen/menu/2492_ver_polymost.png "${EXTRACTDIR}/highres/screen/menu" |
138 | fi |
138 | fi |
139 | 139 | ||
140 | if [ "${HRPTYPE}" = "polymer" ] || [ "${HRPTYPE}" = "full" ] ; then |
140 | if [ "${HRPTYPE}" = "polymer" ] || [ "${HRPTYPE}" = "full" ] ; then |
141 | cp -pv duke3d.def "${EXTRACTDIR}" |
141 | cp -pv duke3d.def "${EXTRACTDIR}" |
142 | if [ "${SET_VERSION}" = "YES" ] ; then |
142 | if [ "${SET_VERSION}" = "YES" ] ; then |
143 | copy_set_version duke3d_hrp.def "${EXTRACTDIR}/duke3d_hrp.def" |
143 | copy_set_version duke3d_hrp.def "${EXTRACTDIR}/duke3d_hrp.def" |
144 | else |
144 | else |
145 | cp -pv duke3d_hrp.def "${EXTRACTDIR}" |
145 | cp -pv duke3d_hrp.def "${EXTRACTDIR}" |
146 | fi |
146 | fi |
147 | echo "\`*.mhk' -> \`${EXTRACTDIR}/*.mhk'" |
147 | echo "\`*.mhk' -> \`${EXTRACTDIR}/*.mhk'" |
148 | cp -p *.mhk "${EXTRACTDIR}" |
148 | cp -p *.mhk "${EXTRACTDIR}" |
149 | #cp -pv highres/screen/menu/2492.png "${EXTRACTDIR}/highres/screen/menu" |
149 | #cp -pv highres/screen/menu/2492.png "${EXTRACTDIR}/highres/screen/menu" |
150 | 150 | ||
151 | #cp -pv highres/common/black.png "${EXTRACTDIR}/highres/common" |
151 | #cp -pv highres/common/black.png "${EXTRACTDIR}/highres/common" |
152 | #cp -pv highres/screen/fonts/digital/digital_minus.png "${EXTRACTDIR}/highres/screen/fonts/digital" |
152 | #cp -pv highres/screen/fonts/digital/digital_minus.png "${EXTRACTDIR}/highres/screen/fonts/digital" |
153 | #cp -pv highres/screen/menu/2493_old.png "${EXTRACTDIR}/highres/screen/menu" |
153 | #cp -pv highres/screen/menu/2493_old.png "${EXTRACTDIR}/highres/screen/menu" |
154 | #cp -pv highres/screen/menu/widescreen/*_wide.png "${EXTRACTDIR}/highres/screen/menu" |
154 | #cp -pv highres/screen/menu/widescreen/*_wide.png "${EXTRACTDIR}/highres/screen/menu" |
155 | #cp -pv highres/sprites/characters/1357_terminarm.md3 "${EXTRACTDIR}/highres/sprites/characters" |
155 | #cp -pv highres/sprites/characters/1357_terminarm.md3 "${EXTRACTDIR}/highres/sprites/characters" |
156 | #cp -pv highres/sprites/firstperson/2510_devastator_n.png "${EXTRACTDIR}/highres/sprites/firstperson" |
156 | #cp -pv highres/sprites/firstperson/2510_devastator_n.png "${EXTRACTDIR}/highres/sprites/firstperson" |
157 | #cp -pv highres/sprites/monsters/1960_reconcar_s.png "${EXTRACTDIR}/highres/sprites/monsters" |
157 | #cp -pv highres/sprites/monsters/1960_reconcar_s.png "${EXTRACTDIR}/highres/sprites/monsters" |
158 | #cp -pv highres/sprites/props/4387.png "${EXTRACTDIR}/highres/sprites/props" |
158 | #cp -pv highres/sprites/props/4387.png "${EXTRACTDIR}/highres/sprites/props" |
159 | #cp -pv highres/sprites/signs/4378.png "${EXTRACTDIR}/highres/sprites/signs" |
159 | #cp -pv highres/sprites/signs/4378.png "${EXTRACTDIR}/highres/sprites/signs" |
160 | #cp -pv highres/sprites/signs/4379.png "${EXTRACTDIR}/highres/sprites/signs" |
160 | #cp -pv highres/sprites/signs/4379.png "${EXTRACTDIR}/highres/sprites/signs" |
161 | #cp -pv highres/sprites/signs/4381-85.png "${EXTRACTDIR}/highres/sprites/signs" |
161 | #cp -pv highres/sprites/signs/4381-85.png "${EXTRACTDIR}/highres/sprites/signs" |
162 | fi |
162 | fi |
163 | 163 | ||
164 | if [ "${HRPTYPE}" = "voxel" ] ; then |
164 | if [ "${HRPTYPE}" = "voxel" ] ; then |
165 | cp -pv readme.txt "${EXTRACTDIR}" |
165 | cp -pv readme.txt "${EXTRACTDIR}" |
166 | cp -pv voxelp_art_license.txt "${EXTRACTDIR}" |
166 | cp -pv voxelp_art_license.txt "${EXTRACTDIR}" |
167 | cp -pv duke3d.def "${EXTRACTDIR}" |
167 | cp -pv duke3d.def "${EXTRACTDIR}" |
168 | cp -pv duke3d_voxel.def "${EXTRACTDIR}" |
168 | cp -pv duke3d_voxel.def "${EXTRACTDIR}" |
169 | echo "\`*.mhk' -> \`${EXTRACTDIR}/*.mhk'" |
169 | echo "\`*.mhk' -> \`${EXTRACTDIR}/*.mhk'" |
170 | cp -p *.mhk "${EXTRACTDIR}" |
170 | cp -p *.mhk "${EXTRACTDIR}" |
171 | fi |
171 | fi |
172 | 172 | ||
173 | if [ "${HRPTYPE}" = "sw_highres" ] ; then |
173 | if [ "${HRPTYPE}" = "sw_highres" ] ; then |
174 | cp -pv sw.def "${EXTRACTDIR}" |
174 | cp -pv sw.def "${EXTRACTDIR}" |
175 | cp -pv highres/sw_hrp.def "${EXTRACTDIR}/highres" |
175 | cp -pv highres/sw_hrp.def "${EXTRACTDIR}/highres" |
176 | cp -pv HRP.bat "${EXTRACTDIR}" |
176 | cp -pv HRP.bat "${EXTRACTDIR}" |
177 | cp -pv HRP_Readme.txt "${EXTRACTDIR}" |
177 | cp -pv HRP_Readme.txt "${EXTRACTDIR}" |
178 | cp -pv HRP_Changes.txt "${EXTRACTDIR}" |
178 | cp -pv HRP_Changes.txt "${EXTRACTDIR}" |
179 | echo "Copying skyboxes ..." |
179 | echo "Copying skyboxes ..." |
180 | tar_copy_dir "highres/skyboxes" "${EXTRACTDIR}/highres/skyboxes" |
180 | tar_copy_dir "highres/skyboxes" "${EXTRACTDIR}/highres/skyboxes" |
181 | cd "${WORKDIR}" |
181 | cd "${WORKDIR}" |
182 | fi |
182 | fi |
183 | 183 | ||
184 | if [ "${HRPTYPE}" = "sw_lowres" ] ; then |
184 | if [ "${HRPTYPE}" = "sw_lowres" ] ; then |
185 | cp -pv lowres/sw_lrp.def "${EXTRACTDIR}/lowres" |
185 | cp -pv lowres/sw_lrp.def "${EXTRACTDIR}/lowres" |
186 | cp -pv LRP.bat "${EXTRACTDIR}" |
186 | cp -pv LRP.bat "${EXTRACTDIR}" |
187 | cp -pv LRP_Readme.txt "${EXTRACTDIR}" |
187 | cp -pv LRP_Readme.txt "${EXTRACTDIR}" |
188 | cp -pv LRP_Changes.txt "${EXTRACTDIR}" |
188 | cp -pv LRP_Changes.txt "${EXTRACTDIR}" |
189 | echo "Copying skyboxes ..." |
189 | echo "Copying skyboxes ..." |
190 | tar_copy_dir "highres/skyboxes" "${EXTRACTDIR}/highres/skyboxes" |
190 | tar_copy_dir "highres/skyboxes" "${EXTRACTDIR}/highres/skyboxes" |
191 | cd "${WORKDIR}" |
191 | cd "${WORKDIR}" |
192 | fi |
192 | fi |
193 | 193 | ||
194 | if [ "${HRPTYPE}" = "default" ] ; then |
194 | if [ "${HRPTYPE}" = "default" ] ; then |
195 | cp -pv "${DEF_TOP}" "${EXTRACTDIR}/${DEF_TOP}" |
195 | cp -pv "${DEF_TOP}" "${EXTRACTDIR}/${DEF_TOP}" |
196 | echo "\`*.txt' -> \`${EXTRACTDIR}/*.txt'" |
196 | echo "\`*.txt' -> \`${EXTRACTDIR}/*.txt'" |
197 | cp -p *.txt "${EXTRACTDIR}" |
197 | cp -p *.txt "${EXTRACTDIR}" |
198 | fi |
198 | fi |
199 | 199 | ||
200 | } # copy_known_files() |
200 | } # copy_known_files() |
201 | 201 | ||
202 | 202 | ||
203 | polymost_mhk_patch() |
203 | polymost_mhk_patch() |
204 | { |
204 | { |
205 | MHKFILE="$1" |
205 | MHKFILE="$1" |
206 | MHK_LINE="$2" |
206 | MHK_LINE="$2" |
207 | 207 | ||
208 | case "${MHKFILE}" in |
208 | case "${MHKFILE}" in |
209 | "E3L1.mhk") |
209 | "E3L1.mhk") |
210 | echo "${MHK_LINE}" >> "${EXTRACTDIR}/${MHKFILE}" |
210 | echo "${MHK_LINE}" >> "${EXTRACTDIR}/${MHKFILE}" |
211 | MHK_INSERT=`echo "${MHK_LINE}" | grep -oE "sprite\ 575\ pitch\ 1"` |
211 | MHK_INSERT=`echo "${MHK_LINE}" | grep -oE "sprite\ 575\ pitch\ 1"` |
212 | if [ ! "${MHK_INSERT}" = "" ] ; then |
212 | if [ ! "${MHK_INSERT}" = "" ] ; then |
213 | echo "sprite 591 mdxoff 425000 // underwater slimebabe (Polymost HRP)\r" \ |
213 | echo "sprite 591 mdxoff 425000 // underwater slimebabe (Polymost HRP)\r" \ |
214 | >> "${EXTRACTDIR}/${MHKFILE}" |
214 | >> "${EXTRACTDIR}/${MHKFILE}" |
215 | echo "sprite 591 pitch 1\r" >> "${EXTRACTDIR}/${MHKFILE}" |
215 | echo "sprite 591 pitch 1\r" >> "${EXTRACTDIR}/${MHKFILE}" |
216 | echo "sprite 592 mdxoff 425000 // underwater slimebabe (Polymost HRP)\r" \ |
216 | echo "sprite 592 mdxoff 425000 // underwater slimebabe (Polymost HRP)\r" \ |
217 | >> "${EXTRACTDIR}/${MHKFILE}" |
217 | >> "${EXTRACTDIR}/${MHKFILE}" |
218 | echo "sprite 592 pitch 1\r" >> "${EXTRACTDIR}/${MHKFILE}" |
218 | echo "sprite 592 pitch 1\r" >> "${EXTRACTDIR}/${MHKFILE}" |
219 | echo "sprite 593 mdxoff 425000 // underwater slimebabe (Polymost HRP)\r" \ |
219 | echo "sprite 593 mdxoff 425000 // underwater slimebabe (Polymost HRP)\r" \ |
220 | >> "${EXTRACTDIR}/${MHKFILE}" |
220 | >> "${EXTRACTDIR}/${MHKFILE}" |
221 | echo "sprite 593 pitch 1\r" >> "${EXTRACTDIR}/${MHKFILE}" |
221 | echo "sprite 593 pitch 1\r" >> "${EXTRACTDIR}/${MHKFILE}" |
222 | fi |
222 | fi |
223 | ;; |
223 | ;; |
224 | "E3L3.mhk") |
224 | "E3L3.mhk") |
225 | MHK_REPLACE=`echo "${MHK_LINE}" | grep -oE "sprite\ 105\ angoff -128"` |
225 | MHK_REPLACE=`echo "${MHK_LINE}" | grep -oE "sprite\ 105\ angoff -128"` |
226 | if [ ! "${MHK_REPLACE}" = "" ] ; then |
226 | if [ ! "${MHK_REPLACE}" = "" ] ; then |
227 | echo "sprite 105 angoff 768 // (Polymost HRP)\r" >> "${EXTRACTDIR}/${MHKFILE}" |
227 | echo "sprite 105 angoff 768 // (Polymost HRP)\r" >> "${EXTRACTDIR}/${MHKFILE}" |
228 | else |
228 | else |
229 | echo "${MHK_LINE}" >> "${EXTRACTDIR}/${MHKFILE}" |
229 | echo "${MHK_LINE}" >> "${EXTRACTDIR}/${MHKFILE}" |
230 | MHK_INSERT=`echo "${MHK_LINE}" | grep -oE "sprite\ 96\ pitch\ 1"` |
230 | MHK_INSERT=`echo "${MHK_LINE}" | grep -oE "sprite\ 96\ pitch\ 1"` |
231 | if [ ! "${MHK_INSERT}" = "" ] ; then |
231 | if [ ! "${MHK_INSERT}" = "" ] ; then |
232 | echo "sprite 105 mdxoff 450000 // underwater slime babe (Polymost HRP)\r" \ |
232 | echo "sprite 105 mdxoff 450000 // underwater slime babe (Polymost HRP)\r" \ |
233 | >> "${EXTRACTDIR}/${MHKFILE}" |
233 | >> "${EXTRACTDIR}/${MHKFILE}" |
234 | echo "sprite 105 pitch 1\r" >> "${EXTRACTDIR}/${MHKFILE}" |
234 | echo "sprite 105 pitch 1\r" >> "${EXTRACTDIR}/${MHKFILE}" |
235 | echo "sprite 447 mdxoff 462000 // underwater slime babe (Polymost HRP)\r" \ |
235 | echo "sprite 447 mdxoff 462000 // underwater slime babe (Polymost HRP)\r" \ |
236 | >> "${EXTRACTDIR}/${MHKFILE}" |
236 | >> "${EXTRACTDIR}/${MHKFILE}" |
237 | echo "sprite 447 pitch 1\r" >> "${EXTRACTDIR}/${MHKFILE}" |
237 | echo "sprite 447 pitch 1\r" >> "${EXTRACTDIR}/${MHKFILE}" |
238 | fi |
238 | fi |
239 | fi |
239 | fi |
240 | ;; |
240 | ;; |
241 | "E3L6.mhk") |
241 | "E3L6.mhk") |
242 | MHK_REPLACE1=`echo "${MHK_LINE}" | grep -oE "sprite\ 307\ angoff -210"` |
242 | MHK_REPLACE1=`echo "${MHK_LINE}" | grep -oE "sprite\ 307\ angoff -210"` |
243 | MHK_REPLACE2=`echo "${MHK_LINE}" | grep -oE "sprite\ 307\ mdxoff -125000 \\/\\/\ flipped hanging babe"` |
243 | MHK_REPLACE2=`echo "${MHK_LINE}" | grep -oE "sprite\ 307\ mdxoff -125000 \\/\\/\ flipped hanging babe"` |
244 | MHK_REPLACE3=`echo "${MHK_LINE}" | grep -oE "sprite\ 307\ mdzoff -11000"` |
244 | MHK_REPLACE3=`echo "${MHK_LINE}" | grep -oE "sprite\ 307\ mdzoff -11000"` |
245 | if [ ! "${MHK_REPLACE1}" = "" ] ; then |
245 | if [ ! "${MHK_REPLACE1}" = "" ] ; then |
246 | echo "sprite 307 angoff 200 // (Polymost HRP)\r" >> "${EXTRACTDIR}/${MHKFILE}" |
246 | echo "sprite 307 angoff 200 // (Polymost HRP)\r" >> "${EXTRACTDIR}/${MHKFILE}" |
247 | elif [ ! "${MHK_REPLACE2}" = "" ] ; then |
247 | elif [ ! "${MHK_REPLACE2}" = "" ] ; then |
248 | echo "sprite 307 mdxoff 750000 // flipped hanging babe (Polymost HRP)\r" \ |
248 | echo "sprite 307 mdxoff 750000 // flipped hanging babe (Polymost HRP)\r" \ |
249 | >> "${EXTRACTDIR}/${MHKFILE}" |
249 | >> "${EXTRACTDIR}/${MHKFILE}" |
250 | elif [ ! "${MHK_REPLACE3}" = "" ] ; then |
250 | elif [ ! "${MHK_REPLACE3}" = "" ] ; then |
251 | echo "sprite 307 mdzoff 625000 // flipped hanging babe (Polymost HRP)\r" \ |
251 | echo "sprite 307 mdzoff 625000 // flipped hanging babe (Polymost HRP)\r" \ |
252 | >> "${EXTRACTDIR}/${MHKFILE}" |
252 | >> "${EXTRACTDIR}/${MHKFILE}" |
253 | else |
253 | else |
254 | echo "${MHK_LINE}" >> "${EXTRACTDIR}/${MHKFILE}" |
254 | echo "${MHK_LINE}" >> "${EXTRACTDIR}/${MHKFILE}" |
255 | fi |
255 | fi |
256 | ;; |
256 | ;; |
257 | *) |
257 | *) |
258 | echo "${MHK_LINE}" >> "${EXTRACTDIR}/${MHKFILE}" |
258 | echo "${MHK_LINE}" >> "${EXTRACTDIR}/${MHKFILE}" |
259 | ;; |
259 | ;; |
260 | esac |
260 | esac |
261 | } # polymost_mhk_patch() |
261 | } # polymost_mhk_patch() |
262 | 262 | ||
263 | 263 | ||
264 | create_polymost_mhk() |
264 | create_polymost_mhk() |
265 | { |
265 | { |
266 | for MHKFILE in *.mhk ; do |
266 | for MHKFILE in *.mhk ; do |
267 | MHKSTOP="0" |
267 | MHKSTOP="0" |
268 | cat ${MHKFILE} | while read MHK_LINE; do |
268 | cat ${MHKFILE} | while read MHK_LINE; do |
269 | if [ "${MHKSTOP}" = "0" ] ; then |
269 | if [ "${MHKSTOP}" = "0" ] ; then |
270 | 270 | ||
271 | if [ "${MHKFILE}" = "E3L1.mhk" ] || [ "${MHKFILE}" = "E3L3.mhk" ] || \ |
271 | if [ "${MHKFILE}" = "E3L1.mhk" ] || [ "${MHKFILE}" = "E3L3.mhk" ] || \ |
272 | [ "${MHKFILE}" = "E3L6.mhk" ] ; then |
272 | [ "${MHKFILE}" = "E3L6.mhk" ] ; then |
273 | polymost_mhk_patch ${MHKFILE} "${MHK_LINE}" |
273 | polymost_mhk_patch ${MHKFILE} "${MHK_LINE}" |
274 | else |
274 | else |
275 | echo "${MHK_LINE}" >> "${EXTRACTDIR}/${MHKFILE}" |
275 | echo "${MHK_LINE}" >> "${EXTRACTDIR}/${MHKFILE}" |
276 | fi |
276 | fi |
277 | 277 | ||
278 | MHK_TERM=`echo "${MHK_LINE}" | grep -owE "\\/\\/\\ LIGHTS"` |
278 | MHK_TERM=`echo "${MHK_LINE}" | grep -owE "\\/\\/\\ LIGHTS"` |
279 | if [ "${MHK_TERM}" = "// LIGHTS" ] ; then |
279 | if [ "${MHK_TERM}" = "// LIGHTS" ] ; then |
280 | MHKSTOP="1" |
280 | MHKSTOP="1" |
281 | fi |
281 | fi |
282 | fi |
282 | fi |
283 | done |
283 | done |
284 | done |
284 | done |
285 | # Some people prefer unusual setups ... |
285 | # Some people prefer unusual setups ... |
286 | zip -rq9 ${EXTRACTDIR}/polymost_hrp_update_polymer_maphacks.zip *.mhk |
286 | zip -rq9 ${EXTRACTDIR}/polymost_hrp_update_polymer_maphacks.zip *.mhk |
287 | } # create_polymost_mhk() |
287 | } # create_polymost_mhk() |
288 | 288 | ||
289 | 289 | ||
290 | # I really don't know yet if this will become necessary, or if it doesn't make |
290 | # I really don't know yet if this will become necessary, or if it doesn't make |
291 | # sense at all, but at least the files involved are listed. |
291 | # sense at all, but at least the files involved are listed. |
292 | dukeplus_polymost_compatibility() |
292 | dukeplus_polymost_compatibility() |
293 | { |
293 | { |
294 | # dukeplus.def expects some files to be present in the HRP |
294 | # dukeplus.def expects some files to be present in the HRP |
295 | # |
295 | # |
296 | # model "highres/sprites/characters/1405_duke.md3" { // all OK, no action required |
296 | # model "highres/sprites/characters/1405_duke.md3" { // all OK, no action required |
297 | # skin { pal 0 surface 0 file "highres/sprites/pickups/0057_jetpack.png" } |
297 | # skin { pal 0 surface 0 file "highres/sprites/pickups/0057_jetpack.png" } |
298 | # skin { pal 0 surface 1 file "highres/sprites/characters/1405_duke.png" } |
298 | # skin { pal 0 surface 1 file "highres/sprites/characters/1405_duke.png" } |
299 | # skin { pal 10 surface 1 file "highres/sprites/characters/1405_duke_10.png" } |
299 | # skin { pal 10 surface 1 file "highres/sprites/characters/1405_duke_10.png" } |
300 | # skin { pal 11 surface 1 file "highres/sprites/characters/1405_duke_11.png" } |
300 | # skin { pal 11 surface 1 file "highres/sprites/characters/1405_duke_11.png" } |
301 | # skin { pal 12 surface 1 file "highres/sprites/characters/1405_duke_12.png" } |
301 | # skin { pal 12 surface 1 file "highres/sprites/characters/1405_duke_12.png" } |
302 | # skin { pal 13 surface 1 file "highres/sprites/characters/1405_duke_13.png" } |
302 | # skin { pal 13 surface 1 file "highres/sprites/characters/1405_duke_13.png" } |
303 | # skin { pal 14 surface 1 file "highres/sprites/characters/1405_duke_14.png" } |
303 | # skin { pal 14 surface 1 file "highres/sprites/characters/1405_duke_14.png" } |
304 | # skin { pal 15 surface 1 file "highres/sprites/characters/1405_duke_15.png" } |
304 | # skin { pal 15 surface 1 file "highres/sprites/characters/1405_duke_15.png" } |
305 | # skin { pal 16 surface 1 file "highres/sprites/characters/1405_duke_16.png" } |
305 | # skin { pal 16 surface 1 file "highres/sprites/characters/1405_duke_16.png" } |
306 | # skin { pal 21 surface 1 file "highres/sprites/characters/1405_duke_21.png" } |
306 | # skin { pal 21 surface 1 file "highres/sprites/characters/1405_duke_21.png" } |
307 | # skin { pal 23 surface 1 file "highres/sprites/characters/1405_duke_23.png" } |
307 | # skin { pal 23 surface 1 file "highres/sprites/characters/1405_duke_23.png" } |
308 | # skin { pal 0 surface 2 file "highres/sprites/pickups/0023_rpg.png" } |
308 | # skin { pal 0 surface 2 file "highres/sprites/pickups/0023_rpg.png" } |
309 | # |
309 | # |
310 | # model "highres/sprites/firstperson/2510_devastator.md3" { // since Imperium, not Eternity |
310 | # model "highres/sprites/firstperson/2510_devastator.md3" { // since Imperium, not Eternity |
311 | # skin { pal 0 file "highres/sprites/firstperson/2510_devastator.png" specfactor 0.5 specpower 35 } |
311 | # skin { pal 0 file "highres/sprites/firstperson/2510_devastator.png" specfactor 0.5 specpower 35 } |
312 | # specular { file "highres/sprites/firstperson/2510_devastator_s.png" } |
312 | # specular { file "highres/sprites/firstperson/2510_devastator_s.png" } |
313 | # glow { file "highres/sprites/firstperson/2510_devastator_g.png" } |
313 | # glow { file "highres/sprites/firstperson/2510_devastator_g.png" } |
314 | # |
314 | # |
315 | # model "highres/sprites/firstperson/2524_pistol.md3" { // most/mer : same MD3 + same skin til r295 |
315 | # model "highres/sprites/firstperson/2524_pistol.md3" { // most/mer : same MD3 + same skin til r295 |
316 | # skin { pal 0 file "highres/sprites/firstperson/2524_pistol.png" } // up to DP2.30 DNE/IMP only |
316 | # skin { pal 0 file "highres/sprites/firstperson/2524_pistol.png" } // up to DP2.30 DNE/IMP only |
317 | # glow { file "highres/sprites/firstperson/2524_pistol_g.png" } // up to DP2.30 DNE/IMP only |
317 | # glow { file "highres/sprites/firstperson/2524_pistol_g.png" } // up to DP2.30 DNE/IMP only |
318 | # model "highres/sprites/firstperson/2530_clip.md3" { // most/mer : diff MD3, same skin |
318 | # model "highres/sprites/firstperson/2530_clip.md3" { // most/mer : diff MD3, same skin |
319 | # skin { pal 0 file "highres/sprites/pickups/0040_pistolammo.jpg" } |
319 | # skin { pal 0 file "highres/sprites/pickups/0040_pistolammo.jpg" } |
320 | # model "highres/sprites/firstperson/2532_cliphand.md3" { // most/mer : same MD3 + same skin til r295 |
320 | # model "highres/sprites/firstperson/2532_cliphand.md3" { // most/mer : same MD3 + same skin til r295 |
321 | # skin { pal 0 file "highres/sprites/firstperson/2532_cliphand.png" } // til r295, then duke_hand_* |
321 | # skin { pal 0 file "highres/sprites/firstperson/2532_cliphand.png" } // til r295, then duke_hand_* |
322 | # |
322 | # |
323 | 323 | ||
324 | SPR="highres/sprites" |
324 | SPR="highres/sprites" |
325 | SPRE="${EXTRACTDIR}/highres/sprites" |
325 | SPRE="${EXTRACTDIR}/highres/sprites" |
326 | PATCHTYPE=$1 |
326 | PATCHTYPE=$1 |
327 | 327 | ||
328 | case "$PATCHTYPE" in |
328 | case "$PATCHTYPE" in |
329 | polymer) |
329 | polymer) |
330 | echo " # Using \"Polymer approach\")" |
330 | echo " # Using \"Polymer approach\")" |
331 | cp -pi $SPR/firstperson/2510_devastator.md3 "$SPRE/firstperson" |
331 | cp -pi $SPR/firstperson/2510_devastator.md3 "$SPRE/firstperson" |
332 | cp -pi $SPR/firstperson/2510_devastator.png "$SPRE/firstperson" |
332 | cp -pi $SPR/firstperson/2510_devastator.png "$SPRE/firstperson" |
333 | cp -pi $SPR/firstperson/2510_devastator_s.png "$SPRE/firstperson" |
333 | cp -pi $SPR/firstperson/2510_devastator_s.png "$SPRE/firstperson" |
334 | cp -pi $SPR/firstperson/2510_devastator_g.png "$SPRE/firstperson" |
334 | cp -pi $SPR/firstperson/2510_devastator_g.png "$SPRE/firstperson" |
335 | cp -pi $SPR/firstperson/2524_pistol.md3 "$SPRE/firstperson" |
335 | cp -pi $SPR/firstperson/2524_pistol.md3 "$SPRE/firstperson" |
336 | cp -pi $SPR/firstperson_polymost/2524_pistol.png "$SPRE/firstperson" |
336 | cp -pi $SPR/firstperson_polymost/2524_pistol.png "$SPRE/firstperson" |
337 | cp -pi $SPR/firstperson_polymost/2524_pistol_g.png "$SPRE/firstperson" |
337 | cp -pi $SPR/firstperson_polymost/2524_pistol_g.png "$SPRE/firstperson" |
338 | cp -pi $SPR/firstperson/2530_clip.md3 "$SPRE/firstperson" |
338 | cp -pi $SPR/firstperson/2530_clip.md3 "$SPRE/firstperson" |
339 | cp -pi $SPR/pickups/0040_pistolammo.jpg "$SPRE/pickups" |
339 | cp -pi $SPR/pickups/0040_pistolammo.jpg "$SPRE/pickups" |
340 | cp -pi $SPR/firstperson/2532_cliphand.md3 "$SPRE/firstperson" |
340 | cp -pi $SPR/firstperson/2532_cliphand.md3 "$SPRE/firstperson" |
341 | cp -pi $SPR/firstperson/2532_cliphand.png "$SPRE/firstperson" |
341 | cp -pi $SPR/firstperson/2532_cliphand.png "$SPRE/firstperson" |
342 | cp -pi $SPR/firstperson/duke_hand_d.png "$SPRE/firstperson" |
342 | cp -pi $SPR/firstperson/duke_hand_d.png "$SPRE/firstperson" |
343 | cp -pi $SPR/firstperson/duke_hand_n.png "$SPRE/firstperson" |
343 | cp -pi $SPR/firstperson/duke_hand_n.png "$SPRE/firstperson" |
344 | cp -pi $SPR/firstperson/duke_hand_s.png "$SPRE/firstperson" |
344 | cp -pi $SPR/firstperson/duke_hand_s.png "$SPRE/firstperson" |
345 | ;; |
345 | ;; |
346 | polymost) |
346 | polymost) |
347 | echo " # Using (\"Polymost approach\")" |
347 | echo " # Using (\"Polymost approach\")" |
348 | cp -pi $SPR/firstperson_polymost/2510_devastator.md3 "$SPRE/firstperson" |
348 | cp -pi $SPR/firstperson_polymost/2510_devastator.md3 "$SPRE/firstperson" |
349 | cp -pi $SPR/firstperson_polymost/2510_devastator.png "$SPRE/firstperson" |
349 | cp -pi $SPR/firstperson_polymost/2510_devastator.png "$SPRE/firstperson" |
350 | #cp -pi $SPR/firstperson/2510_devastator_s.png "$SPRE/firstperson" |
350 | #cp -pi $SPR/firstperson/2510_devastator_s.png "$SPRE/firstperson" |
351 | cp -pi $SPR/firstperson_polymost/2510_devastator_g.png "$SPRE/firstperson" |
351 | cp -pi $SPR/firstperson_polymost/2510_devastator_g.png "$SPRE/firstperson" |
352 | cp -pi $SPR/firstperson_polymost/2524_pistol.md3 "$SPRE/firstperson" |
352 | cp -pi $SPR/firstperson_polymost/2524_pistol.md3 "$SPRE/firstperson" |
353 | cp -pi $SPR/firstperson_polymost/2524_pistol.png "$SPRE/firstperson" |
353 | cp -pi $SPR/firstperson_polymost/2524_pistol.png "$SPRE/firstperson" |
354 | cp -pi $SPR/firstperson_polymost/2524_pistol_g.png "$SPRE/firstperson" |
354 | cp -pi $SPR/firstperson_polymost/2524_pistol_g.png "$SPRE/firstperson" |
355 | cp -pi $SPR/firstperson_polymost/2530_clip.md3 "$SPRE/firstperson" |
355 | cp -pi $SPR/firstperson_polymost/2530_clip.md3 "$SPRE/firstperson" |
356 | cp -pi $SPR/pickups/0040_pistolammo.jpg "$SPRE/pickups" |
356 | cp -pi $SPR/pickups/0040_pistolammo.jpg "$SPRE/pickups" |
357 | cp -pi $SPR/firstperson_polymost/2532_cliphand.md3 "$SPRE/firstperson" |
357 | cp -pi $SPR/firstperson_polymost/2532_cliphand.md3 "$SPRE/firstperson" |
358 | cp -pi $SPR/firstperson/2532_cliphand.png "$SPRE/firstperson" |
358 | cp -pi $SPR/firstperson/2532_cliphand.png "$SPRE/firstperson" |
359 | cp -pi $SPR/firstperson/duke_hand_d.png "$SPRE/firstperson" |
359 | cp -pi $SPR/firstperson/duke_hand_d.png "$SPRE/firstperson" |
360 | cp -pi $SPR/firstperson/duke_hand_n.png "$SPRE/firstperson" |
360 | cp -pi $SPR/firstperson/duke_hand_n.png "$SPRE/firstperson" |
361 | cp -pi $SPR/firstperson/duke_hand_s.png "$SPRE/firstperson" |
361 | cp -pi $SPR/firstperson/duke_hand_s.png "$SPRE/firstperson" |
362 | ;; |
362 | ;; |
363 | mixed) |
363 | mixed) |
364 | echo " # Using (\"Mixed approach\")" |
364 | echo " # Using (\"Mixed approach\")" |
365 | echo " # Not applied / Not yet implemented" |
365 | echo " # Not applied / Not yet implemented" |
366 | ;; |
366 | ;; |
367 | none) |
367 | none) |
368 | #echo " Not applied" |
368 | #echo " Not applied" |
369 | echo " # Not yet implemented" |
369 | echo " # Not yet implemented" |
370 | ;; |
370 | ;; |
371 | *) |
371 | *) |
372 | echo " # Bad parameter" |
372 | echo " # Bad parameter" |
373 | ;; |
373 | ;; |
374 | esac |
374 | esac |
375 | 375 | ||
376 | } # dukeplus_polymost_compatibility() |
376 | } # dukeplus_polymost_compatibility() |
377 | 377 | ||
378 | 378 | ||
379 | parse_defs() |
379 | parse_defs() |
380 | { |
380 | { |
381 | echo "$1" |
381 | echo "$1" |
382 | BLOCK_COMMENT="OFF" |
382 | BLOCK_COMMENT="OFF" |
383 | cat $1 | while read DEF_LINE; do |
383 | cat $1 | while read DEF_LINE; do |
384 | 384 | ||
385 | #DOS only: DEF_FILE=`echo "${DEF_LINE}" | grep -wE "^include" | sed s/include\ //` |
385 | #DOS only: DEF_FILE=`echo "${DEF_LINE}" | grep -wE "^include" | sed s/include\ //` |
386 | DEF_FILE=`echo "${DEF_LINE}" | grep -wE "^include" | sed s/include\ // | sed s/\\\r//` |
386 | DEF_FILE=`echo "${DEF_LINE}" | grep -wE "^include" | sed s/include\ // | sed s/\\\r//` |
387 | if [ "${DEF_FILE}" != "" ] ; then |
387 | if [ "${DEF_FILE}" != "" ] ; then |
388 | cp -p "${DEF_FILE}" "${EXTRACTDIR}/${DEF_FILE}" |
388 | cp -p "${DEF_FILE}" "${EXTRACTDIR}/${DEF_FILE}" |
389 | parse_defs "${DEF_FILE}" |
389 | parse_defs "${DEF_FILE}" |
390 | fi |
390 | fi |
391 | 391 | ||
392 | HRP_TERM=`echo "${DEF_LINE}" | grep -owE "file|model|voxel|front|right|back|left|top|bottom|down"` |
392 | #HRP_TERM=`echo "${DEF_LINE}" | grep -owE "file|model|voxel|front|right|back|left|top|bottom|down"` |
- | 393 | ## Old style added (except "defineskybox"): |
|
- | 394 | HRP_TERM=`echo "${DEF_LINE}" | grep -owE "definetexture|definemodel|definemodelskin|file|model|voxel|front|right|back|left|top|bottom|down"` |
|
393 | #More skybox tokens: tile, pal, ft|rt|bk|lf|up|dn|forward|lt|ceiling|floor|ceil |
395 | #More skybox tokens: tile, pal, ft|rt|bk|lf|up|dn|forward|lt|ceiling|floor|ceil |
394 | 396 | ||
395 | if [ ! "$EXTRACT_COMMENTED_FILES" = "YES" ] ; then |
397 | if [ ! "$EXTRACT_COMMENTED_FILES" = "YES" ] ; then |
396 | 398 | ||
397 | COMMENT_TERM=`echo "${DEF_LINE}" | grep -oE "\\/\\*|\\*\\/"` |
399 | COMMENT_TERM=`echo "${DEF_LINE}" | grep -oE "\\/\\*|\\*\\/"` |
398 | if [ "$COMMENT_TERM" = "/*" ] ; then BLOCK_COMMENT="ON" ; fi |
400 | if [ "$COMMENT_TERM" = "/*" ] ; then BLOCK_COMMENT="ON" ; fi |
399 | 401 | ||
400 | if [ "$BLOCK_COMMENT" = "ON" ] ; then HRP_TERM="" ; fi |
402 | if [ "$BLOCK_COMMENT" = "ON" ] ; then HRP_TERM="" ; fi |
401 | 403 | ||
402 | if [ "$COMMENT_TERM" = "*/" ] ; then BLOCK_COMMENT="OFF" ; fi |
404 | if [ "$COMMENT_TERM" = "*/" ] ; then BLOCK_COMMENT="OFF" ; fi |
403 | 405 | ||
404 | if [ ! "$HRP_TERM" = "" ] ; then |
406 | if [ ! "$HRP_TERM" = "" ] ; then |
405 | HRP_COMMENT=`echo "${DEF_LINE}" | grep -E "//.*$HRP_TERM"` |
407 | HRP_COMMENT=`echo "${DEF_LINE}" | grep -E "//.*$HRP_TERM"` |
406 | if [ ! "$HRP_COMMENT" = "" ] ; then |
408 | if [ ! "$HRP_COMMENT" = "" ] ; then |
407 | HRP_TERM="" |
409 | HRP_TERM="" |
408 | fi |
410 | fi |
409 | fi |
411 | fi |
410 | 412 | ||
411 | fi |
413 | fi |
412 | 414 | ||
413 | case "$HRP_TERM" in |
415 | case "$HRP_TERM" in |
414 | file) |
416 | file) |
415 | #HRP_FILE=`echo "${DEF_LINE}" | sed -r s/^.*file\ *\"//g | sed s/\".*//` |
417 | #HRP_FILE=`echo "${DEF_LINE}" | sed -r s/^.*file\ *\"//g | sed s/\".*//` |
416 | # Mastering the backslash :-) ... hm, no big performance gain ... : |
418 | # Mastering the backslash :-) ... hm, no big performance gain ... : |
417 | HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*file\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/` |
419 | HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*file\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/` |
418 | # Ignore comments WIP: |
420 | # Ignore comments WIP: |
419 | #HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*file\\ *\\)\\(\\"\\(.*\\)\\"\\)\\(.*\\)/\\\3/` |
421 | #HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*file\\ *\\)\\(\\"\\(.*\\)\\"\\)\\(.*\\)/\\\3/` |
420 | ;; |
422 | ;; |
421 | model|voxel) |
423 | model|voxel) |
422 | HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*${HRP_TERM}\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/` |
424 | HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*${HRP_TERM}\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/` |
423 | ;; |
425 | ;; |
424 | front|right|back|left|top|bottom|down) |
426 | front|right|back|left|top|bottom|down) |
425 | #HRP_FILE=`echo "${DEF_LINE}" | sed -r s/^.*${HRP_TERM}\ *\"//g | sed s/\".*//` |
427 | #HRP_FILE=`echo "${DEF_LINE}" | sed -r s/^.*${HRP_TERM}\ *\"//g | sed s/\".*//` |
426 | HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*${HRP_TERM}\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/` |
428 | HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*${HRP_TERM}\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/` |
427 | ;; |
429 | ;; |
- | 430 | ## Old Style |
|
- | 431 | definemodel) |
|
- | 432 | HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*${HRP_TERM}\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/` |
|
- | 433 | ;; |
|
- | 434 | definemodelskin) |
|
- | 435 | HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*${HRP_TERM}\\ 0\\ \"\\)\\([^\"]*\\)\\(.*\\)/\\\2/` |
|
- | 436 | ;; |
|
- | 437 | definetexture) |
|
- | 438 | # Won't work atm if filename in quotes (too lazy) |
|
- | 439 | #HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(\\.*\\)\\(\\ \\)\\(.*\\)\\($\\)/\\\3/` |
|
- | 440 | HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(\\.*\\)\\(\\ \\)\\([0-9a-zA-Z\\_\\/\\.]*\\)\\(.*\\)/\\\3/` |
|
- | 441 | #echo "DEF_LINE : ${DEF_LINE}" |
|
- | 442 | #echo "HRP_FILE : ${HRP_FILE}" |
|
- | 443 | ;; |
|
428 | *) |
444 | *) |
429 | HRP_FILE="" |
445 | HRP_FILE="" |
430 | ;; |
446 | ;; |
431 | esac |
447 | esac |
432 | 448 | ||
433 | if [ ! "${HRP_FILE}" = "" ] ; then |
449 | if [ ! "${HRP_FILE}" = "" ] ; then |
434 | if [ -f "${HRP_FILE}" ] ; then |
450 | if [ -f "${HRP_FILE}" ] ; then |
435 | cp -p "${HRP_FILE}" "${EXTRACTDIR}/${HRP_FILE}" |
451 | cp -p "${HRP_FILE}" "${EXTRACTDIR}/${HRP_FILE}" |
436 | else |
452 | else |
437 | echo "WARNING : ${HRP_FILE} is missing!" |
453 | echo "WARNING : ${HRP_FILE} is missing!" |
438 | fi |
454 | fi |
439 | fi |
455 | fi |
440 | 456 | ||
441 | done |
457 | done |
442 | } # parse_defs() |
458 | } # parse_defs() |
443 | 459 | ||
444 | 460 | ||
445 | delete_empty_folders() |
461 | delete_empty_folders() |
446 | { |
462 | { |
447 | if [ -d "${EXTRACTDIR}" ] ; then |
463 | if [ -d "${EXTRACTDIR}" ] ; then |
448 | rm -rf ${EXTRACTDIR}/.svn |
464 | rm -rf ${EXTRACTDIR}/.svn |
449 | rm -rf ${EXTRACTDIR}/installer |
465 | rm -rf ${EXTRACTDIR}/installer |
450 | DIRLIST=./EXTRACT_DIRECTORIES.lst |
466 | DIRLIST=./EXTRACT_DIRECTORIES.lst |
451 | du "${EXTRACTDIR}" > ${DIRLIST} |
467 | du "${EXTRACTDIR}" > ${DIRLIST} |
452 | cat ${DIRLIST} | while read DIR ; do |
468 | cat ${DIRLIST} | while read DIR ; do |
453 | if [ "0" = "`echo \"${DIR}\" | grep -owE \"0\"`" ] ; then |
469 | if [ "0" = "`echo \"${DIR}\" | grep -owE \"0\"`" ] ; then |
454 | EMPTYDIR="`echo \"${DIR}\" | sed -r --posix s/0//`" |
470 | EMPTYDIR="`echo \"${DIR}\" | sed -r --posix s/0//`" |
455 | if [ -d ${EMPTYDIR} ] ; then |
471 | if [ -d ${EMPTYDIR} ] ; then |
456 | rmdir ${EMPTYDIR} |
472 | rmdir ${EMPTYDIR} |
457 | fi |
473 | fi |
458 | fi |
474 | fi |
459 | done |
475 | done |
460 | rm ${DIRLIST} |
476 | rm ${DIRLIST} |
461 | else |
477 | else |
462 | echo "No ${EXTRACTDIR}." |
478 | echo "No ${EXTRACTDIR}." |
463 | fi |
479 | fi |
464 | } # delete_empty_folders() |
480 | } # delete_empty_folders() |
465 | 481 | ||
466 | 482 | ||
467 | main() |
483 | main() |
468 | { |
484 | { |
469 | EXTRACTDIR=../hrp_${HRPTYPE}_extract |
485 | EXTRACTDIR=../hrp_${HRPTYPE}_extract |
470 | echo "EXTRACT :" ${HRPROOT}/${EXTRACTDIR} |
486 | echo "EXTRACT :" ${HRPROOT}/${EXTRACTDIR} |
471 | 487 | ||
472 | if [ $FORCE = 0 ] ; then |
488 | if [ $FORCE = 0 ] ; then |
473 | if ask "Proceed?" |
489 | if ask "Proceed?" |
474 | then echo "Extracting ${HRPTYPE} from \"${HRPROOT}\" " |
490 | then echo "Extracting ${HRPTYPE} from \"${HRPROOT}\" " |
475 | else exit 0 |
491 | else exit 0 |
476 | fi |
492 | fi |
477 | fi |
493 | fi |
478 | 494 | ||
479 | date +%F" "%H:%M:%S |
495 | date +%F" "%H:%M:%S |
480 | 496 | ||
481 | echo "### Deleting ${EXTRACTDIR} ... ###" |
497 | echo "### Deleting ${EXTRACTDIR} ... ###" |
482 | rm -rf ${EXTRACTDIR} |
498 | rm -rf ${EXTRACTDIR} |
483 | 499 | ||
484 | echo "### Copying directory tree ... ###" |
500 | echo "### Copying directory tree ... ###" |
485 | copy_folders |
501 | copy_folders |
486 | 502 | ||
487 | echo "### Copying 'known' files ... ###" |
503 | echo "### Copying 'known' files ... ###" |
488 | copy_known_files |
504 | copy_known_files |
489 | 505 | ||
490 | if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "polymost_override" ] ; then |
506 | if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "polymost_override" ] ; then |
491 | echo "### Creating Polymost maphacks ... ###" |
507 | echo "### Creating Polymost maphacks ... ###" |
492 | create_polymost_mhk |
508 | create_polymost_mhk |
493 | 509 | ||
494 | #echo "### DukePlus<>Polymost HRP compatibility patch ... ###" |
510 | #echo "### DukePlus<>Polymost HRP compatibility patch ... ###" |
495 | #dukeplus_polymost_compatibility $DUKEPLUS_POLYMOST_COMPATIBILTY_APPROACH |
511 | #dukeplus_polymost_compatibility $DUKEPLUS_POLYMOST_COMPATIBILTY_APPROACH |
496 | fi |
512 | fi |
497 | 513 | ||
498 | echo "### Parsing DEF file hierarchy ... ###" |
514 | echo "### Parsing DEF file hierarchy ... ###" |
499 | if [ "$EXTRACT_COMMENTED_FILES" = "YES" ] ; then |
515 | if [ "$EXTRACT_COMMENTED_FILES" = "YES" ] ; then |
500 | echo " # Extract commented textures and models: $EXTRACT_COMMENTED_FILES" |
516 | echo " # Extract commented textures and models: $EXTRACT_COMMENTED_FILES" |
501 | else |
517 | else |
502 | echo " # Extract commented textures and models: NO" |
518 | echo " # Extract commented textures and models: NO" |
503 | fi |
519 | fi |
504 | if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "full" ] ; then |
520 | if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "full" ] ; then |
505 | parse_defs duke3d_hrp_polymost.def |
521 | parse_defs duke3d_hrp_polymost.def |
506 | fi |
522 | fi |
507 | if [ "${HRPTYPE}" = "polymer" ] || [ "${HRPTYPE}" = "full" ] ; then |
523 | if [ "${HRPTYPE}" = "polymer" ] || [ "${HRPTYPE}" = "full" ] ; then |
508 | parse_defs duke3d_hrp.def |
524 | parse_defs duke3d_hrp.def |
509 | fi |
525 | fi |
510 | if [ "${HRPTYPE}" = "voxel" ] ; then |
526 | if [ "${HRPTYPE}" = "voxel" ] ; then |
511 | parse_defs duke3d_voxel.def |
527 | parse_defs duke3d_voxel.def |
512 | fi |
528 | fi |
513 | if [ "${HRPTYPE}" = "sw_highres" ] ; then |
529 | if [ "${HRPTYPE}" = "sw_highres" ] ; then |
514 | parse_defs highres/sw_hrp.def |
530 | parse_defs highres/sw_hrp.def |
515 | fi |
531 | fi |
516 | if [ "${HRPTYPE}" = "sw_lowres" ] ; then |
532 | if [ "${HRPTYPE}" = "sw_lowres" ] ; then |
517 | parse_defs lowres/sw_lrp.def |
533 | parse_defs lowres/sw_lrp.def |
518 | fi |
534 | fi |
519 | if [ "${HRPTYPE}" = "default" ] ; then |
535 | if [ "${HRPTYPE}" = "default" ] ; then |
520 | parse_defs "${DEF_TOP}" |
536 | parse_defs "${DEF_TOP}" |
521 | fi |
537 | fi |
522 | 538 | ||
523 | echo "### Deleting empty directories in ${EXTRACTDIR} ... ###" |
539 | echo "### Deleting empty directories in ${EXTRACTDIR} ... ###" |
524 | delete_empty_folders |
540 | delete_empty_folders |
525 | 541 | ||
526 | date +%F" "%H:%M:%S |
542 | date +%F" "%H:%M:%S |
527 | 543 | ||
528 | echo "Command line example for creating a ZIP package:" |
544 | echo "Command line example for creating a ZIP package:" |
529 | echo "sh -c \"cd ${EXTRACTDIR} ; zip -rqn .zip:.jpg:.png ${EXTRACTDIR}.zip *\"" |
545 | echo "sh -c \"cd ${EXTRACTDIR} ; zip -rqn .zip:.jpg:.png ${EXTRACTDIR}.zip *\"" |
530 | } # main() |
546 | } # main() |
531 | 547 | ||
532 | 548 | ||
533 | 549 | ||
534 | PRGPATH=$0 |
550 | PRGPATH=$0 |
535 | HRPTYPE=$1 |
551 | HRPTYPE=$1 |
536 | if [ "$2" = "y" ] ; then FORCE=1 ; else FORCE=0 ; fi |
552 | if [ "$2" = "y" ] ; then FORCE=1 ; else FORCE=0 ; fi |
537 | if [ "$2" = "v" ] && [ ! "$3" = "" ] ; then |
553 | if [ "$2" = "v" ] && [ ! "$3" = "" ] ; then |
538 | VERSION="$3" |
554 | VERSION="$3" |
539 | echo "${VERSION}" > VERSION |
555 | echo "${VERSION}" > VERSION |
540 | fi |
556 | fi |
541 | HRPROOT=. |
557 | HRPROOT=. |
542 | WORKDIR=`pwd` |
558 | WORKDIR=`pwd` |
543 | 559 | ||
544 | cd "${HRPROOT}" |
560 | cd "${HRPROOT}" |
545 | echo "PWD : ${WORKDIR}" |
561 | echo "PWD : ${WORKDIR}" |
546 | echo "HRPROOT : ${HRPROOT}" |
562 | echo "HRPROOT : ${HRPROOT}" |
547 | 563 | ||
548 | #if [ ! -f "./duke3d.def" ] && [ ! "${HRPTYPE}" = "default" ] ; then |
564 | #if [ ! -f "./duke3d.def" ] && [ ! "${HRPTYPE}" = "default" ] ; then |
549 | # echo "ERROR : ./duke3d.def not found. This is no HRP root directory. Exit." |
565 | # echo "ERROR : ./duke3d.def not found. This is no HRP root directory. Exit." |
550 | # exit 1 |
566 | # exit 1 |
551 | #fi |
567 | #fi |
552 | 568 | ||
553 | case "$HRPTYPE" in |
569 | case "$HRPTYPE" in |
554 | polymer|polymost_override|polymost) |
570 | polymer|polymost_override|polymost) |
555 | main $HRPTYPE |
571 | main $HRPTYPE |
556 | ;; |
572 | ;; |
557 | full) |
573 | full) |
558 | if [ $FORCE = 0 ] ; then if ask "Extract full HRP (+ Override Pack)?" |
574 | if [ $FORCE = 0 ] ; then if ask "Extract full HRP (+ Override Pack)?" |
559 | then echo "Extracting ${HRPTYPE} from \"${HRPROOT}\" " |
575 | then echo "Extracting ${HRPTYPE} from \"${HRPROOT}\" " |
560 | else exit 0 |
576 | else exit 0 |
561 | fi ; fi |
577 | fi ; fi |
562 | ${PRGPATH} polymost_override y |
578 | ${PRGPATH} polymost_override y |
563 | main $HRPTYPE |
579 | main $HRPTYPE |
564 | ;; |
580 | ;; |
565 | both) |
581 | both) |
566 | if [ $FORCE = 0 ] ; then if ask "Extract both pure HRP?" |
582 | if [ $FORCE = 0 ] ; then if ask "Extract both pure HRP?" |
567 | then echo "Extracting ${HRPTYPE} from \"${HRPROOT}\" " |
583 | then echo "Extracting ${HRPTYPE} from \"${HRPROOT}\" " |
568 | else exit 0 |
584 | else exit 0 |
569 | fi ; fi |
585 | fi ; fi |
570 | ${PRGPATH} polymer y |
586 | ${PRGPATH} polymer y |
571 | ${PRGPATH} polymost y |
587 | ${PRGPATH} polymost y |
572 | ;; |
588 | ;; |
573 | all) |
589 | all) |
574 | if [ $FORCE = 0 ] ; then if ask "Extract all packs from the repository?" |
590 | if [ $FORCE = 0 ] ; then if ask "Extract all packs from the repository?" |
575 | then echo "Extracting ${HRPTYPE} from \"${HRPROOT}\" " |
591 | then echo "Extracting ${HRPTYPE} from \"${HRPROOT}\" " |
576 | else exit 0 |
592 | else exit 0 |
577 | fi ; fi |
593 | fi ; fi |
578 | ${PRGPATH} both y |
594 | ${PRGPATH} both y |
579 | ${PRGPATH} full y |
595 | ${PRGPATH} full y |
580 | ;; |
596 | ;; |
581 | voxel) |
597 | voxel) |
582 | SET_VERSION=NO |
598 | SET_VERSION=NO |
583 | main $HRPTYPE |
599 | main $HRPTYPE |
584 | ;; |
600 | ;; |
585 | sw_highres|sw_lowres) |
601 | sw_highres|sw_lowres) |
586 | SET_VERSION=NO |
602 | SET_VERSION=NO |
587 | main $HRPTYPE |
603 | main $HRPTYPE |
588 | ;; |
604 | ;; |
589 | sw_both) |
605 | sw_both) |
590 | if [ $FORCE = 0 ] ; then if ask "Extract both Shadow Warrior HRP/LRP?" |
606 | if [ $FORCE = 0 ] ; then if ask "Extract both Shadow Warrior HRP/LRP?" |
591 | then echo "Extracting ${HRPTYPE} from \"${HRPROOT}\" " |
607 | then echo "Extracting ${HRPTYPE} from \"${HRPROOT}\" " |
592 | else exit 0 |
608 | else exit 0 |
593 | fi ; fi |
609 | fi ; fi |
594 | ${PRGPATH} sw_lowres y |
610 | ${PRGPATH} sw_lowres y |
595 | ${PRGPATH} sw_highres y |
611 | ${PRGPATH} sw_highres y |
596 | ;; |
612 | ;; |
597 | unused) |
613 | unused) |
598 | echo "Option \"$1\" not yet implemented." |
614 | echo "Option \"$1\" not yet implemented." |
599 | ;; |
615 | ;; |
600 | debug) |
616 | debug) |
601 | echo "Nothing to debug." |
617 | echo "Nothing to debug." |
602 | ;; |
618 | ;; |
603 | *) |
619 | *) |
604 | #if [ ! -f "./${HRPTYPE}.def" ] ; then |
620 | #if [ ! -f "./${HRPTYPE}.def" ] ; then |
605 | # echo "ERROR : ./${HRPTYPE}.def not found. This is no HRP root directory. Exit." |
621 | # echo "ERROR : ./${HRPTYPE}.def not found. This is no HRP root directory. Exit." |
606 | # exit 1 |
622 | # exit 1 |
607 | #fi |
623 | #fi |
608 | if [ -f "${HRPTYPE}.def" ] ; then |
624 | if [ -f "${HRPTYPE}.def" ] ; then |
609 | DEF_TOP="${HRPTYPE}.def" |
625 | DEF_TOP="${HRPTYPE}.def" |
610 | HRPTYPE=default |
626 | HRPTYPE=default |
611 | SET_VERSION=NO |
627 | SET_VERSION=NO |
612 | EXTRACT_COMMENTED_FILES=NO |
628 | EXTRACT_COMMENTED_FILES=NO |
613 | main $HRPTYPE |
629 | main $HRPTYPE |
614 | else |
630 | else |
615 | echo "Usage: ${0} {HRPTYPE|TOP_DEF} [v VERSION]" |
631 | echo "Usage: ${0} {HRPTYPE|TOP_DEF} [v VERSION]" |
616 | echo "HRPTYPEs: {full|polymer|polymost_override|polymost|both|all}" |
632 | echo "HRPTYPEs: {full|polymer|polymost_override|polymost|both|all}" |
617 | echo "HRPTYPEs: {sw_highres|sw_lowres|sw_both}" |
633 | echo "HRPTYPEs: {sw_highres|sw_lowres|sw_both}" |
618 | echo "TOP_DEF: {Filename without extension}" |
634 | echo "TOP_DEF: {Filename without extension}" |
619 | exit 1 |
635 | exit 1 |
620 | fi |
636 | fi |
621 | ;; |
637 | ;; |
622 | esac |
638 | esac |
623 | 639 | ||
624 | exit 0 |
640 | exit 0 |
625 | 641 |