summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandrew <xdotftw@gmail.com>2014-02-23 14:03:40 +0100
committerandrew <xdotftw@gmail.com>2014-02-23 14:05:03 +0100
commitf47187394572027cbfa07884cba2f54eaa6972ec (patch)
tree1f87d8d3f350b1d0c3faf5963c2ad74482ac3174
parentManually exported DoWithMap (diff)
downloadcuberite-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
-rw-r--r--MCServer/Plugins/APIDump/APIDesc.lua4
-rw-r--r--src/Items/ItemEmptyMap.h2
-rw-r--r--src/Items/ItemMap.h2
-rw-r--r--src/Map.cpp12
-rw-r--r--src/Map.h2
-rw-r--r--src/World.cpp6
-rw-r--r--src/World.h9
-rw-r--r--src/WorldStorage/MapSerializer.h6
8 files changed, 28 insertions, 15 deletions
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index c8811df66..8e9d239fa 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -2165,7 +2165,8 @@ end
GetGeneratorQueueLength = { Params = "", Return = "number", Notes = "Returns the number of chunks that are queued in the chunk generator." },
GetHeight = { Params = "BlockX, BlockZ", Return = "number", Notes = "Returns the maximum height of the particula block column in the world. If the chunk is not loaded, it waits for it to load / generate. <b>WARNING</b>: Do not use, Use TryGetHeight() instead for a non-waiting version, otherwise you run the risk of a deadlock!" },
GetIniFileName = { Params = "", Return = "string", Notes = "Returns the name of the world.ini file that the world uses to store the information." },
- GetLightingQueueLength = { Params = "", Return = "number", Notes = "Returns the number of chunks in the lighting thread's queue." },
+ GetLightingQueueLength = { Params = "", Return = "number", Notes = "Returns the number of chunks in the lighting thread's queue." },
+ GetMapManager = { Params = "", Return = "{{cMapManager}}", Notes = "Returns the {{cMapManager|MapManager}} object used by this world." },
GetMaxCactusHeight = { Params = "", Return = "number", Notes = "Returns the configured maximum height to which cacti will grow naturally." },
GetMaxSugarcaneHeight = { Params = "", Return = "number", Notes = "Returns the configured maximum height to which sugarcane will grow naturally." },
GetName = { Params = "", Return = "string", Notes = "Returns the name of the world, as specified in the settings.ini file." },
@@ -2302,7 +2303,6 @@ World:ForEachEntity(
]],
},
}, -- AdditionalInfo
- Inherits = "cMapManager"
}, -- cWorld
HTTPFormData =
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);
}
diff --git a/src/Map.h b/src/Map.h
index a6df7e5f2..a313d5431 100644
--- a/src/Map.h
+++ b/src/Map.h
@@ -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: