Subversion Repositories duke3d_hrp

Rev

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

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