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-08-24 21:36:39 +0000
committerStijn Buys <ingar@osirion.org>2008-08-24 21:36:39 +0000
commite6272cd7d356bbb047dcaebb03ae217235e1e13f (patch)
tree7c7c6551a2d7051d10b0c4f0c4d87554365c63de /src/core
parent9c4d134ab304794b755139e90ca6da9de73a1e9a (diff)
afterburner/reverse/strafe
Diffstat (limited to 'src/core')
-rw-r--r--src/core/application.cc2
-rw-r--r--src/core/entity.cc30
-rw-r--r--src/core/entity.h15
-rw-r--r--src/core/gameserver.cc55
-rw-r--r--src/core/gameserver.h2
-rw-r--r--src/core/net.h2
6 files changed, 103 insertions, 3 deletions
diff --git a/src/core/application.cc b/src/core/application.cc
index 49c61d7..21d5e50 100644
--- a/src/core/application.cc
+++ b/src/core/application.cc
@@ -348,11 +348,13 @@ void Application::save_config()
ofs << "# server.cfg - osiriond dedicated server configuration" << std::endl;
ofs << "# this file is automaticly generated" << std::endl;
+ ofs << std::endl;
for (Cvar::Registry::iterator it = Cvar::registry().begin(); it != Cvar::registry().end(); it++) {
if (((*it).second->flags() & Cvar::Archive) == Cvar::Archive) {
ofs << "# " << (*it).first << " " << (*it).second->info() << std::endl;
ofs << "set " << (*it).first << " " << (*it).second->str() << std::endl;
+ ofs << std::endl;
}
}
ofs.close();
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 04ede71..99462b8 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -376,6 +376,8 @@ EntityControlable::EntityControlable(Player *owner, unsigned int flags) :
target_thrust = 0.0f;
target_pitch = 0.0f;
target_roll = 0.0f;
+ target_strafe = 0.0f;
+ target_afterburner = 0.0f;
entity_owner = 0;
if (owner)
@@ -391,6 +393,8 @@ EntityControlable::EntityControlable(std::istream & is) :
target_thrust = 0.0f;
target_pitch = 0.0f;
target_roll = 0.0f;
+ target_strafe = 0.0f;
+ target_afterburner = 0.0f;
entity_owner = 0;
}
@@ -429,6 +433,8 @@ void EntityControlable::serialize_client_update(std::ostream & os) const
os << target_pitch << " ";
os << target_thrust << " ";
os << target_roll << " ";
+ os << target_strafe << " ";
+ os << target_afterburner << " ";
}
void EntityControlable::receive_client_update(std::istream &is)
@@ -438,6 +444,8 @@ void EntityControlable::receive_client_update(std::istream &is)
is >> target_pitch;
is >> target_thrust;
is >> target_roll;
+ is >> target_strafe;
+ is >> target_afterburner;
}
void EntityControlable::serialize_server_update(std::ostream & os) const
@@ -505,6 +513,28 @@ void EntityControlable::set_roll(float roll)
}
}
+void EntityControlable::set_strafe(float strafe)
+{
+ if ((flags() & Static) == Static)
+ return;
+
+ if (target_strafe != strafe) {
+ target_strafe = strafe;
+ entity_dirty = true;
+ }
+}
+
+void EntityControlable::set_afterburner(float afterburner)
+{
+ if ((flags() & Static) == Static)
+ return;
+
+ if (target_afterburner != afterburner) {
+ target_afterburner = afterburner;
+ entity_dirty = true;
+ }
+}
+
/*----- EntityGlobe ------------------------------------------------ */
EntityGlobe::EntityGlobe(unsigned int flags) :
diff --git a/src/core/entity.h b/src/core/entity.h
index 8a996fd..6214d50 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -342,9 +342,15 @@ public:
/// set the target pitch
void set_pitch(float pitch);
- /// set target roll
+ /// set target roll
void set_roll(float roll);
+ /// set target strafe
+ void set_strafe(float strage);
+
+ /// set afterburner/reverse
+ void set_afterburner(float afterburner);
+
/// runs one game frame for the entity
/**
* The default implementation will set direction() and thrust() to the desired targets
@@ -355,6 +361,7 @@ public:
/// current thrust
float entity_thrust;
+protected:
/* target_ variables can be set by the client */
/// target thrust as set by the client
float target_thrust;
@@ -369,7 +376,11 @@ public:
/// target roll as set by the client
/** target_roll must be in the [-1, 1] range
*/
- float target_roll;
+ float target_roll;
+
+ float target_afterburner;
+
+ float target_strafe;
private:
// owner of the entity
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index fce758e..ea97eaf 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -5,6 +5,7 @@
*/
#include <iomanip>
+#include <fstream>
#include "auxiliary/functions.h"
#include "sys/sys.h"
@@ -13,6 +14,7 @@
#include "core/func.h"
#include "core/gameserver.h"
#include "core/netserver.h"
+#include "filesystem/filesystem.h"
namespace core
{
@@ -119,6 +121,8 @@ GameServer::GameServer() : GameInterface()
return;
}
+ load_config();
+
// set the name of the game
core::Cvar::set("g_name", server_module->name().c_str(), core::Cvar::Game | core::Cvar::ReadOnly);
@@ -190,6 +194,8 @@ GameServer::~GameServer()
server_network = 0;
}
+ save_config();
+
if (server_module) {
if (server_module->running() && !Cvar::sv_dedicated->value())
player_disconnect(localplayer());
@@ -583,5 +589,54 @@ void GameServer::frame(float seconds)
server_previoustime = server_time;
}
+void GameServer::save_config()
+{
+ std::string filename(filesystem::writedir());
+ filename.append("game.cfg");
+ std::ofstream ofs(filename.c_str());
+
+ if (!ofs.is_open()) {
+ con_warn << "Could not write " << filename << std::endl;
+ return;
+ }
+
+ con_print << " writing configuration to " << filename << std::endl;
+
+ ofs << "# game.cfg - " << server_module->name() << " configuration" << std::endl;
+ ofs << "# this file is automaticly generated" << std::endl;
+ ofs << std::endl;
+
+ for (Cvar::Registry::iterator it = Cvar::registry().begin(); it != Cvar::registry().end(); it++) {
+ if ((((*it).second->flags() & Cvar::Archive) == Cvar::Archive) && (((*it).second->flags() & Cvar::Game) == Cvar::Game)){
+ ofs << "# " << (*it).first << " " << (*it).second->info() << std::endl;
+ ofs << "set " << (*it).first << " " << (*it).second->str() << std::endl;
+ ofs << std::endl;
+ }
+ }
+ ofs.close();
+}
+
+void GameServer::load_config()
+{
+ std::string filename(filesystem::writedir());
+ filename.append("game.cfg");
+ std::ifstream ifs(filename.c_str(), std::ifstream::in);
+
+ if (!ifs.is_open()) {
+ con_warn << "Could not read " << filename << std::endl;
+ return;
+ }
+
+ con_print << " reading configuration from " << filename << std::endl;
+
+ char line[MAXCMDSIZE];
+ while (ifs.getline(line, MAXCMDSIZE-1)) {
+ if (line[0] && line[0] != '#' && line[0] != ';')
+ cmd() << line << '\n';
+ }
+
+ // execute commands in the buffer
+ CommandBuffer::exec();
+}
}
diff --git a/src/core/gameserver.h b/src/core/gameserver.h
index 98938fa..1f6d8cc 100644
--- a/src/core/gameserver.h
+++ b/src/core/gameserver.h
@@ -93,6 +93,8 @@ protected:
void abort();
private:
+ void load_config();
+ void save_config();
bool server_running;
Module *server_module;
static GameServer *server_instance;
diff --git a/src/core/net.h b/src/core/net.h
index d5a95a9..c96ec7e 100644
--- a/src/core/net.h
+++ b/src/core/net.h
@@ -11,7 +11,7 @@ namespace core
{
/// network protocol version
-const unsigned int PROTOCOLVERSION = 7;
+const unsigned int PROTOCOLVERSION = 8;
/// maximum lenght of a (compressed) network message block
const unsigned int FRAMESIZE = 1152;