From e1d812498314873fab6153e24d5bf26c80868f1f Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 23 Jul 2011 21:14:36 +0000 Subject: [PATCH] core: Dict::RemoveSlot can now directly remove an Entity. --- src/dict.cpp | 13 +++++++++++++ src/dict.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/dict.cpp b/src/dict.cpp index ce75aeb1..469e0d30 100644 --- a/src/dict.cpp +++ b/src/dict.cpp @@ -134,6 +134,19 @@ void Dict::RemoveSlot(int id) } } +void Dict::RemoveSlot(Entity *entity) +{ + for (int id = 0; id < data->maxid; id++) + if (data->entities[id] == entity) + { + RemoveSlot(id); + return; + } + +#if !LOL_RELEASE + Log::Error("removing unregistered entity %p\n", entity); +#endif +} void Dict::SetEntity(int id, Entity *entity) { diff --git a/src/dict.h b/src/dict.h index 3c94b3e1..a4fc4820 100644 --- a/src/dict.h +++ b/src/dict.h @@ -31,6 +31,7 @@ public: int MakeSlot(char const *name); void RemoveSlot(int id); + void RemoveSlot(Entity *entity); void SetEntity(int id, Entity *entity); Entity *GetEntity(int id);