Subversion Repositories duke3d_hrp

Rev

Rev 709 | Rev 711 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 709 Rev 710
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
2
3
# Duke Nukem 3D High Resolution Pack Extractor  v0.8.0  2019-05-07
3
# Duke Nukem 3D CON/DEF/HRP File Extractor  v0.9.0  2019-05-27
4
#
4
#
5
# Author: LeoD
5
# Author:  LeoD
6
# License: ISC license : https://opensource.org/licenses/isc-license.txt
6
# License: ISC License -> https://opensource.org/licenses/isc-license.txt
7
#
7
#
8
# This script extracts a working copy of your local Duke Nukem 3D High
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.
9
# Resolution Pack's Subversion repository, ready for zipping and distribution.
10
# This is mostly done by hierarchically parsing the *.def files.
10
# This is mostly done by hierarchically parsing the *.def files.
11
# PolyMER or PolyMOST only versions can be chosen.
11
# PolyMER or PolyMOST only versions can be chosen.
-
 
12
#
12
# On Windows you might want MSYS' zip to create package files.
13
# On Windows you may use the Bash shell that comes with either MSYS2 or Git.
13
# ("mingw-get install msys-zip")
-
 
14
# MinGW/MSYS performance is horrible, better go Linux. Even my virtual Debian
14
# Bash's performance of calling executables is horrible, better go Linux. Even
15
# machine accessing the Windows drive is 5 to 10 times faster.
15
# my virtual Debian machine accessing the Windows drive is several times faster.
16
# But it still sucks. This needs to become a Perl script one day.
16
# As of v0.9.0, Bash's builtin regex engine is used for many parts, but it fails
17
# Or maybe MSYS' bash gets finally updated to 4.* and I'll use its regex engine.
17
# to use the \b word delimiter correctly on Windows ( v4.4.23, x86_64-pc-msys ).
18
18
19
DEF_TOP=UNDEFINED
19
DEF_TOP=UNDEFINED
-
 
20
CON_TOP=UNDEFINED
-
 
21
GRP_TOP=UNDEFINED
-
 
22
GRP=""
20
SET_VERSION=YES            # [YES|NO]
23
SET_VERSION=YES            # [YES|NO]
21
EXTRACT_COMMENTED_FILES=NO # [YES|NO]
24
EXTRACT_COMMENTED_FILES=NO # [YES|NO]
22
DUKEPLUS_POLYMOST_COMPATIBILTY_APPROACH=polymost  #[none|polymost|polymer|mixed]
25
DUKEPLUS_POLYMOST_COMPATIBILTY_APPROACH=polymost  #[none|polymost|polymer|mixed]
23
ATTRITION_POLYMOST_COMPATIBILTY_APPROACH=polymost #[none|polymost|polymer|mixed]
26
ATTRITION_POLYMOST_COMPATIBILTY_APPROACH=polymost #[none|polymost|polymer|mixed]
24
27
-
 
28
exit_on_error() {
-
 
29
  echo -e "\e[0;31mERROR   :\e[0m ${@}"
-
 
30
  exit 1
-
 
31
}
-
 
32
-
 
33
warning() {
-
 
34
  echo -e "\e[1;35mWARNING :\e[0m ${@}"
-
 
35
}
-
 
36
25
ask()
37
info() {
-
 
38
  echo -e "\e[0;32mINFO    :\e[0m ${@}"
26
{
39
}
-
 
40
-
 
41
ask() {
27
  echo -n "$@" '[y/N] ' ; read ans
42
  echo -n "$@" '[y/N] ' ; read ans
28
  case "$ans" in
43
  case "$ans" in
29
    y*|Y*) return 0 ;;
44
    y*|Y*) return 0 ;;
30
    *)     return 1 ;;
45
    *)     return 1 ;;
31
  esac
46
  esac
32
} # ask
47
} # ask
33
48
34
49
35
copy_folders()
50
copy_folders() {
36
{
-
 
37
  mkdir ${EXTRACTDIR}
51
  mkdir ${EXTRACTDIR} || exit_on_error "Could not create ${EXTRACTDIR}/"
38
  for HRPDIR in . ; do
52
  for SUBDIR in . ; do
39
    if [ -d "${HRPDIR}" ] ; then
53
    if [ -d "${SUBDIR}" ] ; then
40
      DIRLIST=./HRP_DIRECTORIES.lst
54
      DIRLIST=${EXTRACTDIR}/DIRECTORIES.lst
41
      find "${HRPDIR}" -type d | grep -v ".\svn" > ${DIRLIST}
55
      find  "${SUBDIR}" -type d | grep -v "\.svn" > ${DIRLIST}
42
      cat ${DIRLIST} | while read DIR; do
56
      cat ${DIRLIST} | while read DIR; do
43
        if [ ! -d "${EXTRACTDIR}/${DIR}" ] ; then
57
        if [ ! -d "${EXTRACTDIR}/${DIR}" ] ; then
44
          mkdir "${EXTRACTDIR}/${DIR}"
58
          mkdir   "${EXTRACTDIR}/${DIR}" || exit_on_error\
-
 
59
            "Could not create ${EXTRACTDIR}/${DIR}/"
45
        fi
60
        fi
46
      done
61
      done
47
      rm     ${DIRLIST}
62
      rm ${DIRLIST}
48
    else
63
    else
49
      echo "${HRPDIR} : no HRP."
64
      exit_on_error "${SUBDIR} : Oops."
50
    fi
65
    fi
51
  done
66
  done
52
} # copy_folders()
67
} # copy_folders()
53
68
54
69
55
copy_set_version()
70
copy_set_version() {
56
{
-
 
57
  VER_FILE="$1"
71
  VER_FILE="$1"
58
  TARGET_FILE="$2"
72
  TARGET_FILE="$2"
59
  if [ ! "${SET_VERSION}" = "YES" ] ; then
73
  if [ ! "${SET_VERSION}" = "YES" ] ; then
60
    cp -pv "${VER_FILE}" "${TARGET_FILE}"
74
    cp -pv "${VER_FILE}" "${TARGET_FILE}"
61
  else
75
  else
Line 65... Line 79...
65
      if [ -f VERSION ] ; then
79
      if [ -f VERSION ] ; then
66
        VERSION=`grep -owE "[0-9\\.]*" VERSION`
80
        VERSION=`grep -owE "[0-9\\.]*" VERSION`
67
      fi
81
      fi
68
    fi
82
    fi
69
83
70
    echo "copy_set_version ${VER_FILE} -> ${TARGET_FILE}"
84
    echo "copy_set_version: ${VER_FILE} -> ${TARGET_FILE}"
71
85
72
    case "${VER_FILE}" in
86
    case "${VER_FILE}" in
73
      hrp_readme.txt)
87
      hrp_readme.txt)
74
        cat "${VER_FILE}" | sed -r --posix \
88
        cat "${VER_FILE}" | sed -r --posix \
75
          s/\(Version\ *\)\([0-9\.]*\)\(.*\)\(\\\)\)\(.*\)/\\1${VERSION}\ \(${V_DATE}\)\ \ \\5/ \
89
          s/\(Version\ *\)\([0-9\.]*\)\(.*\)\(\\\)\)\(.*\)/\\1${VERSION}\ \(${V_DATE}\)\ \ \\5/ \
Line 87... Line 101...
87
        fi
101
        fi
88
        ;;
102
        ;;
89
      duke3d_hrp_polymost.def | \
103
      duke3d_hrp_polymost.def | \
90
      tools/polymost_override/duke3d_hrp_polymost_override.def | \
104
      tools/polymost_override/duke3d_hrp_polymost_override.def | \
91
      duke3d_hrp_megaton.def | \
105
      duke3d_hrp_megaton.def | \
92
      tools/megaton_override/duke3d_hrp_megaton_override.def )
106
      tools/megaton_override/duke3d_hrp_megaton_override.def | \
-
 
107
      duke3d_maphacks.def )
93
        cat "${VER_FILE}" | sed -r --posix \
108
        cat "${VER_FILE}" | sed -r --posix \
94
          s/\(Version\ *\)\([0-9\.]*\)\(.*\)/\\1${VERSION}\\3/ \
109
          s/\(Version\ *\)\([0-9\.]*\)\(.*\)/\\1${VERSION}\\3/ \
95
          >> "${TARGET_FILE}"
110
          >> "${TARGET_FILE}"
96
        ;;
111
        ;;
97
      *)
112
      *)
98
        echo "###ERROR: copy_set_version() - BAD FILE: ${VER_FILE}"
113
        exit_on_error "copy_set_version() - UNKNOWN FILE: ${VER_FILE}"
99
        exit 1
-
 
100
        ;;
114
        ;;
101
    esac
115
    esac
102
  fi
116
  fi
103
} # copy_set_version()
117
} # copy_set_version()
104
118
105
tar_copy_dir()
119
tar_copy_dir() {
106
{
-
 
107
  (cd ${1}; tar cf - . ) | (cd ${2}; tar xf -)
120
  (cd ${1}; tar cf - . ) | (cd ${2}; tar xf -)
108
}
121
}
109
122
110
copy_known_files()
123
copy_known_files() {
111
{
124
112
  if [ -f  hrp_readme.txt ] ; then
125
  if [ -f hrp_readme.txt ] ; then
113
    copy_set_version hrp_readme.txt "${EXTRACTDIR}/hrp_readme.txt"
126
    copy_set_version hrp_readme.txt "${EXTRACTDIR}/hrp_readme.txt"
114
  fi
127
  fi
115
128
116
  if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "polymost_override" ] ||\
129
  if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "polymost_override" ] ||\
Line 119... Line 132...
119
     [ "${HRPTYPE}" = "polymer"  ] || [ "${HRPTYPE}" = "full" ] ; then
132
     [ "${HRPTYPE}" = "polymer"  ] || [ "${HRPTYPE}" = "full" ] ; then
120
    cp -pv hrp_art_license.txt      "${EXTRACTDIR}"
133
    cp -pv hrp_art_license.txt      "${EXTRACTDIR}"
121
  fi
134
  fi
122
135
123
  if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "polymer" ] ||\
136
  if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "polymer" ] ||\
124
     [ "${HRPTYPE}" = "maphacks" ] || [ "${HRPTYPE}" = "full" ] ; then
137
     [ "${HRPTYPE}" = "maphacks" ] || [ "${HRPTYPE}" = "full" ] ||\
-
 
138
     [ "${HRPTYPE}" = "voxels" ] ; then
125
    cp -pv maphacks/MapHacks.txt    "${EXTRACTDIR}/maphacks/"
139
    cp -pv maphacks/MapHacks.txt    "${EXTRACTDIR}/maphacks/"
126
  fi
140
  fi
127
141
128
  if [ "${HRPTYPE}" = "polymost" ] ; then
142
  if [ "${HRPTYPE}" = "polymost" ] ; then
129
    cp -pv           duke3d_hrp_polymost.def "${EXTRACTDIR}"
143
    cp -pv           duke3d_hrp_polymost.def "${EXTRACTDIR}"
Line 167... Line 181...
167
      "${EXTRACTDIR}/highres/screen/menu/2492_ver_megaton.png"
181
      "${EXTRACTDIR}/highres/screen/menu/2492_ver_megaton.png"
168
    cp -pv  tools/megaton_override/*.bat   "${EXTRACTDIR}"
182
    cp -pv  tools/megaton_override/*.bat   "${EXTRACTDIR}"
169
    cp -pvr tools/megaton_override/dukedc* "${EXTRACTDIR}"
183
    cp -pvr tools/megaton_override/dukedc* "${EXTRACTDIR}"
170
    cp -pvr tools/megaton_override/highres "${EXTRACTDIR}"
184
    cp -pvr tools/megaton_override/highres "${EXTRACTDIR}"
171
    # Let Megaton Override work on top of Polymost HRP:
185
    # Let Megaton Override work on top of Polymost HRP:
172
    cp -pv highres/screen_megaton.def          "${EXTRACTDIR}/highres/"
186
    #cp -pv highres/screen_megaton.def          "${EXTRACTDIR}/highres/"
173
    cp -pv highres/screen/menu_megaton.def     "${EXTRACTDIR}/highres/"
187
    #cp -pv highres/screen/menu_megaton.def     "${EXTRACTDIR}/highres/screen/"
174
    cp -pv highres/sprites_megaton.def         "${EXTRACTDIR}/highres/"
188
    #cp -pv highres/sprites_megaton.def         "${EXTRACTDIR}/highres/"
175
    cp -pv highres/sprites/effects_megaton.def "${EXTRACTDIR}/highres/sprites/"
189
    #cp -pv highres/sprites/effects_megaton.def "${EXTRACTDIR}/highres/sprites/"
176
  fi
190
  fi
177
191
178
  if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "megaton" ] ; then
192
  if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "megaton" ] ; then
179
    cp -pv duke3d.def "${EXTRACTDIR}"
193
    cp -pv duke3d.def "${EXTRACTDIR}"
180
    cp -pv highres/screen/menu/2492_polymost.png \
194
    cp -pv highres/screen/menu/2492_polymost.png \
Line 211... Line 225...
211
225
212
  if [ "${HRPTYPE}" = "maphacks" ] ; then
226
  if [ "${HRPTYPE}" = "maphacks" ] ; then
213
    cp -pv           maphacks/MapHacks.txt          "${EXTRACTDIR}"
227
    cp -pv           maphacks/MapHacks.txt          "${EXTRACTDIR}"
214
    cp -pv           maphacks/mhk-extract.def       "${EXTRACTDIR}/maphacks/"
228
    cp -pv           maphacks/mhk-extract.def       "${EXTRACTDIR}/maphacks/"
215
    cp -pv           maphacks/maphacks_polymost.def "${EXTRACTDIR}/maphacks/"
229
    cp -pv           maphacks/maphacks_polymost.def "${EXTRACTDIR}/maphacks/"
216
    cp -pv           duke3d_maphacks_standalone.def "${EXTRACTDIR}"
230
    cp -pv           duke3d_maphacks.def            "${EXTRACTDIR}"
217
    copy_set_version duke3d_maphacks_standalone.def "${EXTRACTDIR}/duke3d.def"
231
    copy_set_version duke3d_maphacks.def            "${EXTRACTDIR}/duke3d.def"
218
  fi
232
  fi
219
233
220
  if [ "${HRPTYPE}" = "voxel" ] ; then
234
  if [ "${HRPTYPE}" = "voxels" ] ; then
221
    cp -pv voxelpack_readme.txt      "${EXTRACTDIR}"
235
    cp -pv voxelpack_readme.txt      "${EXTRACTDIR}"
222
    cp -pv voxelpack_art_license.txt "${EXTRACTDIR}"
236
    cp -pv voxelpack_art_license.txt "${EXTRACTDIR}"
223
    cp -pv duke3d.def                "${EXTRACTDIR}"
237
    cp -pv duke3d.def                "${EXTRACTDIR}"
224
    cp -pv duke3d_voxels.def         "${EXTRACTDIR}"
238
    cp -pv duke3d_voxels.def         "${EXTRACTDIR}"
225
    if [ -f  EDUKE.CON ] ; then
239
    if [ -f  EDUKE.CON ] ; then
226
      cp -pv EDUKE.CON               "${EXTRACTDIR}"
240
      cp -pv EDUKE.CON               "${EXTRACTDIR}"
-
 
241
      #cp -pv scripts/animation.con   "${EXTRACTDIR}/scripts/"
-
 
242
      #cp -pv scripts/rotation.con    "${EXTRACTDIR}/scripts/"
-
 
243
      cp -pv scripts/*.con           "${EXTRACTDIR}/scripts/"
227
    fi
244
    fi
228
  fi
245
  fi
229
246
230
  if [ "${HRPTYPE}" = "sw_highres" ] ; then
247
  if [ "${HRPTYPE}" = "sw_highres" ] ; then
231
    cp -pv sw.def                   "${EXTRACTDIR}"
248
    cp -pv sw.def                   "${EXTRACTDIR}"
232
    cp -pv highres/sw_hrp.def       "${EXTRACTDIR}/highres/"
249
    cp -pv highres/sw_hrp.def       "${EXTRACTDIR}/highres/"
233
    cp -pv HRP.bat                  "${EXTRACTDIR}"
250
    cp -pv HRP.bat                  "${EXTRACTDIR}"
234
    cp -pv HRP_Readme.txt           "${EXTRACTDIR}"
251
    cp -pv HRP_Readme.txt           "${EXTRACTDIR}"
235
    cp -pv HRP_Changes.txt          "${EXTRACTDIR}"
252
    cp -pv HRP_Changes.txt          "${EXTRACTDIR}"
236
    echo "Copying skyboxes ..."
253
    info "Copying  skyboxes ..."
237
    tar_copy_dir "highres/skyboxes" "${EXTRACTDIR}/highres/skyboxes"
254
    tar_copy_dir "highres/skyboxes" "${EXTRACTDIR}/highres/skyboxes"
238
    cd "${WORKDIR}"
255
    cd "${WORKDIR}"
239
  fi
256
  fi
240
257
241
  if [ "${HRPTYPE}" = "sw_lowres" ] ; then
258
  if [ "${HRPTYPE}" = "sw_lowres" ] ; then
242
    echo "Creating sw.def for lowres HRP ..."
259
    info "Creating sw.def for lowres HRP ..."
243
    echo "include lowres/sw_lrp.def" > "${EXTRACTDIR}/sw.def"
260
    echo "include lowres/sw_lrp.def" > "${EXTRACTDIR}/sw.def"
244
    cp -pv lowres/sw_lrp.def           "${EXTRACTDIR}/lowres/"
261
    cp -pv lowres/sw_lrp.def           "${EXTRACTDIR}/lowres/"
245
    cp -pv LRP.bat                     "${EXTRACTDIR}"
262
    cp -pv LRP.bat                     "${EXTRACTDIR}"
246
    cp -pv LRP_Readme.txt              "${EXTRACTDIR}"
263
    cp -pv LRP_Readme.txt              "${EXTRACTDIR}"
247
    cp -pv LRP_Changes.txt             "${EXTRACTDIR}"
264
    cp -pv LRP_Changes.txt             "${EXTRACTDIR}"
248
    echo "Copying skyboxes ..."
265
    info "Copying  skyboxes ..."
249
    tar_copy_dir "highres/skyboxes"    "${EXTRACTDIR}/highres/skyboxes"
266
    tar_copy_dir "highres/skyboxes"    "${EXTRACTDIR}/highres/skyboxes"
250
    cd "${WORKDIR}"
267
    cd "${WORKDIR}"
251
  fi
268
  fi
252
269
253
  if [ "${HRPTYPE}" = "default" ] ; then
270
  if [ "${HRPTYPE}" = "auto" ] ; then
254
    cp -pv  "${DEF_TOP}"          "${EXTRACTDIR}/${DEF_TOP}"
-
 
255
    echo            "\`*.txt' -> \`${EXTRACTDIR}/*.txt'"
271
    for txtfile in *.txt; do
256
    cp -p  *.txt                  "${EXTRACTDIR}"
272
      cp -pv "$txtfile" "${EXTRACTDIR}"
-
 
273
    done
257
  fi
274
  fi
258
275
259
} # copy_known_files()
276
} # copy_known_files()
260
277
261
278
262
copy_polymost_mhk()
279
copy_polymost_mhk() {
263
{
-
 
264
  cp -p maphacks/3drealms/E?L*_polymost.mhk "${EXTRACTDIR}"
280
  cp -p maphacks/3drealms/E?L*_polymost.mhk "${EXTRACTDIR}"
265
  cp -p maphacks/dukedc/DUKEDC*-megaton.mhk "${EXTRACTDIR}"
281
  cp -p maphacks/dukedc/DUKEDC*-megaton.mhk "${EXTRACTDIR}"
266
  rm -f "${EXTRACTDIR}"/*_13d_*.mhk
282
  rm -f "${EXTRACTDIR}"/*_13d_*.mhk
-
 
283
  rm -f "${EXTRACTDIR}"/*_worldtour_*.mhk
267
  # bashism:
284
  # bashism:
268
  for i in "${EXTRACTDIR}"/*_polymost.mhk ; do mv "$i" "${i/_polymost}" ; done
285
  for i in "${EXTRACTDIR}"/*_polymost.mhk ; do mv "$i" "${i/_polymost}" ; done
269
  for i in "${EXTRACTDIR}"/*-megaton.mhk  ; do mv "$i" "${i/-megaton}"  ; done
286
  for i in "${EXTRACTDIR}"/*-megaton.mhk  ; do mv "$i" "${i/-megaton}"  ; done
270
} # copy_polymost_mhk()
287
} # copy_polymost_mhk()
271
288
Line 308... Line 325...
308
  SPRE="${EXTRACTDIR}/highres/sprites"
325
  SPRE="${EXTRACTDIR}/highres/sprites"
309
  PATCHTYPE=$1
326
  PATCHTYPE=$1
310
327
311
  case "$PATCHTYPE" in
328
  case "$PATCHTYPE" in
312
    polymer)
329
    polymer)
313
      echo "  # (Using \"Polymer approach\")"
330
      echo "          (Using \"Polymer approach\")"
314
      cp -pi $SPR/firstperson/2510_devastator.md3            "$SPRE/firstperson/"
331
      cp -pi $SPR/firstperson/2510_devastator.md3            "$SPRE/firstperson/"
315
      cp -pi $SPR/firstperson/2510_devastator.png            "$SPRE/firstperson/"
332
      cp -pi $SPR/firstperson/2510_devastator.png            "$SPRE/firstperson/"
316
      cp -pi $SPR/firstperson/2510_devastator_s.png          "$SPRE/firstperson/"
333
      cp -pi $SPR/firstperson/2510_devastator_s.png          "$SPRE/firstperson/"
317
      cp -pi $SPR/firstperson/2510_devastator_g.png          "$SPRE/firstperson/"
334
      cp -pi $SPR/firstperson/2510_devastator_g.png          "$SPRE/firstperson/"
318
      cp -pi $SPR/firstperson/2524_pistol.md3                "$SPRE/firstperson/"
335
      cp -pi $SPR/firstperson/2524_pistol.md3                "$SPRE/firstperson/"
Line 325... Line 342...
325
      cp -pi $SPR/firstperson/duke_hand_d.png                "$SPRE/firstperson/"
342
      cp -pi $SPR/firstperson/duke_hand_d.png                "$SPRE/firstperson/"
326
      cp -pi $SPR/firstperson/duke_hand_n.png                "$SPRE/firstperson/"
343
      cp -pi $SPR/firstperson/duke_hand_n.png                "$SPRE/firstperson/"
327
      cp -pi $SPR/firstperson/duke_hand_s.png                "$SPRE/firstperson/"
344
      cp -pi $SPR/firstperson/duke_hand_s.png                "$SPRE/firstperson/"
328
      ;;
345
      ;;
329
    polymost)
346
    polymost)
330
      echo "  # (Using \"Polymost approach\")"
347
      echo "          (Using \"Polymost approach\")"
331
      #cp -pi $SPR/firstperson_polymost/2510_devastator.md3   "$SPRE/firstperson/"
348
      #cp -pi $SPR/firstperson_polymost/2510_devastator.md3   "$SPRE/firstperson/"
332
      #cp -pi $SPR/firstperson_polymost/2510_devastator.png   "$SPRE/firstperson/"
349
      #cp -pi $SPR/firstperson_polymost/2510_devastator.png   "$SPRE/firstperson/"
333
      ##cp -pi $SPR/firstperson/2510_devastator_s.png          "$SPRE/firstperson/"
350
      ##cp -pi $SPR/firstperson/2510_devastator_s.png          "$SPRE/firstperson/"
334
      #cp -pi $SPR/firstperson_polymost/2510_devastator_g.png "$SPRE/firstperson/"
351
      #cp -pi $SPR/firstperson_polymost/2510_devastator_g.png "$SPRE/firstperson/"
335
      cp -pi $SPR/firstperson_polymost/2524_pistol.md3       "$SPRE/firstperson/"
352
      cp -pi $SPR/firstperson_polymost/2524_pistol.md3       "$SPRE/firstperson/"
Line 342... Line 359...
342
      #cp -pi $SPR/firstperson/duke_hand_d.png                "$SPRE/firstperson/"
359
      #cp -pi $SPR/firstperson/duke_hand_d.png                "$SPRE/firstperson/"
343
      #cp -pi $SPR/firstperson/duke_hand_n.png                "$SPRE/firstperson/"
360
      #cp -pi $SPR/firstperson/duke_hand_n.png                "$SPRE/firstperson/"
344
      #cp -pi $SPR/firstperson/duke_hand_s.png                "$SPRE/firstperson/"
361
      #cp -pi $SPR/firstperson/duke_hand_s.png                "$SPRE/firstperson/"
345
      ;;
362
      ;;
346
    mixed)
363
    mixed)
347
      echo "  # (Using \"Mixed approach\")"
364
      echo "          (Using \"Mixed approach\")"
348
      echo "    # Not applied / Not yet implemented"
365
      echo "          Not applied / Not yet implemented"
349
      ;;
366
      ;;
350
    none)
367
    none)
351
      echo "  Not applied"
368
      info "  Not applied"
352
      #echo "  # Not yet implemented"
369
      #echo "  # Not yet implemented"
353
      ;;
370
      ;;
354
    *)
371
    *)
355
      echo "  # Bad parameter"
372
      warning "  Bad parameter"
356
      ;;
373
      ;;
357
  esac
374
  esac
358
375
359
} # dukeplus_polymost_hrp_compatibility()
376
} # dukeplus_polymost_hrp_compatibility()
360
377
361
378
362
attrition_polymost_hrp_compatibility()
379
attrition_polymost_hrp_compatibility() {
363
{
-
 
364
  # attr_hrp.def expects some files to be present in the HRP
380
  # attr_hrp.def expects some files to be present in the HRP
365
  #
381
  #
366
  # model "highres/sprites/firstperson/2524_pistol.md3" {    // most/mer : same MD3 + same skin til r295     
382
  # model "highres/sprites/firstperson/2524_pistol.md3" {    // most/mer : same MD3 + same skin til r295     
367
  #    skin { pal 0 file "highres/sprites/firstperson/2524_pistol.png" } // up to DP2.30 DNE/IMP only
383
  #    skin { pal 0 file "highres/sprites/firstperson/2524_pistol.png" } // up to DP2.30 DNE/IMP only
368
  #    glow { file "highres/sprites/firstperson/2524_pistol_g.png" }     // up to DP2.30 DNE/IMP only
384
  #    glow { file "highres/sprites/firstperson/2524_pistol_g.png" }     // up to DP2.30 DNE/IMP only
Line 371... Line 387...
371
  SPRE="${EXTRACTDIR}/highres/sprites"
387
  SPRE="${EXTRACTDIR}/highres/sprites"
372
  PATCHTYPE=$1
388
  PATCHTYPE=$1
373
389
374
  case "$PATCHTYPE" in
390
  case "$PATCHTYPE" in
375
    polymer)
391
    polymer)
376
      echo "  # (Using \"Polymer approach\")"
392
      echo "          (Using \"Polymer approach\")"
377
      ;;
393
      ;;
378
    polymost)
394
    polymost)
379
      echo "  # (Using \"Polymost approach\")"
395
      echo "          (Using \"Polymost approach\")"
380
      cp -piu $SPR/firstperson_polymost/2524_pistol.md3      "$SPRE/firstperson/"
396
      cp -piu $SPR/firstperson_polymost/2524_pistol.md3      "$SPRE/firstperson/"
381
      cp -pi  $SPR/firstperson_polymost/2524_pistol.png      "$SPRE/firstperson/"
397
      cp -pi  $SPR/firstperson_polymost/2524_pistol.png      "$SPRE/firstperson/"
382
      cp -pi  $SPR/firstperson_polymost/2524_pistol_g.png    "$SPRE/firstperson/"
398
      cp -pi  $SPR/firstperson_polymost/2524_pistol_g.png    "$SPRE/firstperson/"
383
      cp -pi  $SPR/firstperson/2530_clip.md3                 "$SPRE/firstperson/"
399
      cp -pi  $SPR/firstperson/2530_clip.md3                 "$SPRE/firstperson/"
384
      #cp -pi  $SPR/firstperson/2532_cliphand.md3             "$SPRE/firstperson/"
400
      #cp -pi  $SPR/firstperson/2532_cliphand.md3             "$SPRE/firstperson/"
385
      ##cp -pi  $SPR/firstperson/2532_cliphand.png             "$SPRE/firstperson/"
401
      ##cp -pi  $SPR/firstperson/2532_cliphand.png             "$SPRE/firstperson/"
386
      #cp -pi  $SPR/firstperson/duke_hand_d.png               "$SPRE/firstperson/2532_cliphand.png"
402
      #cp -pi  $SPR/firstperson/duke_hand_d.png               "$SPRE/firstperson/2532_cliphand.png"
387
      ;;
403
      ;;
388
    mixed)
404
    mixed)
389
      echo "  # (Using \"Mixed approach\")"
405
      echo "          (Using \"Mixed approach\")"
390
      cp -piu $SPR/firstperson_polymost/2524_pistol.md3       "$SPRE/firstperson/"
406
      cp -piu $SPR/firstperson_polymost/2524_pistol.md3       "$SPRE/firstperson/"
391
      cp -pi  $SPR/firstperson_polymost/2524_pistol.png       "$SPRE/firstperson/"
407
      cp -pi  $SPR/firstperson_polymost/2524_pistol.png       "$SPRE/firstperson/"
392
      cp -pi  $SPR/firstperson_polymost/2524_pistol_g.png     "$SPRE/firstperson/"
408
      cp -pi  $SPR/firstperson_polymost/2524_pistol_g.png     "$SPRE/firstperson/"
393
      cp -pi  $SPR/firstperson/2530_clip.md3                 "$SPRE/firstperson/"
409
      cp -pi  $SPR/firstperson/2530_clip.md3                 "$SPRE/firstperson/"
394
      #cp -pi  $SPR/firstperson/2532_cliphand.md3             "$SPRE/firstperson/"
410
      #cp -pi  $SPR/firstperson/2532_cliphand.md3             "$SPRE/firstperson/"
Line 403... Line 419...
403
      cp -pi  $SPR/firstperson/duke_hand_s.png               "$SPRE/firstperson/"
419
      cp -pi  $SPR/firstperson/duke_hand_s.png               "$SPRE/firstperson/"
404
      cp -pi  $SPR/firstperson/muzzle_flash_01.png           "$SPRE/firstperson/"
420
      cp -pi  $SPR/firstperson/muzzle_flash_01.png           "$SPRE/firstperson/"
405
      cp -pi  highres/common/transp.png                      "${EXTRACTDIR}/highres/common"
421
      cp -pi  highres/common/transp.png                      "${EXTRACTDIR}/highres/common"
406
      ;;
422
      ;;
407
    none)
423
    none)
408
      echo "  Not applied"
424
      info "  Not applied"
409
      #echo "  # Not yet implemented"
425
      #echo "  # Not yet implemented"
410
      ;;
426
      ;;
411
    *)
427
    *)
412
      echo "  # Bad parameter"
428
      warning "  Bad parameter"
413
      ;;
429
      ;;
414
  esac
430
  esac
415
431
416
} # attrition_polymost_hrp_compatibility()
432
} # attrition_polymost_hrp_compatibility()
417
433
418
434
419
parse_defs()
435
extract_file() {
420
{
-
 
421
  echo "$1"
436
  local FILE="$1"
-
 
437
  if [ -f "${FILE}" ] ; then
-
 
438
    cp -p "${FILE}" "${EXTRACTDIR}/${FILE}"
-
 
439
  elif [ ${GRP} ] ; then
-
 
440
    cd "${EXTRACTDIR}/${GRP}"
-
 
441
      kextract "${WORKDIR}/${GRP}" "${FILE}" > /dev/null
422
  BLOCK_COMMENT="OFF"
442
    cd "${WORKDIR}"
-
 
443
    if [ ! -f "${EXTRACTDIR}/${GRP}/${FILE}" ] ; then
423
  cat $1 | while read DEF_LINE; do
444
      warning "${FILE} is missing!"
-
 
445
    #else
-
 
446
    #  echo -e "${FILE} -> \e[0;33m${GRP}/\e[0m${FILE^^}"
-
 
447
    fi
-
 
448
  else
-
 
449
    warning "${FILE} is missing!"
-
 
450
  fi
-
 
451
}
-
 
452
424
453
-
 
454
parse_defs() {
425
    #DOS only: DEF_FILE=`echo "${DEF_LINE}" | grep -wE "^include" | sed s/include\ //`
455
  local DEF_FILE="$1"
426
    #DEF_FILE=`echo "${DEF_LINE}" | grep -wE "^include" | sed s/include\ // | sed s/\\\r//`
456
  extract_file "${DEF_FILE}"
427
#    DEF_FILE=`echo "${DEF_LINE}" | grep -wE "^include" | sed s/include\ // | sed s/\\\/\\\/.*// | sed s/\\\r//`
457
  if [ -f "${DEF_FILE}" ] ; then
