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