2015-01-11 16:42:31 +00:00
|
|
|
// by commy2
|
2015-01-13 21:32:56 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2019-02-14 18:49:56 +00:00
|
|
|
private _aceWhitelist = missionNamespace getVariable ["ACE_Version_Whitelist", []];
|
|
|
|
private _files = CBA_common_addons select {
|
|
|
|
(_x select [0,3] != "a3_") &&
|
2019-03-16 10:00:20 +00:00
|
|
|
{_x select [0,4] != "ace_"} &&
|
2019-02-14 18:49:56 +00:00
|
|
|
{!((toLower _x) in _aceWhitelist)}
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _versions = [];
|
2015-01-11 16:42:31 +00:00
|
|
|
{
|
2019-03-16 10:05:01 +00:00
|
|
|
getText (configFile >> "CfgPatches" >> _x >> "version") splitString "." params [["_major", "0"], ["_minor", "0"]];
|
2019-03-16 10:00:20 +00:00
|
|
|
private _version = parseNumber _major + parseNumber _minor/100;
|
2015-05-09 14:01:53 +00:00
|
|
|
_versions set [_forEachIndex, _version];
|
2015-01-11 16:42:31 +00:00
|
|
|
} forEach _files;
|
|
|
|
|
|
|
|
if (isServer) then {
|
2015-05-09 14:01:53 +00:00
|
|
|
ACE_Version_ServerVersions = [_files, _versions];
|
|
|
|
publicVariable "ACE_Version_ServerVersions";
|
2015-01-11 16:42:31 +00:00
|
|
|
} else {
|
2015-05-09 14:01:53 +00:00
|
|
|
ACE_Version_ClientVersions = [_files, _versions];
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Begin client version check
|
|
|
|
if (!isServer) then {
|
2015-05-09 14:01:53 +00:00
|
|
|
// Wait for server to send the servers files and version numbers
|
|
|
|
waitUntil {
|
|
|
|
sleep 1;
|
|
|
|
!isNil "ACE_Version_ClientVersions" && {!isNil "ACE_Version_ServerVersions"}
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _client = profileName;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-05-09 14:01:53 +00:00
|
|
|
_files = ACE_Version_ClientVersions select 0;
|
|
|
|
_versions = ACE_Version_ClientVersions select 1;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _serverFiles = ACE_Version_ServerVersions select 0;
|
|
|
|
private _serverVersions = ACE_Version_ServerVersions select 1;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-05-09 14:01:53 +00:00
|
|
|
// Compare client and server files and versions
|
2017-10-10 14:39:59 +00:00
|
|
|
private _missingAddons = [];
|
|
|
|
private _oldVersionsClient = [];
|
|
|
|
private _oldVersionsServer = [];
|
2015-05-09 14:01:53 +00:00
|
|
|
{
|
2017-10-10 14:39:59 +00:00
|
|
|
private _serverVersion = _serverVersions select _forEachIndex;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _index = _files find _x;
|
2015-05-09 14:01:53 +00:00
|
|
|
if (_index == -1) then {
|
2015-05-11 16:02:13 +00:00
|
|
|
if (_x != "ace_server") then {_missingAddons pushBack _x;};
|
2015-05-09 14:01:53 +00:00
|
|
|
} else {
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _clientVersion = _versions select _index;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-05-09 14:01:53 +00:00
|
|
|
if (_clientVersion < _serverVersion) then {
|
|
|
|
_oldVersionsClient pushBack [_x, _clientVersion, _serverVersion];
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-05-09 14:01:53 +00:00
|
|
|
if (_clientVersion > _serverVersion) then {
|
|
|
|
_oldVersionsServer pushBack [_x, _clientVersion, _serverVersion];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} forEach _serverFiles;
|
|
|
|
|
|
|
|
// find client files which the server doesn't have
|
2017-10-10 14:39:59 +00:00
|
|
|
private _missingAddonsServer = [];
|
2015-01-11 16:42:31 +00:00
|
|
|
{
|
2017-10-10 14:39:59 +00:00
|
|
|
private _index = _serverFiles find _x;
|
2015-05-09 14:01:53 +00:00
|
|
|
if (_index == -1) then {
|
|
|
|
_missingAddonsServer pushBack _x;
|
|
|
|
}
|
|
|
|
} forEach _files;
|
|
|
|
|
|
|
|
// display and log error messages
|
2017-05-14 19:48:05 +00:00
|
|
|
private _fnc_cutComma = {
|
2017-10-10 14:39:59 +00:00
|
|
|
private _string = _this;
|
2015-05-09 14:01:53 +00:00
|
|
|
_string = toArray _string;
|
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _count = count _string;
|
2015-05-09 14:01:53 +00:00
|
|
|
_string set [_count - 2, toArray "." select 0];
|
|
|
|
_string set [_count - 1, -1];
|
|
|
|
_string = _string - [-1];
|
|
|
|
|
|
|
|
toString _string;
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _missingAddon = false;
|
2015-05-09 14:01:53 +00:00
|
|
|
if (count _missingAddons > 0) then {
|
|
|
|
_missingAddon = true;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2018-12-30 04:11:19 +00:00
|
|
|
private _error = format ["[ACE] %1: ERROR client missing addon(s): ", _client];
|
2015-05-09 14:01:53 +00:00
|
|
|
{
|
|
|
|
_error = _error + format ["%1, ", _x];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2018-12-30 04:11:19 +00:00
|
|
|
if (_forEachIndex > 9) exitWith {};
|
2015-05-09 14:01:53 +00:00
|
|
|
} forEach _missingAddons;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-05-09 14:01:53 +00:00
|
|
|
_error = _error call _fnc_cutComma;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-05-09 14:01:53 +00:00
|
|
|
diag_log text _error;
|
2016-06-03 01:13:09 +00:00
|
|
|
[QGVAR(systemChatGlobal), _error] call CBA_fnc_globalEvent;
|
2019-10-05 00:56:25 +00:00
|
|
|
[QGVAR(serverLog), _error] call CBA_fnc_serverEvent;
|
2015-05-09 14:01:53 +00:00
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _missingAddonServer = false;
|
2015-05-09 14:01:53 +00:00
|
|
|
if (count _missingAddonsServer > 0) then {
|
|
|
|
_missingAddonServer = true;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2018-12-30 04:11:19 +00:00
|
|
|
private _error = format ["[ACE] %1: ERROR server missing addon(s): ", _client];
|
2015-05-09 14:01:53 +00:00
|
|
|
{
|
|
|
|
_error = _error + format ["%1, ", _x];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2018-12-30 04:11:19 +00:00
|
|
|
if (_forEachIndex > 9) exitWith {};
|
2015-05-09 14:01:53 +00:00
|
|
|
} forEach _missingAddonsServer;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-05-09 14:01:53 +00:00
|
|
|
_error = _error call _fnc_cutComma;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-05-09 14:01:53 +00:00
|
|
|
diag_log text _error;
|
2016-06-03 01:13:09 +00:00
|
|
|
[QGVAR(systemChatGlobal), _error] call CBA_fnc_globalEvent;
|
2019-10-05 00:56:25 +00:00
|
|
|
[QGVAR(serverLog), _error] call CBA_fnc_serverEvent;
|
2015-05-09 14:01:53 +00:00
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _oldVersionClient = false;
|
2015-05-09 14:01:53 +00:00
|
|
|
if (count _oldVersionsClient > 0) then {
|
|
|
|
_oldVersionClient = true;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2018-12-30 04:11:19 +00:00
|
|
|
private _error = format ["[ACE] %1: ERROR outdated client addon(s): ", _client];
|
2015-05-09 14:01:53 +00:00
|
|
|
{
|
|
|
|
_error = _error + format ["%1 (client: %2, server: %3), ", _x select 0, _x select 1, _x select 2];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2018-12-30 04:11:19 +00:00
|
|
|
if (_forEachIndex > 9) exitWith {};
|
2015-05-09 14:01:53 +00:00
|
|
|
} forEach _oldVersionsClient;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-05-09 14:01:53 +00:00
|
|
|
_error = _error call _fnc_cutComma;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-05-09 14:01:53 +00:00
|
|
|
diag_log text _error;
|
2016-06-03 01:13:09 +00:00
|
|
|
[QGVAR(systemChatGlobal), _error] call CBA_fnc_globalEvent;
|
2019-10-05 00:56:25 +00:00
|
|
|
[QGVAR(serverLog), _error] call CBA_fnc_serverEvent;
|
2015-05-09 14:01:53 +00:00
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _oldVersionServer = false;
|
2015-05-09 14:01:53 +00:00
|
|
|
if (count _oldVersionsServer > 0) then {
|
|
|
|
_oldVersionServer = true;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _error = format ["[ACE] %1: ERROR outdated server addon(s): ", _client];
|
2015-05-09 14:01:53 +00:00
|
|
|
{
|
|
|
|
_error = _error + format ["%1 (client: %2, server: %3), ", _x select 0, _x select 1, _x select 2];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2018-12-30 04:11:19 +00:00
|
|
|
if (_forEachIndex > 9) exitWith {};
|
2015-05-09 14:01:53 +00:00
|
|
|
} forEach _oldVersionsServer;
|
|
|
|
|
|
|
|
_error = _error call _fnc_cutComma;
|
|
|
|
|
|
|
|
diag_log text _error;
|
2016-06-03 01:13:09 +00:00
|
|
|
[QGVAR(systemChatGlobal), _error] call CBA_fnc_globalEvent;
|
2019-10-05 00:56:25 +00:00
|
|
|
[QGVAR(serverLog), _error] call CBA_fnc_serverEvent;
|
2015-05-09 14:01:53 +00:00
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-05-09 14:01:53 +00:00
|
|
|
ACE_Version_ClientErrors = [_missingAddon, _missingAddonServer, _oldVersionClient, _oldVersionServer];
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|