summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
authorandrew <xdotftw@gmail.com>2014-02-14 15:21:16 +0100
committerandrew <xdotftw@gmail.com>2014-02-14 15:21:16 +0100
commit5b92b877bcc0c5072dbea98b6c54106f954aa758 (patch)
treefa91320608d925cac74804fd44597198e2f3760e /src/World.cpp
parentIDCount Serialization (diff)
downloadcuberite-5b92b877bcc0c5072dbea98b6c54106f954aa758.tar
cuberite-5b92b877bcc0c5072dbea98b6c54106f954aa758.tar.gz
cuberite-5b92b877bcc0c5072dbea98b6c54106f954aa758.tar.bz2
cuberite-5b92b877bcc0c5072dbea98b6c54106f954aa758.tar.lz
cuberite-5b92b877bcc0c5072dbea98b6c54106f954aa758.tar.xz
cuberite-5b92b877bcc0c5072dbea98b6c54106f954aa758.tar.zst
cuberite-5b92b877bcc0c5072dbea98b6c54106f954aa758.zip
Diffstat (limited to 'src/World.cpp')
-rw-r--r--src/World.cpp45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/World.cpp b/src/World.cpp
index a308778df..2a3e53332 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -1554,6 +1554,42 @@ bool cWorld::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlock
+cMap * cWorld::GetMapData(unsigned int a_ID)
+{
+ if (a_ID < m_MapData.size())
+ {
+ return &m_MapData[a_ID];
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+
+
+
+
+cMap * cWorld::CreateMap(int a_CenterX, int a_CenterY, int a_Scale)
+{
+ if (m_MapData.size() >= 65536)
+ {
+ LOGD("cWorld::CreateMap - Too many maps in use");
+
+ return NULL;
+ }
+
+ cMap Map(m_MapData.size(), a_CenterX, a_CenterY, this, a_Scale);
+
+ m_MapData.push_back(Map);
+
+ return &m_MapData[Map.GetID()];
+}
+
+
+
+
+
void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed, bool IsPlayerCreated)
{
MTRand r1;
@@ -2958,7 +2994,7 @@ void cWorld::LoadMapData(void)
IDSerializer.Load();
- unsigned int MapCount = IDSerializer.GetMapCount();
+ unsigned int MapCount = IDSerializer.GetMapCount() + 1;
m_MapData.clear();
@@ -2980,9 +3016,14 @@ void cWorld::LoadMapData(void)
void cWorld::SaveMapData(void)
{
+ if (m_MapData.empty())
+ {
+ return;
+ }
+
cIDCountSerializer IDSerializer(GetName());
- IDSerializer.SetMapCount(m_MapData.size());
+ IDSerializer.SetMapCount(m_MapData.size() - 1);
IDSerializer.Save();