Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/application.cc3
-rw-r--r--src/core/cvar.cc1
-rw-r--r--src/core/cvar.h1
-rw-r--r--src/core/netserver.cc11
4 files changed, 15 insertions, 1 deletions
diff --git a/src/core/application.cc b/src/core/application.cc
index dc08595..5c7e4e7 100644
--- a/src/core/application.cc
+++ b/src/core/application.cc
@@ -150,6 +150,9 @@ void Application::init(int count, char **arguments)
Cvar::net_framerate = Cvar::get("net_framerate", "25");
Cvar::net_framerate->set_info("[int] network framerate in frames/sec");
+ Cvar::net_selecttimeout = Cvar::get("net_selecttimeout", "10000");
+ Cvar::net_framerate->set_info("[int] network select() call timeout, in microseconds");
+
Cvar::mem_vertex = core::Cvar::get("mem_vertex", "64" , core::Cvar::Archive);
Cvar::mem_vertex->set_info("[int] amount of video memory reserved for model geometry, in megabytes");
diff --git a/src/core/cvar.cc b/src/core/cvar.cc
index 100f31f..66da4d4 100644
--- a/src/core/cvar.cc
+++ b/src/core/cvar.cc
@@ -31,6 +31,7 @@ Cvar *Cvar::net_port = 0;
Cvar *Cvar::net_maxclients = 0;
Cvar *Cvar::net_timeout = 0;
Cvar *Cvar::net_framerate = 0;
+Cvar *Cvar::net_selecttimeout = 0;
Cvar *Cvar::mem_vertex = 0;
diff --git a/src/core/cvar.h b/src/core/cvar.h
index 4c55fad..ffc11bf 100644
--- a/src/core/cvar.h
+++ b/src/core/cvar.h
@@ -165,6 +165,7 @@ public:
static Cvar *net_maxclients;// maximum number of connected clients
static Cvar *net_timeout; // network timeout in seconds
static Cvar *net_framerate; // client network send framerate
+ static Cvar *net_selecttimeout; // timeout for select() call, in microseconds
static Cvar *mem_vertex; // amount of video memory reserved for model geometry, in megabytes
diff --git a/src/core/netserver.cc b/src/core/netserver.cc
index 4769f68..937d91b 100644
--- a/src/core/netserver.cc
+++ b/src/core/netserver.cc
@@ -187,7 +187,16 @@ void NetServer::receive()
timeval timeout;
timeout.tv_sec = 0;
- timeout.tv_usec = 2500;
+
+ // 1,000,000 microseconds = 1 second, default is 2500
+ timeout.tv_usec = (long) Cvar::net_selecttimeout->value();
+ if (timeout.tv_usec < 0)
+ timeout.tv_usec = 0;
+ else if (timeout.tv_usec > 1000000) {
+ timeout.tv_sec = timeout.tv_usec / 1000000;
+ timeout.tv_usec %= 1000000;
+ }
+
fd_set readset = serverset;
int nb = select(fd() + 1, &readset, NULL, NULL, &timeout);