428
    DEF_FILE=`echo "${DEF_LINE}" | grep -wE "^include" | awk '{ print $2 }' | sed 's/\r//'`
458
    echo  "${DEF_FILE}"
429
    if [ "${DEF_FILE}" != "" ] ; then
459
  elif [  -f "${EXTRACTDIR}/${GRP}/${DEF_FILE}" ] ; then
430
      cp -p      "${DEF_FILE}" "${EXTRACTDIR}/${DEF_FILE}"
460
    echo   -e "${DEF_FILE} -> \e[0;33m${GRP}/\e[0m${DEF_FILE^^}"
431
      parse_defs "${DEF_FILE}"
461
    DEF_FILE="${EXTRACTDIR}/${GRP}/${DEF_FILE^^}"
-
 
462
  else
-
 
463
    return
432
    fi
464
  fi
433
465
-
 
466
  BLOCK_COMMENT="OFF"
-
 
467
-
 
468
  cat "${DEF_FILE}" | while read DEF_LINE; do
-
 
469
-
 
470
    #echo "DEF_LINE1: ${DEF_LINE}"
434
    #HRP_TERM=`echo "${DEF_LINE}" | grep -owE "file|model|voxel|front|right|back|left|top|bottom|down"`
471
    #DEF_TERM=`echo "${DEF_LINE}" | grep -owE "file|model|voxel|front|right|back|left|top|bottom|down"`
