diff options
author | andrew <xdotftw@gmail.com> | 2014-02-23 14:03:40 +0100 |
---|---|---|
committer | andrew <xdotftw@gmail.com> | 2014-02-23 14:05:03 +0100 |
commit | f47187394572027cbfa07884cba2f54eaa6972ec (patch) | |
tree | 1f87d8d3f350b1d0c3faf5963c2ad74482ac3174 /src | |
parent | Manually exported DoWithMap (diff) | |
download | cuberite-f47187394572027cbfa07884cba2f54eaa6972ec.tar cuberite-f47187394572027cbfa07884cba2f54eaa6972ec.tar.gz cuberite-f47187394572027cbfa07884cba2f54eaa6972ec.tar.bz2 cuberite-f47187394572027cbfa07884cba2f54eaa6972ec.tar.lz cuberite-f47187394572027cbfa07884cba2f54eaa6972ec.tar.xz cuberite-f47187394572027cbfa07884cba2f54eaa6972ec.tar.zst cuberite-f47187394572027cbfa07884cba2f54eaa6972ec.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Items/ItemEmptyMap.h | 2 | ||||
-rw-r--r-- | src/Items/ItemMap.h | 2 | ||||
-rw-r--r-- | src/Map.cpp | 12 | ||||
-rw-r--r-- | src/Map.h | 2 | ||||
-rw-r--r-- | src/World.cpp | 6 | ||||
-rw-r--r-- | src/World.h | 9 | ||||
-rw-r--r-- | src/WorldStorage/MapSerializer.h | 6 |
7 files changed, 26 insertions, 13 deletions
diff --git a/src/Items/ItemEmptyMap.h b/src/Items/ItemEmptyMap.h index b06cf9d13..db28511f3 100644 --- a/src/Items/ItemEmptyMap.h +++ b/src/Items/ItemEmptyMap.h @@ -41,7 +41,7 @@ public: int CenterX = round(a_Player->GetPosX() / (float) RegionWidth) * RegionWidth; int CenterZ = round(a_Player->GetPosZ() / (float) RegionWidth) * RegionWidth; - cMap * NewMap = a_World->CreateMap(CenterX, CenterZ, DEFAULT_SCALE); + cMap * NewMap = a_World->GetMapManager().CreateMap(CenterX, CenterZ, DEFAULT_SCALE); // Remove empty map from inventory if (!a_Player->GetInventory().RemoveOneEquippedItem()) diff --git a/src/Items/ItemMap.h b/src/Items/ItemMap.h index 9bb16b189..e8ff9da88 100644 --- a/src/Items/ItemMap.h +++ b/src/Items/ItemMap.h @@ -29,7 +29,7 @@ public: virtual void OnUpdate(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item) { - cMap * Map = a_World->GetMapData(a_Item.m_ItemDamage); + cMap * Map = a_World->GetMapManager().GetMapData(a_Item.m_ItemDamage); if (Map == NULL) { diff --git a/src/Map.cpp b/src/Map.cpp index e89fad8b0..2b8c4c74c 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -344,13 +344,19 @@ void cMap::UpdateDecorators(void) -void cMap::AddPlayer(cPlayer * a_Player, cClientHandle * a_Handle, Int64 a_WorldAge) +void cMap::AddPlayer(cPlayer * a_Player, Int64 a_WorldAge) { + cClientHandle * Handle = a_Player->GetClientHandle(); + if (Handle == NULL) + { + return; + } + cMapClient MapClient; MapClient.m_LastUpdate = a_WorldAge; MapClient.m_SendInfo = true; - MapClient.m_Handle = a_Handle; + MapClient.m_Handle = Handle; m_Clients.push_back(MapClient); @@ -470,7 +476,7 @@ void cMap::UpdateClient(cPlayer * a_Player) } // New player, construct a new client state - AddPlayer(a_Player, Handle, WorldAge); + AddPlayer(a_Player, WorldAge); } @@ -226,7 +226,7 @@ private: bool UpdatePixel(unsigned int a_X, unsigned int a_Z); /** Add a new map client. */ - void AddPlayer(cPlayer * a_Player, cClientHandle * a_Handle, Int64 a_WorldAge); + void AddPlayer(cPlayer * a_Player, Int64 a_WorldAge); /** Remove inactive or invalid clients. */ void RemoveInactiveClients(Int64 a_WorldAge); diff --git a/src/World.cpp b/src/World.cpp index 01fdae697..4870e7d6e 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -233,7 +233,6 @@ void cWorld::cTickThread::Execute(void) // cWorld: cWorld::cWorld(const AString & a_WorldName) : - cMapManager(this), m_WorldName(a_WorldName), m_IniFileName(m_WorldName + "/world.ini"), m_StorageSchema("Default"), @@ -254,6 +253,7 @@ cWorld::cWorld(const AString & a_WorldName) : m_bCommandBlocksEnabled(false), m_bUseChatPrefixes(true), m_Scoreboard(this), + m_MapManager(this), m_GeneratorCallbacks(*this), m_TickThread(*this) { @@ -265,7 +265,7 @@ cWorld::cWorld(const AString & a_WorldName) : cScoreboardSerializer Serializer(m_WorldName, &m_Scoreboard); Serializer.Load(); - LoadMapData(); + m_MapManager.LoadMapData(); } @@ -289,7 +289,7 @@ cWorld::~cWorld() cScoreboardSerializer Serializer(m_WorldName, &m_Scoreboard); Serializer.Save(); - SaveMapData(); + m_MapManager.SaveMapData(); delete m_ChunkMap; } diff --git a/src/World.h b/src/World.h index f05ea9b2a..4b74f7aba 100644 --- a/src/World.h +++ b/src/World.h @@ -71,8 +71,7 @@ typedef cItemCallback<cMobHeadEntity> cMobHeadBlockCallback; class cWorld : public cForEachChunkProvider, public cWorldInterface, - public cBroadcastInterface, - public cMapManager + public cBroadcastInterface { public: @@ -582,9 +581,12 @@ public: /** Returns the name of the world.ini file used by this world */ const AString & GetIniFileName(void) const {return m_IniFileName; } - /** Returns the associated scoreboard instance */ + /** Returns the associated scoreboard instance. */ cScoreboard & GetScoreBoard(void) { return m_Scoreboard; } + /** Returns the associated map manager instance. */ + cMapManager & GetMapManager(void) { return m_MapManager; } + bool AreCommandBlocksEnabled(void) const { return m_bCommandBlocksEnabled; } void SetCommandBlocksEnabled(bool a_Flag) { m_bCommandBlocksEnabled = a_Flag; } @@ -850,6 +852,7 @@ private: cChunkGenerator m_Generator; cScoreboard m_Scoreboard; + cMapManager m_MapManager; /** The callbacks that the ChunkGenerator uses to store new chunks and interface to plugins */ cChunkGeneratorCallbacks m_GeneratorCallbacks; diff --git a/src/WorldStorage/MapSerializer.h b/src/WorldStorage/MapSerializer.h index 85fe917f5..eb7678a08 100644 --- a/src/WorldStorage/MapSerializer.h +++ b/src/WorldStorage/MapSerializer.h @@ -51,7 +51,11 @@ private: -/** Utility class used to serialize item ID counts. */ +/** Utility class used to serialize item ID counts. + * + * In order to perform bounds checking (while loading), + * the last registered ID of each item is serialized to an NBT file. + */ class cIDCountSerializer { public: |