From 13f946689e28e99ac71172925f63f4320798a0ee Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 5 Mar 2018 16:07:07 -0500 Subject: Added entity indexing Changed the world format so that map objects are indexed (per map). The next available map object index is cached for each map. --- tools/mapedit/src/object.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'tools/mapedit/src/object.cpp') diff --git a/tools/mapedit/src/object.cpp b/tools/mapedit/src/object.cpp index 8ed29af..aeb8fc1 100644 --- a/tools/mapedit/src/object.cpp +++ b/tools/mapedit/src/object.cpp @@ -184,9 +184,15 @@ bool MapObject::operator!=(const MapObject& other) const return id != other.id; } -MapObjectEntry::MapObjectEntry(const MapObject& object, int posx, int posy) : object(object) +MapObjectEntry::MapObjectEntry( + const MapObject& object, + int posx, + int posy, + size_t index) : + object(object), + position(std::make_pair(posx, posy)), + index(index) { - position = std::make_pair(posx, posy); } const MapObject& MapObjectEntry::getObject() const @@ -209,6 +215,11 @@ const std::map& MapObjectEntry::getItems() co return items; } +size_t MapObjectEntry::getIndex() const +{ + return index; +} + void MapObjectEntry::addItem(std::string id, Item& item) { items[id] = item; -- cgit 1.4.1