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/clientstate.cc17
-rw-r--r--src/core/clientstate.h10
-rw-r--r--src/core/entity.cc5
-rw-r--r--src/core/gameinterface.cc12
-rw-r--r--src/core/gameserver.cc44
-rw-r--r--src/core/netserver.cc10
6 files changed, 59 insertions, 39 deletions
diff --git a/src/core/clientstate.cc b/src/core/clientstate.cc
index 57802fa..865c0bb 100644
--- a/src/core/clientstate.cc
+++ b/src/core/clientstate.cc
@@ -6,6 +6,7 @@
#include "core/clientstate.h"
#include "core/application.h"
+#include "sys/sys.h"
namespace core {
@@ -14,18 +15,24 @@ ClientState::ClientState()
state_visible = false;
state_detailvisible = false;
state_targetable = false;
- state_enginesound = 0;
- for (size_t i = 0; i < 3; i++)
- state_screenlocation[i] = 0;
+ state_enginesound = 0;
+ state_engine_trail_offset = 0;
state_fuzz = math::randomf();
- state_engine_trail_offset = 0;
}
ClientState::ClientState(Entity *entity)
{
- ClientState();
+ state_visible = false;
+ state_detailvisible = false;
+ state_targetable = false;
+
+ state_enginesound = 0;
+ state_engine_trail_offset = 0;
+
+ state_fuzz = math::randomf();
+
assign(entity);
}
diff --git a/src/core/clientstate.h b/src/core/clientstate.h
index 91cd3e1..42ead3d 100644
--- a/src/core/clientstate.h
+++ b/src/core/clientstate.h
@@ -29,13 +29,13 @@ public:
~ClientState();
- inline math::Vector3f const & location() { return state_location; }
+ inline math::Vector3f const & location() const { return state_location; }
- inline math::Vector3f const & previouslocation() { return state_previouslocation; }
+ inline math::Vector3f const & previouslocation() const { return state_previouslocation; }
- inline math::Axis const & previousaxis() { return state_previousaxis; }
+ inline math::Axis const & previousaxis() const { return state_previousaxis; }
- inline math::Axis const & axis() { return state_axis; }
+ inline math::Axis const & axis() const { return state_axis; }
inline bool visible() const { return state_visible; }
@@ -58,8 +58,6 @@ public:
math::Vector3f state_previouslocation;
math::Axis state_previousaxis;
- double state_screenlocation[3];
-
bool state_visible;
bool state_detailvisible;
bool state_targetable;
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 98fef0e..20e1b05 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -56,6 +56,7 @@ void Entity::erase(unsigned int id)
Registry::iterator it = entity_registry.find(id);
if (it != entity_registry.end()) {
delete((*it).second);
+ (*it).second = 0;
entity_registry.erase(it);
} else {
con_warn << "Could not erase entity " << id << "!\n";
@@ -171,8 +172,10 @@ Entity::Entity(std::istream & is)
Entity::~Entity()
{
- if (entity_clientstate)
+ if (entity_clientstate) {
delete entity_clientstate;
+ entity_clientstate = 0;
+ }
if (entity_zone)
entity_zone->remove(this);
diff --git a/src/core/gameinterface.cc b/src/core/gameinterface.cc
index 7833bf5..ecb58fc 100644
--- a/src/core/gameinterface.cc
+++ b/src/core/gameinterface.cc
@@ -83,18 +83,22 @@ void GameInterface::clear()
Zone::registry().clear();
// remove all game functions
- for (Func::Registry::iterator it = Func::registry().begin(); it != Func::registry().end(); it++) {
+ for (Func::Registry::iterator it = Func::registry().begin(); it != Func::registry().end();) {
if ( ((*it).second->flags() & Func::Game) == Func::Game) {
delete (*it).second;
- Func::registry().erase(it);
+ Func::registry().erase(it++);
+ } else {
+ ++it;
}
}
// remove all game cvars
- for (Cvar::Registry::iterator it = Cvar::registry().begin(); it != Cvar::registry().end(); it++) {
+ for (Cvar::Registry::iterator it = Cvar::registry().begin(); it != Cvar::registry().end(); ) {
if ( ((*it).second->flags() & Cvar::Game) == Cvar::Game) {
delete (*it).second;
- Cvar::registry().erase(it);
+ Cvar::registry().erase(it++);
+ } else {
+ ++it;
}
}
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index db8852a..53698c2 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -564,7 +564,7 @@ void GameServer::frame(float seconds)
server_network->broadcast_frame(server_time, server_previoustime);
// send changes in the world
- for (Entity::Registry::iterator it=Entity::registry().begin(); it != Entity::registry().end(); it++) {
+ for (Entity::Registry::iterator it=Entity::registry().begin(); it != Entity::registry().end(); ) {
Entity *entity = (*it).second;
@@ -574,19 +574,24 @@ void GameServer::frame(float seconds)
server_network->broadcast_entity_delete(entity);
}
- core::Entity::erase(entity->id());
+ delete entity;
+ (*it).second = entity = 0;
+ Entity::registry().erase(it++);
- } else if (entity->entity_created) {
-
- server_network->broadcast_entity_create(entity);
- entity->entity_created = false;
-
- } else if (entity->dirty()) {
-
- server_network->broadcast_entity_update(entity);
+ } else {
+ if (entity->entity_created) {
+
+ server_network->broadcast_entity_create(entity);
+ entity->entity_created = false;
+ entity->entity_dirty = false;
+
+ } else if (entity->dirty()) {
+
+ server_network->broadcast_entity_update(entity);
+ entity->entity_dirty = false;
+ }
+ ++it;
}
-
- entity->entity_dirty = false;
}
// update player info
@@ -598,17 +603,18 @@ void GameServer::frame(float seconds)
} else {
// local update stub
- for (Entity::Registry::iterator it=Entity::registry().begin(); it != Entity::registry().end(); it++) {
-
+ for (Entity::Registry::iterator it=Entity::registry().begin(); it != Entity::registry().end(); ) {
Entity *entity = (*it).second;
- if (entity->entity_destroyed) {
- Entity::erase(entity->id());
- } else if (entity->entity_created) {
+ if (entity->entity_destroyed) {
+ delete entity;
+ (*it).second = entity = 0;
+ Entity::registry().erase(it++);
+ } else {
entity->entity_created = false;
-
+ entity->entity_dirty = false;
+ ++it;
}
- entity->entity_dirty = false;
}
}
diff --git a/src/core/netserver.cc b/src/core/netserver.cc
index 10fd554..dd5dc38 100644
--- a/src/core/netserver.cc
+++ b/src/core/netserver.cc
@@ -125,7 +125,7 @@ void NetServer::abort() {
// remove disconnected clients
void NetServer::reap()
{
- for (Clients:: iterator it = clients.begin(); it != clients.end(); it++) {
+ for (Clients:: iterator it = clients.begin(); it != clients.end(); ) {
NetClient *client = *it;
if (client->client_timeout + NETTIMEOUT < application()->time()) {
@@ -151,10 +151,12 @@ void NetServer::reap()
server()->player_disconnect((*it)->player());
// remove the client
- clients.erase(it);
delete client;
- it=clients.begin();
- }
+ clients.erase(it++);
+
+ } else {
+ ++it;
+ }
}
}