Subversion Repositories duke3d_hrp

Rev

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
 
324 leod 17
SET_VERSION=YES # [YES|NO]
18
EXTRACT_COMMENTED_FILES=NO # [YES|NO]
19
DUKEPLUS_POLYMOST_COMPATIBILTY_APPROACH=none # [none|polymost|polymer|mixed]
20
 
320 leod 21
ask()
22
{
23
  echo -n "$@" '[y/N] ' ; read ans
24
  case "$ans" in
25
    y*|Y*) return 0 ;;
26
    *)     return 1 ;;
27
  esac
28
} # ask
29
 
30
 
31
copy_folders()
32
{
33
  mkdir ${EXTRACTDIR}
34
  for HRPDIR in . ; do
35
    if [ -d "${HRPDIR}" ] ; then
36
      DIRLIST=./HRP_DIRECTORIES.lst
37
      find "${HRPDIR}" -type d > ${DIRLIST}
38
      cat ${DIRLIST} | while read DIR; do
39
        if [ ! -d "${EXTRACTDIR}/${DIR}" ] ; then
40
          mkdir "${EXTRACTDIR}/${DIR}"
41
        fi
42
      done
43
      rm     ${DIRLIST}
44
    else
45
      echo "${HRPDIR} : no HRP."
46
    fi
47
  done
48
} # copy_folders()
49
 
50
 
324 leod 51
copy_set_version()
52
{
53
  VER_FILE="$1"
54
  TARGET_FILE="$2"
55
  V_DATE=`date +%F`
56
  if [ "${VERSION}" = "" ] ; then
57
    if [ -f VERSION ] ; then
58
      VERSION=`grep -owE "[0-9\\.]*" VERSION`
59
    fi
60
  fi
61
 
62
  echo "copy_set_version ${VER_FILE} -> ${TARGET_FILE}"
63
 
64
  case "${VER_FILE}" in
65
    hrp_readme.txt)
66
      cat "${VER_FILE}" | sed -r --posix \
67
        s/\(Version\ *\)\([0-9\.]*\)\(.*\)\(\\\)\)\(.*\)/\\1${VERSION}\ \(${V_DATE}\)\ \ \\5/ \
68
        >> "${TARGET_FILE}"
69
      ;;
70
    duke3d_hrp.def)
325 leod 71
      if [ "${HRPTYPE}" = "polymer" ] ; then
72
        cat "${VER_FILE}" | sed -r --posix \
73
          s/\(Version\ *\)\([0-9\.]*\)\(.*\)/\\1${VERSION}\ Polymer\\3/ \
74
          >> "${TARGET_FILE}"
75
      else
76
        cat "${VER_FILE}" | sed -r --posix \
77
          s/\(Version\ *\)\([0-9\.]*\)\(.*\)/\\1${VERSION}\\3/ \
78
          >> "${TARGET_FILE}"
79
      fi
324 leod 80
      ;;
81
    duke3d_hrp_polymost.def)
82
      if [ "${HRPTYPE}" = "polymost_override" ] ; then
83
        cat "${VER_FILE}" | sed -r --posix \
84
          s/\(Version\ *\)\([0-9\.]*\)\(\ Polymost\)/\\1${VERSION}\ Polymost\ Override/ \
85
          >> "${TARGET_FILE}"
86
      else
87
        cat "${VER_FILE}" | sed -r --posix \
88
          s/\(Version\ *\)\([0-9\.]*\)\(.*\)/\\1${VERSION}\\3/ \
89
          >> "${TARGET_FILE}"
90
      fi
91
      ;;
92
    *)
93
      echo "###ERROR: copy_set_version() - BAD FILE: ${VER_FILE}"
94
      exit 1
95
      ;;
96
  esac
97
}
98
 
320 leod 99
copy_known_files()
100
{
324 leod 101
  if [ "${SET_VERSION}" = "YES" ] ; then
102
    copy_set_version hrp_readme.txt "${EXTRACTDIR}/hrp_readme.txt"
103
  else
104
    cp -pv hrp_readme.txt           "${EXTRACTDIR}"
105
  fi
106
  cp -pv hrp_art_license.txt        "${EXTRACTDIR}"
320 leod 107
 
108
  if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "polymost_override" ] ; then
