1
0
Fork 0
cuberite-2a/src/MapManager.h

73 lines
1.3 KiB
C
Raw Normal View History

2014-02-20 14:38:37 +00:00
// MapManager.h
#pragma once
#include "Map.h"
typedef cItemCallback<cMap> cMapCallback;
2014-02-23 10:55:55 +00:00
// tolua_begin
2014-02-20 14:38:37 +00:00
/** Manages the in-game maps of a single world - Thread safe. */
class cMapManager
{
public:
2014-02-23 10:55:55 +00:00
// tolua_end
2014-02-20 14:38:37 +00:00
cMapManager(cWorld * a_World);
2014-10-20 20:55:07 +00:00
/** Returns the map with the specified ID, nullptr if out of range.
2015-03-21 14:18:17 +00:00
WARNING: The returned map object is not thread safe. */
2014-02-20 14:38:37 +00:00
cMap * GetMapData(unsigned int a_ID);
2014-10-20 20:55:07 +00:00
/** Creates a new map. Returns nullptr on error */
2014-02-20 14:38:37 +00:00
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.
2015-03-21 14:18:17 +00:00
Callback return value is ignored. */
bool DoWithMap(UInt32 a_ID, cMapCallback & a_Callback); // Exported in ManualBindings.cpp
2014-02-20 14:38:37 +00:00
/** Calls the callback for each map.
2015-03-21 14:18:17 +00:00
Returns true if all maps processed, false if the callback aborted by returning true. */
2014-02-20 14:38:37 +00:00
bool ForEachMap(cMapCallback & a_Callback);
size_t GetNumMaps(void) const; // tolua_export
2014-02-20 14:38:37 +00:00
/** 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;
}; // tolua_export
2014-02-20 14:38:37 +00:00