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
|
|
|
|
|
|
|
sleep 1; //wait for module
|
|
|
|
|
|
|
|
_files = [];
|
|
|
|
|
2015-01-12 04:02:33 +00:00
|
|
|
if (missionNamespace getVariable ["ACE_Version_CheckAll", false]) then {
|
2015-01-11 16:42:31 +00:00
|
|
|
{
|
2015-01-12 04:02:33 +00:00
|
|
|
if (toLower _x find "a3_" != 0 && {!(toLower _x in (missionNamespace getVariable ["ACE_Version_Whitelist", []]))}) then {
|
2015-01-11 16:42:31 +00:00
|
|
|
_files pushBack _x;
|
|
|
|
};
|
|
|
|
} forEach activatedAddons;
|
|
|
|
} else {
|
|
|
|
{
|
2015-01-15 17:41:22 +00:00
|
|
|
if (toLower _x find "ace_" == 0) then {
|
2015-01-11 16:42:31 +00:00
|
|
|
_files pushBack _x;
|
|
|
|
};
|
|
|
|
} forEach activatedAddons;
|
|
|
|
};
|
|
|
|
|
2015-01-13 21:32:56 +00:00
|
|
|
_versionMain = parseNumber getText (configFile >> "CfgPatches" >> QUOTE(ADDON) >> "version");
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
_versions = [];
|
|
|
|
{
|
|
|
|
_version = parseNumber getText (configFile >> "CfgPatches" >> _x >> "version");
|
|
|
|
_versions set [_forEachIndex, _version];
|
|
|
|
} forEach _files;
|
|
|
|
|
2015-04-07 22:27:00 +00:00
|
|
|
_versionFull = getText (configFile >> "CfgPatches" >> QUOTE(ADDON) >> "versionStr");
|
|
|
|
diag_log text format ["[ACE] Full Version Number: %1", _versionFull];
|
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
if (isServer) then {
|
2015-01-12 18:22:58 +00:00
|
|
|
diag_log text format ["[ACE] Server: ACE_Common is Version %1.", _versionMain];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
{
|
2015-01-15 17:41:22 +00:00
|
|
|
if (toLower _x find "ace_" == 0) then {//
|
2015-01-11 16:42:31 +00:00
|
|
|
_version = _versions select _forEachIndex;
|
|
|
|
if (_version != _versionMain) then {
|
2015-01-12 04:02:33 +00:00
|
|
|
diag_log text format ["[ACE] Server: %1 is Version %2.", _x, _version];
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
} forEach _files;
|
|
|
|
|
2015-01-12 04:02:33 +00:00
|
|
|
ACE_Version_ServerVersions = [_files, _versions];
|
|
|
|
publicVariable "ACE_Version_ServerVersions";
|
2015-01-11 16:42:31 +00:00
|
|
|
} else {
|
2015-01-12 18:22:58 +00:00
|
|
|
diag_log text format ["[ACE] Client: ACE_Common is Version %1.", _versionMain];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
{
|
2015-01-15 17:41:22 +00:00
|
|
|
if (toLower _x find "ace_" == 0) then {//
|
2015-01-11 16:42:31 +00:00
|
|
|
_version = _versions select _forEachIndex;
|
|
|
|
if (_version != _versionMain) then {
|
2015-01-12 04:02:33 +00:00
|
|
|
diag_log text format ["[ACE] Client: %1 is Version %2.", _x, _version];
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
} forEach _files;
|
|
|
|
|
2015-01-12 04:02:33 +00:00
|
|
|
ACE_Version_ClientVersions = [_files, _versions];
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Begin client version check
|
|
|
|
if (!isServer) then {
|
|
|
|
// Wait for server to send the servers files and version numbers
|
|
|
|
waitUntil {
|
|
|
|
sleep 1;
|
2015-01-12 04:02:33 +00:00
|
|
|
!isNil "ACE_Version_ClientVersions" && {!isNil "ACE_Version_ServerVersions"}
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_client = profileName;
|
|
|
|
|
2015-01-12 04:02:33 +00:00
|
|
|
_files = ACE_Version_ClientVersions select 0;
|
|
|
|
_versions = ACE_Version_ClientVersions select 1;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-01-12 04:02:33 +00:00
|
|
|
_serverFiles = ACE_Version_ServerVersions select 0;
|
|
|
|
_serverVersions = ACE_Version_ServerVersions select 1;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
// Compare client and server files and versions
|
|
|
|
_missingAddons = [];
|
|
|
|
_oldVersionsClient = [];
|
|
|
|
_oldVersionsServer = [];
|
|
|
|
{
|
|
|
|
_serverVersion = _serverVersions select _forEachIndex;
|
|
|
|
|
|
|
|
_index = _files find _x;
|
|
|
|
if (_index == -1) then {
|
2015-04-07 22:14:27 +00:00
|
|
|
if (_x != "ace_serverconfig") then {_missingAddons pushBack _x;};
|
2015-01-11 16:42:31 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
_clientVersion = _versions select _index;
|
|
|
|
|
|
|
|
if (_clientVersion < _serverVersion) then {
|
|
|
|
_oldVersionsClient pushBack [_x, _clientVersion, _serverVersion];
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_clientVersion > _serverVersion) then {
|
|
|
|
_oldVersionsServer pushBack [_x, _clientVersion, _serverVersion];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} forEach _serverFiles;
|
|
|
|
|
|
|
|
// find client files which the server doesn't have
|
|
|
|
_missingAddonsServer = [];
|
|
|
|
{
|
|
|
|
_index = _serverFiles find _x;
|
|
|
|
if (_index == -1) then {
|
|
|
|
_missingAddonsServer pushBack _x;
|
|
|
|
}
|
|
|
|
} forEach _files;
|
|
|
|
|
|
|
|
// display and log error messages
|
|
|
|
_fnc_cutComma = {
|
|
|
|
_string = _this;
|
|
|
|
_string = toArray _string;
|
|
|
|
|
|
|
|
_count = count _string;
|
|
|
|
_string set [_count - 2, toArray "." select 0];
|
|
|
|
_string set [_count - 1, -1];
|
|
|
|
_string = _string - [-1];
|
|
|
|
|
|
|
|
toString _string;
|
|
|
|
};
|
|
|
|
|
|
|
|
_missingAddon = false;
|
|
|
|
if (count _missingAddons > 0) then {
|
|
|
|
_missingAddon = true;
|
|
|
|
|
2015-01-12 04:02:33 +00:00
|
|
|
_error = format ["[ACE] %1: ERROR missing addon(s): ", _client];
|
2015-01-11 16:42:31 +00:00
|
|
|
{
|
|
|
|
_error = _error + format ["%1, ", _x];
|
|
|
|
|
|
|
|
if (_forEachIndex > 9) exitWith {};//
|
|
|
|
} forEach _missingAddons;
|
|
|
|
|
|
|
|
_error = _error call _fnc_cutComma;
|
|
|
|
|
|
|
|
diag_log text _error;
|
2015-01-11 18:20:14 +00:00
|
|
|
[_error, "{systemChat _this}"] call FUNC(execRemoteFnc);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_missingAddonServer = false;
|
|
|
|
if (count _missingAddonsServer > 0) then {
|
|
|
|
_missingAddonServer = true;
|
|
|
|
|
2015-01-12 04:02:33 +00:00
|
|
|
_error = format ["[ACE] %1: ERROR missing server addon(s): ", _client];
|
2015-01-11 16:42:31 +00:00
|
|
|
{
|
|
|
|
_error = _error + format ["%1, ", _x];
|
|
|
|
|
|
|
|
if (_forEachIndex > 9) exitWith {};//
|
|
|
|
} forEach _missingAddonsServer;
|
|
|
|
|
|
|
|
_error = _error call _fnc_cutComma;
|
|
|
|
|
|
|
|
diag_log text _error;
|
2015-01-11 18:20:14 +00:00
|
|
|
[_error, "{systemChat _this}"] call FUNC(execRemoteFnc);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_oldVersionClient = false;
|
|
|
|
if (count _oldVersionsClient > 0) then {
|
|
|
|
_oldVersionClient = true;
|
|
|
|
|
2015-01-12 04:02:33 +00:00
|
|
|
_error = format ["[ACE] %1: ERROR outdated addon(s): ", _client];
|
2015-01-11 16:42:31 +00:00
|
|
|
{
|
|
|
|
_error = _error + format ["%1 (client: %2, server: %3), ", _x select 0, _x select 1, _x select 2];
|
|
|
|
|
|
|
|
if (_forEachIndex > 9) exitWith {};//
|
|
|
|
} forEach _oldVersionsClient;
|
|
|
|
|
|
|
|
_error = _error call _fnc_cutComma;
|
|
|
|
|
|
|
|
diag_log text _error;
|
2015-01-11 18:20:14 +00:00
|
|
|
[_error, "{systemChat _this}"] call FUNC(execRemoteFnc);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_oldVersionServer = false;
|
|
|
|
if (count _oldVersionsServer > 0) then {
|
|
|
|
_oldVersionServer = true;
|
|
|
|
|
2015-01-12 04:02:33 +00:00
|
|
|
_error = format ["[ACE] %1: ERROR outdated server addon(s): ", _client];
|
2015-01-11 16:42:31 +00:00
|
|
|
{
|
|
|
|
_error = _error + format ["%1 (client: %2, server: %3), ", _x select 0, _x select 1, _x select 2];
|
|
|
|
|
|
|
|
if (_forEachIndex > 9) exitWith {};//
|
|
|
|
} forEach _oldVersionsServer;
|
|
|
|
|
|
|
|
_error = _error call _fnc_cutComma;
|
|
|
|
|
|
|
|
diag_log text _error;
|
2015-01-11 18:20:14 +00:00
|
|
|
[_error, "{systemChat _this}"] call FUNC(execRemoteFnc);
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
2015-01-12 04:02:33 +00:00
|
|
|
ACE_Version_ClientErrors = [_missingAddon, _missingAddonServer, _oldVersionClient, _oldVersionServer];
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|