435
    ## Old style added (except "defineskybox"):
472
    ## Old style added (except "defineskybox"):
436
    HRP_TERM=`echo "${DEF_LINE}" | grep -owE "definetexture|definemodel|definemodelskin|file|mhkfile|model|voxel|front|right|back|left|top|bottom|down"`
473
    #DEF_TERM=`echo "${DEF_LINE}" | grep -owE "include|definetexture|definemodel|definemodelskin|file|mhkfile|model|voxel|front|right|back|left|top|bottom|down|\\/\\*|\\*\\/"`
437
    #More skybox tokens: tile, pal, ft|rt|bk|lf|up|dn|forward|lt|ceiling|floor|ceil
474
    #More skybox tokens: tile, pal, ft|rt|bk|lf|up|dn|forward|lt|ceiling|floor|ceil
-
 
475
    #echo "DEF_TERM1: ${DEF_TERM}"
438
476
-
 
477
    local TOKEN_LIST='\b(include\b'
-
 
478
    local TOKEN_LIST='^(include)'
-
 
479
    local TOKEN_LIST='(^include|file|^definetexture|^definemodel|^definemodelskin|^mhkfile|^model|^voxel|^front|^right|^back|^left|^top|^bottom|^down|\/\*|\*\/)'
-
 
480
439
    if [ ! "$EXTRACT_COMMENTED_FILES" = "YES" ] ; then
481
    if [[ ${DEF_LINE} =~ ${TOKEN_LIST} ]] ; then
-
 
482
      DEF_TERM="${BASH_REMATCH}"
-
 
483
    else
-
 
484
      DEF_TERM=""
-
 
485
    fi
440
486
-
 
487
    if [ "${DEF_TERM}" ] && [ "$EXTRACT_COMMENTED_FILES" = "NO" ] ; then
441
      COMMENT_TERM=`echo "${DEF_LINE}" | grep -oE "\\/\\*|\\*\\/"`
488
      #COMMENT_TERM=`echo "${DEF_LINE}" | grep -oE "\\/\\*|\\*\\/"`
-
 
489
      COMMENT_TERM="${DEF_TERM}"
442
      if [ "$COMMENT_TERM"  = "/*" ] ; then BLOCK_COMMENT="ON" ; fi
490
      if [ "$COMMENT_TERM"  = "/*" ] ; then BLOCK_COMMENT="ON" ; fi
443
491
444
      if [ "$BLOCK_COMMENT" = "ON" ] ; then HRP_TERM="" ; fi
492
      if [ "$BLOCK_COMMENT" = "ON" ] ; then DEF_TERM="" ; fi
445
493
446
      if [ "$COMMENT_TERM"  = "*/" ] ; then BLOCK_COMMENT="OFF" ; fi
494
      if [ "$COMMENT_TERM"  = "*/" ] ; then BLOCK_COMMENT="OFF" ; fi
447
495
448
      if [ ! "$HRP_TERM" = "" ] ; then
496
      if [ $DEF_TERM ] ; then
449
        HRP_COMMENT=`echo "${DEF_LINE}" | grep -E "//.*$HRP_TERM"`
-
 
450
        if [ ! "$HRP_COMMENT" = "" ] ; then
497
        if [[ ${DEF_LINE} =~ //.*$DEF_TERM ]] ; then
451
          HRP_TERM=""
498
          DEF_TERM=""
452
        fi
499
        fi
453
      fi
500
      fi
454
-
 
455
    fi
501
    fi
456
502
457
    case "$HRP_TERM" in
503
    if [ "${DEF_TERM}" ] ; then case "$DEF_TERM" in
458
      file|mhkfile)
504
      include)
459
        #HRP_FILE=`echo "${DEF_LINE}" | sed -r s/^.*file\ *\"//g | sed s/\".*//`
505
        local SUB_DEF_FILE=`echo "${DEF_LINE}" | grep -wE "^include" | awk '{ print $2 }' | sed 's/\r//'`
-
 
506
        if [          ${SUB_DEF_FILE} ] ; then
-
 
507
          parse_defs "${SUB_DEF_FILE}"
-
 
508
        fi
-
 
509
        ;;
-
 
510
      file)
460
        # Mastering the backslash :-) ... hm, no big performance gain ... :
511
        if [[ ${DEF_LINE} =~ \ file\  ]] ; then
461
        HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*file\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/`
512
          HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*${DEF_TERM}\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/`
462
        # Ignore comments WIP:
513
        elif [[ ! ${DEF_LINE} =~ mapfile ]] ; then
463
        #HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*file\\ *\\)\\(\\"\\(.*\\)\\"\\)\\(.*\\)/\\\3/`
514
          warning "Bad 'file' statement: ${DEF_LINE}"
-
 
515
        fi
464
        ;;
516
        ;;
465
      model|voxel)
517
      mhkfile|model|voxel)
466
        HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*${HRP_TERM}\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/`
518
        HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*${DEF_TERM}\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/`
467
        ;;
519
        ;;
468
      front|right|back|left|top|bottom|down)
520
      front|right|back|left|top|bottom|down)
469
        #HRP_FILE=`echo "${DEF_LINE}" | sed -r s/^.*${HRP_TERM}\ *\"//g | sed s/\".*//`
-
 
470
        HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*${HRP_TERM}\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/`
521
        HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*${DEF_TERM}\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/`
471
        ;;
522
        ;;
472
      ## Old Style
523
      ## Old Style
473
      definemodel)
524
      definemodel)
474
        HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*${HRP_TERM}\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/`
525
        HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*${DEF_TERM}\\ *\"\\)\\([^\"]*\\)\\(.*\\)/\\\2/`
475
        ;;
526
        ;;
476
      definemodelskin)
527
      definemodelskin)
477
        HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*${HRP_TERM}\\ 0\\ \"\\)\\([^\"]*\\)\\(.*\\)/\\\2/`
528
        HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(^.*${DEF_TERM}\\ 0\\ \"\\)\\([^\"]*\\)\\(.*\\)/\\\2/`
478
        ;;
529
        ;;
479
      definetexture)
530
      definetexture)
480
        # Won't work atm if filename in quotes (too lazy)
531
        # Won't work atm if filename in quotes (too lazy)
481
        #HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(\\.*\\)\\(\\ \\)\\(.*\\)\\($\\)/\\\3/`
532
        #HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(\\.*\\)\\(\\ \\)\\(.*\\)\\($\\)/\\\3/`
