Maps: Improvements
This commit is contained in:
parent
30b22e9f59
commit
f471873945
@ -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 =
|
||||
|
@ -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())
|
||||
|
@ -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)
|
||||
{
|
||||
|
12
src/Map.cpp
12
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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user