summaryrefslogtreecommitdiff
path: root/src/game-server/map.h
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-10-19 23:55:30 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-10-19 23:55:30 +0200
commit8629addec23239b667295c68ee3061ebc4ca918d (patch)
tree067f2969ea12053e5636dbb6035def59c32b01a2 /src/game-server/map.h
parent77ea3d90114a7d6503d19e89ffaf2e548f63e420 (diff)
parent03ff7c110e536de1f8b239817e50cb07c492da6f (diff)
downloadmanaserv-8629addec23239b667295c68ee3061ebc4ca918d.tar.gz
manaserv-8629addec23239b667295c68ee3061ebc4ca918d.tar.bz2
manaserv-8629addec23239b667295c68ee3061ebc4ca918d.tar.xz
manaserv-8629addec23239b667295c68ee3061ebc4ca918d.zip
Merge branch 'master' of github.com:mana/manaserv
Conflicts: src/game-server/accountconnection.cpp
Diffstat (limited to 'src/game-server/map.h')
-rw-r--r--src/game-server/map.h63
1 files changed, 61 insertions, 2 deletions
diff --git a/src/game-server/map.h b/src/game-server/map.h
index 7c58d005..eca36863 100644
--- a/src/game-server/map.h
+++ b/src/game-server/map.h
@@ -26,11 +26,12 @@
#include <string>
#include <vector>
+#include "utils/logger.h"
#include "utils/point.h"
+#include "utils/string.h"
typedef std::list<Point> Path;
typedef Path::iterator PathIterator;
-
enum BlockType
{
BLOCKTYPE_NONE = -1,
@@ -59,6 +60,49 @@ class MetaTile
char blockmask; /**< walkability bitfield */
};
+class MapObject
+{
+ public:
+ MapObject(const Rectangle &bounds,
+ const std::string &name,
+ const std::string &type)
+ : mBounds(bounds),
+ mName(name),
+ mType(type)
+ { }
+
+ void addProperty(const std::string &key, const std::string &value)
+ {
+ if (mProperties.contains(key))
+ LOG_WARN("Duplicate property " << key <<
+ " of object " << mName);
+ else
+ mProperties.insert(key, value);
+ }
+
+ std::string getProperty(const std::string &key) const
+ { return mProperties.find(key); }
+
+ const std::string &getName() const
+ { return mName; }
+
+ const std::string &getType() const
+ { return mType; }
+
+ const Rectangle &getBounds() const
+ { return mBounds; }
+
+ int getX() const { return mBounds.x; }
+ int getY() const { return mBounds.y; }
+
+ private:
+ Rectangle mBounds;
+ std::string mName;
+ std::string mType;
+ utils::NameMap<std::string> mProperties;
+};
+
+
/**
* A tile map.
*/
@@ -71,6 +115,8 @@ class Map
Map(int width, int height,
int tileWidth, int tileHeight);
+ ~Map();
+
/**
* Sets the size of the map. This will destroy any existing map data.
*/
@@ -129,9 +175,21 @@ class Map
/**
* Sets a map property
*/
- void setProperty(const std::string& key, const std::string& val)
+ void setProperty(const std::string &key, const std::string &val)
{ mProperties[key] = val; }
+ /**
+ * Adds an object.
+ */
+ void addObject(MapObject *object)
+ { mMapObjects.push_back(object); }
+
+ /**
+ * Returns the objects of the map.
+ */
+ const std::vector<MapObject*> &getObjects() const
+ { return mMapObjects; }
+
/**
* Find a path from one location to the next.
*/
@@ -154,6 +212,7 @@ class Map
std::map<std::string, std::string> mProperties;
std::vector<MetaTile> mMetaTiles;
+ std::vector<MapObject*> mMapObjects;
};
#endif