324 leod 109
    if [ "${SET_VERSION}" = "YES" ] ; then
110
      copy_set_version duke3d_hrp_polymost.def "${EXTRACTDIR}/duke3d_hrp.def"
111
    else
112
      cp -pv           duke3d_hrp_polymost.def "${EXTRACTDIR}/duke3d_hrp.def"
113
    fi
320 leod 114
  fi
115
 
116
  if [ "${HRPTYPE}" = "polymost" ] ; then
117
    cp -pv duke3d.def "${EXTRACTDIR}"
118
    #cp -pv duke3d_hrp_polymost.def               "${EXTRACTDIR}"
119
    #cp -pv highres/screen/menu/2492_polymost.png "${EXTRACTDIR}/highres/screen/menu"
120
  fi
121
 
122
  if [ "${HRPTYPE}" = "full" ] ; then
324 leod 123
    if [ "${SET_VERSION}" = "YES" ] ; then
124
      copy_set_version duke3d_hrp_polymost.def "${EXTRACTDIR}/duke3d_hrp_polymost.def"
125
    else
126
      cp -pv           duke3d_hrp_polymost.def "${EXTRACTDIR}"
127
    fi
320 leod 128
  fi
129
 
130
  if [ "${HRPTYPE}" = "polymost_override" ] || [ "${HRPTYPE}" = "full" ] ; then
131
    cp -pv highres/screen/menu/2492_ver_polymost.png "${EXTRACTDIR}/highres/screen/menu"
132
  fi
133
 
134
  if [ "${HRPTYPE}" = "polymer" ] || [ "${HRPTYPE}" = "full" ] ; then
135
    cp -pv duke3d.def                   "${EXTRACTDIR}"
324 leod 136
    if [ "${SET_VERSION}" = "YES" ] ; then
137
      copy_set_version duke3d_hrp.def "${EXTRACTDIR}/duke3d_hrp.def"
138
    else
139
      cp -pv           duke3d_hrp.def "${EXTRACTDIR}"
140
    fi
320 leod 141
    echo                  "\`*.mhk' -> \`${EXTRACTDIR}/*.mhk'"
142
    cp -p  *.mhk                        "${EXTRACTDIR}"
143
    #cp -pv highres/screen/menu/2492.png "${EXTRACTDIR}/highres/screen/menu"
144
 
324 leod 145
    #cp -pv highres/common/black.png                          "${EXTRACTDIR}/highres/common"
146
    #cp -pv highres/screen/fonts/digital/digital_minus.png    "${EXTRACTDIR}/highres/screen/fonts/digital"
147
    #cp -pv highres/screen/menu/2493_old.png                  "${EXTRACTDIR}/highres/screen/menu"
148
    #cp -pv highres/screen/menu/widescreen/*_wide.png         "${EXTRACTDIR}/highres/screen/menu"
149
    #cp -pv highres/sprites/characters/1357_terminarm.md3     "${EXTRACTDIR}/highres/sprites/characters"
150
    #cp -pv highres/sprites/firstperson/2510_devastator_n.png "${EXTRACTDIR}/highres/sprites/firstperson"
151
    #cp -pv highres/sprites/monsters/1960_reconcar_s.png      "${EXTRACTDIR}/highres/sprites/monsters"
152
    #cp -pv highres/sprites/props/4387.png                    "${EXTRACTDIR}/highres/sprites/props"
153
    #cp -pv highres/sprites/signs/4378.png                    "${EXTRACTDIR}/highres/sprites/signs"
154
    #cp -pv highres/sprites/signs/4379.png                    "${EXTRACTDIR}/highres/sprites/signs"
155
    #cp -pv highres/sprites/signs/4381-85.png                 "${EXTRACTDIR}/highres/sprites/signs"
320 leod 156
  fi
157
 
158
} # copy_known_files()
159
 
160
 
161
polymost_mhk_patch()
162
{
163
  MHKFILE="$1"
164
  MHK_LINE="$2"
165
 
166
  case "${MHKFILE}" in
167
    "E3L1.mhk")
168
      echo "${MHK_LINE}" >> "${EXTRACTDIR}/${MHKFILE}"
169
      MHK_INSERT=`echo "${MHK_LINE}" | grep -oE "sprite\ 575\ pitch\ 1"`
