diff options
Diffstat (limited to 'src/game-server/mapcomposite.cpp')
-rw-r--r-- | src/game-server/mapcomposite.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/game-server/mapcomposite.cpp b/src/game-server/mapcomposite.cpp index e00407ff..deb43b4e 100644 --- a/src/game-server/mapcomposite.cpp +++ b/src/game-server/mapcomposite.cpp @@ -285,6 +285,8 @@ struct MapContent */ void deallocate(Entity *); + Entity *findEntityById(int publicId) const; + /** * Fills a region of zones within the range of a point. */ @@ -396,6 +398,19 @@ void MapContent::deallocate(Entity *obj) buckets[id / 256]->deallocate(id % 256); } +/** + * Returns the entity matching \a publicId, or null if no such entity exists. + */ +Entity *MapContent::findEntityById(int publicId) const +{ + if (ObjectBucket *b = buckets[publicId / 256]) { + const int bucketIndex = publicId % 256; + if (b->isAllocated(bucketIndex)) + return b->objects[bucketIndex]; + } + return 0; +} + static void addZone(MapRegion &r, unsigned z) { MapRegion::iterator i_end = r.end(), @@ -725,6 +740,11 @@ void MapComposite::remove(Entity *ptr) } } +Entity *MapComposite::findEntityById(int publicId) const +{ + return mContent->findEntityById(publicId); +} + void MapComposite::update() { // Update object status |