Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-05-03 18:31:13 +0000
committerStijn Buys <ingar@osirion.org>2008-05-03 18:31:13 +0000
commit5388c37bdc040ba50d21ec16a01f399d20592a90 (patch)
tree9c43947b1b25d7d7e40e5c3cada5ff1f48cd8d61
parent5d1e18b796d41e035d0d3e828cc6db54ed21a4b6 (diff)
server frame time, rotation snap, flares
-rw-r--r--osirion.kdevelop.pcsbin594820 -> 597984 bytes
-rw-r--r--osirion.kdevses24
-rw-r--r--src/core/gameserver.cc16
-rw-r--r--src/core/gameserver.h1
-rw-r--r--src/core/model.cc15
-rw-r--r--src/core/model.h10
-rw-r--r--src/core/netserver.cc13
-rw-r--r--src/game/ship.cc6
-rw-r--r--src/render/draw.cc24
-rw-r--r--src/server/server.cc5
10 files changed, 86 insertions, 28 deletions
diff --git a/osirion.kdevelop.pcs b/osirion.kdevelop.pcs
index f753658..6b67d1f 100644
--- a/osirion.kdevelop.pcs
+++ b/osirion.kdevelop.pcs
Binary files differ
diff --git a/osirion.kdevses b/osirion.kdevses
index c085632..db2bc64 100644
--- a/osirion.kdevses
+++ b/osirion.kdevses
@@ -1,19 +1,25 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
- <DocsAndViews NumberOfDocuments="4" >
- <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/camera.cc" >
- <View0 Encoding="" line="183" Type="Source" />
+ <DocsAndViews NumberOfDocuments="6" >
+ <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/model.cc" >
+ <View0 Encoding="" line="316" Type="Source" />
</Doc0>
- <Doc1 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/render/draw.cc" >
- <View0 Encoding="" line="39" Type="Source" />
+ <Doc1 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/model.h" >
+ <View0 Encoding="" line="150" Type="Source" />
</Doc1>
- <Doc2 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/input.cc" >
- <View0 Encoding="" line="97" Type="Source" />
+ <Doc2 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/render/draw.cc" >
+ <View0 Encoding="" line="275" Type="Source" />
</Doc2>
- <Doc3 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/camera.h" >
- <View0 Encoding="" line="0" Type="Source" />
+ <Doc3 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/view.cc" >
+ <View0 Encoding="" line="209" Type="Source" />
</Doc3>
+ <Doc4 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/render/textures.h" >
+ <View0 Encoding="" line="39" Type="Source" />
+ </Doc4>
+ <Doc5 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/render/textures.cc" >
+ <View0 Encoding="" line="127" Type="Source" />
+ </Doc5>
</DocsAndViews>
<pluginList>
<kdevdebugger>
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index 2169e21..bedab1d 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -32,6 +32,7 @@ GameServer::GameServer() : GameInterface()
con_print << "Initializing game server...\n";
server_instance = this;
server_network = 0;
+ server_frametime = 0.0f;
server_maxplayerid = 1;
server_module = Module::preload();
@@ -255,19 +256,28 @@ void GameServer::frame(float seconds)
if (localplayer()->dirty())
localplayer()->update_info();
+ float f = 0;
+ server_frametime += seconds;
+ if (core::Cvar::sv_framerate->value()) {
+ f = 1.0f / core::Cvar::sv_framerate->value();
+ if (server_frametime < f) {
+ return;
+ }
+ }
+
// run a time frame on each entity
std::map<unsigned int, Entity *>::iterator it;
for (it=Entity::registry.begin(); it != Entity::registry.end(); it++) {
Entity *entity = (*it).second;
if ((entity->type() == Entity::Controlable) || (entity->type() == Entity::Dynamic)) {
- entity->frame(seconds);
+ entity->frame(server_frametime);
}
}
// run a frame on the module
if (server_module) {
- server_module->frame(seconds);
+ server_module->frame(server_frametime);
if (server_module->error()) {
abort();
return;
@@ -347,6 +357,8 @@ void GameServer::frame(float seconds)
entity->entity_dirty = false;
}
}
+
+ server_frametime -= f;
}
diff --git a/src/core/gameserver.h b/src/core/gameserver.h
index 6003629..907d69e 100644
--- a/src/core/gameserver.h
+++ b/src/core/gameserver.h
@@ -74,6 +74,7 @@ private:
NetServer *server_network;
unsigned int server_maxplayerid;
+ float server_frametime;
};
inline GameServer *server() { return GameServer::instance(); }
diff --git a/src/core/model.cc b/src/core/model.cc
index c38749b..c6f5dde 100644
--- a/src/core/model.cc
+++ b/src/core/model.cc
@@ -185,6 +185,8 @@ Light::Light(math::Vector3f const & location, math::Color const & color, bool st
light_frequency = 1.0f;
light_offset = 0.0f;
light_time = 0.5f;
+ light_flare = 0;
+ render_texture = 0;
}
Light::~Light()
@@ -253,6 +255,7 @@ Model::Model(std::string const & name) :
float class_frequency = 1.0f;
float class_offset = 0;
float class_time = 0.0f;
+ unsigned int class_flare = 0;
bool brush_detail = false;
while (ifs) {
@@ -275,6 +278,7 @@ Model::Model(std::string const & name) :
class_offset = 0;
class_frequency = 1.0f;
class_time = 0.0f;
+ class_flare = 0;
brush_detail = false;
}
level ++;
@@ -309,6 +313,8 @@ Model::Model(std::string const & name) :
light->light_frequency = class_frequency;
if (class_time > 0 )
light->light_time = class_time;
+ if (class_flare > 0)
+ light->light_flare = class_flare;
add_light(light);
}
@@ -415,6 +421,15 @@ Model::Model(std::string const & name) :
std::istringstream is(tmp);
is >> class_time;
+ } else if (firstword == "\"flare\"") {
+ std::string tmp;
+ char c;
+ while ((linestream.get(c)) && (c != '"'));
+ while ((linestream.get(c)) && (c != '"'))
+ tmp += c;
+ std::istringstream is(tmp);
+ is >> class_flare;
+
} else if (firstword == "(") {
if ((level == 2) && (class_name == "worldspawn")) {
//cout << " BRUSH PLANE" << std::endl;
diff --git a/src/core/model.h b/src/core/model.h
index 6175ec7..e9b3de4 100644
--- a/src/core/model.h
+++ b/src/core/model.h
@@ -133,6 +133,12 @@ public:
/// fraction a strobe light will be on, default is 0.5f
inline float time() const { return light_time; }
+
+ /// flare texture number
+ inline size_t flare() const { return light_flare; }
+
+ /// render texture number
+ inline size_t texture() const { return render_texture; }
math::Vector3f light_location;
math::Color light_color;
@@ -141,6 +147,10 @@ public:
float light_frequency;
float light_offset;
float light_time;
+
+ size_t light_flare;
+
+ size_t render_texture;
};
diff --git a/src/core/netserver.cc b/src/core/netserver.cc
index 50702ac..ca08def 100644
--- a/src/core/netserver.cc
+++ b/src/core/netserver.cc
@@ -178,7 +178,7 @@ void NetServer::receive()
timeval timeout;
timeout.tv_sec = 0;
- timeout.tv_usec = 500;
+ timeout.tv_usec = 5000;
fd_set readset = serverset;
int nb = select(fd()+1, &readset, NULL, NULL, &timeout);
@@ -189,7 +189,8 @@ void NetServer::receive()
return;
}
- while (nb && FD_ISSET(fd(), &readset)) {
+ if (nb && FD_ISSET(fd(), &readset)) {
+
// receive incoming data
struct sockaddr_in client_addr;
socklen_t client_addr_len = sizeof(client_addr);
@@ -246,14 +247,6 @@ void NetServer::receive()
}
}
- readset = serverset;
- nb = select(fd(), &readset, NULL, NULL, &timeout);
- if (nb == -1) {
- con_error << "Network error on select()" << std::endl;
- //perror("select");
- abort();
- return;
- }
}
// remove dead connections
diff --git a/src/game/ship.cc b/src/game/ship.cc
index 9a7c059..a1d4531 100644
--- a/src/game/ship.cc
+++ b/src/game/ship.cc
@@ -52,7 +52,7 @@ void Ship::frame(float seconds)
} else if (current_target_pitch > target_pitch) {
current_target_pitch -= direction_change_speed * seconds;
}
- if (fabs(current_target_pitch) < 0.005f) {
+ if (fabs(current_target_pitch) < direction_change_speed * seconds) {
current_target_pitch = 0.0f;
} else {
math::clamp(current_target_pitch, -1.0f, 1.0f);
@@ -67,7 +67,7 @@ void Ship::frame(float seconds)
} else if (current_target_direction > target_direction) {
current_target_direction -= direction_change_speed * seconds;
}
- if (fabs(current_target_direction) < 0.005f) {
+ if (fabs(current_target_direction) < direction_change_speed * seconds) {
current_target_direction = 0.0f;
} else {
math::clamp(current_target_direction, -1.0f, 1.0f);
@@ -82,7 +82,7 @@ void Ship::frame(float seconds)
} else if (current_target_roll > target_roll) {
current_target_roll -= direction_change_speed * seconds;
}
- if (fabs(current_target_roll) < 0.005f) {
+ if (fabs(current_target_roll) < direction_change_speed * seconds) {
current_target_roll = 0.0f;
} else {
math::clamp(current_target_roll, -1.0f, 1.0f);
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 18e587a..2938442 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -4,6 +4,9 @@
the terms and conditions of the GNU General Public License version 2
*/
+#include <sstream>
+#include <iomanip>
+
#include "core/core.h"
#include "core/model.h"
#include "render/render.h"
@@ -259,8 +262,18 @@ void pass_visibility()
if (!entity->model() && entity->modelname().size()) {
entity->entity_model = core::Model::get(entity->modelname());
- if (!entity->model())
+ if (!entity->model()) {
entity->entity_modelname.clear();
+ } else {
+ for (std::list<core::Light *>::iterator lit = entity->model()->model_light.begin(); lit != entity->model()->model_light.end(); lit++) {
+ core::Light *light = (*lit);
+
+ // load flare texture
+ std::stringstream flarename;
+ flarename << "bitmaps/fx/flare" << std::setfill('0') << std::setw(2) << light->flare();
+ light->render_texture = Textures::load(flarename.str());
+ }
+ }
}
if (entity->model()) {
@@ -385,7 +398,7 @@ void draw_pass_model_fx() {
void draw_pass_model_lights()
{
//glPointSize(10);
- Textures::bind("bitmaps/fx/flare00");
+ size_t flare_texture = Textures::bind("bitmaps/fx/flare00");
gl::enable(GL_TEXTURE_2D);
gl::begin(gl::Quads);
@@ -404,7 +417,12 @@ void draw_pass_model_lights()
if (!(*lit)->strobe() || (( t - floorf(t)) <= (*lit)->time())) {
math::Vector3f location = entity->location() + (entity->axis() * (*lit)->location());
float light_size = 0.0625 * (*lit)->radius();
-
+
+ if ((*lit)->render_texture != flare_texture) {
+ gl::end();
+ flare_texture = Textures::bind((*lit)->render_texture);
+ gl::begin(gl::Quads);
+ }
math::Color color((*lit)->color());
color.a = 0.8;
diff --git a/src/server/server.cc b/src/server/server.cc
index 8dcbb65..69e8923 100644
--- a/src/server/server.cc
+++ b/src/server/server.cc
@@ -79,11 +79,14 @@ void Server::run()
timer.mark();
frame(elapsed);
elapsed = timer.elapsed();
-
+
+ /*
if (elapsed < server_framerate) {
sys::sleep(server_framerate - elapsed);
+
elapsed = server_framerate;
}
+ */
}
}