Skip to content

Commit

Permalink
Compatibility with acemod#9568
Browse files Browse the repository at this point in the history
  • Loading branch information
johnb432 committed Oct 23, 2023
2 parents c41f623 + 9d1695f commit 942a72d
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 14 deletions.
1 change: 1 addition & 0 deletions addons/common/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ PREP(canGetInPosition);
PREP(canInteractWith);
PREP(changeProjectileDirection);
PREP(checkFiles);
PREP(checkFiles_diagnoseACE);
PREP(checkPBOs);
PREP(checkVersionNumber);
PREP(claim);
Expand Down
59 changes: 45 additions & 14 deletions addons/common/functions/fnc_checkFiles.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// Check addons
///////////////
private _cfgPatches = configFile >> "CfgPatches";
private _version = getText (_cfgPatches >> "ace_main" >> "versionStr");
private _mainVersion = getText (_cfgPatches >> "ace_main" >> "versionStr");

// CBA Versioning check - close main display if using incompatible version
private _cbaVersionAr = getArray (_cfgPatches >> "cba_main" >> "versionAr");
Expand All @@ -28,7 +28,7 @@ private _cbaRequiredAr = getArray (configFile >> "CfgSettings" >> "CBA" >> "Vers
private _cbaVersionStr = _cbaVersionAr joinString ".";
private _cbaRequiredStr = _cbaRequiredAr joinString ".";

INFO_3("ACE is version %1 - CBA is version %2 (min required %3)",_version,_cbaVersionStr,_cbaRequiredStr);
INFO_3("ACE is version %1 - CBA is version %2 (min required %3)",_mainVersion,_cbaVersionStr,_cbaRequiredStr);

if ([_cbaRequiredAr, _cbaVersionAr] call CBA_versioning_fnc_version_compare) then {
private _errorMsg = format ["CBA version %1 is outdated (required %2)", _cbaVersionStr, _cbaRequiredStr];
Expand All @@ -42,30 +42,57 @@ if ([_cbaRequiredAr, _cbaVersionAr] call CBA_versioning_fnc_version_compare) the
//private _addons = activatedAddons; // Broken with High-Command module, see #2134
private _addons = (CBA_common_addons select {(_x select [0, 4]) == "ace_"}) apply {toLower _x};

private _errorMsg = "";
private _addonCfg = configNull;
private _addonVersion = "";
private _addonSource = "";

private _oldAddons = [];
private _oldSources = [];
private _oldCompats = [];

{
if (getText (_cfgPatches >> _x >> "versionStr") != _version) then {
_errorMsg = format ["File %1.pbo is outdated.", _x];
_addonCfg = configFile >> "CfgPatches" >> _x;
_addonVersion = getText (_addonCfg >> "versionStr");

if (_addonVersion != _mainVersion) then {
_addonSource = configSourceMod _addonCfg;

ERROR(_errorMsg);
_oldSources pushBackUnique _addonSource;

// Check ACE install
call FUNC(checkFiles_diagnoseACE);

if ((_x select [0, 10]) != "ace_compat") then {
if (hasInterface) then {
["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}, {findDisplay 46 closeDisplay 0}, nil, [true, false]] call FUNC(errorMessage);
};
_oldAddons pushBack _x;
} else {
_oldCompats pushBack _x; // Don't block game if it's just an old compat pbo
_oldCompats pushBack [_x, _addonVersion]; // Don't block game if it's just an old compat pbo
};
};
} forEach _addons;

if (_oldAddons isNotEqualTo []) then {
_oldAddons = _oldAddons apply {"%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.<br/>Loaded mods with outdated ACE files: %4", (_oldAddons select [0, 3]) joinString ", ", (count _oldAddons) - 3, _mainVersion, _oldSources joinString ", "];
} else {
format ["The following files are outdated: %1.<br/>ACE Main version is %2.<br/>Loaded mods with outdated ACE files: %3", _oldAddons joinString ", ", _mainVersion, _oldSources joinString ", "];
};

if (hasInterface) then {
["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}, {findDisplay 46 closeDisplay 0}, nil, [true, false]] call FUNC(errorMessage);
};

ERROR(_errorMsg);
};

if (_oldCompats isNotEqualTo []) then {
_oldCompats = _oldCompats apply {format ["%1 (%2, source: %3)", _x select 0, _x select 1]};

[{
// Lasts for ~10 seconds
ERROR_WITH_TITLE_1("The following ACE compatiblity PBOs are outdated", "%1", _this);
}, _oldCompats, 1] call CBA_fnc_waitAndExecute;
ERROR_WITH_TITLE_2("The following ACE compatiblity PBOs are outdated", "%1. ACE Main version is %2",_this select 0,_this select 1);
}, [_oldCompats, _mainVersion], 1] call CBA_fnc_waitAndExecute;
};

///////////////
Expand Down Expand Up @@ -103,7 +130,7 @@ if (!isServer && {_platform in ["linux", "osx"]}) then {
private _platformExt = [".dll", ".so"] select (_platform == "linux");
_extensionFile = format ["%1%2", _extensionFile, _platformExt];

_errorMsg = format ["Extension %1 not found.", _extensionFile];
private _errorMsg = format ["Extension %1 not found.", _extensionFile];
ERROR(_errorMsg);

if (hasInterface) then {
Expand All @@ -130,7 +157,7 @@ if (isMultiplayer) then {

if (isServer) then {
// Send server's version of ACE to all clients
GVAR(ServerVersion) = _version;
GVAR(ServerVersion) = _mainVersion;
GVAR(ServerAddons) = _addons;
publicVariable QGVAR(ServerVersion);
publicVariable QGVAR(ServerAddons);
Expand All @@ -142,6 +169,8 @@ if (isMultiplayer) then {
if (GVAR(ClientVersion) != GVAR(ServerVersion)) then {
private _errorMsg = format ["Client/Server Version Mismatch. Server: %1, Client: %2.", GVAR(ServerVersion), GVAR(ClientVersion)];

// Check ACE install
call FUNC(checkFiles_diagnoseACE);
ERROR(_errorMsg);

if (hasInterface) then {
Expand All @@ -154,6 +183,8 @@ if (isMultiplayer) then {
if (_addons isNotEqualTo []) then {
private _errorMsg = format ["Client/Server Addon Mismatch. Client has extra addons: %1.", _addons];

// Check ACE install
call FUNC(checkFiles_diagnoseACE);
ERROR(_errorMsg);

if (hasInterface) then {
Expand Down
58 changes: 58 additions & 0 deletions addons/common/functions/fnc_checkFiles_diagnoseACE.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include "..\script_component.hpp"
/*
* Author: PabstMirror
* Diagnose ACE install problems, this will only be called if there is a known problem
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* [] call ace_common_fnc_checkFiles_diagnoseACE
*
* Public: No
*/

// Only run once
if (missionNameSpace getVariable [QGVAR(checkFiles_diagnoseACE), false]) exitWith {};
GVAR(checkFiles_diagnoseACE) = true;

private _addons = cba_common_addons select {(_x select [0,4]) == "ace_"};
private _cfgPatches = configFile >> "CfgPatches";
private _allMods = createHashMap;

// Check ACE_ADDONs are in expected mod DIR
{
private _cfg = (_cfgPatches >> _x);
private _actualModDir = configSourceMod _cfg;
private _expectedModDir = getText (_cfg >> "ACE_expectedModDir");
if (_expectedModDir == "") then { _expectedModDir = "@ace" };
private _expectedSteamID = getText (_cfg >> "ACE_expectedSteamID");
if (_expectedSteamID == "") then { _expectedSteamID = "463939057" };

(_allMods getOrDefault [_actualModDir, [], true]) pushBackUnique _expectedSteamID;
if (_actualModDir != _expectedModDir) then {
private _errorMsg = format ["%1 loading from unexpected modDir [%2]",_x,_actualModDir];
systemChat _errorMsg;
WARNING_1("%1",_errorMsg);
};
} forEach _addons;

// Check all ACE ModDirs have expected steam WS ID
{
private _modDir = _x;
if ((count _y) != 1) then { ERROR_2("Unexpected multiple steamIDs %1 - %2",_modDir,_y) };
private _expectedSteamID = _y # 0;
private _index = getLoadedModsInfo findIf {_x#1 == _modDir};
(getLoadedModsInfo param [_index, []]) params [["_modName", "$Error$"], "", "", "", "", "", "", ["_actualID", ""]];

if (_actualID != _expectedSteamID) then {
private _errorMsg = format ["%1 [%2] unexpected workshopID [%3]",_modDir,_modName,_actualID];
systemChat _errorMsg;
WARNING_1("%1",_errorMsg);
};
} forEach _allMods;

_allMods
2 changes: 2 additions & 0 deletions optionals/noactionmenu/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class CfgPatches {
authors[] = {"commy2"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
ACE_expectedModDir = "@ACE No Action Menu";
ACE_expectedSteamID = "2202412030";
};
};

Expand Down
2 changes: 2 additions & 0 deletions optionals/nocrosshair/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class CfgPatches {
authors[] = {"commy2"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
ACE_expectedModDir = "@ACE No Cross Hair";
ACE_expectedSteamID = "2202412481";
};
};

Expand Down
2 changes: 2 additions & 0 deletions optionals/nomedical/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ class CfgPatches {
authors[] = {"Dystopian"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
ACE_expectedModDir = "@ACE No Medical";
ACE_expectedSteamID = "3053169823";
};
};
2 changes: 2 additions & 0 deletions optionals/norealisticnames/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ class CfgPatches {
authors[] = {"Dystopian"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
ACE_expectedModDir = "@ACE No Realistic Names";
ACE_expectedSteamID = "3053177117";
};
};
2 changes: 2 additions & 0 deletions optionals/nouniformrestrictions/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class CfgPatches {
authors[] = {"654wak654", "jonpas"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
ACE_expectedModDir = "@ACE No Uniform Restrictions";
ACE_expectedSteamID = "2202413047";
};
};

Expand Down
2 changes: 2 additions & 0 deletions optionals/particles/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class CfgPatches {
authors[] = {"BaerMitUmlaut"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
ACE_expectedModDir = "@ACE Particles";
ACE_expectedSteamID = "2202413537";
};
};

Expand Down
2 changes: 2 additions & 0 deletions optionals/realisticdispersion/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class CfgPatches {
authors[] = {"Ruthberg"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
ACE_expectedModDir = "@ACE Realistic Dispersion";
ACE_expectedSteamID = "2202414018";
};
};

Expand Down
2 changes: 2 additions & 0 deletions optionals/tracers/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class CfgPatches {
authors[] = {"ACE2 Team"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
ACE_expectedModDir = "@ACE Tracers";
ACE_expectedSteamID = "2202414450";
};
};

Expand Down

0 comments on commit 942a72d

Please sign in to comment.