2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
/*
|
2024-06-22 13:52:59 +00:00
|
|
|
* Author: commy2, johnb43
|
2015-01-11 16:42:31 +00:00
|
|
|
* Used to execute the checkPBOs module without placing the module. Don't use this together with the module.
|
2015-05-28 18:49:30 +00:00
|
|
|
* Checks PBO versions and compares to the one running on server.
|
2015-01-11 16:42:31 +00:00
|
|
|
*
|
2015-05-28 18:49:30 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: Mode <NUMBER>
|
2015-09-18 11:09:40 +00:00
|
|
|
* 0 = Warn once
|
|
|
|
* 1 = Warn permanently
|
|
|
|
* 2 = Kick
|
2024-06-22 13:52:59 +00:00
|
|
|
* 1: Check all PBOs? <BOOL> (default: false)
|
|
|
|
* 2: Whitelist <STRING> (default: "")
|
2015-01-11 16:42:31 +00:00
|
|
|
*
|
2015-09-18 11:09:40 +00:00
|
|
|
* Return Value:
|
2015-05-28 18:49:30 +00:00
|
|
|
* None
|
2015-09-18 11:09:40 +00:00
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [0, false, ""] call ace_common_fnc_checkPBOs
|
|
|
|
*
|
2015-09-18 11:09:40 +00:00
|
|
|
* Public: Yes
|
2015-01-11 16:42:31 +00:00
|
|
|
*/
|
|
|
|
|
2015-12-03 05:58:41 +00:00
|
|
|
params ["_mode", ["_checkAll", false], ["_whitelist", "", [""]]];
|
|
|
|
TRACE_3("params",_mode,_checkAll,_whitelist);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2024-06-22 13:52:59 +00:00
|
|
|
// Lowercase and convert whiteList string into array of strings
|
2024-03-07 21:08:13 +00:00
|
|
|
_whitelist = toLowerANSI _whitelist;
|
2015-12-03 05:58:41 +00:00
|
|
|
_whitelist = _whitelist splitString "[,""']";
|
|
|
|
TRACE_1("Array",_whitelist);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-05-28 18:49:30 +00:00
|
|
|
ACE_Version_CheckAll = _checkAll;
|
|
|
|
ACE_Version_Whitelist = _whitelist;
|
|
|
|
|
2024-06-22 13:52:59 +00:00
|
|
|
// ACE is checked by FUNC(checkFiles)
|
|
|
|
if (!_checkAll) exitWith {};
|
2015-08-13 05:31:29 +00:00
|
|
|
|
2015-05-28 18:49:30 +00:00
|
|
|
if (!isServer) then {
|
2024-06-22 13:52:59 +00:00
|
|
|
["ace_versioning_clientCheckDone", {
|
|
|
|
// Don't let this event get triggered again
|
|
|
|
[_thisType, _thisId] call CBA_fnc_removeEventHandler;
|
|
|
|
|
|
|
|
params ["_clientErrors"];
|
|
|
|
_clientErrors params ["_missingAddonClient", "_additionalAddonClient", "_olderVersionClient", "_newerVersionClient"];
|
|
|
|
_thisArgs params ["_mode"];
|
|
|
|
|
|
|
|
// Display error message(s)
|
|
|
|
if (_missingAddonClient || {_additionalAddonClient} || {_olderVersionClient} || {_newerVersionClient}) then {
|
|
|
|
private _errorMsg = "[ACE] Version mismatch:<br/><br/>";
|
|
|
|
private _error = [];
|
|
|
|
|
|
|
|
if (_missingAddonClient) then {
|
|
|
|
_errorMsg = _errorMsg + "Detected missing addon on client<br/>";
|
|
|
|
_error pushBack "Missing file(s)";
|
2015-05-28 18:49:30 +00:00
|
|
|
};
|
2024-06-22 13:52:59 +00:00
|
|
|
|
|
|
|
if (_additionalAddonClient) then {
|
|
|
|
_errorMsg = _errorMsg + "Detected additional addon on client<br/>";
|
|
|
|
_error pushBack "Additional file(s)";
|
2015-05-28 18:49:30 +00:00
|
|
|
};
|
2024-06-22 13:52:59 +00:00
|
|
|
|
|
|
|
if (_olderVersionClient) then {
|
|
|
|
_errorMsg = _errorMsg + "Detected older client version<br/>";
|
|
|
|
_error pushBack "Older version";
|
2015-05-28 18:49:30 +00:00
|
|
|
};
|
2024-06-22 13:52:59 +00:00
|
|
|
|
|
|
|
if (_newerVersionClient) then {
|
|
|
|
_errorMsg = _errorMsg + "Detected newer client version<br/>";
|
|
|
|
_error pushBack "Newer version";
|
2015-05-28 18:49:30 +00:00
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2024-06-22 13:52:59 +00:00
|
|
|
ERROR_2("[ACE] Version mismatch: %1: %2",profileName,_error joinString ", ");
|
2016-05-21 17:59:44 +00:00
|
|
|
|
2024-06-22 13:52:59 +00:00
|
|
|
_errorMsg = parseText format ["<t align='center'>%1</t>", _errorMsg];
|
2015-05-28 18:49:30 +00:00
|
|
|
|
2024-06-22 13:52:59 +00:00
|
|
|
// Warn
|
2015-06-15 18:23:16 +00:00
|
|
|
if (_mode < 2) then {
|
2015-12-12 15:48:54 +00:00
|
|
|
private _rscLayer = "ACE_RscErrorHint" call BIS_fnc_rscLayer;
|
2015-06-15 18:23:16 +00:00
|
|
|
_rscLayer cutRsc ["ACE_RscErrorHint", "PLAIN", 0, true];
|
2015-05-28 18:49:30 +00:00
|
|
|
|
2024-06-22 13:52:59 +00:00
|
|
|
(uiNamespace getVariable "ACE_ctrlErrorHint") ctrlSetStructuredText composeText [lineBreak, _errorMsg];
|
2015-05-28 18:49:30 +00:00
|
|
|
|
2015-06-15 18:23:16 +00:00
|
|
|
if (_mode == 0) then {
|
2015-12-02 04:50:28 +00:00
|
|
|
[{
|
2024-06-22 13:52:59 +00:00
|
|
|
TRACE_2("Hiding Error message after 10 seconds",time,_this);
|
|
|
|
_this cutFadeOut 0.2;
|
|
|
|
}, _rscLayer, 10] call CBA_fnc_waitAndExecute;
|
2015-06-15 18:23:16 +00:00
|
|
|
};
|
2024-06-22 13:52:59 +00:00
|
|
|
} else {
|
|
|
|
// Kick
|
|
|
|
["[ACE] ERROR", composeText [_errorMsg]] call FUNC(errorMessage);
|
2015-05-28 18:49:30 +00:00
|
|
|
};
|
|
|
|
};
|
2024-06-22 13:52:59 +00:00
|
|
|
}, [_mode]] call CBA_fnc_addEventHandlerArgs;
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
2024-06-22 13:52:59 +00:00
|
|
|
// Check file version numbers
|
|
|
|
[_whitelist] call FUNC(checkVersionNumber);
|