Subversion Repositories duke3d_hrp

Rev

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

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