Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
8 files changed, 71 insertions, 19 deletions
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;
}
+ */
}
}