Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/chat.cc8
-rw-r--r--src/client/client.cc39
-rw-r--r--src/core/application.cc4
-rw-r--r--src/core/entity.cc12
-rw-r--r--src/core/gameconnection.cc2
-rw-r--r--src/server/server.cc19
6 files changed, 48 insertions, 36 deletions
diff --git a/src/client/chat.cc b/src/client/chat.cc
index 4e7416f..8d5e94c 100644
--- a/src/client/chat.cc
+++ b/src/client/chat.cc
@@ -73,9 +73,11 @@ void draw()
// draw the console input
gl::enable(GL_TEXTURE_2D);
- gl::color(0.0f, 1.0f, 0.0f, 1.0f);
- draw_text(CHARWIDTH , 4 + CHARHEIGHT * (MAXNOTIFYLINES+1), "Say:");
-
+ gl::color(1.0f, 1.0f, 1.0f, 1.0f);
+ draw_text(CHARWIDTH , 4 + CHARHEIGHT * (MAXNOTIFYLINES+1), "say");
+ gl::color(0.0f, 1.0f, .0f, 1.0f);
+ draw_text(CHARWIDTH*4 , 4 + CHARHEIGHT * (MAXNOTIFYLINES+1), ":");
+
gl::color(1.0f, 1.0f, 1.0f, 1.0f);
draw_text(CHARWIDTH*6, 4 + CHARHEIGHT * (MAXNOTIFYLINES+1), (*history_pos));
diff --git a/src/client/client.cc b/src/client/client.cc
index 33b3a04..a25b958 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -23,6 +23,8 @@
namespace client
{
+core::Cvar *cl_framerate = 0;
+
//--- private definition ------------------------------------------
/// client application implementation
class Client : public core::Application
@@ -90,6 +92,7 @@ void Client::init()
// client variables
core::Cvar::get("cl_name", "Player", core::Cvar::Archive);
core::Cvar::get("cl_color", "1.0 1.0 1.0", core::Cvar::Archive);
+ cl_framerate = core::Cvar::get("cl_framerate", "0");
// initialize SDL, but do not initialize any subsystems
SDL_Init(0);
@@ -115,28 +118,30 @@ void Client::run()
{
con_print << "Running client..." << std::endl;
- Uint32 chrono = SDL_GetTicks();
+
+
+ Uint32 client_framerate = (Uint32)(1000/120);
+ Uint32 elapsed = 0;
while (true) {
- Uint32 current = SDL_GetTicks();
+ if (cl_framerate->value())
+ client_framerate = (Uint32) (1000.0f / cl_framerate->value());
- // overflow protection ~49 days
- if (current < chrono) {
- chrono = current;
- }
+ Uint32 chrono = SDL_GetTicks();
- // run a core frame
- float seconds = ((float)(current - chrono)) / 1000.0f;
- core::Application::frame(seconds);
-
- // run a video frame
- video::frame(seconds);
+ core::Application::frame((float)elapsed / 1000.0f);
+ video::frame((float)elapsed / 1000.0f);
+ input::frame((float)elapsed / 1000.0f);
- // process input
- input::frame(seconds);
-
- // update the main loop chronometer
- chrono = current;
+ // sleep
+ Uint32 current = SDL_GetTicks();
+
+ elapsed = current - chrono;
+
+ if (elapsed < client_framerate) {
+ SDL_Delay(client_framerate - elapsed);
+ elapsed = client_framerate;
+ }
}
}
diff --git a/src/core/application.cc b/src/core/application.cc
index 7d6f62a..358c655 100644
--- a/src/core/application.cc
+++ b/src/core/application.cc
@@ -263,12 +263,12 @@ void Application::frame(float seconds)
// execute commands in the buffer
CommandBuffer::exec();
+ application_time += seconds;
+
// don't run zero lenght time frames
if (seconds == 0.0f)
return;
- application_time += seconds;
-
if (!connected())
return;
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 4cce2cb..a0da4ea 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -295,14 +295,18 @@ void EntityControlable::frame(float seconds)
void EntityControlable::set_thrust(float thrust)
{
- target_thrust = thrust;
- entity_dirty = true;
+ if (!(thrust == target_thrust)) {
+ target_thrust = thrust;
+ entity_dirty = true;
+ }
}
void EntityControlable::set_direction(float direction)
{
- target_direction = direction;
- entity_dirty = true;
+ if (!(target_direction == direction)) {
+ target_direction = direction;
+ entity_dirty = true;
+ }
}
}
diff --git a/src/core/gameconnection.cc b/src/core/gameconnection.cc
index 07a27a6..4c31f78 100644
--- a/src/core/gameconnection.cc
+++ b/src/core/gameconnection.cc
@@ -94,6 +94,7 @@ void GameConnection::frame(float seconds)
connection_frametime += seconds;
f = 1.0f / core::Cvar::sv_framerate->value();
if (connection_frametime < f) {
+ /*
// run client prediction
std::map<unsigned int, Entity *>::iterator it;
for (it=Entity::registry.begin(); it != Entity::registry.end(); it++) {
@@ -102,6 +103,7 @@ void GameConnection::frame(float seconds)
entity->frame(seconds);
}
}
+ */
return;
}
} else {
diff --git a/src/server/server.cc b/src/server/server.cc
index c07be52..d68d278 100644
--- a/src/server/server.cc
+++ b/src/server/server.cc
@@ -64,24 +64,23 @@ void Server::init()
void Server::run()
{
- float server_framerate = 1.0f / 20.0f;
+ float server_framerate = 1.0f / 25.0f;
+
if (core::Cvar::sv_framerate->value())
server_framerate = 1.0f / core::Cvar::sv_framerate->value();
server::Timer timer;
+ float elapsed = 0;
while(true) {
timer.mark();
- frame(server_framerate);
- float elapsed = timer.elapsed();
-
- float sleeptime = server_framerate - elapsed;
- if (sleeptime <0)
- sleeptime = 0;
+ frame(elapsed);
+ elapsed = timer.elapsed();
- sys::sleep(sleeptime);
-
-
+ if (elapsed < server_framerate) {
+ sys::sleep(server_framerate - elapsed);
+ elapsed = server_framerate;
+ }
}
}