fix: downgrade logic

This commit is contained in:
v4n
2025-01-23 09:29:48 +02:00
parent 55f382a8e5
commit 35902f1f8f
4 changed files with 11 additions and 12 deletions
+2 -1
View File
@@ -16,7 +16,8 @@ bash -c "$(curl -fsSL https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/head
> Running this script will require sudo permissions. **DO NOT TRUST** random scripts from the internet. If you want to review the script before running it, check out the mod repository for yourself.
If for some reason, the installation command doesn't work you can:
1. Go to https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/master/install.sh
1. Go to <https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/master/install.sh>
1. Right click -> Save page as...
1. Go to your downloads folders `cd ~/Downloads`
1. Give the script execution permissions `chmod +x install.sh`
+5 -5
View File
@@ -1,6 +1,6 @@
#!/bin/bash
VERSION="0.3.0"
VERSION="0.3.1"
# --- Globals ---
@@ -102,8 +102,8 @@ function find_game_directory() {
fi
# first time setup, or directory is not valid anymore
echo "Searching for the Helldivers 2 data directory..." >&2
game_dir=$(find "$search_dir" -type d -path "*/$target_dir" 2>/dev/null | head -n 1)
echo "Searching for the Helldivers 2 data directory... (20 seconds timeout)" >&2
game_dir=$(timeout 20 find "$search_dir" -type d -path "*/$target_dir" 2>/dev/null | head -n 1)
if [[ -z "$game_dir" ]]; then
echo "Could not find the Helldivers 2 data directory automatically." >&2
@@ -677,7 +677,7 @@ function mod_uninstall() {
mod=$(get_filename_without_path "$mod")
patch_version=$(echo $mod | grep -oP '(?<=patch_)\d+')
if [[ $patch_version -gt ${downgrades_versions[$base_name_with_patch]} ]]; then
new_version=$((patch_version - downgrades_to_remove["$base_name"] - 1))
new_version=$((patch_version - downgrades_to_remove["$base_name"]))
extension=$(get_extension "$mod")
new_patch="${base_name}.patch_${new_version}${extension}"
@@ -729,7 +729,7 @@ function mod_export() {
[[ $(wc -l < "$DB_FILE") -le 1 ]] && { echo "No modpacks saved."; exit 1; }
if [[ silent == false ]]; then
if [[ $modpack_export == false ]]; then
echo -ne "Archive file will be saved to ${save_dir}/${archive_name}. Make? (Y/n): "
read -r confirm
fi
+3 -5
View File
@@ -58,8 +58,8 @@ if [[ -x "$(command -v $SCRIPT_NAME)" ]]; then
if [[ $latest_major -gt $installed_major ]]; then
echo -e "${ORANGE}Warning:${NC} Major version upgrade detected."
echo "Check out the changelogs here:"
echo "https://github.com/v4n00/h2mm-cli/releases"
echo "${ORANGE}!${NC} Check out the changelogs here:"
echo "${ORANGE}!${NC} https://github.com/v4n00/h2mm-cli/releases"
echo "The script will proceed to upgrade ${SCRIPT_NAME} to avoid breaking changes."
# find hd2 path
@@ -80,13 +80,11 @@ if [[ -x "$(command -v $SCRIPT_NAME)" ]]; then
[[ ! -f "$game_dir/mods.csv" ]] && { echo -e "${RED}Error:${NC} mods.csv not found in $game_dir."; exit 1; }
# make backup of mods in case something goes wrong
echo "Creating a backup of mods.csv."
echo "${ORANGE}V${NC} It is advised to make a backup before proceeding."
h2mm export
# iterate from installed major number to latest major number
for ((i = installed_major + 1; i <= latest_major; i++)); do
echo -e "Applying breaking changes patch for version $i."
if [[ -n "${breaking_changes_patches[$i]}" ]]; then
eval $(echo "${breaking_changes_patches[$i]}" | sed "s:\$1:$game_dir:")
else
+1 -1
View File
@@ -1 +1 @@
0.3.0
0.3.1