summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/network/network.cpp12
-rw-r--r--src/network/network.h2
-rw-r--r--src/video/dedicated_v.cpp10
3 files changed, 23 insertions, 1 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 57a6412c6..a3c8fd4a9 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -97,6 +97,18 @@ byte _network_clients_connected = 0;
extern void StateGameLoop();
/**
+ * Return whether there is any client connected or trying to connect at all.
+ * @return whether we have any client activity
+ */
+bool HasClients()
+{
+ NetworkClientSocket *cs;
+ FOR_ALL_CLIENT_SOCKETS(cs) return true;
+
+ return false;
+}
+
+/**
* Basically a client is leaving us right now.
*/
NetworkClientInfo::~NetworkClientInfo()
diff --git a/src/network/network.h b/src/network/network.h
index 3dd63d03c..26f94482e 100644
--- a/src/network/network.h
+++ b/src/network/network.h
@@ -18,6 +18,7 @@
void NetworkStartUp();
void NetworkShutDown();
void NetworkDrawChatMessage();
+bool HasClients();
extern bool _networking; ///< are we in networking mode?
extern bool _network_server; ///< network-server is active
@@ -31,6 +32,7 @@ extern bool _is_network_server; ///< Does this client wants to be a network-ser
static inline void NetworkStartUp() {}
static inline void NetworkShutDown() {}
static inline void NetworkDrawChatMessage() {}
+static inline bool HasClients() { return false; }
#define _networking 0
#define _network_server 0
diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp
index 8e5b9ea91..9be1b2d3c 100644
--- a/src/video/dedicated_v.cpp
+++ b/src/video/dedicated_v.cpp
@@ -316,7 +316,15 @@ void VideoDriver_Dedicated::MainLoop()
}
/* Don't sleep when fast forwarding (for desync debugging) */
- if (!_ddc_fastforward) CSleep(1);
+ if (!_ddc_fastforward) {
+ /* Sleep longer on a dedicated server, if the game is paused and no clients connected.
+ * That can allow the CPU to better use deep sleep states. */
+ if (_pause_mode != 0 && !HasClients()) {
+ CSleep(100);
+ } else {
+ CSleep(1);
+ }
+ }
}
}