2023-09-12 18:58:10 +00:00
#include "..\script_component.hpp"
2015-05-09 11:25:19 +00:00
/*
* Author: commy2
* Compares version numbers of PBOs and DLLs.
*
2015-09-18 11:09:40 +00:00
* Arguments:
* None
*
* Return Value:
* None
2015-05-09 11:25:19 +00:00
*
2017-06-08 13:31:51 +00:00
* Example:
* call ace_common_fnc_checkFiles
*
2015-09-18 11:09:40 +00:00
* Public: No
2015-05-09 11:25:19 +00:00
*/
///////////////
// check addons
///////////////
2023-10-23 21:09:09 +00:00
private _mainCfg = configFile >> "CfgPatches" >> "ace_main";
private _mainVersion = getText (_mainCfg >> "versionStr");
private _mainSource = configSourceMod _mainCfg;
2015-05-09 11:25:19 +00:00
2016-03-02 22:33:29 +00:00
//CBA Versioning check - close main display if using incompatible version
private _cbaVersionAr = getArray (configFile >> "CfgPatches" >> "cba_main" >> "versionAr");
2016-10-05 18:06:21 +00:00
private _cbaRequiredAr = getArray (configFile >> "CfgSettings" >> "CBA" >> "Versioning" >> "ACE" >> "dependencies" >> "CBA") select 1;
private _cbaVersionStr = _cbaVersionAr joinString ".";
private _cbaRequiredStr = _cbaRequiredAr joinString ".";
2023-10-23 20:29:32 +00:00
INFO_3("ACE is version %1 - CBA is version %2 (min required %3)",_mainVersion,_cbaVersionStr,_cbaRequiredStr);
2016-10-05 18:06:21 +00:00
2016-03-02 22:33:29 +00:00
if ([_cbaRequiredAr, _cbaVersionAr] call cba_versioning_fnc_version_compare) then {
2016-10-05 18:06:21 +00:00
private _errorMsg = format ["CBA version %1 is outdated (required %2)", _cbaVersionStr, _cbaRequiredStr];
2016-10-02 10:55:31 +00:00
ERROR(_errorMsg);
2016-03-02 22:33:29 +00:00
if (hasInterface) then {
["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage);
};
};
2015-12-12 15:48:54 +00:00
//private _addons = activatedAddons; // broken with High-Command module, see #2134
2024-03-07 21:08:13 +00:00
private _addons = (cba_common_addons select {(_x select [0,4]) == "ace_"}) apply {toLowerANSI _x};
2023-10-23 20:29:32 +00:00
private _oldAddons = [];
private _oldSources = [];
2017-05-22 18:19:43 +00:00
private _oldCompats = [];
2015-05-09 11:25:19 +00:00
{
2023-10-23 20:29:32 +00:00
private _addonCfg = configFile >> "CfgPatches" >> _x;
private _addonVersion = getText (_addonCfg >> "versionStr");
if (_addonVersion != _mainVersion) then {
private _addonSource = configSourceMod _addonCfg;
_oldSources pushBackUnique _addonSource;
call FUNC(checkFiles_diagnoseACE);
2015-05-09 11:25:19 +00:00
2017-05-22 18:19:43 +00:00
if ((_x select [0, 10]) != "ace_compat") then {
if (hasInterface) then {
2023-10-23 20:29:32 +00:00
_oldAddons pushBack _x;
2017-05-22 18:19:43 +00:00
};
} else {
2023-10-23 20:29:32 +00:00
_oldCompats pushBack [_x, _addonVersion]; // Don't block game if it's just an old compat pbo
2015-05-09 11:25:19 +00:00
};
};
2023-10-23 20:29:32 +00:00
} forEach _addons;
if (_oldAddons isNotEqualTo []) then {
2023-12-07 03:20:47 +00:00
_oldAddons = _oldAddons apply { format ["%1.pbo", _x] };
2023-10-23 20:29:32 +00:00
private _errorMsg = "";
if (count _oldAddons > 3) then {
2023-10-23 21:09:09 +00:00
_errorMsg = format ["The following files are outdated: %1, and %2 more.<br/>ACE Main version is %3 from %4.<br/>Loaded mods with outdated ACE files: %5", (_oldAddons select [0, 3]) joinString ", ", (count _oldAddons) -3, _mainVersion, _mainSource, (_oldSources joinString ", ")];
2023-10-23 20:29:32 +00:00
} else {
2023-10-23 21:09:09 +00:00
_errorMsg = format ["The following files are outdated: %1.<br/>ACE Main version is %2 from %3.<br/>Loaded mods with outdated ACE files: %4", (_oldAddons) joinString ", ", _mainVersion, _mainSource, (_oldSources) joinString ", "];
2023-10-23 20:29:32 +00:00
};
if (hasInterface) then {
["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage);
};
ERROR(_errorMsg);
};
2021-02-27 17:05:05 +00:00
if (_oldCompats isNotEqualTo []) then {
2023-10-23 21:09:09 +00:00
_oldCompats = _oldCompats apply {format ["%1 (%2)", _x select 0, _x select 1]};
2017-05-22 18:19:43 +00:00
[{
// Lasts for ~10 seconds
2024-02-05 17:04:24 +00:00
ERROR_WITH_TITLE_3("The following ACE compatiblity PBOs are outdated","%1. ACE Main version is %2 from %3.",_this select 0,_this select 1,_this select 2);
2023-10-23 21:09:09 +00:00
}, [_oldCompats, _mainVersion, _mainSource], 1] call CBA_fnc_waitAndExecute;
2017-05-22 18:19:43 +00:00
};
2015-05-09 11:25:19 +00:00
///////////////
2019-09-28 21:03:55 +00:00
// check extensions
2015-05-09 11:25:19 +00:00
///////////////
2024-03-07 21:08:13 +00:00
private _platform = toLowerANSI (productVersion select 6);
2019-09-28 21:03:55 +00:00
if (!isServer && {_platform in ["linux", "osx"]}) then {
// Linux and OSX client ports do not support extensions at all
INFO("Operating system does not support extensions");
2016-08-19 14:01:59 +00:00
} else {
{
2019-09-28 21:03:55 +00:00
private _extension = configName _x;
private _isWindows = _platform == "windows" && {getNumber (_x >> "windows") == 1};
private _isLinux = _platform == "linux" && {getNumber (_x >> "linux") == 1};
private _isClient = hasInterface && {getNumber (_x >> "client") == 1};
private _isServer = !hasInterface && {getNumber (_x >> "server") == 1};
if ((_isWindows || _isLinux) && {_isClient || _isServer}) then {
private _versionEx = _extension callExtension "version";
if (_versionEx == "") then {
private _extensionFile = _extension;
if (productVersion select 7 == "x64") then {
_extensionFile = format ["%1_x64", _extensionFile];
};
private _platformExt = [".dll", ".so"] select (_platform == "linux");
_extensionFile = format ["%1%2", _extensionFile, _platformExt];
private _errorMsg = format ["Extension %1 not found.", _extensionFile];
ERROR(_errorMsg);
if (hasInterface) then {
["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage);
};
} else {
// Print the current extension version
INFO_2("Extension version: %1: %2",_extension,_versionEx);
2017-12-20 21:41:06 +00:00
};
2015-05-09 11:25:19 +00:00
};
2019-09-28 21:03:55 +00:00
} forEach ("true" configClasses (configFile >> "ACE_Extensions"));
2016-08-19 14:01:59 +00:00
};
2019-12-17 16:14:45 +00:00
if (isArray (configFile >> "ACE_Extensions" >> "extensions")) then {
WARNING("extensions[] array no longer supported");
};
2015-05-09 15:03:51 +00:00
///////////////
2015-06-23 13:27:49 +00:00
// check server version/addons
2015-05-09 15:03:51 +00:00
///////////////
if (isMultiplayer) then {
2015-09-17 00:13:21 +00:00
// don't check optional addons
2016-02-06 10:42:35 +00:00
_addons = _addons select {getNumber (configFile >> "CfgPatches" >> _x >> "ACE_isOptional") != 1};
2015-09-17 00:13:21 +00:00
2015-05-09 15:03:51 +00:00
if (isServer) then {
// send servers version of ACE to all clients
2023-10-23 20:29:32 +00:00
GVAR(ServerVersion) = _mainVersion;
2015-06-23 13:27:49 +00:00
GVAR(ServerAddons) = _addons;
2015-05-09 15:03:51 +00:00
publicVariable QGVAR(ServerVersion);
2015-06-23 13:27:49 +00:00
publicVariable QGVAR(ServerAddons);
2015-05-09 15:03:51 +00:00
} else {
2015-06-23 13:27:49 +00:00
// clients have to wait for the variables
2015-05-09 15:03:51 +00:00
[{
2015-06-23 13:27:49 +00:00
if (isNil QGVAR(ServerVersion) || isNil QGVAR(ServerAddons)) exitWith {};
2015-05-09 15:03:51 +00:00
2023-10-23 20:29:32 +00:00
(_this select 0) params ["_mainVersion", "_addons"];
2015-05-09 15:03:51 +00:00
2023-10-23 20:29:32 +00:00
if (_mainVersion != GVAR(ServerVersion)) then {
private _errorMsg = format ["Client/Server Version Mismatch. Server: %1, Client: %2.", GVAR(ServerVersion), _mainVersion];
2015-05-09 15:03:51 +00:00
2023-10-23 20:29:32 +00:00
call FUNC(checkFiles_diagnoseACE);
2016-10-02 10:55:31 +00:00
ERROR(_errorMsg);
2015-05-09 15:03:51 +00:00
2015-08-26 13:20:11 +00:00
if (hasInterface) then {
2015-05-09 15:03:51 +00:00
["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage);
};
};
2015-06-29 13:15:46 +00:00
_addons = _addons - GVAR(ServerAddons);
2021-02-27 17:05:05 +00:00
if (_addons isNotEqualTo []) then {
2017-05-14 19:48:05 +00:00
private _errorMsg = format ["Client/Server Addon Mismatch. Client has extra addons: %1.",_addons];
2015-06-23 13:27:49 +00:00
2023-10-23 20:29:32 +00:00
call FUNC(checkFiles_diagnoseACE);
2016-10-02 10:55:31 +00:00
ERROR(_errorMsg);
2015-06-23 13:27:49 +00:00
2015-08-26 13:20:11 +00:00
if (hasInterface) then {
2015-06-29 13:15:46 +00:00
["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage);
2015-06-23 13:27:49 +00:00
};
2015-06-29 13:15:46 +00:00
};
2015-06-23 13:27:49 +00:00
2015-05-09 15:03:51 +00:00
[_this select 1] call CBA_fnc_removePerFrameHandler;
2023-10-23 20:29:32 +00:00
}, 1, [_mainVersion,_addons]] call CBA_fnc_addPerFrameHandler;
2015-05-09 15:03:51 +00:00
};
};