170
      if [ ! "${MHK_INSERT}" = "" ] ; then
171
        echo "sprite 591 mdxoff 425000 // underwater slimebabe (Polymost HRP)\r" \
172
             >> "${EXTRACTDIR}/${MHKFILE}"
173
        echo "sprite 591 pitch 1\r" >> "${EXTRACTDIR}/${MHKFILE}"
174
        echo "sprite 592 mdxoff 425000 // underwater slimebabe (Polymost HRP)\r" \
175
             >> "${EXTRACTDIR}/${MHKFILE}"
176
        echo "sprite 592 pitch 1\r" >> "${EXTRACTDIR}/${MHKFILE}"
177
        echo "sprite 593 mdxoff 425000 // underwater slimebabe (Polymost HRP)\r" \
178
             >> "${EXTRACTDIR}/${MHKFILE}"
179
        echo "sprite 593 pitch 1\r" >> "${EXTRACTDIR}/${MHKFILE}"
180
      fi
181
      ;;
182
    "E3L3.mhk")
183
      MHK_REPLACE=`echo "${MHK_LINE}" | grep -oE "sprite\ 105\ angoff -128"`
184
      if [ ! "${MHK_REPLACE}" = "" ] ; then
185
        echo "sprite 105 angoff 768 // (Polymost HRP)\r" >> "${EXTRACTDIR}/${MHKFILE}"
186
      else
187
        echo "${MHK_LINE}" >> "${EXTRACTDIR}/${MHKFILE}"
188
        MHK_INSERT=`echo "${MHK_LINE}" | grep -oE "sprite\ 96\ pitch\ 1"`
189
        if [ ! "${MHK_INSERT}" = "" ] ; then
190
          echo "sprite 105 mdxoff 450000 // underwater slime babe (Polymost HRP)\r" \
324 leod 191
                                      >> "${EXTRACTDIR}/${MHKFILE}"
320 leod 192
          echo "sprite 105 pitch 1\r" >> "${EXTRACTDIR}/${MHKFILE}"
193
          echo "sprite 447 mdxoff 462000 // underwater slime babe (Polymost HRP)\r" \
324 leod 194
                                      >> "${EXTRACTDIR}/${MHKFILE}"
320 leod 195
          echo "sprite 447 pitch 1\r" >> "${EXTRACTDIR}/${MHKFILE}"
196
        fi
197
      fi
198
      ;;
199
    "E3L6.mhk")
200
      MHK_REPLACE1=`echo "${MHK_LINE}" | grep -oE "sprite\ 307\ angoff -210"`
201
      MHK_REPLACE2=`echo "${MHK_LINE}" | grep -oE "sprite\ 307\ mdxoff -125000 \\/\\/\ flipped hanging babe"`
202
      MHK_REPLACE3=`echo "${MHK_LINE}" | grep -oE "sprite\ 307\ mdzoff -11000"`
324 leod 203
      if   [ ! "${MHK_REPLACE1}" = "" ] ; then
320 leod 204
        echo "sprite 307 angoff 200 // (Polymost HRP)\r" >> "${EXTRACTDIR}/${MHKFILE}"
205
      elif [ ! "${MHK_REPLACE2}" = "" ] ; then
206
        echo "sprite 307 mdxoff 750000 // flipped hanging babe (Polymost HRP)\r" \
324 leod 207
             >> "${EXTRACTDIR}/${MHKFILE}"
320 leod 208
      elif [ ! "${MHK_REPLACE3}" = "" ] ; then
209
        echo "sprite 307 mdzoff 625000 // flipped hanging babe (Polymost HRP)\r" \
324 leod 210
             >> "${EXTRACTDIR}/${MHKFILE}"
320 leod 211
      else
212
        echo "${MHK_LINE}" >> "${EXTRACTDIR}/${MHKFILE}"
213
      fi
214
      ;;
215
    *)
216
      echo "${MHK_LINE}" >> "${EXTRACTDIR}/${MHKFILE}"
217
      ;;
218
  esac
219
} # polymost_mhk_patch()
220
 
221
 
