summaryrefslogtreecommitdiff
path: root/src/game-server/entity.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-09-19 15:43:18 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-09-19 16:54:32 +0200
commitcae44328f1f3ca9f7f13f9252d279231e3c8ef2a (patch)
tree5b31fecb2b3a76578d151fe7b6595eb8cb57deb4 /src/game-server/entity.cpp
parentdf8e8de0e0850d54992ae4fc8727cbe17527ccb5 (diff)
downloadmanaserv-cae44328f1f3ca9f7f13f9252d279231e3c8ef2a.tar.gz
manaserv-cae44328f1f3ca9f7f13f9252d279231e3c8ef2a.tar.bz2
manaserv-cae44328f1f3ca9f7f13f9252d279231e3c8ef2a.tar.xz
manaserv-cae44328f1f3ca9f7f13f9252d279231e3c8ef2a.zip
Have Lua use entity IDs instead of direct pointers
Allows to report access to removed entities instead of crashing.
Diffstat (limited to 'src/game-server/entity.cpp')
-rw-r--r--src/game-server/entity.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/game-server/entity.cpp b/src/game-server/entity.cpp
index b40ac442..15afc29d 100644
--- a/src/game-server/entity.cpp
+++ b/src/game-server/entity.cpp
@@ -21,7 +21,10 @@
#include "game-server/entity.h"
+IdManager<Entity> Entity::mIdManager;
+
Entity::Entity(EntityType type, MapComposite *map) :
+ mId(mIdManager.allocate(this)),
mMap(map),
mType(type)
{
@@ -33,6 +36,8 @@ Entity::~Entity()
{
for (int i = 0; i < ComponentTypeCount; ++i)
delete mComponents[i];
+
+ mIdManager.free(mId);
}
/**