From 7fb56d4fd56ff032511477108f45cee65c340e04 Mon Sep 17 00:00:00 2001
From: commy2 <commy-2@gmx.de>
Date: Sat, 9 May 2015 17:03:51 +0200
Subject: [PATCH] simple check to compare client and server version of ace

---
 addons/common/functions/fnc_checkFiles.sqf   | 34 +++++++++++++++++++-
 addons/common/functions/fnc_errorMessage.sqf | 15 +++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/addons/common/functions/fnc_checkFiles.sqf b/addons/common/functions/fnc_checkFiles.sqf
index 35cb552a8a..6aa38d61c0 100644
--- a/addons/common/functions/fnc_checkFiles.sqf
+++ b/addons/common/functions/fnc_checkFiles.sqf
@@ -17,7 +17,7 @@
 private "_version";
 _version = getText (configFile >> "CfgPatches" >> "ace_main" >> "versionStr");
 
-diag_log text format ["[ACE]: ACE is version %1", _version];
+diag_log text format ["[ACE]: ACE is version %1.", _version];
 
 private ["_addons", "_index"];
 
@@ -57,3 +57,35 @@ _addons = [_addons, {_this find "ace_" == 0}] call FUNC(filter);
         };
     };
 } forEach getArray (configFile >> "ACE_Extensions" >> "extensions");
+
+///////////////
+// check server version
+///////////////
+if (isMultiplayer) then {
+    if (isServer) then {
+        // send servers version of ACE to all clients
+        GVAR(ServerVersion) = _version;
+        publicVariable QGVAR(ServerVersion);
+    } else {
+        // clients have to wait for the variable
+        [{
+            if (isNil QGVAR(ServerVersion)) exitWith {};
+
+            private "_version";
+            _version = _this select 0;
+
+            if (_version != GVAR(ServerVersion)) then {
+                private "_errorMsg";
+                _errorMsg = format ["Client/Server Version Mismatch. Server: %1, Client: %2.", GVAR(ServerVersion), _version];
+
+                diag_log text format ["[ACE] ERROR: %1", _errorMsg];
+
+                if (hasInterface) then {diag_log str "1";
+                    ["[ACE] ERROR", _errorMsg, {findDisplay 46 closeDisplay 0}] call FUNC(errorMessage);
+                };
+            };
+
+            [_this select 1] call CBA_fnc_removePerFrameHandler;
+        }, 1, _version] call CBA_fnc_addPerFrameHandler;
+    };
+};
diff --git a/addons/common/functions/fnc_errorMessage.sqf b/addons/common/functions/fnc_errorMessage.sqf
index e061772942..9665fed5bb 100644
--- a/addons/common/functions/fnc_errorMessage.sqf
+++ b/addons/common/functions/fnc_errorMessage.sqf
@@ -15,6 +15,21 @@
 disableSerialization;
 endLoadingScreen;
 
+
+// no message without player possible
+if (!hasInterface) exitWith {};
+
+// wait for display
+if (isNull (call BIS_fnc_displayMission)) exitWith {
+    [{
+        if (isNull (call BIS_fnc_displayMission)) exitWith {};
+
+        (_this select 0) call FUNC(errorMessage);
+        [_this select 1] call CBA_fnc_removePerFrameHandler;
+
+    }, 1, _this] call CBA_fnc_addPerFrameHandler;
+};
+
 private ["_textHeader", "_textMessage", "_onOK", "_onCancel"];
 
 _textHeader = _this select 0;