222
create_polymost_mhk()
223
{
224
  for MHKFILE in *.mhk ; do
225
    MHKSTOP="0"
226
    cat   ${MHKFILE} | while read MHK_LINE; do
227
      if [ "${MHKSTOP}" = "0" ] ; then
228
 
229
        if [ "${MHKFILE}" = "E3L1.mhk" ] || [ "${MHKFILE}" = "E3L3.mhk" ] || \
230
           [ "${MHKFILE}" = "E3L6.mhk" ] ; then
231
          polymost_mhk_patch ${MHKFILE} "${MHK_LINE}"
232
        else
233
          echo "${MHK_LINE}" >> "${EXTRACTDIR}/${MHKFILE}"
234
        fi
235
 
236
        MHK_TERM=`echo "${MHK_LINE}" | grep -owE "\\/\\/\\ LIGHTS"`
237
        if [ "${MHK_TERM}" = "// LIGHTS" ] ; then
238
          MHKSTOP="1"
239
        fi
240
      fi
241
    done
242
  done
243
  # Some people prefer unusual setups ...
244
  zip -rq9 ${EXTRACTDIR}/polymost_hrp_update_polymer_maphacks.zip *.mhk
245
} # create_polymost_mhk()
246
 
247
 
324 leod 248
# I really don't know yet if this will become necessary, or if it doesn't make
249
# sense at all, but at least the files involved are listed.
250
dukeplus_polymost_compatibility()
320 leod 251
{
324 leod 252
  # dukeplus.def expects some files to be present in the HRP
253
  #
254
  # model "highres/sprites/characters/1405_duke.md3" { // all OK, no action required
255
  #    skin { pal 0 surface 0 file "highres/sprites/pickups/0057_jetpack.png" }
256
  #    skin { pal 0 surface 1 file "highres/sprites/characters/1405_duke.png" }
257
  #    skin { pal 10 surface 1 file "highres/sprites/characters/1405_duke_10.png" }
258
  #    skin { pal 11 surface 1 file "highres/sprites/characters/1405_duke_11.png" }
259
  #    skin { pal 12 surface 1 file "highres/sprites/characters/1405_duke_12.png" }
260
  #    skin { pal 13 surface 1 file "highres/sprites/characters/1405_duke_13.png" }
261
  #    skin { pal 14 surface 1 file "highres/sprites/characters/1405_duke_14.png" }
262
  #    skin { pal 15 surface 1 file "highres/sprites/characters/1405_duke_15.png" }
263
  #    skin { pal 16 surface 1 file "highres/sprites/characters/1405_duke_16.png" }
264
  #    skin { pal 21 surface 1 file "highres/sprites/characters/1405_duke_21.png" }
265
  #    skin { pal 23 surface 1 file "highres/sprites/characters/1405_duke_23.png" }
266
  #    skin { pal 0 surface 2 file "highres/sprites/pickups/0023_rpg.png" }
267
  #
268
  # model "highres/sprites/firstperson/2510_devastator.md3" { // since Imperium, not Eternity
269
  #    skin { pal 0 file "highres/sprites/firstperson/2510_devastator.png" specfactor 0.5 specpower 35 }
270
  #    specular { file "highres/sprites/firstperson/2510_devastator_s.png" }
271
  #    glow { file "highres/sprites/firstperson/2510_devastator_g.png" }
272
  #
273
  # model "highres/sprites/firstperson/2524_pistol.md3" {    // most/mer : same MD3 + same skin til r295     
274
  #    skin { pal 0 file "highres/sprites/firstperson/2524_pistol.png" } // up to DP2.30 DNE/IMP only
275
  #    glow { file "highres/sprites/firstperson/2524_pistol_g.png" }     // up to DP2.30 DNE/IMP only
276
  # model "highres/sprites/firstperson/2530_clip.md3" {                  // most/mer : diff MD3, same skin
277
  #    skin { pal 0 file "highres/sprites/pickups/0040_pistolammo.jpg" }
278
  # model "highres/sprites/firstperson/2532_cliphand.md3" {  // most/mer : same MD3 + same skin til r295
279
  #    skin { pal 0 file "highres/sprites/firstperson/2532_cliphand.png" } // til r295, then duke_hand_*
280
  #
320 leod 281
 
324 leod 282
  SPR="highres/sprites"
283
  SPRE="${EXTRACTDIR}/highres/sprites"
284
  PATCHTYPE=$1
320 leod 285
 
324 leod 286
  case "$PATCHTYPE" in
287
    polymer)
