Subversion Repositories duke3d_hrp

Rev

Rev 714 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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