Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common - Fix retrieving the version of an addon when searching for mismatches #10377

Merged
merged 5 commits into from
Oct 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions addons/common/functions/fnc_checkVersionNumber.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "..\script_component.hpp"
/*
* Author: commy2, johnb43
* Author: commy2, johnb43, Timi007
* Compares version numbers from loaded addons.
*
* Arguments:
Expand Down Expand Up @@ -32,8 +32,37 @@ private _cfgPatches = configFile >> "CfgPatches";
private _versions = [];

{
(getText (_cfgPatches >> _x >> "version") splitString ".") params [["_major", "0"], ["_minor", "0"]];
private _version = parseNumber _major + parseNumber _minor / 100;
// Determine the version of the addon. Parse it into a floating point number for comparison. Only major and minor are used.
// If no version is found or a parsing error occurs, the version is zero.
private _addonCfgPatches = _cfgPatches >> _x;
private _versionCfg = _addonCfgPatches >> "version";
private _version = switch (true) do {
// Normal case. Version is defined as a floating point number -> MAJOR.MINOR
case (isNumber _versionCfg): {
getNumber _versionCfg
};
// Addon Builder converts the version into a string if it is an invalid float -> "MAJOR.MINOR.PATCH"
case (isText _versionCfg): {
(getText _versionCfg splitString ".") params [["_major", "0"], ["_minor", "0"]];

parseNumber _major + parseNumber _minor / 100
};
// Fallback 1 (maybe versionAr is defined)
case (isArray (_addonCfgPatches >> "versionAr")): {
(getArray (_addonCfgPatches >> "versionAr")) params [["_major", 0], ["_minor", 0]];

_major + _minor / 100
};
// Fallback 2 (maybe versionStr is defined)
case (isText (_addonCfgPatches >> "versionStr")): {
(getText (_addonCfgPatches >> "versionStr") splitString ".") params [["_major", "0"], ["_minor", "0"]];

parseNumber _major + parseNumber _minor / 100
};
// No version found
default { 0 };
};

_versions pushBack _version;
} forEach _files;

Expand Down