mkwiimm_fonts.sh: fixes and code review

This commit is contained in:
Christopher Roy Bratusek 2016-08-05 21:28:46 +02:00
parent 30cd5e2493
commit eb68b7638e

View File

@ -23,13 +23,13 @@ Supported Versions: EUR, JAP, USA
check_input_image_special () { check_input_image_special () {
ask_input_image_mkwiimm ask_input_image_mkwiimm
echo -e "type ALL or RMC???.wbfs:\n" echo -e "type RMC???.wbfs:\n"
read ID read -r ID
if [[ -f ${PWD}/${ID} ]]; then if [[ -f ${PWD}/${ID} ]]; then
GAMEDIR=${PWD} GAMEDIR="${PWD}"
elif [[ -f ${PATCHIMAGE_WBFS_DIR}/${ID} ]]; then elif [[ -f ${PATCHIMAGE_WBFS_DIR}/${ID} ]]; then
GAMEDIR=${PATCHIMAGE_WBFS_DIR} GAMEDIR="${PATCHIMAGE_WBFS_DIR}"
else echo "invalid user input." else echo "invalid user input."
exit 75 exit 75
fi fi
@ -42,10 +42,10 @@ download_wiimm () {
orig Original Mario Kart Wii Font" orig Original Mario Kart Wii Font"
gawk -F \: '{print $1 "\t\t" $2}' < ${PATCHIMAGE_DATABASE_DIR}/mkwiimm_fonts.db gawk -F : '{print $1 "\t\t" $2}' < "${PATCHIMAGE_DATABASE_DIR}"/mkwiimm_fonts.db
echo -e "\ntype ???.szs or orig" echo -e "\ntype ???.szs or orig"
read FONT read -r FONT
if [[ ${FONT} != orig ]]; then if [[ ${FONT} != orig ]]; then
if [[ ! -f ${PATCHIMAGE_DATA_DIR}/mkwiimm_fonts/${FONT} ]]; then if [[ ! -f ${PATCHIMAGE_DATA_DIR}/mkwiimm_fonts/${FONT} ]]; then
@ -60,23 +60,23 @@ build_mkwiimm () {
rm -rf workdir rm -rf workdir
echo "*** 5) extracting image" echo "*** 5) extracting image"
${WIT} extract ${IMAGE%/*}/${ID} workdir -q || exit 51 "${WIT}" extract "${GAMEDIR}"/"${ID}" workdir -q || exit 51
if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/Font.szs_${ID/.*} ]]; then if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/Font.szs_${ID/.*} ]]; then
echo "*** 6) this is the first run, so backing up font.szs echo "*** 6) this is the first run, so backing up font.szs
(in ${PATCHIMAGE_RIIVOLUTION_DIR}) for future customizations" (in ${PATCHIMAGE_RIIVOLUTION_DIR}) for future customizations"
cp workdir/${FSZS} "${PATCHIMAGE_RIIVOLUTION_DIR}"/Font.szs_${ID/.*} cp workdir/"${FSZS}" "${PATCHIMAGE_RIIVOLUTION_DIR}"/Font.szs_"${ID/.*}"
else else
echo "*** 6) restoring original common.szs" echo "*** 6) restoring original common.szs"
cp "${PATCHIMAGE_RIIVOLUTION_DIR}"/Font.szs_${ID/.*} workdir/${FSZS} cp "${PATCHIMAGE_RIIVOLUTION_DIR}"/Font.szs_"${ID/.*}" workdir/"${FSZS}"
fi fi
echo "*** 7) replacing font" echo "*** 7) replacing font"
cp "${PATCHIMAGE_DATA_DIR}"/mkwiimm_fonts/${FONT} workdir/${FSZS} cp "${PATCHIMAGE_DATA_DIR}"/mkwiimm_fonts/"${FONT}" workdir/"${FSZS}"
echo "*** 8) rebuilding game" echo "*** 8) rebuilding game"
echo " (storing game in ${PATCHIMAGE_GAME_DIR}/${ID})" echo " (storing game in ${PATCHIMAGE_GAME_DIR}/${ID})"
${WIT} cp -o -q -B workdir ${PATCHIMAGE_GAME_DIR}/${ID} || exit 51 "${WIT}" cp -o -q -B workdir "${PATCHIMAGE_GAME_DIR}"/"${ID}" || exit 51
rm -rf workdir rm -rf workdir