Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
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 /src/core
parent5d1e18b796d41e035d0d3e828cc6db54ed21a4b6 (diff)
server frame time, rotation snap, flares
Diffstat (limited to 'src/core')
-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
5 files changed, 43 insertions, 12 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