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>2011-02-04 13:23:05 +0000
committerStijn Buys <ingar@osirion.org>2011-02-04 13:23:05 +0000
commita69521970793424754421c8a5fba2eb465e817e6 (patch)
treef44f178a27f621f0f11ed5959418d83ee399ffcd /src/core/gameserver.cc
parent7129e31075e021112ba6a859af29513e69671626 (diff)
Made time(), timestamp() and related methods non-virtual, corrects a crash when
the dedicated server quits.
Diffstat (limited to 'src/core/gameserver.cc')
-rw-r--r--src/core/gameserver.cc52
1 files changed, 15 insertions, 37 deletions
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index cb1e66d..1bd0dbe 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -125,7 +125,6 @@ GameServer::GameServer() : GameInterface()
con_print << "^BInitializing game server...\n";
server_instance = this;
server_network = 0;
- server_timestamp = 0;
server_previoustime = 0;
server_maxplayerid = 1;
server_startup = application()->timestamp();
@@ -149,7 +148,9 @@ GameServer::GameServer() : GameInterface()
return;
}
- if (server_module->interactive()) {
+ set_interactive(server_module->interactive());
+
+ if (interactive()) {
//FIXME interferes with command line because of cmd.exec
load_config();
}
@@ -160,7 +161,7 @@ GameServer::GameServer() : GameInterface()
con_print << " module '^B" << server_module->name() << "^N'\n";
- if (server_module->interactive() && (Cvar::sv_dedicated->value() || Cvar::sv_private->value())) {
+ if (interactive() && (Cvar::sv_dedicated->value() || Cvar::sv_private->value())) {
server_network = new NetServer(Cvar::net_host->str(), (unsigned int) Cvar::net_port->value());
if (!server_network->valid()) {
delete server_network;
@@ -197,12 +198,12 @@ GameServer::GameServer() : GameInterface()
player_connect(localplayer());
}
- server_running = true;
+ set_running(true);
}
GameServer::~GameServer()
{
- server_running = false;
+ set_running(false);
con_print << "^BShutting down game server...\n";
@@ -243,16 +244,6 @@ GameServer::~GameServer()
server_instance = 0;
}
-unsigned long GameServer::timestamp() const
-{
- return server_timestamp;
-}
-
-float GameServer::time() const
-{
- return ((float)(server_timestamp) / 1000.0f);
-}
-
Info *GameServer::request_info(unsigned int id)
{
return Info::find(id);
@@ -264,20 +255,6 @@ Inventory *GameServer::request_inventory(Entity *entity)
}
-void GameServer::abort()
-{
- server_running = false;
-}
-
-bool GameServer::interactive() const
-{
- if (!server_module) {
- return false;
- } else {
- return server_module->interactive();
- }
-}
-
void GameServer::say(Player *player, std::string const &message)
{
if (!message.size())
@@ -505,15 +482,16 @@ void GameServer::frame(unsigned long timestamp)
if ((Cvar::sv_dedicated->value() || Cvar::sv_private->value())) {
if (core::Cvar::sv_framerate->value()) {
float f = 1000.0f / core::Cvar::sv_framerate->value();
- if (server_startup + server_timestamp + f > timestamp) {
+ if (server_startup + this->timestamp() + f > timestamp) {
return;
}
}
}
- server_previoustime = server_timestamp;
- server_timestamp = timestamp - server_startup;
- const float elapsed = (float)(server_timestamp - server_previoustime) / 1000.0f;
+ server_previoustime = this->timestamp();
+ set_timestamp(timestamp - server_startup);
+
+ const float elapsed = (float)(this->timestamp() - server_previoustime) / 1000.0f;
const unsigned long keepalive_timeout = (Cvar::sv_keepalive ? 1000 * (unsigned long) Cvar::sv_keepalive->value() : (unsigned long) 0 );
// reset zone keepalive state
@@ -548,12 +526,12 @@ void GameServer::frame(unsigned long timestamp)
if (zone && entity->flag_is_set(Entity::KeepAlive)) {
if (zone->keepalive_run() && zone->keepalive_box().inside(entity->location())) {
- entity->set_keepalive(server_timestamp);
+ entity->set_keepalive(this->timestamp());
}
// run upkeep if the keepalive timeout has elapsed
- if (entity->keepalive() + keepalive_timeout < server_timestamp) {
- entity->upkeep(server_timestamp);
+ if (entity->keepalive() + keepalive_timeout < this->timestamp()) {
+ entity->upkeep(this->timestamp());
}
}
}
@@ -619,7 +597,7 @@ void GameServer::frame(unsigned long timestamp)
if (server_network) {
// send network updates
- server_network->frame(server_timestamp);
+ server_network->frame(this->timestamp());
}
// remove deleted entities and mark remaining entities as updated