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
*/
2024-06-22 13:52:59 +00:00
// Don't execute in scheduled environment
if (canSuspend) exitWith {
[FUNC(checkFiles), nil] call CBA_fnc_directCall;
};
2015-05-09 11:25:19 +00:00
///////////////
2024-06-22 13:52:59 +00:00
// Check addons
2015-05-09 11:25:19 +00:00
///////////////
2024-06-22 13:52:59 +00:00
private _cfgPatches = configFile >> "CfgPatches";
private _mainVersion = getText (_cfgPatches >> "ace_main" >> "versionStr");
private _mainSource = configSourceMod (_cfgPatches >> "ace_main");
2015-05-09 11:25:19 +00:00
2024-06-22 13:52:59 +00:00
// CBA Versioning check - close main display if using incompatible version
private _cbaVersionAr = getArray (_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
2024-06-22 13:52:59 +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);
2024-06-22 13:52:59 +00:00
2016-03-02 22:33:29 +00:00
if (hasInterface) then {
2024-06-22 13:52:59 +00:00
["[ACE] ERROR", _errorMsg] call FUNC(errorMessage);
2016-03-02 22:33:29 +00:00
};
};
2024-06-22 13:52:59 +00:00
//private _addons = activatedAddons; // Broken with High-Command module, see #2134
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 = [];
2024-06-22 13:52:59 +00:00
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");
2024-06-22 13:52:59 +00:00
2023-10-23 20:29:32 +00:00
if (_addonVersion != _mainVersion) then {
private _addonSource = configSourceMod _addonCfg;
2024-06-22 13:52:59 +00:00
2023-10-23 20:29:32 +00:00
_oldSources pushBackUnique _addonSource;
2024-06-22 13:52:59 +00:00
// Check ACE install
2023-10-23 20:29:32 +00:00
call FUNC(checkFiles_diagnoseACE);
2015-05-09 11:25:19 +00:00
2024-06-22 13:52:59 +00:00
// Don't block game if it's just an old compat pbo
2017-05-22 18:19:43 +00:00
if ((_x select [0, 10]) != "ace_compat") then {
2024-06-22 13:52:59 +00:00
_oldAddons pushBack _x;
2017-05-22 18:19:43 +00:00
} else {
2024-06-22 13:52:59 +00:00
_oldCompats pushBack [_x, _addonVersion];
2015-05-09 11:25:19 +00:00
};
};
2023-10-23 20:29:32 +00:00
} forEach _addons;
if (_oldAddons isNotEqualTo []) then {
2024-06-22 13:52:59 +00:00
_oldAddons = _oldAddons apply {format ["%1.pbo", _x]};
private _errorMsg = if (count _oldAddons > 3) then {
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 {
2024-06-22 13:52:59 +00:00
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
};
2024-06-22 13:52:59 +00:00
2023-10-23 20:29:32 +00:00
if (hasInterface) then {
2024-06-22 13:52:59 +00:00
["[ACE] ERROR", _errorMsg] call FUNC(errorMessage);
2023-10-23 20:29:32 +00:00
};
2024-06-22 13:52:59 +00:00
2023-10-23 20:29:32 +00:00
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]};
2024-06-22 13:52:59 +00:00
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
///////////////
2024-06-22 13:52:59 +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);
2024-06-22 13:52:59 +00:00
2024-08-17 15:50:38 +00:00
if (_platform in ["linux", "osx"]) then {
2019-09-28 21:03:55 +00:00
// Linux and OSX client ports do not support extensions at all
2024-08-17 15:50:38 +00:00
if (hasInterface) then {
WARNING("Operating system does not support extensions");
} else {
INFO("Operating system does not support extensions");
};
2016-08-19 14:01:59 +00:00
} else {
2024-08-17 15:50:38 +00:00
("ace" callExtension ["version", []]) params [["_versionEx", "", [""]], ["_returnCode", -1, [-1]]];
if (_returnCode != 0 || {_versionEx == ""}) then {
private _errorMsg = format ["Extension not found. [Return Code: %1]", _returnCode];
ERROR(_errorMsg);
if (hasInterface) then {
["[ACE] ERROR", _errorMsg] call FUNC(errorMessage);
2015-05-09 11:25:19 +00:00
};
2024-08-17 15:50:38 +00:00
} else {
_versionEx = _versionEx select [0, 8]; // git hash
INFO_1("Extension [Version: %1]",_versionEx);
};
2016-08-19 14:01:59 +00:00
};
2024-06-22 13:52:59 +00:00
2015-05-09 15:03:51 +00:00
///////////////
2024-06-22 13:52:59 +00:00
// Check server version/addons
2015-05-09 15:03:51 +00:00
///////////////
if (isMultiplayer) then {
2024-06-22 13:52:59 +00:00
// Don't check optional addons
_addons = _addons select {getNumber (_cfgPatches >> _x >> "ACE_isOptional") != 1};
2015-09-17 00:13:21 +00:00
2015-05-09 15:03:51 +00:00
if (isServer) then {
2024-06-22 13:52:59 +00:00
// Send server's version of ACE to all clients
GVAR(serverVersion) = _mainVersion;
GVAR(serverAddons) = _addons;
GVAR(serverSource) = _mainSource;
publicVariable QGVAR(serverVersion);
publicVariable QGVAR(serverAddons);
publicVariable QGVAR(serverSource);
2015-05-09 15:03:51 +00:00
} else {
2024-06-22 13:52:59 +00:00
GVAR(clientVersion) = _version;
GVAR(clientAddons) = _addons;
2015-05-09 15:03:51 +00:00
2024-06-22 13:52:59 +00:00
private _fnc_check = {
if (GVAR(clientVersion) != GVAR(serverVersion)) then {
private _errorMsg = format ["Client/Server Version Mismatch. Server: %1, Client: %2. Server modDir: %3", GVAR(serverVersion), GVAR(clientVersion), GVAR(serverSource)];
2015-05-09 15:03:51 +00:00
2024-06-22 13:52:59 +00:00
// Check ACE install
2023-10-23 20:29:32 +00:00
call FUNC(checkFiles_diagnoseACE);
2024-06-22 13:52:59 +00:00
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 {
2024-06-22 13:52:59 +00:00
["[ACE] ERROR", _errorMsg] call FUNC(errorMessage);
2015-05-09 15:03:51 +00:00
};
};
2024-06-22 13:52:59 +00:00
private _addons = GVAR(clientAddons) - GVAR(serverAddons);
2021-02-27 17:05:05 +00:00
if (_addons isNotEqualTo []) then {
2024-06-22 13:52:59 +00:00
private _errorMsg = format ["Client/Server Addon Mismatch. Client has additional addons: %1. Server modDir: %2", _addons, GVAR(serverSource)];
2015-06-23 13:27:49 +00:00
2024-06-22 13:52:59 +00:00
// Check ACE install
2023-10-23 20:29:32 +00:00
call FUNC(checkFiles_diagnoseACE);
2024-06-22 13:52:59 +00:00
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 {
2024-06-22 13:52:59 +00:00
["[ACE] ERROR", _errorMsg] call FUNC(errorMessage);
2015-06-23 13:27:49 +00:00
};
2015-06-29 13:15:46 +00:00
};
2024-06-22 13:52:59 +00:00
};
2015-06-23 13:27:49 +00:00
2024-06-22 13:52:59 +00:00
// Clients have to wait for the variables
if (isNil QGVAR(serverVersion) || isNil QGVAR(serverAddons)) then {
GVAR(serverVersion) addPublicVariableEventHandler _fnc_check;
} else {
call _fnc_check;
};
2015-05-09 15:03:51 +00:00
};
};