mirror of
https://gitlab.com/Nanolx/patchimage.git
synced 2024-12-27 09:41:49 +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 () {
|
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
|
||||||
@ -60,11 +60,9 @@ ask_items () {
|
|||||||
if [[ -f ${HOME}/.patchimage.choice ]]; then
|
if [[ -f ${HOME}/.patchimage.choice ]]; then
|
||||||
echo "Your choices from last time can be re-used."
|
echo "Your choices from last time can be re-used."
|
||||||
echo "y (yes) or n (no)"
|
echo "y (yes) or n (no)"
|
||||||
read choice
|
read -r choice
|
||||||
|
|
||||||
if [[ ${choice} == y ]]; then
|
[[ ${choice} == y ]] && source "${HOME}"/.patchimage.choice
|
||||||
source ${HOME}/.patchimage.choice
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${choosenitems[@]} == "" ]]; then
|
if [[ ${choosenitems[@]} == "" ]]; then
|
||||||
@ -77,22 +75,22 @@ ask_items () {
|
|||||||
|
|
||||||
orig Original item"
|
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"
|
echo -e "\ntype orig or ???.brres"
|
||||||
read slotid
|
read -r slotid
|
||||||
echo "<<<<<<>>>>>>"
|
echo "<<<<<<>>>>>>"
|
||||||
choosenitems=( ${choosenitems[@]} ${slot}:${slotid} )
|
choosenitems=( ${choosenitems[@]} ${slot}:${slotid} )
|
||||||
done
|
done
|
||||||
|
|
||||||
echo ${choosenitems[@]}
|
echo "${choosenitems[@]}"
|
||||||
echo "choosenitems=( ${choosenitems[@]} )" > ${HOME}/.patchimage.choice
|
echo "choosenitems=( ${choosenitems[*]} )" > "${HOME}"/.patchimage.choice
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
download_items () {
|
download_items () {
|
||||||
|
|
||||||
for item in ${choosenitems[@]}; do
|
for item in "${choosenitems[@]}"; do
|
||||||
id=${item/*:}
|
id=${item/*:}
|
||||||
if [[ ! -f ${PATCHIMAGE_DATA_DIR}/mkwiimm_items/${id} ]]; then
|
if [[ ! -f ${PATCHIMAGE_DATA_DIR}/mkwiimm_items/${id} ]]; then
|
||||||
echo "unknown Item ${item}"
|
echo "unknown Item ${item}"
|
||||||
@ -113,34 +111,34 @@ 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}"/Common.szs_${ID/.*} ]]; then
|
if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/Common.szs_${ID/.*} ]]; then
|
||||||
echo "*** 6) this is the first run, so backing up common.szs
|
echo "*** 6) this is the first run, so backing up common.szs
|
||||||
(in ${PATCHIMAGE_RIIVOLUTION_DIR}) for future customizations"
|
(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
|
else
|
||||||
echo "*** 6) restoring original common.szs"
|
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
|
fi
|
||||||
|
|
||||||
echo "*** 7) replacing items"
|
echo "*** 7) replacing items"
|
||||||
rm -rf workdir/${CSZD}
|
rm -rf workdir/"${CSZD}"
|
||||||
${SZS} extract workdir/${CSZS} -q || \
|
"${SZS}" extract workdir/"${CSZS}" -q || \
|
||||||
( echo "szs caught an erro extracting common.szs" && exit 51 )
|
( echo "szs caught an error extracting common.szs" && exit 51 )
|
||||||
for item in ${choosenitems[@]}; do
|
for item in "${choosenitems[@]}"; do
|
||||||
slot=${item/:*}
|
slot=${item/:*}
|
||||||
newi=${item/*:}
|
newi=${item/*:}
|
||||||
cp ${PATCHIMAGE_DATA_DIR}/mkwiimm_items/${newi} \
|
cp "${PATCHIMAGE_DATA_DIR}"/mkwiimm_items/"${newi}" \
|
||||||
workdir/${CSZD}/${slot}
|
workdir/"${CSZD}"/"${slot}"
|
||||||
done
|
done
|
||||||
${SZS} create -o workdir/${CSZD} -q || \
|
"${SZS}" create -o workdir/"${CSZD}" -q || \
|
||||||
( echo "szs caught an error rebuilding common.szs" && exit 51 )
|
( echo "szs caught an error rebuilding common.szs" && exit 51 )
|
||||||
rm -rf workdir/${CSZD}
|
rm -rf workdir/"${CSZD}"
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user