288
      echo "  # Using \"Polymer approach\")"
289
      cp -pi $SPR/firstperson/2510_devastator.md3            "$SPRE/firstperson"
290
      cp -pi $SPR/firstperson/2510_devastator.png            "$SPRE/firstperson"
291
      cp -pi $SPR/firstperson/2510_devastator_s.png          "$SPRE/firstperson"
292
      cp -pi $SPR/firstperson/2510_devastator_g.png          "$SPRE/firstperson"
293
      cp -pi $SPR/firstperson/2524_pistol.md3                "$SPRE/firstperson"
294
      cp -pi $SPR/firstperson_polymost/2524_pistol.png       "$SPRE/firstperson"
295
      cp -pi $SPR/firstperson_polymost/2524_pistol_g.png     "$SPRE/firstperson"
296
      cp -pi $SPR/firstperson/2530_clip.md3                  "$SPRE/firstperson"
297
      cp -pi $SPR/pickups/0040_pistolammo.jpg                "$SPRE/pickups"
298
      cp -pi $SPR/firstperson/2532_cliphand.md3              "$SPRE/firstperson"
299
      cp -pi $SPR/firstperson/2532_cliphand.png              "$SPRE/firstperson"
300
      cp -pi $SPR/firstperson/duke_hand_d.png                "$SPRE/firstperson"
301
      cp -pi $SPR/firstperson/duke_hand_n.png                "$SPRE/firstperson"
302
      cp -pi $SPR/firstperson/duke_hand_s.png                "$SPRE/firstperson"
303
      ;;
304
    polymost)
305
      echo "  # Using (\"Polymost approach\")"
306
      cp -pi $SPR/firstperson_polymost/2510_devastator.md3   "$SPRE/firstperson"
307
      cp -pi $SPR/firstperson_polymost/2510_devastator.png   "$SPRE/firstperson"
308
      #cp -pi $SPR/firstperson/2510_devastator_s.png          "$SPRE/firstperson"
309
      cp -pi $SPR/firstperson_polymost/2510_devastator_g.png "$SPRE/firstperson"
310
      cp -pi $SPR/firstperson_polymost/2524_pistol.md3       "$SPRE/firstperson"
311
      cp -pi $SPR/firstperson_polymost/2524_pistol.png       "$SPRE/firstperson"
312
      cp -pi $SPR/firstperson_polymost/2524_pistol_g.png     "$SPRE/firstperson"
313
      cp -pi $SPR/firstperson_polymost/2530_clip.md3         "$SPRE/firstperson"
314
      cp -pi $SPR/pickups/0040_pistolammo.jpg                "$SPRE/pickups"
315
      cp -pi $SPR/firstperson_polymost/2532_cliphand.md3     "$SPRE/firstperson"
316
      cp -pi $SPR/firstperson/2532_cliphand.png              "$SPRE/firstperson"
317
      cp -pi $SPR/firstperson/duke_hand_d.png                "$SPRE/firstperson"
318
      cp -pi $SPR/firstperson/duke_hand_n.png                "$SPRE/firstperson"
319
      cp -pi $SPR/firstperson/duke_hand_s.png                "$SPRE/firstperson"
320
      ;;
321
    mixed)
322
      echo "  # Using (\"Mixed approach\")"
323
      echo "    # Not applied / Not yet implemented"
324
      ;;
325
    none)
326
      #echo "  Not applied"
327
      echo "  # Not yet implemented"
328
      ;;
329
    *)
330
      echo "  # Bad parameter"
331
      ;;
332
  esac
333
 
334
} # dukeplus_polymost_compatibility()
335
 
336
 
