Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/gameconnection.cc')
-rw-r--r--src/core/gameconnection.cc22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/core/gameconnection.cc b/src/core/gameconnection.cc
index 114931c..eaafe91 100644
--- a/src/core/gameconnection.cc
+++ b/src/core/gameconnection.cc
@@ -22,7 +22,9 @@ GameConnection::GameConnection(std::string const &connectionstr)
connection_instance = this;
connection_network = 0;
connection_running = false;
- connection_frametime = 0;
+
+ connection_timestamp = 0;
+ connection_netframe = 0;
unsigned int port = DEFAULTPORT;
std::string host(connectionstr);
@@ -101,7 +103,7 @@ void GameConnection::private_message(std::string const &args)
connection_network->send_private_message(args);
}
-void GameConnection::frame(float seconds)
+void GameConnection::frame(unsigned long timestamp)
{
if (!running())
return;
@@ -111,20 +113,21 @@ void GameConnection::frame(float seconds)
return;
}
- update_clientstate(seconds);
-
- connection_network->frame(seconds);
+ update_clientstate();
- connection_frametime += seconds;
+ // get incoming messages
+ connection_network->frame();
float f = 0;
if (core::Cvar::net_framerate->value()) {
- f = 0.5f / core::Cvar::net_framerate->value();
- if (connection_frametime < f) {
+ f = 1000.0f / core::Cvar::net_framerate->value();
+ if (connection_netframe + f > timestamp) {
return;
}
}
+ connection_netframe = timestamp;
+
if (connection_network->state() == NetConnection::Connected) {
if(localcontrol() && localcontrol()->dirty()) {
@@ -139,9 +142,8 @@ void GameConnection::frame(float seconds)
}
}
+ connection_timestamp = connection_network->timestamp();
connection_network->transmit();
-
- connection_frametime = 0;
}
}