From 5c9d41ce013205bdef4ebff837fadf2e0763401c Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Wed, 2 May 2012 23:26:04 +0300
Subject: Add timeout option between connections to sub servers. This can be
 usefull for bad and slow connections.

---
 src/defaults.cpp         | 1 +
 src/gui/setup_other.cpp  | 3 +++
 src/net/tmwa/network.cpp | 4 ++++
 3 files changed, 8 insertions(+)

(limited to 'src')

diff --git a/src/defaults.cpp b/src/defaults.cpp
index efd1c5fc6..d65e722de 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -253,6 +253,7 @@ DefaultsData* getConfigDefaults()
     AddDEF(configData, "repeateInterval", SDL_DEFAULT_REPEAT_INTERVAL);
     AddDEF(configData, "compresstextures", false);
     AddDEF(configData, "rectangulartextures", true);
+    AddDEF(configData, "networksleep", 0);
     return configData;
 }
 
diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp
index bf186b45a..2f86db8af 100644
--- a/src/gui/setup_other.cpp
+++ b/src/gui/setup_other.cpp
@@ -226,6 +226,9 @@ Setup_Other::Setup_Other()
         "", "usefbo", this, "usefboEvent");
 #endif
 
+    new SetupItemIntTextField(_("Network delay between sub servers"),
+        "", "networksleep", this, "networksleepEvent", 0, 10000);
+
     new SetupItemCheckBox(_("Show background"), "", "showBackground",
         this, "showBackgroundEvent");
 
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index 956067f4a..c54972253 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -22,6 +22,7 @@
 
 #include "net/tmwa/network.h"
 
+#include "configuration.h"
 #include "logger.h"
 
 #include "net/messagehandler.h"
@@ -191,6 +192,9 @@ void Network::disconnect()
         // need call SDLNet_TCP_DelSocket?
         SDLNet_TCP_Close(mSocket);
         mSocket = nullptr;
+        int sleep = config.getIntValue("networksleep");
+        if (sleep > 0)
+            SDL_Delay(sleep);
     }
 }
 
-- 
cgit v1.2.3-70-g09d2