320 leod 337
parse_defs()
338
{
339
  echo "$1"
324 leod 340
  BLOCK_COMMENT="OFF"
320 leod 341
  cat $1 | while read DEF_LINE; do
342
 
343
    #DOS only: DEF_FILE=`echo "${DEF_LINE}" | grep -wE "^include" | sed s/include\ //`
344
    DEF_FILE=`echo "${DEF_LINE}" | grep -wE "^include" | sed s/include\ // | sed s/\\\r//`
345
    if [ "${DEF_FILE}" != "" ] ; then
346
      cp -p      "${DEF_FILE}" "${EXTRACTDIR}/${DEF_FILE}"
347
      parse_defs "${DEF_FILE}"
348
    fi
349
 
350
    HRP_TERM=`echo "${DEF_LINE}" | grep -owE "file|model|front|right|back|left|top|down"`
351
 
324 leod 352
    if [ ! "$EXTRACT_COMMENTED_FILES" = "YES" ] ; then
353
 
354
      COMMENT_TERM=`echo "${DEF_LINE}" | grep -oE "\\/\\*|\\*\\/"`
355
      if [ "$COMMENT_TERM"  = "/*" ] ; then BLOCK_COMMENT="ON" ; fi
356
 
357
      if [ "$BLOCK_COMMENT" = "ON" ] ; then HRP_TERM="" ; fi
358
 
359
      if [ "$COMMENT_TERM"  = "*/" ] ; then BLOCK_COMMENT="OFF" ; fi
360
 
361
      if [ ! "$HRP_TERM" = "" ] ; then
362
        HRP_COMMENT=`echo "${DEF_LINE}" | grep -E "//.*$HRP_TERM"`
363
        if [ ! "$HRP_COMMENT" = "" ] ; then
364
          HRP_TERM=""
365
        fi
366
      fi
367
 
368
    fi
369
 
320 leod 370
    case "$HRP_TERM" in
371
      file)
372
        #HRP_FILE=`echo "${DEF_LINE}" | sed -r s/^.*file\ *\"//g | sed s/\".*//`
373
        # Mastering the backslash :-) ... hm, no big performance gain ... :
374
        HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*file\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/`
375
        # Ignore comments WIP:
376
        #HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*file\\ *\\)\\(\\"\\(.*\\)\\"\\)\\(.*\\)/\\\3/`
377
        ;;
378
      model)
379
        HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*model\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/`
380
        ;;
381
      front|right|back|left|top|down)
382
        #HRP_FILE=`echo "${DEF_LINE}" | sed -r s/^.*${HRP_TERM}\ *\"//g | sed s/\".*//`
383
        HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*${HRP_TERM}\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/`
384
        ;;
385
      *)
386
        HRP_FILE=""
387
        ;;
388
    esac
389
 
390
    if [  !   "${HRP_FILE}" = "" ] ; then
391
      if [ -f "${HRP_FILE}" ] ; then
392
        cp -p "${HRP_FILE}" "${EXTRACTDIR}/${HRP_FILE}"
393
      else
394
        echo  "WARNING : ${HRP_FILE} is missing!"
395
      fi
396
    fi
397
 
398
  done
399
} # parse_defs()
400
 
401
 
402
delete_empty_folders()
403
{
404
    if [ -d "${EXTRACTDIR}" ] ; then
405
      rm -rf ${EXTRACTDIR}/.svn
406
      rm -rf ${EXTRACTDIR}/installer
407
      DIRLIST=./EXTRACT_DIRECTORIES.lst
408
      du "${EXTRACTDIR}" > ${DIRLIST}
409
      cat ${DIRLIST} | while read DIR ; do
410
        if [ "0" = "`echo \"${DIR}\" | grep -owE \"0\"`" ] ; then
411
          EMPTYDIR="`echo \"${DIR}\" | sed -r --posix s/0//`"
412
          if [ -d ${EMPTYDIR} ] ; then
413
            rmdir ${EMPTYDIR}
414
          fi
415
        fi
416
      done
417
      rm ${DIRLIST}
418
    else
419
      echo "No ${EXTRACTDIR}."
420
    fi
421
} # delete_empty_folders()
422
 
423
 
424
main()
425
{
426
  EXTRACTDIR=../hrp_${HRPTYPE}_extract
427
  echo  "EXTRACT :" ${HRPROOT}/${EXTRACTDIR}
428
 
429
  if [ $FORCE = 0 ] ; then
430
    if ask "Proceed?"
431
      then echo "Extracting ${HRPTYPE} from \"${HRPROOT}\" "
432
      else exit 0
433
    fi
434
  fi
435
 
436
  date +%F" "%H:%M:%S
437
 
438
  echo "### Deleting ${EXTRACTDIR} ... ###"
439
  rm -rf ${EXTRACTDIR}
440
 
441
  echo "### Copying directory tree ... ###"
442
  copy_folders
443
 
444
  echo "### Copying 'known' files ... ###"
445
  copy_known_files
446
 
447
  if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "polymost_override" ] ; then
