summaryrefslogtreecommitdiffstats
path: root/src/MapManager.h
diff options
context:
space:
mode:
authorandrew <xdotftw@gmail.com>2014-02-20 15:38:37 +0100
committerandrew <xdotftw@gmail.com>2014-02-20 15:38:37 +0100
commitf201f4f176fc908e9ddebfed86d4c8ef5582556c (patch)
tree9cb6601cc1eeeab979c088faa66be52fe27e086e /src/MapManager.h
parentManual merge (Fixed conflicts) (diff)
downloadcuberite-f201f4f176fc908e9ddebfed86d4c8ef5582556c.tar
cuberite-f201f4f176fc908e9ddebfed86d4c8ef5582556c.tar.gz
cuberite-f201f4f176fc908e9ddebfed86d4c8ef5582556c.tar.bz2
cuberite-f201f4f176fc908e9ddebfed86d4c8ef5582556c.tar.lz
cuberite-f201f4f176fc908e9ddebfed86d4c8ef5582556c.tar.xz
cuberite-f201f4f176fc908e9ddebfed86d4c8ef5582556c.tar.zst
cuberite-f201f4f176fc908e9ddebfed86d4c8ef5582556c.zip
Diffstat (limited to '')
-rw-r--r--src/MapManager.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/MapManager.h b/src/MapManager.h
new file mode 100644
index 000000000..05673c694
--- /dev/null
+++ b/src/MapManager.h
@@ -0,0 +1,76 @@
+
+// MapManager.h
+
+
+
+
+
+#pragma once
+
+
+
+
+
+#include "Map.h"
+
+
+
+
+typedef cItemCallback<cMap> cMapCallback;
+
+
+
+
+
+/** Manages the in-game maps of a single world - Thread safe. */
+class cMapManager
+{
+public:
+
+ cMapManager(cWorld * a_World);
+
+ /** Returns the map with the specified ID, NULL if out of range.
+ *
+ * WARNING: The returned map object is not thread safe.
+ */
+ cMap * GetMapData(unsigned int a_ID);
+
+ /** Creates a new map. Returns NULL on error */
+ cMap * CreateMap(int a_CenterX, int a_CenterY, int a_Scale = 3);
+
+ /** Calls the callback for the map with the specified ID.
+ *
+ * Returns true if the map was found and the callback called, false if map not found.
+ * Callback return ignored.
+ */
+ bool DoWithMap(unsigned int a_ID, cMapCallback & a_Callback);
+
+ /** Calls the callback for each map.
+ *
+ * Returns true if all maps processed, false if the callback aborted by returning true.
+ */
+ bool ForEachMap(cMapCallback & a_Callback);
+
+ unsigned int GetNumMaps(void) const;
+
+ /** Loads the map data from the disk */
+ void LoadMapData(void);
+
+ /** Saves the map data to the disk */
+ void SaveMapData(void);
+
+
+private:
+
+ typedef std::vector<cMap> cMapList;
+
+ cCriticalSection m_CS;
+
+ cMapList m_MapData;
+
+ cWorld * m_World;
+
+};
+
+
+