482
        HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(\\.*\\)\\(\\ \\)\\([0-9a-zA-Z\\_\\/\\.]*\\)\\(.*\\)/\\\3/`
533
        HRP_FILE=`echo "${DEF_LINE}" | sed -r --posix s/\\(\\.*\\)\\(\\ \\)\\([0-9a-zA-Z\\_\\/\\.]*\\)\\(.*\\)/\\\3/`
Line 484... Line 535...
484
        #echo "HRP_FILE : ${HRP_FILE}"
535
        #echo "HRP_FILE : ${HRP_FILE}"
485
        ;;
536
        ;;
486
      *)
537
      *)
487
        HRP_FILE=""
538
        HRP_FILE=""
488
        ;;
539
        ;;
-
 
540
    esac ; fi
-
 
541
-
 
542
    if [ "${HRP_FILE}" ] ; then
-
 
543
      extract_file "${HRP_FILE}"
-
 
544
    fi
-
 
545
-
 
546
  done
-
 
547
} # parse_defs()
-
 
548
-
 
549
-
 
550
parse_cons() {
-
 
551
  local CON_FILE="$1"
-
 
552
  extract_file "${CON_FILE}"
-
 
553
  if [ -f "${CON_FILE}" ] ; then
-
 
554
    echo  "${CON_FILE}"
-
 
555
  elif [  -f "${EXTRACTDIR}/${GRP}/${CON_FILE}" ] ; then
-
 
556
    echo   -e "${CON_FILE} -> \e[0;33m${GRP}/\e[0m${CON_FILE^^}"
-
 
557
    CON_FILE="${EXTRACTDIR}/${GRP}/${CON_FILE^^}"
-
 
558
  else
-
 
559
    return
-
 
560
  fi
-
 
561
-
 
562
  MUSIC_FLAG=""
-
 
563
  MUSIC_POS=""
-
 
564
-
 
565
  BLOCK_COMMENT="OFF"
-
 
566
-
 
567
  cat "${CON_FILE}" | while read CON_LINE; do
-
 
568
-
 
569
    #echo "CON_LINE : ${CON_LINE}"
-
 
570
    #CON_TERM=`echo "${CON_LINE}" | grep -owE "include|setdefname|definelevelname|definesound|music|\\/\\*|\\*\\/"`
-
 
571
    #echo "CON_TERM : ${CON_TERM}"
-
 
572
-
 
573
    #if [[ ${CON_LINE} =~ include|setdefname|definelevelname|definesound|music|\/\*|\*\/ ]] ; then
-
 
574
    local TOKEN_LIST='\b(include\b'
-
 
575
    local TOKEN_LIST='^(include)'
-
 
576
    local TOKEN_LIST='(include|setdefname|definelevelname|definesound|music|\/\*|\*\/)'
-
 
577
    if [[ ${CON_LINE} =~ ${TOKEN_LIST} ]] ; then
-
 
578
      #echo "Rematch  : ${BASH_REMATCH}"
-
 
579
      CON_TERM="${BASH_REMATCH}"
-
 
580
    else
-
 
581
      CON_TERM=""
-
 
582
    fi
-
 
583
-
 
584
    if [ ${MUSIC_FLAG} ] && [ "${CON_TERM}" = "" ] ; then
-
 
585
      MUSIC_POS="1"
-
 
586
	  MUSIC_FLAG=""
489
    esac
587
    else
-
 
588
      MUSIC_POS=""
-
 
589
    fi
-
 
590
-
 
591
    if [ "${CON_TERM}" ] && [ "$EXTRACT_COMMENTED_FILES" = "NO" ] ; then
-
 
592
      COMMENT_TERM="${CON_TERM}"
-
 
593
      if [ "$COMMENT_TERM"  = "/*" ] ; then BLOCK_COMMENT="ON"  ; fi
-
 
594
-
 
595
      if [ "$BLOCK_COMMENT" = "ON" ] ; then CON_TERM=""         ; fi
-
 
596
-
 
597
      if [ "$COMMENT_TERM"  = "*/" ] ; then BLOCK_COMMENT="OFF" ; fi
-
 
598
-
 
599
      if [ $CON_TERM ] ; then
-
 
600
        if [[ ${CON_LINE} =~ //.*$CON_TERM ]] ; then
-
 
601
          CON_TERM=""
-
 
602
        fi
-
 
603
      fi
-
 
604
    fi
-
 
605
-
 
606
    if [ "${CON_TERM}" ] ; then case "$CON_TERM" in
-
 
607
      include)
-
 
608
        local SUB_CON_FILE=`echo "${CON_LINE}" | grep -wE "$CON_TERM" | awk '{ print $2 }' | sed 's/\r//'`
-
 
609
        if [          ${SUB_CON_FILE} ] ; then
-
 
610
          parse_cons "${SUB_CON_FILE}"
-
 
611
        fi
-
 
612
        ;;
-
 
613
      setdefname)
-
 
614
        local     DEF_FILE=`echo "${CON_LINE}" | grep -wE "$CON_TERM" | awk '{ print $2 }' | sed 's/\r//'`
-
 
615
        if [       ${DEF_FILE} ] ; then
-
 
616
          DEF_TOP="${DEF_FILE}"
-
 
617
          info "Toplevel DEF set to ${DEF_TOP}"
-
 
618
          echo "${DEF_TOP}"  >   "${EXTRACTDIR}/DEF_TOP.tmp"
-
 
619
        fi
-
 
620
        ;;
-
 
621
      definesound)
-
 
622
        SOUND_FILE=`echo "${CON_LINE}" | grep -wE "$CON_TERM" | awk '{ print $3 }' | sed 's/\r//'`
-
 
623
        if [            ${SOUND_FILE} ] ; then
-
 
624
          extract_file "${SOUND_FILE}"
-
 
625
        fi
-
 
626
        ;;
-
 
627
      definelevelname)
-
 
628
          MAP_FILE=`echo "${CON_LINE}" | grep -wE "$CON_TERM" | awk '{ print $4 }' | sed 's/\r//'`
-
 
629
        if [            ${MAP_FILE} ] ; then
-
 
630
          extract_file "${MAP_FILE}"
-
 
631
        fi
-
 
632
        ;;
-
 
633
      music)
-
 
634
        MUSIC_POS=3
-
 
635
        while [ ${MUSIC_POS} ] ; do
-
 
636
          MUSIC_FILE=`echo "${CON_LINE}" | grep -wE "$CON_TERM" | awk "{ print \\$$MUSIC_POS }" | sed 's/\r//'`
-
 
637
          if [            ${MUSIC_FILE} ] ; then
-
 
638
            extract_file "${MUSIC_FILE}"
-
 
639
            MUSIC_POS=$(($MUSIC_POS + 1))
-
 
640
            MUSIC_FLAG=true
-
 
641
          else
-
 
642
            MUSIC_POS=""
-
 
643
          fi
-
 
644
        done
-
 
645
        ;;
-
 
646
      *)
-
 
647
        ;;
-
 
648
    esac ; fi
490
649
491
    if [  !   "${HRP_FILE}" = "" ] ; then
650
    if [ ${MUSIC_POS} ] ; then
-
 
651
      while [ ${MUSIC_POS} ] ; do
-
 
652
        MUSIC_FILE=`echo "${CON_LINE}" | grep -wE ".*\\.mid" | awk "{ print \\$$MUSIC_POS }" | sed 's/\r//'`
492
      if [ -f "${HRP_FILE}" ] ; then
653
        if [            ${MUSIC_FILE} ] ; then
493
        cp -p "${HRP_FILE}" "${EXTRACTDIR}/${HRP_FILE}"
654
          extract_file "${MUSIC_FILE}"
-
 
655
          MUSIC_POS=$(($MUSIC_POS + 1))
-
 
656
          MUSIC_FLAG=true
494
      else
657
        else
495
        echo  "WARNING : ${HRP_FILE} is missing!"
658
          MUSIC_POS=""
496
      fi
659
        fi
-
 
660
      done
497
    fi
661
    fi
498
662
499
  done
663
  done
500
} # parse_defs()
664
} # parse_cons()
501
665
502
666
503
delete_empty_folders()
667
delete_empty_folders() {
504
{
-
 
505
    if [ -d "${EXTRACTDIR}" ] ; then
668
  if [ -d "${EXTRACTDIR}" ] ; then
506
      rm -rf ${EXTRACTDIR}/.svn
669
    rm -rf ${EXTRACTDIR}/.svn
507
      DIRLIST=./EXTRACT_DIRECTORIES.lst
670
    DIRLIST=./EXTRACT_DIRECTORIES.lst
508
      du "${EXTRACTDIR}" > ${DIRLIST}
671
    du "${EXTRACTDIR}" > ${DIRLIST}
509
      cat ${DIRLIST} | while read DIR ; do
672
    cat ${DIRLIST} | while read DIR ; do
Line 514... Line 677...
514
          fi
677
        fi
515
        fi
678
      fi
516
      done
679
    done
517
      rm ${DIRLIST}
680
    rm ${DIRLIST}
518
    else
681
  else
519
      echo "No ${EXTRACTDIR}."
682
    warning "No ${EXTRACTDIR}."
520
    fi
683
  fi
521
} # delete_empty_folders()
684
} # delete_empty_folders()
522
685
523
686
524
main()
687
main() {
525
{
688
526
  EXTRACTDIR=../hrp_${HRPTYPE}_extract
689
  EXTRACTDIR=../${HRPTYPE}_extract
-
 
690
  [[ ${HRPTYPE} =~ (.*)(/)(.*) ]] # greedy first .* required
-
 
691
  if [ ${BASH_REMATCH[3]} ] ; then
-
 
692
    EXTRACTDIR=../${BASH_REMATCH[3]}_extract
-
 
693
  fi
527
  echo  "EXTRACT :" ${HRPROOT}/${EXTRACTDIR}
694
  echo "EXTRACT :" ${HRPROOT}/${EXTRACTDIR}
528
695
529
  if [ $FORCE = 0 ] ; then
696
  if [ $FORCE = 0 ] ; then
530
    if ask "Proceed?"
697
    if ask "Proceed?"
531
      then echo "Extracting ${HRPTYPE} from \"${HRPROOT}\" "
698
      then echo "Extracting ${HRPTYPE} from \"${HRPROOT}\" "
532
      else exit 0
699
      else exit 0
533
    fi
700
    fi
534
  fi
701
  fi
535
702
536
  date +%F" "%H:%M:%S
703
  #date +%F" "%H:%M:%S
537
704
538
  echo "### Deleting ${EXTRACTDIR} ... ###"
705
  info "Deleting ${EXTRACTDIR} ..."
539
  rm -rf ${EXTRACTDIR}
706
  rm -rf ${EXTRACTDIR}
540
707
541
  echo "### Copying directory tree ... ###"
708
  info "Copying  directory tree ..."
542
  copy_folders
709
  copy_folders
543
710
544
  if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "polymost_override" ] ||\
711
  if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "polymost_override" ] ||\
545
    [ "${HRPTYPE}" = "megaton" ] || [ "${HRPTYPE}" = "megaton_override" ] ; then
712
    [ "${HRPTYPE}" = "megaton" ] || [ "${HRPTYPE}" = "megaton_override" ] ; then
546
713
547
    echo "### DukePlus<>Polymost HRP compatibility patch ... ###"
714
    info "DukePlus<>Polymost HRP compatibility patch ..."
548
    dukeplus_polymost_hrp_compatibility $DUKEPLUS_POLYMOST_COMPATIBILTY_APPROACH
715
    dukeplus_polymost_hrp_compatibility $DUKEPLUS_POLYMOST_COMPATIBILTY_APPROACH
549
716
550
    echo "### Attrition<>Polymost HRP compatibility patch ... ###"
717
    info "Attrition<>Polymost HRP compatibility patch ..."
551
    attrition_polymost_hrp_compatibility $ATTRITION_POLYMOST_COMPATIBILTY_APPROACH
718
    attrition_polymost_hrp_compatibility $ATTRITION_POLYMOST_COMPATIBILTY_APPROACH
552
  fi
719
  fi
553
720
554
721
555
  if [ "${HRPTYPE}" = "polymost" ]||[ "${HRPTYPE}" = "polymost_override" ]; then
722
  if [ "${HRPTYPE}" = "polymost" ]||[ "${HRPTYPE}" = "polymost_override" ]; then
Line 557... Line 724...
557
    zip -rq9 ${EXTRACTDIR}/polymost_hrp_polymer_maphacks.zip \
724
    zip -rq9 ${EXTRACTDIR}/polymost_hrp_polymer_maphacks.zip \
558
    maphacks/3drealms/*.mhk
725
    maphacks/3drealms/*.mhk
559
  fi
726
  fi
560
727
561
  if [ "${HRPTYPE}" = "megaton" ] || [ "${HRPTYPE}" = "megaton_override" ]; then
728
  if [ "${HRPTYPE}" = "megaton" ] || [ "${HRPTYPE}" = "megaton_override" ]; then
562
    echo "### Copying maphacks for Megaton ... ###"
729
    info "Copying  maphacks for Megaton ..."
563
    copy_polymost_mhk
730
    copy_polymost_mhk
564
  fi
731
  fi
565
732
566
  echo "### Parsing DEF file hierarchy ... ###"
-
 
567
  if [ "$EXTRACT_COMMENTED_FILES" = "YES" ] ; then
-
 
568
    echo "  # Extract commented textures and models: $EXTRACT_COMMENTED_FILES"
733
  info "Extract  commented items - $EXTRACT_COMMENTED_FILES"
569
  else
-
 
570
    echo "  # Extract commented textures and models: NO"
734
  info "Parsing  file hierarchy :"
571
  fi
735
572
  if [ "${HRPTYPE}" = "megaton" ]  || [ "${HRPTYPE}" = "full" ] ; then
736
  if [ "${HRPTYPE}" = "megaton" ]  || [ "${HRPTYPE}" = "full" ] ; then
573
    parse_defs duke3d_hrp_megaton.def
737
    parse_defs duke3d_hrp_megaton.def
574
  fi
738
  fi
575
  if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "full" ] ; then
739
  if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "full" ] ; then
576
    parse_defs duke3d_hrp_polymost.def
740
    parse_defs duke3d_hrp_polymost.def
577
  fi
741
  fi
578
  if [ "${HRPTYPE}" = "polymer" ]  || [ "${HRPTYPE}" = "full" ] ; then
742
  if [ "${HRPTYPE}" = "polymer" ]  || [ "${HRPTYPE}" = "full" ] ; then
579
    parse_defs duke3d_hrp.def
743
    parse_defs duke3d_hrp.def
580
  fi
744
  fi
-
 
745
  #if [ "${HRPTYPE}" = "voxels" ]   || [ "${HRPTYPE}" = "full" ] ; then
581
  if [ "${HRPTYPE}" = "voxel" ] ; then
746
  if [ "${HRPTYPE}" = "voxels" ] ; then
582
    parse_defs duke3d_voxel.def
747
    parse_defs duke3d_voxels.def
583
  fi
748
  fi
584
  if [ "${HRPTYPE}" = "sw_highres" ] ; then
749
  if [ "${HRPTYPE}" = "sw_highres" ] ; then
585
    parse_defs highres/sw_hrp.def
750
    parse_defs highres/sw_hrp.def
586
  fi
751
  fi
587
  if [ "${HRPTYPE}" = "sw_lowres" ] ; then
752
  if [ "${HRPTYPE}" = "sw_lowres" ] ; then
588
    parse_defs lowres/sw_lrp.def
753
    parse_defs lowres/sw_lrp.def
589
  fi
754
  fi
590
  if [ "${HRPTYPE}" = "maphacks" ] ; then
755
  if [ "${HRPTYPE}" = "maphacks" ] ; then
591
    parse_defs maphacks/mhk-extract.def
756
    parse_defs maphacks/mhk-extract.def
592
  fi
757
  fi
-
 
758
  if [ "${HRPTYPE}" = "${DEF_TOP}" ] ; then
-
 
759
    parse_defs "${DEF_TOP}"
-
 
760
  fi
-
 
761
  if [ "${HRPTYPE}" = "${CON_TOP}" ] ; then
-
 
762
    parse_cons "${CON_TOP}"
-
 
763
    if [ -f        "${EXTRACTDIR}/DEF_TOP.tmp" ] ; then
-
 
764
      DEF_TOP=`cat "${EXTRACTDIR}/DEF_TOP.tmp"`
-
 
765
      rm           "${EXTRACTDIR}/DEF_TOP.tmp"
-
 
766
      if [ -f      "${DEF_TOP}" ] ; then
-
 
767
        cp -p      "${DEF_TOP}" "${EXTRACTDIR}/${DEF_TOP}"
-
 
768
        parse_defs "${DEF_TOP}"
-
 
769
      else
-
 
770
        warning "${DEF_TOP} is missing!"
-
 
771
      fi
-
 
772
    fi
-
 
773
  fi
-
 
774
  if [ "${HRPTYPE}" = "${GRP_TOP}" ] ; then
-
 
775
    GRP="${GRP_TOP}"
-
 
776
    #parse_grp "${GRP}"
-
 
777
    if hash kextract 2>/dev/null; then
-
 
778
      #echo "kextract ${GRP} : "
-
 
779
      #kextract "${GRP}" | wc -l
-
 
780
      #kextract "${GRP}" > "${EXTRACTDIR}/${GRP}.lst"
-
 
781
      mkdir    "${EXTRACTDIR}/${GRP}" || exit_on_error\
-
 
782
        "Could not create ${EXTRACTDIR}/${GRP}"
-
 
783
      cd       "${EXTRACTDIR}/${GRP}"
-
 
784
      kextract "${WORKDIR}/${GRP}" "GAME.CON"  > /dev/null
-
 
785
      kextract "${WORKDIR}/${GRP}" "EDUKE.CON" > /dev/null
-
 
786
      cd "${WORKDIR}"
-
 
787
      if [ -f    "${EXTRACTDIR}/${GRP}/EDUKE.CON" ] ; then
-
 
788
        CON_FILE="EDUKE.CON"
-
 
789
        rm -f    "${EXTRACTDIR}/${GRP}/GAME.CON"
-
 
790
      elif [ -f  "${EXTRACTDIR}/${GRP}/GAME.CON" ] ; then
-
 
791
        CON_FILE="GAME.CON"
-
 
792
      else
-
 
793
        exit_on_error "No EDUKE.CON or GAME.CON in ${GRP}!"
-
 
794
      fi
-
 
795
      parse_cons "${CON_FILE}"
-
 
796
-
 
797
    else
-
 
798
      exit_on_error "No 'kextract' executable found."
-
 
799
    fi
-
 
800
  fi
593
  if [ "${HRPTYPE}" = "default" ] ; then
801
  if [ "${HRPTYPE}" = "auto" ] ; then
-
 
802
-
 
803
    if [ -f "duke3d.grp" ] ; then GRP="duke3d.grp" ; fi
-
 
804
    if [ -f "DUKE3D.GRP" ] ; then GRP="DUKE3D.GRP" ; fi
-
 
805
    if [ ${GRP} ] ; then
-
 
806
      info "Auto mode found ${GRP}"
-
 
807
      if hash kextract 2>/dev/null; then
-
 
808
        mkdir "${EXTRACTDIR}/${GRP}"
-
 
809
      else
-
 
810
        info "No 'kextract' executable found."
-
 
811
        GRP=""
-
 
812
      fi
-
 
813
    fi
-
 
814
-
 
815
    if [     -f "EDUKE.CON" ] || [ -f "GAME.CON" ] ; then
-
 
816
      if [   -f "EDUKE.CON" ] ; then
-
 
817
        CON_TOP="EDUKE.CON"
-
 
818
      else
-
 
819
        CON_TOP="GAME.CON"
-
 
820
      fi
-
 
821
      info "Auto mode found ${CON_TOP}"
-
 
822
      parse_cons "${CON_TOP}"
-
 
823
      if [ -f        "${EXTRACTDIR}/DEF_TOP.tmp" ] ; then
-
 
824
        DEF_TOP=`cat "${EXTRACTDIR}/DEF_TOP.tmp"`
-
 
825
        rm           "${EXTRACTDIR}/DEF_TOP.tmp"
-
 
826
        if [ -f      "${DEF_TOP}" ] ; then
-
 
827
          cp -p      "${DEF_TOP}" "${EXTRACTDIR}/${DEF_TOP}"
-
 
828
          parse_defs "${DEF_TOP}"
-
 
829
        else
-
 
830
          warning "${DEF_TOP} is missing!"
-
 
831
        fi
-
 
832
      elif [ -f "duke3d.def" ] ; then
-
 
833
        DEF_TOP="duke3d.def"
-
 
834
        info "Auto mode found ${DEF_TOP}"
-
 
835
        parse_defs "${DEF_TOP}"
-
 
836
      fi
-
 
837
    elif [ -f "duke3d.def" ] ; then
-
 
838
      DEF_TOP="duke3d.def"
-
 
839
      info "Auto mode found ${DEF_TOP}"
594
    parse_defs "${DEF_TOP}"
840
      parse_defs "${DEF_TOP}"
-
 
841
    else
-
 
842
      exit_on_error "Please report to LeoD"
-
 
843
    fi
595
  fi
844
  fi
596
845
597
  echo "### Copying 'known' files ... ###"
846
  info "Copying  'known' files ..."
598
  copy_known_files
847
  copy_known_files
599
848
600
  echo "### Deleting empty directories in ${EXTRACTDIR} ... ###"
849
  info "Deleting empty directories in ${EXTRACTDIR}/ ..."
601
  delete_empty_folders
850
  delete_empty_folders
602
851
603
  date +%F" "%H:%M:%S
852
  #date +%F" "%H:%M:%S
604
853
605
  echo "Command line example for creating a ZIP package:"
854
  #echo "Command line example for creating a ZIP package:"
606
  echo "sh -c \"cd ${EXTRACTDIR}; zip -9rqn .jpg:.png:.zip ${EXTRACTDIR}.zip\
855
  #echo "sh -c \"cd ${EXTRACTDIR}; zip -9rqn .jpg:.png:.zip ${EXTRACTDIR}.zip\
607
  highpal highres maphacks *.def *.txt\""
856
  #highpal highres maphacks *.def *.txt\""
608
} # main()
857
} # main()
609
858
610
859
611
860
612
PRGPATH=$0
861
PRGPATH=$0
613
HRPTYPE=$1
862
HRPTYPE=$1
614
if [ "$2" = "y" ] ; then FORCE=1 ; else FORCE=0 ; fi
863
if [ "$2" = "y" ] ; then FORCE=1 ; else FORCE=0 ; fi
615
if [ "$2" = "v" ] && [ ! "$3" = "" ] ; then
864
if [ "$2" = "v" ] && [ ! "$3" = "" ] ; then
616
  VERSION="$3"
865
  VERSION="$3"
617
  echo "${VERSION}" > VERSION
866
  info "${VERSION}" > VERSION
618
fi
867
fi
619
HRPROOT=.
868
HRPROOT=.
620
WORKDIR=`pwd`
869
WORKDIR=`pwd`
621
870
622
cd               "${HRPROOT}"
871
cd              "${HRPROOT}"
Line 656... Line 905...
656
    ${PRGPATH} both     y
905
    ${PRGPATH} both     y
657
    ${PRGPATH} megaton  y
906
    ${PRGPATH} megaton  y
658
    ${PRGPATH} maphacks y
907
    ${PRGPATH} maphacks y
659
    ${PRGPATH} full     y
908
    ${PRGPATH} full     y
660
    ;;
909
    ;;
661
  voxel)
910
  voxels)
662
    SET_VERSION=NO
911
    SET_VERSION=NO
663
    main $HRPTYPE
912
    main $HRPTYPE
664
    ;;
913
    ;;
665
  sw_highres|sw_lowres)
914
  sw_highres|sw_lowres)
666
    SET_VERSION=NO
915
    SET_VERSION=NO
Line 672... Line 921...
672
      else exit 0
921
      else exit 0
673
    fi ; fi
922
    fi ; fi
674
    ${PRGPATH} sw_lowres  y
923
    ${PRGPATH} sw_lowres  y
675
    ${PRGPATH} sw_highres y
924
    ${PRGPATH} sw_highres y
676
    ;;
925
    ;;
-
 
926
  auto)
-
 
927
    SET_VERSION=NO
-
 
928
    EXTRACT_COMMENTED_FILES=NO
-
 
929
    if [ -f "EDUKE.CON" ] || [ -f "GAME.CON" ] || [ -f "duke3d.def" ] ; then
-
 
930
      main $HRPTYPE
-
 
931
    else
-
 
932
      exit_on_error "Auto mode found no suitable toplevel file (EDUKE.CON|GAME.CON|duke3d.def)."
-
 
933
    fi
-
 
934
    ;;
677
  unused)
935
  unused)
678
    echo "Option \"$1\" not yet implemented."
936
    exit_on_error "Option \"$1\" not yet implemented."
679
    ;;
937
    ;;
680
  debug)
938
  debug)
681
    echo "Nothing to debug."
939
    exit_on_error "Nothing to debug."
682
    ;;
940
    ;;
683
  *)
941
  *)
684
    if [ -f "${HRPTYPE}" ] && [ "${HRPTYPE##*.}" = "def" ] ; then
-
 
685
      DEF_TOP="${HRPTYPE}"
942
    if [ -f "${HRPTYPE}" ] ; then
686
      HRPTYPE=default
-
 
687
      SET_VERSION=NO
943
      SET_VERSION=NO
688
      EXTRACT_COMMENTED_FILES=NO
944
      EXTRACT_COMMENTED_FILES=NO
-
 
945
      #EXTRACT_COMMENTED_FILES=YES
-
 
946
      if [      "${HRPTYPE##*.}" = "def" ] ; then
-
 
947
        DEF_TOP="${HRPTYPE}"
-
 
948
      elif [    "${HRPTYPE##*.}" = "CON" ] || [ "${HRPTYPE##*.}" = "con" ]; then
-
 
949
        CON_TOP="${HRPTYPE}"
-
 
950
      elif [    "${HRPTYPE##*.}" = "GRP" ] || [ "${HRPTYPE##*.}" = "grp" ]; then
-
 
951
        GRP_TOP="${HRPTYPE}"
-
 
952
      else
-
 
953
        exit_on_error "Bad file type: ${HRPTYPE##*.}."
-
 
954
      fi
689
      main $HRPTYPE
955
      main $HRPTYPE
690
    else
956
    else
691
      echo "Usage: ${0} {HRPTYPE|TOP_DEF_FILE} [v VERSION]"
957
      echo "Usage   : ${0} {auto|TOP_CON_FILE|TOP_DEF_FILE|GRP_FILE|HRPTYPE [v VERSION]}"
692
      echo "HRPTYPEs: {full|ovr|all}"
958
      echo "HRPTYPEs: {full|ovr|all}"
693
      echo "HRPTYPEs: {polymer|polymost_override|polymost|both}"
959
      echo "HRPTYPEs: {polymer|polymost_override|polymost|both}"
694
      echo "HRPTYPEs: {megaton_override|megaton}"
960
      echo "HRPTYPEs: {megaton_override|megaton}"
695
      echo "HRPTYPEs: {maphacks}"
961
      echo "HRPTYPEs: {maphacks|voxels}"
696
      echo "HRPTYPEs: {sw_highres|sw_lowres|sw_both}"
962
      echo "HRPTYPEs: {sw_highres|sw_lowres|sw_both}"
697
      exit 1
963
      exit 1
698
    fi
964
    fi
699
    ;;
965
    ;;
700
esac
966
esac