1
0

Maps: Improvements

This commit is contained in:
andrew 2014-02-23 15:03:40 +02:00
parent 30b22e9f59
commit f471873945
8 changed files with 28 additions and 15 deletions

View File

@ -2166,6 +2166,7 @@ end
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!" }, 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." }, 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." }, 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." }, 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." }, 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 }, -- AdditionalInfo
Inherits = "cMapManager"
}, -- cWorld }, -- cWorld
HTTPFormData = HTTPFormData =

View File

@ -41,7 +41,7 @@ public:
int CenterX = round(a_Player->GetPosX() / (float) RegionWidth) * RegionWidth; int CenterX = round(a_Player->GetPosX() / (float) RegionWidth) * RegionWidth;
int CenterZ = round(a_Player->GetPosZ() / (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 // Remove empty map from inventory
if (!a_Player->GetInventory().RemoveOneEquippedItem()) if (!a_Player->GetInventory().RemoveOneEquippedItem())

View File

@ -29,7 +29,7 @@ public:
virtual void OnUpdate(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item) 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) if (Map == NULL)
{ {

View File

@ -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; cMapClient MapClient;
MapClient.m_LastUpdate = a_WorldAge; MapClient.m_LastUpdate = a_WorldAge;
MapClient.m_SendInfo = true; MapClient.m_SendInfo = true;
MapClient.m_Handle = a_Handle; MapClient.m_Handle = Handle;
m_Clients.push_back(MapClient); m_Clients.push_back(MapClient);
@ -470,7 +476,7 @@ void cMap::UpdateClient(cPlayer * a_Player)
} }
// New player, construct a new client state // New player, construct a new client state
AddPlayer(a_Player, Handle, WorldAge); AddPlayer(a_Player, WorldAge);
} }

View File

@ -226,7 +226,7 @@ private:
bool UpdatePixel(unsigned int a_X, unsigned int a_Z); bool UpdatePixel(unsigned int a_X, unsigned int a_Z);
/** Add a new map client. */ /** 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. */ /** Remove inactive or invalid clients. */
void RemoveInactiveClients(Int64 a_WorldAge); void RemoveInactiveClients(Int64 a_WorldAge);

View File

@ -233,7 +233,6 @@ void cWorld::cTickThread::Execute(void)
// cWorld: // cWorld:
cWorld::cWorld(const AString & a_WorldName) : cWorld::cWorld(const AString & a_WorldName) :
cMapManager(this),
m_WorldName(a_WorldName), m_WorldName(a_WorldName),
m_IniFileName(m_WorldName + "/world.ini"), m_IniFileName(m_WorldName + "/world.ini"),
m_StorageSchema("Default"), m_StorageSchema("Default"),
@ -254,6 +253,7 @@ cWorld::cWorld(const AString & a_WorldName) :
m_bCommandBlocksEnabled(false), m_bCommandBlocksEnabled(false),
m_bUseChatPrefixes(true), m_bUseChatPrefixes(true),
m_Scoreboard(this), m_Scoreboard(this),
m_MapManager(this),
m_GeneratorCallbacks(*this), m_GeneratorCallbacks(*this),
m_TickThread(*this) m_TickThread(*this)
{ {
@ -265,7 +265,7 @@ cWorld::cWorld(const AString & a_WorldName) :
cScoreboardSerializer Serializer(m_WorldName, &m_Scoreboard); cScoreboardSerializer Serializer(m_WorldName, &m_Scoreboard);
Serializer.Load(); Serializer.Load();
LoadMapData(); m_MapManager.LoadMapData();
} }
@ -289,7 +289,7 @@ cWorld::~cWorld()
cScoreboardSerializer Serializer(m_WorldName, &m_Scoreboard); cScoreboardSerializer Serializer(m_WorldName, &m_Scoreboard);
Serializer.Save(); Serializer.Save();
SaveMapData(); m_MapManager.SaveMapData();
delete m_ChunkMap; delete m_ChunkMap;
} }

View File

@ -71,8 +71,7 @@ typedef cItemCallback<cMobHeadEntity> cMobHeadBlockCallback;
class cWorld : class cWorld :
public cForEachChunkProvider, public cForEachChunkProvider,
public cWorldInterface, public cWorldInterface,
public cBroadcastInterface, public cBroadcastInterface
public cMapManager
{ {
public: public:
@ -582,9 +581,12 @@ public:
/** Returns the name of the world.ini file used by this world */ /** Returns the name of the world.ini file used by this world */
const AString & GetIniFileName(void) const {return m_IniFileName; } const AString & GetIniFileName(void) const {return m_IniFileName; }
/** Returns the associated scoreboard instance */ /** Returns the associated scoreboard instance. */
cScoreboard & GetScoreBoard(void) { return m_Scoreboard; } 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; } bool AreCommandBlocksEnabled(void) const { return m_bCommandBlocksEnabled; }
void SetCommandBlocksEnabled(bool a_Flag) { m_bCommandBlocksEnabled = a_Flag; } void SetCommandBlocksEnabled(bool a_Flag) { m_bCommandBlocksEnabled = a_Flag; }
@ -850,6 +852,7 @@ private:
cChunkGenerator m_Generator; cChunkGenerator m_Generator;
cScoreboard m_Scoreboard; cScoreboard m_Scoreboard;
cMapManager m_MapManager;
/** The callbacks that the ChunkGenerator uses to store new chunks and interface to plugins */ /** The callbacks that the ChunkGenerator uses to store new chunks and interface to plugins */
cChunkGeneratorCallbacks m_GeneratorCallbacks; cChunkGeneratorCallbacks m_GeneratorCallbacks;

View File

@ -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 class cIDCountSerializer
{ {
public: public: