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