Skip to content

Commit 4368c1a

Browse files
authored
Common - Fix checkfiles if versions are delayed (#11254)
* Common - Fix checkfiles if versions are delayed * fix style
1 parent 2d5b1be commit 4368c1a

File tree

1 file changed

+63
-62
lines changed

1 file changed

+63
-62
lines changed

addons/common/functions/fnc_checkFiles.sqf

Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -186,81 +186,81 @@ if (isMultiplayer) then {
186186
GVAR(clientVersionAr) = _mainVersionAr;
187187
GVAR(clientAddons) = _addons;
188188

189-
private _fnc_diagnose_versionMismatch = {
190-
private _title = "[ACE] ERROR: VERSION MISMATCH";
191-
private _fixMsg = format ["Fix: %1", "Make sure versions of server and client match. You may be using ACE from different Steam Workshop items, or just haven't updated properly."];
192-
193-
// If versions don't match, someone's outdated, if it's not the client, then it's the server
194-
private _clientIsOutdated = [GVAR(serverVersionAr), GVAR(clientVersionAr)] call CBA_versioning_fnc_version_compare;
195-
private _reasonMsg = format ["Reason: %1", ["Reason: Server is outdated (client version is higher than server's).", "Reason: Client is outdated (client version is lower than server's)."] select _clientIsOutdated];
196-
197-
private _infoMsg = format ["Server version is %1, Client version is %2.<br/>Server mod folder is named ""%3"".", GVAR(serverVersion), GVAR(clientVersion), GVAR(serverSource)];
189+
private _fnc_multiplayerCheck = {
190+
private _fnc_diagnose_versionMismatch = {
191+
private _title = "[ACE] ERROR: VERSION MISMATCH";
192+
private _fixMsg = format ["Fix: %1", "Make sure versions of server and client match. You may be using ACE from different Steam Workshop items, or just haven't updated properly."];
198193

199-
[_title, _reasonMsg, _fixMsg, _infoMsg, _infoMsg] // return
200-
};
194+
// If versions don't match, someone's outdated, if it's not the client, then it's the server
195+
private _clientIsOutdated = [GVAR(serverVersionAr), GVAR(clientVersionAr)] call CBA_versioning_fnc_version_compare;
196+
private _reasonMsg = format ["Reason: %1", ["Reason: Server is outdated (client version is higher than server's).", "Reason: Client is outdated (client version is lower than server's)."] select _clientIsOutdated];
201197

202-
private _fnc_diagnose_addonMismatch = {
203-
//IGNORE_PRIVATE_WARNING ["_additionalAddons", "_cfgPatches", "_addons", "_mainSource"];
204-
private _title = "[ACE] ERROR: ADDON MISMATCH";
198+
private _infoMsg = format ["Server version is %1, Client version is %2.<br/>Server mod folder is named ""%3"".", GVAR(serverVersion), GVAR(clientVersion), GVAR(serverSource)];
205199

206-
// Figure out why we have a mismatch and where it's coming from
207-
// Integrated compats are the usual culprit
208-
private _additionalCompats = _addons select {(_x select [0, 10]) == "ace_compat"};
209-
_additionalAddons = _additionalAddons - _additionalCompats;
200+
[_title, _reasonMsg, _fixMsg, _infoMsg, _infoMsg] // return
201+
};
210202

211-
// Server most likely just uses a different ACE repack with some components removed
212-
// Higher priority than compats, as we'll load compats for components as well
213-
// Don't show compats in the error message, only components
214-
if (_additionalAddons isNotEqualTo []) exitWith {
215-
private _reasonMsg = format ["Reason: %1", "Client has ACE components not present on the server."];
216-
private _fixMsg = format ["Fix: %1", "Make sure you're using ACE from the same Steam Workshop item or repository as the server."];
203+
private _fnc_diagnose_addonMismatch = {
204+
//IGNORE_PRIVATE_WARNING ["_additionalAddons", "_cfgPatches", "_addons", "_mainSource"];
205+
private _title = "[ACE] ERROR: ADDON MISMATCH";
217206

218-
private _infoMsgLog = format ["Client has additional addons: %1.<br/>Server mod folder is named ""%2"".", _additionalAddons joinString ", ", GVAR(serverSource)]; // Build the whole thing so we can log it to RPT
207+
// Figure out why we have a mismatch and where it's coming from
208+
// Integrated compats are the usual culprit
209+
private _additionalCompats = _addons select {(_x select [0, 10]) == "ace_compat"};
210+
_additionalAddons = _additionalAddons - _additionalCompats;
219211

220-
private _infoMsg = if (count _additionalAddons > 3) then { // Truncate it for display
221-
format ["Client has additional addons: %1, and %2 more.<br/>Server mod folder is named ""%3"".", (_additionalAddons select [0, 3]) joinString ", ", (count _additionalAddons) - 3, GVAR(serverSource)];
222-
} else {
223-
_infoMsgLog
224-
};
212+
// Server most likely just uses a different ACE repack with some components removed
213+
// Higher priority than compats, as we'll load compats for components as well
214+
// Don't show compats in the error message, only components
215+
if (_additionalAddons isNotEqualTo []) exitWith {
216+
private _reasonMsg = format ["Reason: %1", "Client has ACE components not present on the server."];
217+
private _fixMsg = format ["Fix: %1", "Make sure you're using ACE from the same Steam Workshop item or repository as the server."];
225218

226-
[_title, _reasonMsg, _fixMsg, _infoMsg, _infoMsgLog] // return
227-
};
219+
private _infoMsgLog = format ["Client has additional addons: %1.<br/>Server mod folder is named ""%2"".", _additionalAddons joinString ", ", GVAR(serverSource)]; // Build the whole thing so we can log it to RPT
228220

229-
// CDLC/content mod with integrated compats is loaded when it shouldn't be
230-
// No need to show which addons, just show the mod that the compats are for
231-
if (_additionalCompats isNotEqualTo []) exitWith {
232-
// Fix is easy
233-
private _fixMsg = format ["Fix: %1", "Make sure your mod list matches or add those mods to the server.<br/><br/>If you're the server administrator, repair the mods below, check your server mod files and '-mod=' parameter."];
221+
private _infoMsg = if (count _additionalAddons > 3) then { // Truncate it for display
222+
format ["Client has additional addons: %1, and %2 more.<br/>Server mod folder is named ""%3"".", (_additionalAddons select [0, 3]) joinString ", ", (count _additionalAddons) - 3, GVAR(serverSource)];
223+
} else {
224+
_infoMsgLog
225+
};
234226

235-
private _additionalMods = [];
236-
private _loadedModsInfo = getLoadedModsInfo;
237-
private _defaultModDirs = [_mainSource] + (_loadedModsInfo select {_x select 2} apply {_x select 1}); // Skip ACE itself and anything vanilla
238-
239-
{ // Evil O(n^infinityAndBeyond) loop, can't do much about it.
240-
{ // Get the real mod name for the compats we're loading
241-
private _sourceModDir = configSourceMod (_cfgPatches >> _x);
242-
if !(_sourceModDir in _defaultModDirs) then {
243-
_additionalMods pushBackUnique (_loadedModsInfo select {_x select 1 == _sourceModDir} select 0 select 0);
244-
};
245-
} forEach (getArray (_cfgPatches >> _x >> "requiredAddons"));
246-
} forEach _additionalCompats;
227+
[_title, _reasonMsg, _fixMsg, _infoMsg, _infoMsgLog] // return
228+
};
247229

248-
private _reasonMsg = format ["Reason: %1", "Client has extra mods requiring compats loaded (listed below)"];
249-
private _infoMsg = format ["Additional compatibility is being loaded for:<br/>%1", _additionalMods joinString ", "];
230+
// CDLC/content mod with integrated compats is loaded when it shouldn't be
231+
// No need to show which addons, just show the mod that the compats are for
232+
if (_additionalCompats isNotEqualTo []) exitWith {
233+
// Fix is easy
234+
private _fixMsg = format ["Fix: %1", "Make sure your mod list matches or add those mods to the server.<br/><br/>If you're the server administrator, repair the mods below, check your server mod files and '-mod=' parameter."];
235+
236+
private _additionalMods = [];
237+
private _loadedModsInfo = getLoadedModsInfo;
238+
private _defaultModDirs = [_mainSource] + (_loadedModsInfo select {_x select 2} apply {_x select 1}); // Skip ACE itself and anything vanilla
239+
240+
{ // Evil O(n^infinityAndBeyond) loop, can't do much about it.
241+
{ // Get the real mod name for the compats we're loading
242+
private _sourceModDir = configSourceMod (_cfgPatches >> _x);
243+
if !(_sourceModDir in _defaultModDirs) then {
244+
_additionalMods pushBackUnique (_loadedModsInfo select {_x select 1 == _sourceModDir} select 0 select 0);
245+
};
246+
} forEach (getArray (_cfgPatches >> _x >> "requiredAddons"));
247+
} forEach _additionalCompats;
248+
249+
private _reasonMsg = format ["Reason: %1", "Client has extra mods requiring compats loaded (listed below)"];
250+
private _infoMsg = format ["Additional compatibility is being loaded for:<br/>%1", _additionalMods joinString ", "];
251+
252+
[_title, _reasonMsg, _fixMsg, _infoMsg, _infoMsg] // return
253+
};
250254

251-
[_title, _reasonMsg, _fixMsg, _infoMsg, _infoMsg] // return
255+
[
256+
_title,
257+
"Reason: Exceptional combination of additional addons. Good job, you broke our error handling.",
258+
"Fix: Open an issue on GitHub with your logs so we can add handling for this.",
259+
"Have a cookie.",
260+
"Unimplemented addon mismatch"
261+
] // default return
252262
};
253263

254-
[
255-
_title,
256-
"Reason: Exceptional combination of additional addons. Good job, you broke our error handling.",
257-
"Fix: Open an issue on GitHub with your logs so we can add handling for this.",
258-
"Have a cookie.",
259-
"Unimplemented addon mismatch"
260-
] // default return
261-
};
262-
263-
private _fnc_multiplayerCheck = {
264264
// Check if we'll actually throw an error
265265
private _versionMismatch = GVAR(clientVersion) != GVAR(serverVersion);
266266
private _additionalAddons = GVAR(clientAddons) - GVAR(serverAddons);
@@ -294,6 +294,7 @@ if (isMultiplayer) then {
294294

295295
// Clients have to wait for the variables
296296
if (isNil QGVAR(serverVersion) || isNil QGVAR(serverAddons)) then {
297+
WARNING("Waiting for server version/addon vars");
297298
QGVAR(serverVersion) addPublicVariableEventHandler _fnc_multiplayerCheck;
298299
} else {
299300
call _fnc_multiplayerCheck;

0 commit comments

Comments
 (0)