Subversion Repositories duke3d_hrp

Rev

Rev 639 | Rev 645 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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