From 5efde255858832778e60351d5506fb87bd84ad07 Mon Sep 17 00:00:00 2001
From: PabstMirror <elephantisaterriblemascot@gmail.com>
Date: Fri, 29 May 2015 21:03:47 -0500
Subject: [PATCH 1/2] Fix ace_settings

---
 addons/common/XEH_postInit.sqf | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf
index 291cfc442e..d39ba13ba8 100644
--- a/addons/common/XEH_postInit.sqf
+++ b/addons/common/XEH_postInit.sqf
@@ -255,11 +255,18 @@ GVAR(commonPostInited) = true;
     // If post inits are not ready then wait
     if !(SLX_XEH_MACHINE select 8) exitWith {};
     // If settings are not initialized then wait
-    if !(GVAR(SettingsInitialized)) exitWith {};
+    if (isNil QGVAR(settings)) exitWith {
+        diag_log text format["[ACE] Waiting on settings from server"];
+    };
 
     [(_this select 1)] call cba_fnc_removePerFrameHandler;
 
     diag_log text format["[ACE] Settings initialized"];
+    
+    //Load from profile and localize settings:
+    ["ServerSettingsReceived", []] call FUNC(localEvent);
+    
+    //Event that settings are safe to use:
     ["SettingsInitialized", []] call FUNC(localEvent);
 
 }, 0, []] call cba_fnc_addPerFrameHandler;

From afa6a2fad90bec49f96b567347b6f9b576c7507e Mon Sep 17 00:00:00 2001
From: esteldunedain <nicolas.d.badano@gmail.com>
Date: Sat, 30 May 2015 00:43:51 -0300
Subject: [PATCH 2/2] Remove the "ServerSettingsReceived" event, which is not
 longer needed. As per @pabstmirror solution, the GVAR(Settings) variable is
 monitored to determine when the server info has arrived. Fix #1273

---
 addons/common/XEH_postInit.sqf | 14 ++++++++++----
 addons/common/XEH_preInit.sqf  | 14 --------------
 2 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf
index d39ba13ba8..07ffe970cb 100644
--- a/addons/common/XEH_postInit.sqf
+++ b/addons/common/XEH_postInit.sqf
@@ -254,6 +254,7 @@ GVAR(commonPostInited) = true;
 [{
     // If post inits are not ready then wait
     if !(SLX_XEH_MACHINE select 8) exitWith {};
+
     // If settings are not initialized then wait
     if (isNil QGVAR(settings)) exitWith {
         diag_log text format["[ACE] Waiting on settings from server"];
@@ -261,11 +262,16 @@ GVAR(commonPostInited) = true;
 
     [(_this select 1)] call cba_fnc_removePerFrameHandler;
 
+    diag_log text format["[ACE] Settings received from server"];
+
+    // Load user settings from profile
+    if (hasInterface) then {
+        call FUNC(loadSettingsFromProfile);
+        call FUNC(loadSettingsLocalizedText);
+    };
+
     diag_log text format["[ACE] Settings initialized"];
-    
-    //Load from profile and localize settings:
-    ["ServerSettingsReceived", []] call FUNC(localEvent);
-    
+
     //Event that settings are safe to use:
     ["SettingsInitialized", []] call FUNC(localEvent);
 
diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf
index fbd5f3ddd5..4d93705898 100644
--- a/addons/common/XEH_preInit.sqf
+++ b/addons/common/XEH_preInit.sqf
@@ -294,23 +294,9 @@ GVAR(waitAndExecArray) = [];
 //Debug
 ACE_COUNTERS = [];
 
-// Wait for server settings to arrive
-GVAR(SettingsInitialized) = false;
-["ServerSettingsReceived", {
-    diag_log text format["[ACE] Settings received from server"];
-    // Load user settings from profile
-    if (hasInterface) then {
-        call FUNC(loadSettingsFromProfile);
-        call FUNC(loadSettingsLocalizedText);
-    };
-    GVAR(SettingsInitialized) = true;
-}] call FUNC(addEventhandler);
-
 // Load settings on the server and broadcast them
 if (isServer) then {
     call FUNC(loadSettingsOnServer);
-    // Raise a local event for other modules to listen too
-    ["ServerSettingsReceived", []] call FUNC(localEvent);
 };
 
 ACE_player = player;