ACE3/addons/common/functions/fnc_checkFiles.sqf

151 lines
4.9 KiB
Plaintext
Raw Normal View History

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
*
* Example:
* call ace_common_fnc_checkFiles
*
2015-09-18 11:09:40 +00:00
* Public: No
2015-05-09 11:25:19 +00:00
*/
#include "script_component.hpp"
///////////////
// check addons
///////////////
private _version = getText (configFile >> "CfgPatches" >> "ace_main" >> "versionStr");
2015-05-09 11:25:19 +00:00
INFO_1("ACE is version %1.",_version);
2015-05-09 11:25:19 +00:00
//CBA Versioning check - close main display if using incompatible version
private _cbaVersionAr = getArray (configFile >> "CfgPatches" >> "cba_main" >> "versionAr");
private _cbaRequiredAr = getArray (configFile >> "CfgSettings" >> "CBA" >> "Versioning" >> "ACE" >> "dependencies" >> "CBA") select 1;
private _cbaVersionStr = _cbaVersionAr joinString ".";
private _cbaRequiredStr = _cbaRequiredAr joinString ".";
INFO_2("CBA is version %1 (min required %2)",_cbaVersionStr,_cbaRequiredStr);
if ([_cbaRequiredAr, _cbaVersionAr] call cba_versioning_fnc_version_compare) then {
private _errorMsg = format ["CBA version %1 is outdated (required %2)", _cbaVersionStr, _cbaRequiredStr];
ERROR(_errorMsg);
if (hasInterface) then {
["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage);
};
};
//private _addons = activatedAddons; // broken with High-Command module, see #2134
private _addons = "true" configClasses (configFile >> "CfgPatches");//
_addons = _addons apply {toLower configName _x};//
_addons = _addons select {_x find "ace_" == 0};
2015-05-09 11:25:19 +00:00
private _oldCompats = [];
2015-05-09 11:25:19 +00:00
{
if (getText (configFile >> "CfgPatches" >> _x >> "versionStr") != _version) then {
private _errorMsg = format ["File %1.pbo is outdated.", _x];
2015-05-09 11:25:19 +00:00
ERROR(_errorMsg);
2015-05-09 11:25:19 +00:00
if ((_x select [0, 10]) != "ace_compat") then {
if (hasInterface) then {
["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage);
};
} else {
_oldCompats pushBack _x; // Don't block game if it's just an old compat pbo
2015-05-09 11:25:19 +00:00
};
};
2015-09-18 11:09:40 +00:00
false
} count _addons;
if (!(_oldCompats isEqualTo [])) then {
[{
// Lasts for ~10 seconds
ERROR_WITH_TITLE_1("The following ACE compatiblity PBOs are outdated", "%1", _this);
}, _oldCompats, 1] call CBA_fnc_waitAndExecute;
};
2015-05-09 11:25:19 +00:00
///////////////
// check dlls
///////////////
if (toLower (productVersion select 6) in ["linux", "osx"]) then {
INFO_2("Operating system does not support DLL file format");
} else {
{
private _versionEx = _x callExtension "version";
2015-09-18 11:09:40 +00:00
if (_versionEx == "") then {
2017-12-20 21:41:06 +00:00
private _extension = ".dll";
if (productVersion select 7 == "x64") then {
_extension = "_x64.dll";
};
if (productVersion select 6 == "Linux") then {
_extension = ".so";
};
private _errorMsg = format ["Extension %1%2 not found.", _x, _extension];
2015-05-09 11:25:19 +00:00
ERROR(_errorMsg);
2015-05-09 11:25:19 +00:00
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",_x,_versionEx);
2015-05-09 11:25:19 +00:00
};
false
} count getArray (configFile >> "ACE_Extensions" >> "extensions");
};
///////////////
// check server version/addons
///////////////
if (isMultiplayer) then {
2015-09-17 00:13:21 +00:00
// don't check optional addons
_addons = _addons select {getNumber (configFile >> "CfgPatches" >> _x >> "ACE_isOptional") != 1};
2015-09-17 00:13:21 +00:00
if (isServer) then {
// send servers version of ACE to all clients
GVAR(ServerVersion) = _version;
GVAR(ServerAddons) = _addons;
publicVariable QGVAR(ServerVersion);
publicVariable QGVAR(ServerAddons);
} else {
// clients have to wait for the variables
[{
if (isNil QGVAR(ServerVersion) || isNil QGVAR(ServerAddons)) exitWith {};
2015-09-18 11:09:40 +00:00
(_this select 0) params ["_version", "_addons"];
if (_version != GVAR(ServerVersion)) then {
private _errorMsg = format ["Client/Server Version Mismatch. Server: %1, Client: %2.", GVAR(ServerVersion), _version];
ERROR(_errorMsg);
if (hasInterface) then {
["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage);
};
};
2015-06-29 13:15:46 +00:00
_addons = _addons - GVAR(ServerAddons);
if !(_addons isEqualTo []) then {
private _errorMsg = format ["Client/Server Addon Mismatch. Client has extra addons: %1.",_addons];
ERROR(_errorMsg);
if (hasInterface) then {
2015-06-29 13:15:46 +00:00
["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage);
};
2015-06-29 13:15:46 +00:00
};
[_this select 1] call CBA_fnc_removePerFrameHandler;
}, 1, [_version,_addons]] call CBA_fnc_addPerFrameHandler;
};
};