mirror of
https://gitlab.com/Nanolx/patchimage.git
synced 2024-11-01 07:15:06 +01:00
mkwiimm_items.sh: fixes and code review
This commit is contained in:
parent
b745154c30
commit
30cd5e2493
@ -23,13 +23,13 @@ Supported Versions: EUR, JAP, USA
|
||||
check_input_image_special () {
|
||||
|
||||
ask_input_image_mkwiimm
|
||||
echo -e "type ALL or RMC???.wbfs:\n"
|
||||
read ID
|
||||
echo -e "type RMC???.wbfs:\n"
|
||||
read -r ID
|
||||
|
||||
if [[ -f ${PWD}/${ID} ]]; then
|
||||
GAMEDIR=${PWD}
|
||||
GAMEDIR="${PWD}"
|
||||
elif [[ -f ${PATCHIMAGE_WBFS_DIR}/${ID} ]]; then
|
||||
GAMEDIR=${PATCHIMAGE_WBFS_DIR}
|
||||
GAMEDIR="${PATCHIMAGE_WBFS_DIR}"
|
||||
else echo "invalid user input."
|
||||
exit 75
|
||||
fi
|
||||
@ -60,11 +60,9 @@ ask_items () {
|
||||
if [[ -f ${HOME}/.patchimage.choice ]]; then
|
||||
echo "Your choices from last time can be re-used."
|
||||
echo "y (yes) or n (no)"
|
||||
read choice
|
||||
read -r choice
|
||||
|
||||
if [[ ${choice} == y ]]; then
|
||||
source ${HOME}/.patchimage.choice
|
||||
fi
|
||||
[[ ${choice} == y ]] && source "${HOME}"/.patchimage.choice
|
||||
fi
|
||||
|
||||
if [[ ${choosenitems[@]} == "" ]]; then
|
||||
@ -77,22 +75,22 @@ ask_items () {
|
||||
|
||||
orig Original item"
|
||||
|
||||
gawk -F \: "/${slot}/"'{print $1 "\t" $3}' < ${PATCHIMAGE_DATABASE_DIR}/mkwiimm_items.db
|
||||
gawk -F : "/${slot}/"'{print $1 "\t" $3}' < "${PATCHIMAGE_DATABASE_DIR}"/mkwiimm_items.db
|
||||
echo -e "\ntype orig or ???.brres"
|
||||
read slotid
|
||||
read -r slotid
|
||||
echo "<<<<<<>>>>>>"
|
||||
choosenitems=( ${choosenitems[@]} ${slot}:${slotid} )
|
||||
done
|
||||
|
||||
echo ${choosenitems[@]}
|
||||
echo "choosenitems=( ${choosenitems[@]} )" > ${HOME}/.patchimage.choice
|
||||
echo "${choosenitems[@]}"
|
||||
echo "choosenitems=( ${choosenitems[*]} )" > "${HOME}"/.patchimage.choice
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
download_items () {
|
||||
|
||||
for item in ${choosenitems[@]}; do
|
||||
for item in "${choosenitems[@]}"; do
|
||||
id=${item/*:}
|
||||
if [[ ! -f ${PATCHIMAGE_DATA_DIR}/mkwiimm_items/${id} ]]; then
|
||||
echo "unknown Item ${item}"
|
||||
@ -113,34 +111,34 @@ build_mkwiimm () {
|
||||
|
||||
rm -rf workdir
|
||||
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}"/Common.szs_${ID/.*} ]]; then
|
||||
echo "*** 6) this is the first run, so backing up common.szs
|
||||
(in ${PATCHIMAGE_RIIVOLUTION_DIR}) for future customizations"
|
||||
cp workdir/${CSZS} "${PATCHIMAGE_RIIVOLUTION_DIR}"/Common.szs_${ID/.*}
|
||||
cp workdir/"${CSZS}" "${PATCHIMAGE_RIIVOLUTION_DIR}"/Common.szs_"${ID/.*}"
|
||||
else
|
||||
echo "*** 6) restoring original common.szs"
|
||||
cp "${PATCHIMAGE_RIIVOLUTION_DIR}"/Common.szs_${ID/.*} workdir/${CSZS}
|
||||
cp "${PATCHIMAGE_RIIVOLUTION_DIR}"/Common.szs_"${ID/.*}" workdir/"${CSZS}"
|
||||
fi
|
||||
|
||||
echo "*** 7) replacing items"
|
||||
rm -rf workdir/${CSZD}
|
||||
${SZS} extract workdir/${CSZS} -q || \
|
||||
( echo "szs caught an erro extracting common.szs" && exit 51 )
|
||||
for item in ${choosenitems[@]}; do
|
||||
rm -rf workdir/"${CSZD}"
|
||||
"${SZS}" extract workdir/"${CSZS}" -q || \
|
||||
( echo "szs caught an error extracting common.szs" && exit 51 )
|
||||
for item in "${choosenitems[@]}"; do
|
||||
slot=${item/:*}
|
||||
newi=${item/*:}
|
||||
cp ${PATCHIMAGE_DATA_DIR}/mkwiimm_items/${newi} \
|
||||
workdir/${CSZD}/${slot}
|
||||
cp "${PATCHIMAGE_DATA_DIR}"/mkwiimm_items/"${newi}" \
|
||||
workdir/"${CSZD}"/"${slot}"
|
||||
done
|
||||
${SZS} create -o workdir/${CSZD} -q || \
|
||||
"${SZS}" create -o workdir/"${CSZD}" -q || \
|
||||
( echo "szs caught an error rebuilding common.szs" && exit 51 )
|
||||
rm -rf workdir/${CSZD}
|
||||
rm -rf workdir/"${CSZD}"
|
||||
|
||||
echo "*** 8) rebuilding game"
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user