Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/application.cc3
-rw-r--r--src/core/cvar.cc3
-rw-r--r--src/core/cvar.h3
-rw-r--r--src/core/entity.cc14
-rw-r--r--src/core/entity.h2
-rw-r--r--src/core/gameconnection.cc24
-rw-r--r--src/core/gameinterface.cc9
-rw-r--r--src/core/parser.cc7
-rw-r--r--src/core/physics.cc16
-rw-r--r--src/core/physics.h3
-rw-r--r--src/core/player.cc12
-rw-r--r--src/core/player.h28
12 files changed, 103 insertions, 21 deletions
diff --git a/src/core/application.cc b/src/core/application.cc
index 15179c9..dc08595 100644
--- a/src/core/application.cc
+++ b/src/core/application.cc
@@ -149,6 +149,9 @@ void Application::init(int count, char **arguments)
Cvar::net_framerate = Cvar::get("net_framerate", "25");
Cvar::net_framerate->set_info("[int] network framerate in frames/sec");
+
+ Cvar::mem_vertex = core::Cvar::get("mem_vertex", "64" , core::Cvar::Archive);
+ Cvar::mem_vertex->set_info("[int] amount of video memory reserved for model geometry, in megabytes");
#ifdef _WIN32
Cvar::con_ansi = Cvar::get("con_ansi", "0", Cvar::Archive);
diff --git a/src/core/cvar.cc b/src/core/cvar.cc
index bbdf395..100f31f 100644
--- a/src/core/cvar.cc
+++ b/src/core/cvar.cc
@@ -24,7 +24,6 @@ Cvar *Cvar::sv_framerate = 0;
Cvar *Cvar::sv_name = 0;
Cvar *Cvar::sv_description = 0;
Cvar *Cvar::sv_password = 0;
-Cvar *Cvar::sv_arraysize = 0;
Cvar *Cvar::sv_keepalive = 0;
Cvar *Cvar::net_host = 0;
@@ -33,6 +32,8 @@ Cvar *Cvar::net_maxclients = 0;
Cvar *Cvar::net_timeout = 0;
Cvar *Cvar::net_framerate = 0;
+Cvar *Cvar::mem_vertex = 0;
+
Cvar::Registry Cvar::cvar_registry;
Cvar::Cvar(const char* name, const unsigned int flags) : cvar_name(name), cvar_info(), cvar_str()
diff --git a/src/core/cvar.h b/src/core/cvar.h
index 2487adc..4c55fad 100644
--- a/src/core/cvar.h
+++ b/src/core/cvar.h
@@ -155,7 +155,6 @@ public:
static Cvar *sv_name; // server name
static Cvar *sv_description; // server description
static Cvar *sv_password; // server rcon password
- static Cvar *sv_arraysize; // vertex array size in MegaBytes
static Cvar *sv_keepalive; // entity keepalive timeout
static Cvar *con_ansi; // console ANSI colors
@@ -167,6 +166,8 @@ public:
static Cvar *net_timeout; // network timeout in seconds
static Cvar *net_framerate; // client network send framerate
+ static Cvar *mem_vertex; // amount of video memory reserved for model geometry, in megabytes
+
private:
std::string cvar_name;
std::string cvar_info;
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 4c7b0da..9275477 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -508,7 +508,19 @@ void Entity::reset()
// create collision shape
if (model() && model()->radius()) {
const float modelscale = radius() / model()->radius();
- entity_collision_shape = new btBoxShape(to_btVector3(model()->box().max() * modelscale));
+
+ if (flag_is_set(Complex) && model()->collisionmesh()) {
+ // use collision mesh
+ btBvhTriangleMeshShape *mesh = new btBvhTriangleMeshShape(model()->collisionmesh()->triangles(), true, true);
+ entity_collision_shape = mesh;
+
+ btVector3 modelscalevec(modelscale, modelscale, modelscale);
+ mesh->setLocalScaling(modelscalevec);
+
+ } else {
+ // use bounding box
+ entity_collision_shape = new btBoxShape(to_btVector3(model()->box().max() * modelscale));
+ }
} else {
entity_collision_shape = new btSphereShape(radius());
}
diff --git a/src/core/entity.h b/src/core/entity.h
index 2d79132..378a71a 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -44,7 +44,7 @@ public:
/**
* @brief entity flags
*/
- enum Flags {NonSolid = 2, Bright = 4, Dockable = 8, ShowOnMap = 16, KeepAlive = 32};
+ enum Flags {NonSolid = 2, Bright = 4, Dockable = 8, ShowOnMap = 16, KeepAlive = 32, Complex = 64};
/// Entity type constants
enum Type {Default = 0, Dynamic = 1, Controlable = 2, Globe = 3};
diff --git a/src/core/gameconnection.cc b/src/core/gameconnection.cc
index ba18bd5..982ac7d 100644
--- a/src/core/gameconnection.cc
+++ b/src/core/gameconnection.cc
@@ -8,6 +8,7 @@
#include <sstream>
#include "sys/sys.h"
+#include "filesystem/filesystem.h"
#include "core/cvar.h"
#include "core/gameconnection.h"
#include "core/net.h"
@@ -62,7 +63,28 @@ GameConnection::GameConnection(std::string const &connectionstr)
game_players.push_back(localplayer());
set_playerlist_timestamp(timestamp());
-
+
+ // generate player GUID
+ // we do it here because offline play doesn't require it
+ if (!localplayer()->guid().size()) {
+
+ // read keys.ini
+
+ // write keys.ini
+ std::string filename(filesystem::homedir());
+ filename.append("keys.ini");
+
+ std::ofstream ofs(filename.c_str());
+ if (!ofs.is_open()) {
+ con_warn << "Could not write " << filename << std::endl;
+ } else {
+ ofs << "; keys.ini - osirion client identification" << std::endl;
+ ofs << "; DO NOT EDIT OR DELETE THIS FILE" << std::endl;
+ ofs << "; If you do you will not be able to use existing characters on a remote server" << std::endl;
+ ofs.close();
+ }
+ }
+
connection_running = true;
}
diff --git a/src/core/gameinterface.cc b/src/core/gameinterface.cc
index 23018d3..0a485bc 100644
--- a/src/core/gameinterface.cc
+++ b/src/core/gameinterface.cc
@@ -70,18 +70,13 @@ GameInterface::GameInterface()
Func *func = Func::add("list_players", func_list_players);
func->set_info("get the local list of connected players");
- // size of the vertex array in megabytes
- Cvar::sv_arraysize = core::Cvar::get("sv_arraysize", 128.0f , core::Cvar::Archive);
- Cvar::sv_arraysize->set_info("[int] size of the vertex array in megabyte");
-
- size_t mb = (size_t) Cvar::sv_arraysize->value();
+ size_t mb = (size_t) Cvar::mem_vertex->value();
if (mb < 4 * sizeof(float))
mb = 4 * sizeof(float);
if (mb > 512)
mb = 512;
- (*Cvar::sv_arraysize) = (float) mb;
+ (*Cvar::mem_vertex) = (float) mb;
game_vertexarray = new model::VertexArray(mb);
-
}
GameInterface::~GameInterface()
diff --git a/src/core/parser.cc b/src/core/parser.cc
index aa159bc..b210cdd 100644
--- a/src/core/parser.cc
+++ b/src/core/parser.cc
@@ -72,6 +72,13 @@ bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity)
entity->unset_flag(Entity::ShowOnMap);
return true;
+ } else if (inifile.got_key_bool("complex", blnval)) {
+ if (blnval)
+ entity->set_flag(Entity::Complex);
+ else
+ entity->unset_flag(Entity::Complex);
+ return true;
+
} else if (inifile.got_key_bool("nonsolid", blnval)) {
if (blnval)
entity->set_flag(Entity::NonSolid);
diff --git a/src/core/physics.cc b/src/core/physics.cc
index 4dadf07..6969b06 100644
--- a/src/core/physics.cc
+++ b/src/core/physics.cc
@@ -4,19 +4,22 @@
the terms and conditions of the GNU General Public License version 2
*/
+#include "model/collisionmesh.h"
#include "core/physics.h"
#include "core/zone.h"
namespace core {
-btDefaultCollisionConfiguration *Physics::physics_configuration;
-btCollisionDispatcher *Physics::physics_dispatcher;
-btSequentialImpulseConstraintSolver *Physics::physics_solver;
-unsigned long Physics::physics_timestamp;
+btDefaultCollisionConfiguration *Physics::physics_configuration = 0;
+btCollisionDispatcher *Physics::physics_dispatcher = 0;
+btSequentialImpulseConstraintSolver *Physics::physics_solver = 0;
+unsigned long Physics::physics_timestamp = 0;
void Physics::init()
{
con_print << "^BInitializing physics engine..." << std::endl;
+
+ model::CollisionMesh::init();
physics_configuration = new btDefaultCollisionConfiguration();
physics_dispatcher = new btCollisionDispatcher(physics_configuration);
@@ -27,7 +30,10 @@ void Physics::init()
void Physics::done()
{
- con_print << "^Bshutting down physics engine..." << std::endl;
+ con_print << "^BShutting down physics engine..." << std::endl;
+
+ model::CollisionMesh::shutdown();
+
delete physics_solver;
delete physics_dispatcher;
delete physics_configuration;
diff --git a/src/core/physics.h b/src/core/physics.h
index ecceb67..3237c3a 100644
--- a/src/core/physics.h
+++ b/src/core/physics.h
@@ -10,6 +10,8 @@
#include "sys/sys.h"
#include "math/vector3f.h"
#include "math/axis.h"
+#include "core/cvar.h"
+#include "model/collisionmesh.h"
#include "btBulletDynamicsCommon.h"
#include "BulletCollision/CollisionShapes/btTriangleMesh.h"
@@ -46,6 +48,7 @@ private:
static btSequentialImpulseConstraintSolver *physics_solver;
static unsigned long physics_timestamp;
+
};
} // namespace core
diff --git a/src/core/player.cc b/src/core/player.cc
index e048b91..f183a4c 100644
--- a/src/core/player.cc
+++ b/src/core/player.cc
@@ -42,6 +42,8 @@ void Player::clear()
player_ping = 0;
player_level = 1;
player_warningtime = 0;
+
+ player_admin_level = 0;
}
@@ -136,6 +138,16 @@ void Player::set_level(const int level)
player_level = level;
}
+void Player::set_admin_level(const int admin_level)
+{
+ player_admin_level = admin_level;
+}
+
+void Player::set_guid(const std::string & guid)
+{
+ player_guid.assign(guid);
+}
+
void Player::update_info()
{
Cvar *cl_name = Cvar::find("cl_name");
diff --git a/src/core/player.h b/src/core/player.h
index 20a3b2d..dbcc161 100644
--- a/src/core/player.h
+++ b/src/core/player.h
@@ -117,6 +117,16 @@ public:
const int level() const {
return player_level;
}
+
+ /// player admin level
+ const int admin_level() const {
+ return player_admin_level;
+ }
+
+ /// player global unique id
+ const std::string & guid() const {
+ return player_guid;
+ }
/*----- messages -------------------------------------------------- */
@@ -140,7 +150,6 @@ public:
return player_warningtime;
}
-
/*----- mutators -------------------------------------------------- */
/// serialize player info to a stream
@@ -208,7 +217,12 @@ public:
/// set the player level
void set_level(const int level);
-
+
+ /// set the admin level
+ void set_admin_level(const int admin_level);
+
+ void set_guid(const std::string & guid);
+
/// set the dirty bit
inline void set_dirty(const bool dirty = true) {
player_dirty = dirty;
@@ -252,10 +266,16 @@ private:
Zone *player_zone;
long player_credits;
+ // in-game level
+ int player_level;
+
long player_ping;
std::string player_rconpassword;
- int player_level;
-
+ int player_admin_level;
+
+ // global unique id
+ std::string player_guid;
+
// dirty bit
bool player_dirty;
// bit to indicate zone has changed