448
    echo "### Creating Polymost maphacks ... ###"
449
    create_polymost_mhk
450
 
324 leod 451
    #echo "### DukePlus<>Polymost HRP compatibility patch ... ###"
452
    #dukeplus_polymost_compatibility $DUKEPLUS_POLYMOST_COMPATIBILTY_APPROACH
320 leod 453
  fi
454
 
455
  echo "### Parsing DEF file hierarchy ... ###"
324 leod 456
  if [ "$EXTRACT_COMMENTED_FILES" = "YES" ] ; then
457
    echo "  # Extract commented textures and models: $EXTRACT_COMMENTED_FILES"
458
  else
459
    echo "  # Extract commented textures and models: NO"
460
  fi
320 leod 461
  if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "full" ] ; then
462
    parse_defs duke3d_hrp_polymost.def
463
  fi
464
  if [ "${HRPTYPE}" = "polymer" ] || [ "${HRPTYPE}" = "full" ] ; then
465
    parse_defs duke3d_hrp.def
466
  fi
467
 
468
  echo "### Deleting empty directories in ${EXTRACTDIR} ... ###"
469
  delete_empty_folders
470
 
471
  date +%F" "%H:%M:%S
472
 
473
  echo "Command line example for creating a ZIP package:"
474
  echo "sh -c \"cd ${EXTRACTDIR} ; zip -rqn .zip:.jpg:.png ${EXTRACTDIR}.zip *\""
475
} # main()
476
 
477
 
478
 
479
PRGPATH=$0
480
HRPTYPE=$1
481
if [ "$2" = "y" ] ; then FORCE=1 ; else FORCE=0 ; fi
325 leod 482
if [ "$2" = "v" ] && [ ! "$3" = "" ] ; then
483
  VERSION="$3"
484
  echo "${VERSION}" > VERSION
485
fi
320 leod 486
HRPROOT=.
487
 
488
cd               "${HRPROOT}"
489
echo  "PWD     :" `pwd`
490
echo  "HRPROOT :" ${HRPROOT}
491
 
492
if [ ! -f "./duke3d.def" ] ; then
493
  echo "ERROR : ./duke3d.def not found. This is no HRP root directory. Exit."
494
  exit 1
495
fi
496
 
497
case "$HRPTYPE" in
498
  polymer|polymost_override|polymost)
499
    main $HRPTYPE
500
    ;;
501
  full)
502
    if [ $FORCE = 0 ] ; then if ask "Extract full HRP (+ Override Pack)?"
503
      then echo "Extracting ${HRPTYPE} from \"${HRPROOT}\" "
504
      else exit 0
505
    fi ; fi
506
    ${PRGPATH} polymost_override y
507
    main $HRPTYPE
508
    ;;
509
  both)
510
    if [ $FORCE = 0 ] ; then if ask "Extract both pure HRP?"
511
      then echo "Extracting ${HRPTYPE} from \"${HRPROOT}\" "
512
      else exit 0
513
    fi ; fi
514
    ${PRGPATH} polymer  y
515
    ${PRGPATH} polymost y
516
    ;;
517
  all)
518
    if [ $FORCE = 0 ] ; then if ask "Extract all packs from the repository?"
519
      then echo "Extracting ${HRPTYPE} from \"${HRPROOT}\" "
520
      else exit 0
521
    fi ; fi
522
    ${PRGPATH} both y
523
    ${PRGPATH} full y
524
    ;;
525
  unused)
526
    echo "Option \"$1\" not yet implemented."
527
    ##(cd ${1}; tar cf - . ) | (cd ${2}; tar xf -)
528
    ;;
529
  debug)
530
    echo "Nothing to debug."
531
    ;;
532
  *)
324 leod 533
    echo "Usage: ${0} {full|polymer|polymost_override|polymost|both|all} [v VERSION]"
320 leod 534
    exit 1
535
    ;;
536
esac
537
 
538
exit 0