From efbd7d348c086bc3ff63e86b6761ca0b83d8bc63 Mon Sep 17 00:00:00 2001 From: v4n <105587619+v4n00@users.noreply.github.com> Date: Wed, 15 Jan 2025 21:00:17 +0200 Subject: [PATCH] fix: uninstall logic --- README.md | 9 ++++++--- h2mm | 10 +++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9d2e907..eb5bed1 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,8 @@ h2mm install -n "Example mod" mod.patch_0 mod.patch_0.stream # -n is mandatory w h2mm install -n "Example mod" mod* # using a wildcard to include all files ``` +Important: If the mod has more than 1 variant, you need to install the one you want by unarchiving it separately. + #### Uninstall a mod ```bash @@ -112,6 +114,7 @@ Feel free to contribute to this project by creating a pull request or opening an ## Planned features -- [ ] Enable/disable mods -- [ ] Easier way to change mod presets -- [ ] Change to `.tar.xz` for exporting and importing +- [ ] ! Enable/disable mods +- [ ] !! Easier way to change mod presets +- [ ] !! Change to `.tar.xz` for exporting and importing +- [ ] !!! Find a way to make use of `manifest.json` and simplify installing variants diff --git a/h2mm b/h2mm index 42f623e..744a302 100755 --- a/h2mm +++ b/h2mm @@ -82,7 +82,7 @@ function initialize_directories() { # --- Help Functions --- function display_help() { - echo "Helldivers 2 Mod Manager v0.1.5" + echo "Helldivers 2 Mod Manager v0.1.6" echo "Usage: h2mm [command] [options]" echo "Commands:" echo " install Install a mod with files (short form: h2mm i)." @@ -112,6 +112,7 @@ function display_install_help() { echo " h2mm install /path/to/mod/files" echo " h2mm install -n \"Example mod\" mod.patch_0 mod.patch_0.stream # -n is mandatory when using files" echo " h2mm install -n \"Example mod\" mod* # using a wildcard to include all files" + echo "If the mod has more than 1 variant, you need to install the one you want by unarchiving it separately." } function display_uninstall_help() { @@ -221,7 +222,6 @@ function mod_install() { # check if mod name was provided, otherwise use the zip file name, get rid of .zip and version numbers if [[ -z "$mod_name" ]]; then mod_name=$(basename "$mod_zip" | sed -E 's/\.zip//' | awk -F/ '{print $NF}' | sed -E 's/-[0-9]+-.*//') - echo "$mod_name" fi mod_dir=$(mktemp -d) @@ -376,7 +376,7 @@ function mod_uninstall() { base_name=$(get_basename "$file") current_version=$(echo $file | grep -oP '(?<=patch_)\d+') - downgrades["$base_name"]=current_version + downgrades["$base_name"]=$current_version fi done @@ -390,7 +390,7 @@ function mod_uninstall() { patch=$(get_filename_without_path "$patch") patch_version=$(echo $patch | grep -oP '(?<=patch_)\d+') if [[ $patch_version -gt ${downgrades[$file]} ]]; then - new_version=$((patch_version - 1)) + new_version=$((patch_version - downgrades[$base_name] - 1)) extension=$(echo "$patch" | sed -E 's/.*patch_[0-9]+//') new_patch="${base_name}.patch_${new_version}${extension}" @@ -427,7 +427,7 @@ function mod_export() { MODS_EXPORT_DIR="$OUT_DIR/Helldivers 2 Mods" mkdir -p "$MODS_EXPORT_DIR" cp "$DB_FILE" "$MODS_EXPORT_DIR" - + for file in $(ls "$MODS_DIR/" 2>/dev/null | grep -E 'patch_.*'); do cp "$MODS_DIR/$file" "$MODS_EXPORT_DIR" done