mirror of
https://github.com/factoriotools/factorio-docker.git
synced 2025-07-07 09:44:44 +02:00
Fix mod version compatibility checking for major version differences (#575)
This fixes issue #517 where the auto mod updater was downloading the wrong mod versions after updating to Space Age (Factorio 2.0). The problem was that the version checking logic was incorrectly rejecting compatible mod versions. Changes: - Fixed check_game_version() to properly handle major version differences - Game versions can now run mods designed for older major versions (backward compatibility) - Game versions correctly reject mods requiring newer versions - Fixed variable references in check_dependency_version() - Added clarifying comments about the version checking behavior This also addresses issue #468 by ensuring mods requiring newer Factorio versions than currently installed are properly skipped. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@ -23,24 +23,33 @@ print_failure()
|
|||||||
echo "$1"
|
echo "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Checks game version vs version in mod.
|
# Checks if the current game version satisfies the mod's minimum required version.
|
||||||
# Returns 0 if major version differs or mod minor version is less than game version, 1 if ok
|
# Returns 1 if the game version is compatible with the mod, 0 if not
|
||||||
check_game_version() {
|
check_game_version() {
|
||||||
local game_version="$1"
|
local mod_required_version="$1" # The minimum Factorio version required by the mod
|
||||||
local mod_version="$2"
|
local current_game_version="$2" # The current Factorio version
|
||||||
|
|
||||||
local game_major mod_major game_minor mod_minor
|
local mod_major mod_minor game_major game_minor
|
||||||
game_major=$(echo "$game_version" | cut -d '.' -f1)
|
mod_major=$(echo "$mod_required_version" | cut -d '.' -f1)
|
||||||
game_minor=$(echo "$game_version" | cut -d '.' -f2)
|
mod_minor=$(echo "$mod_required_version" | cut -d '.' -f2)
|
||||||
mod_major=$(echo "$mod_version" | cut -d '.' -f1)
|
game_major=$(echo "$current_game_version" | cut -d '.' -f1)
|
||||||
mod_minor=$(echo "$mod_version" | cut -d '.' -f2)
|
game_minor=$(echo "$current_game_version" | cut -d '.' -f2)
|
||||||
|
|
||||||
if [[ "$game_major" -ne "$mod_major" ]]; then
|
# If game major version is greater than mod's required major version, it's compatible
|
||||||
|
if [[ "$game_major" -gt "$mod_major" ]]; then
|
||||||
|
echo 1
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If game major version is less than mod's required major version, it's not compatible
|
||||||
|
if [[ "$game_major" -lt "$mod_major" ]]; then
|
||||||
echo 0
|
echo 0
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$mod_minor" -ge "$game_minor" ]]; then
|
# Major versions are equal, check minor versions
|
||||||
|
# Game minor version must be >= mod's required minor version
|
||||||
|
if [[ "$game_minor" -ge "$mod_minor" ]]; then
|
||||||
echo 1
|
echo 1
|
||||||
else
|
else
|
||||||
echo 0
|
echo 0
|
||||||
@ -79,7 +88,7 @@ check_dependency_version()
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
">")
|
">")
|
||||||
if [[ "$(printf '%s\n%s\n' "$required_version" "$mod_version" | sort -V | head -n1)" == "$required_version" && "$required_version" != "$FACTORIO_VERSION" ]]; then
|
if [[ "$(printf '%s\n%s\n' "$required_version" "$mod_version" | sort -V | head -n1)" == "$required_version" && "$required_version" != "$mod_version" ]]; then
|
||||||
echo 1
|
echo 1
|
||||||
else
|
else
|
||||||
echo 0
|
echo 0
|
||||||
@ -93,7 +102,7 @@ check_dependency_version()
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"<")
|
"<")
|
||||||
if [[ "$(printf '%s\n%s\n' "$required_version" "$mod_version" | sort -V | tail -n1)" == "$required_version" && "$required_version" != "$FACTORIO_VERSION" ]]; then
|
if [[ "$(printf '%s\n%s\n' "$required_version" "$mod_version" | sort -V | tail -n1)" == "$required_version" && "$required_version" != "$mod_version" ]]; then
|
||||||
echo 1
|
echo 1
|
||||||
else
|
else
|
||||||
echo 0
|
echo 0
|
||||||
@ -116,11 +125,15 @@ get_mod_info()
|
|||||||
{
|
{
|
||||||
local mod_info_json="$1"
|
local mod_info_json="$1"
|
||||||
|
|
||||||
|
# Process mod releases from newest to oldest, looking for a compatible version
|
||||||
while IFS= read -r mod_release_info; do
|
while IFS= read -r mod_release_info; do
|
||||||
local mod_version mod_factorio_version
|
local mod_version mod_factorio_version
|
||||||
mod_version=$(echo "$mod_release_info" | jq -r ".version")
|
mod_version=$(echo "$mod_release_info" | jq -r ".version")
|
||||||
mod_factorio_version=$(echo "$mod_release_info" | jq -r ".info_json.factorio_version")
|
mod_factorio_version=$(echo "$mod_release_info" | jq -r ".info_json.factorio_version")
|
||||||
|
|
||||||
|
# Check if this mod version is compatible with our Factorio version
|
||||||
|
# This prevents downloading mods that require a newer Factorio version (fixes #468)
|
||||||
|
# and ensures backward compatibility (e.g., Factorio 2.0 can use 1.x mods) (fixes #517)
|
||||||
if [[ $(check_game_version "$mod_factorio_version" "$FACTORIO_VERSION") == 0 ]]; then
|
if [[ $(check_game_version "$mod_factorio_version" "$FACTORIO_VERSION") == 0 ]]; then
|
||||||
echo " Skipping mod version $mod_version because of factorio version mismatch" >&2
|
echo " Skipping mod version $mod_version because of factorio version mismatch" >&2
|
||||||
continue
|
continue
|
||||||
|
Reference in New Issue
Block a user