diff options
author | andrew <xdotftw@gmail.com> | 2014-02-14 15:21:16 +0100 |
---|---|---|
committer | andrew <xdotftw@gmail.com> | 2014-02-14 15:21:16 +0100 |
commit | 5b92b877bcc0c5072dbea98b6c54106f954aa758 (patch) | |
tree | fa91320608d925cac74804fd44597198e2f3760e /src/World.cpp | |
parent | IDCount Serialization (diff) | |
download | cuberite-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 '')
-rw-r--r-- | src/World.cpp | 45 |
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(); |