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