summaryrefslogtreecommitdiffstats
path: root/src/Chunk.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-11-18 14:56:32 +0100
committerHowaner <franzi.moos@googlemail.com>2014-11-18 14:56:32 +0100
commit42120e2ea5db0cdb9920ff1c5efef33e0f496d48 (patch)
tree20ba1ae0a53f757cb8814b6cd6a466fe5acf1308 /src/Chunk.cpp
parentFixed compile errors. (diff)
parentMerge pull request #1598 from mc-server/SignEditor (diff)
downloadcuberite-42120e2ea5db0cdb9920ff1c5efef33e0f496d48.tar
cuberite-42120e2ea5db0cdb9920ff1c5efef33e0f496d48.tar.gz
cuberite-42120e2ea5db0cdb9920ff1c5efef33e0f496d48.tar.bz2
cuberite-42120e2ea5db0cdb9920ff1c5efef33e0f496d48.tar.lz
cuberite-42120e2ea5db0cdb9920ff1c5efef33e0f496d48.tar.xz
cuberite-42120e2ea5db0cdb9920ff1c5efef33e0f496d48.tar.zst
cuberite-42120e2ea5db0cdb9920ff1c5efef33e0f496d48.zip
Diffstat (limited to 'src/Chunk.cpp')
-rw-r--r--src/Chunk.cpp120
1 files changed, 60 insertions, 60 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index ddec950ea..45004fa22 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -93,22 +93,22 @@ cChunk::cChunk(
m_NeighborZP(a_NeighborZP),
m_WaterSimulatorData(a_World->GetWaterSimulator()->CreateChunkData()),
m_LavaSimulatorData (a_World->GetLavaSimulator ()->CreateChunkData()),
- m_RedstoneSimulatorData(NULL),
+ m_RedstoneSimulatorData(a_World->GetRedstoneSimulator()->CreateChunkData()),
m_AlwaysTicked(0)
{
- if (a_NeighborXM != NULL)
+ if (a_NeighborXM != nullptr)
{
a_NeighborXM->m_NeighborXP = this;
}
- if (a_NeighborXP != NULL)
+ if (a_NeighborXP != nullptr)
{
a_NeighborXP->m_NeighborXM = this;
}
- if (a_NeighborZM != NULL)
+ if (a_NeighborZM != nullptr)
{
a_NeighborZM->m_NeighborZP = this;
}
- if (a_NeighborZP != NULL)
+ if (a_NeighborZP != nullptr)
{
a_NeighborZP->m_NeighborZM = this;
}
@@ -120,7 +120,7 @@ cChunk::cChunk(
cChunk::~cChunk()
{
- cPluginManager::Get()->CallHookChunkUnloaded(m_World, m_PosX, m_PosZ);
+ cPluginManager::Get()->CallHookChunkUnloaded(*m_World, m_PosX, m_PosZ);
// LOGINFO("### delete cChunk() (%i, %i) from %p, thread 0x%x ###", m_PosX, m_PosZ, this, GetCurrentThreadId());
@@ -142,28 +142,28 @@ cChunk::~cChunk()
}
}
- if (m_NeighborXM != NULL)
+ if (m_NeighborXM != nullptr)
{
- m_NeighborXM->m_NeighborXP = NULL;
+ m_NeighborXM->m_NeighborXP = nullptr;
}
- if (m_NeighborXP != NULL)
+ if (m_NeighborXP != nullptr)
{
- m_NeighborXP->m_NeighborXM = NULL;
+ m_NeighborXP->m_NeighborXM = nullptr;
}
- if (m_NeighborZM != NULL)
+ if (m_NeighborZM != nullptr)
{
- m_NeighborZM->m_NeighborZP = NULL;
+ m_NeighborZM->m_NeighborZP = nullptr;
}
- if (m_NeighborZP != NULL)
+ if (m_NeighborZP != nullptr)
{
- m_NeighborZP->m_NeighborZM = NULL;
+ m_NeighborZP->m_NeighborZM = nullptr;
}
delete m_WaterSimulatorData;
- m_WaterSimulatorData = NULL;
+ m_WaterSimulatorData = nullptr;
delete m_LavaSimulatorData;
- m_LavaSimulatorData = NULL;
+ m_LavaSimulatorData = nullptr;
delete m_RedstoneSimulatorData;
- m_RedstoneSimulatorData = NULL;
+ m_RedstoneSimulatorData = nullptr;
}
@@ -334,7 +334,7 @@ void cChunk::SetAllData(cSetChunkData & a_SetChunkData)
{
BLOCKTYPE EntityBlockType = (*itr)->GetBlockType();
BLOCKTYPE WorldBlockType = GetBlock((*itr)->GetRelX(), (*itr)->GetPosY(), (*itr)->GetRelZ());
- ASSERT(EntityBlockType == WorldBlockType);
+ ASSERT(WorldBlockType == EntityBlockType);
} // for itr - m_BlockEntities
#endif // _DEBUG
@@ -582,7 +582,7 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner)
}
cEntity * newMob = a_MobSpawner.TryToSpawnHere(this, TryX, TryY, TryZ, Biome, MaxNbOfSuccess);
- if (newMob == NULL)
+ if (newMob == nullptr)
{
continue;
}
@@ -640,7 +640,7 @@ void cChunk::Tick(float a_Dt)
{
// Remove all entities that are travelling to another world
MarkDirty();
- (*itr)->SetWorldTravellingFrom(NULL);
+ (*itr)->SetWorldTravellingFrom(nullptr);
itr = m_Entities.erase(itr);
}
else if (
@@ -669,7 +669,7 @@ void cChunk::Tick(float a_Dt)
void cChunk::TickBlock(int a_RelX, int a_RelY, int a_RelZ)
{
cBlockHandler * Handler = BlockHandler(GetBlock(a_RelX, a_RelY, a_RelZ));
- ASSERT(Handler != NULL); // Happenned on server restart, FS #243
+ ASSERT(Handler != nullptr); // Happenned on server restart, FS #243
cChunkInterface ChunkInterface(this->GetWorld()->GetChunkMap());
cBlockInServerPluginInterface PluginInterface(*this->GetWorld());
Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, a_RelX, a_RelY, a_RelZ);
@@ -682,10 +682,10 @@ void cChunk::TickBlock(int a_RelX, int a_RelY, int a_RelZ)
void cChunk::MoveEntityToNewChunk(cEntity * a_Entity)
{
cChunk * Neighbor = GetNeighborChunk(a_Entity->GetChunkX() * cChunkDef::Width, a_Entity->GetChunkZ() * cChunkDef::Width);
- if (Neighbor == NULL)
+ if (Neighbor == nullptr)
{
Neighbor = m_ChunkMap->GetChunkNoLoad(a_Entity->GetChunkX(), a_Entity->GetChunkZ());
- if (Neighbor == NULL)
+ if (Neighbor == nullptr)
{
// TODO: What to do with this?
LOGWARNING("%s: Failed to move entity, destination chunk unreachable. Entity lost", __FUNCTION__);
@@ -848,7 +848,7 @@ void cChunk::TickBlocks(void)
}
cBlockHandler * Handler = BlockHandler(GetBlock(m_BlockTickX, m_BlockTickY, m_BlockTickZ));
- ASSERT(Handler != NULL); // Happenned on server restart, FS #243
+ ASSERT(Handler != nullptr); // Happenned on server restart, FS #243
Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, m_BlockTickX, m_BlockTickY, m_BlockTickZ);
} // for i - tickblocks
}
@@ -1128,7 +1128,7 @@ bool cChunk::UnboundedRelGetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE
return false;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
- if ((Chunk == NULL) || !Chunk->IsValid())
+ if ((Chunk == nullptr) || !Chunk->IsValid())
{
// The chunk is not available, bail out
return false;
@@ -1149,7 +1149,7 @@ bool cChunk::UnboundedRelGetBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKT
return false;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
- if ((Chunk == NULL) || !Chunk->IsValid())
+ if ((Chunk == nullptr) || !Chunk->IsValid())
{
// The chunk is not available, bail out
return false;
@@ -1170,7 +1170,7 @@ bool cChunk::UnboundedRelGetBlockMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLE
return false;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
- if ((Chunk == NULL) || !Chunk->IsValid())
+ if ((Chunk == nullptr) || !Chunk->IsValid())
{
// The chunk is not available, bail out
return false;
@@ -1191,7 +1191,7 @@ bool cChunk::UnboundedRelGetBlockBlockLight(int a_RelX, int a_RelY, int a_RelZ,
return false;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
- if ((Chunk == NULL) || !Chunk->IsValid())
+ if ((Chunk == nullptr) || !Chunk->IsValid())
{
// The chunk is not available, bail out
return false;
@@ -1212,7 +1212,7 @@ bool cChunk::UnboundedRelGetBlockSkyLight(int a_RelX, int a_RelY, int a_RelZ, NI
return false;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
- if ((Chunk == NULL) || !Chunk->IsValid())
+ if ((Chunk == nullptr) || !Chunk->IsValid())
{
// The chunk is not available, bail out
return false;
@@ -1233,7 +1233,7 @@ bool cChunk::UnboundedRelGetBlockLights(int a_RelX, int a_RelY, int a_RelZ, NIBB
return false;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
- if ((Chunk == NULL) || !Chunk->IsValid())
+ if ((Chunk == nullptr) || !Chunk->IsValid())
{
// The chunk is not available, bail out
return false;
@@ -1255,7 +1255,7 @@ bool cChunk::UnboundedRelSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE
return false;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
- if ((Chunk == NULL) || !Chunk->IsValid())
+ if ((Chunk == nullptr) || !Chunk->IsValid())
{
// The chunk is not available, bail out
return false;
@@ -1276,7 +1276,7 @@ bool cChunk::UnboundedRelFastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKT
return false;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
- if ((Chunk == NULL) || !Chunk->IsValid())
+ if ((Chunk == nullptr) || !Chunk->IsValid())
{
// The chunk is not available, bail out
return false;
@@ -1297,7 +1297,7 @@ void cChunk::UnboundedQueueTickBlock(int a_RelX, int a_RelY, int a_RelZ)
return;
}
cChunk * Chunk = GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
- if ((Chunk != NULL) && Chunk->IsValid())
+ if ((Chunk != nullptr) && Chunk->IsValid())
{
Chunk->QueueTickBlock(a_RelX, a_RelY, a_RelZ);
}
@@ -1454,12 +1454,12 @@ void cChunk::SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType,
// If there was a block entity, remove it:
Vector3i WorldPos = PositionToWorldPosition(a_RelX, a_RelY, a_RelZ);
cBlockEntity * BlockEntity = GetBlockEntity(WorldPos);
- if (BlockEntity != NULL)
+ if (BlockEntity != nullptr)
{
BlockEntity->Destroy();
RemoveBlockEntity(BlockEntity);
delete BlockEntity;
- BlockEntity = NULL;
+ BlockEntity = nullptr;
}
// If the new block is a block entity, create the entity object:
@@ -1622,7 +1622,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
void cChunk::SendBlockTo(int a_RelX, int a_RelY, int a_RelZ, cClientHandle * a_Client)
{
- if (a_Client == NULL)
+ if (a_Client == nullptr)
{
// Queue the block for all clients in the chunk (will be sent in Tick())
m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(a_RelX, a_RelY, a_RelZ), GetMeta(a_RelX, a_RelY, a_RelZ)));
@@ -1676,7 +1676,7 @@ cBlockEntity * cChunk::GetBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ)
}
} // for itr - m_BlockEntities[]
- return NULL;
+ return nullptr;
}
@@ -1711,7 +1711,7 @@ void cChunk::SetAlwaysTicked(bool a_AlwaysTicked)
void cChunk::UseBlockEntity(cPlayer * a_Player, int a_X, int a_Y, int a_Z)
{
cBlockEntity * be = GetBlockEntity(a_X, a_Y, a_Z);
- if (be != NULL)
+ if (be != nullptr)
{
be->UsedBy(a_Player);
}
@@ -1745,7 +1745,7 @@ void cChunk::SetAreaBiome(int a_MinRelX, int a_MaxRelX, int a_MinRelZ, int a_Max
// Re-send the chunk to all clients:
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
{
- m_World->ForceSendChunkTo(m_PosX, m_PosZ, (*itr));
+ m_World->ForceSendChunkTo(m_PosX, m_PosZ, cChunkSender::E_CHUNK_PRIORITY_MEDIUM, (*itr));
} // for itr - m_LoadedByClient[]
}
@@ -1753,11 +1753,11 @@ void cChunk::SetAreaBiome(int a_MinRelX, int a_MaxRelX, int a_MinRelZ, int a_Max
-void cChunk::CollectPickupsByPlayer(cPlayer * a_Player)
+void cChunk::CollectPickupsByPlayer(cPlayer & a_Player)
{
- double PosX = a_Player->GetPosX();
- double PosY = a_Player->GetPosY();
- double PosZ = a_Player->GetPosZ();
+ double PosX = a_Player.GetPosX();
+ double PosY = a_Player.GetPosY();
+ double PosZ = a_Player.GetPosZ();
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
{
@@ -2617,7 +2617,7 @@ BLOCKTYPE cChunk::GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
-void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
+void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const
{
a_BlockType = GetBlock(a_RelX, a_RelY, a_RelZ);
a_BlockMeta = m_ChunkData.GetMeta(a_RelX, a_RelY, a_RelZ);
@@ -2667,10 +2667,10 @@ cChunk * cChunk::GetRelNeighborChunk(int a_RelX, int a_RelZ)
bool ReturnThis = true;
if (a_RelX < 0)
{
- if (m_NeighborXM != NULL)
+ if (m_NeighborXM != nullptr)
{
cChunk * Candidate = m_NeighborXM->GetRelNeighborChunk(a_RelX + cChunkDef::Width, a_RelZ);
- if (Candidate != NULL)
+ if (Candidate != nullptr)
{
return Candidate;
}
@@ -2680,10 +2680,10 @@ cChunk * cChunk::GetRelNeighborChunk(int a_RelX, int a_RelZ)
}
else if (a_RelX >= cChunkDef::Width)
{
- if (m_NeighborXP != NULL)
+ if (m_NeighborXP != nullptr)
{
cChunk * Candidate = m_NeighborXP->GetRelNeighborChunk(a_RelX - cChunkDef::Width, a_RelZ);
- if (Candidate != NULL)
+ if (Candidate != nullptr)
{
return Candidate;
}
@@ -2694,24 +2694,24 @@ cChunk * cChunk::GetRelNeighborChunk(int a_RelX, int a_RelZ)
if (a_RelZ < 0)
{
- if (m_NeighborZM != NULL)
+ if (m_NeighborZM != nullptr)
{
return m_NeighborZM->GetRelNeighborChunk(a_RelX, a_RelZ + cChunkDef::Width);
// For requests crossing both X and Z, the X-first way has been already tried
}
- return NULL;
+ return nullptr;
}
else if (a_RelZ >= cChunkDef::Width)
{
- if (m_NeighborZP != NULL)
+ if (m_NeighborZP != nullptr)
{
return m_NeighborZP->GetRelNeighborChunk(a_RelX, a_RelZ - cChunkDef::Width);
// For requests crossing both X and Z, the X-first way has been already tried
}
- return NULL;
+ return nullptr;
}
- return (ReturnThis ? this : NULL);
+ return (ReturnThis ? this : nullptr);
}
@@ -2734,27 +2734,27 @@ cChunk * cChunk::GetRelNeighborChunkAdjustCoords(int & a_RelX, int & a_RelZ) con
// Request for a different chunk, calculate chunk offset:
int RelX = a_RelX; // Make a local copy of the coords (faster access)
int RelZ = a_RelZ;
- while ((RelX >= Width) && (ToReturn != NULL))
+ while ((RelX >= Width) && (ToReturn != nullptr))
{
RelX -= Width;
ToReturn = ToReturn->m_NeighborXP;
}
- while ((RelX < 0) && (ToReturn != NULL))
+ while ((RelX < 0) && (ToReturn != nullptr))
{
RelX += Width;
ToReturn = ToReturn->m_NeighborXM;
}
- while ((RelZ >= Width) && (ToReturn != NULL))
+ while ((RelZ >= Width) && (ToReturn != nullptr))
{
RelZ -= Width;
ToReturn = ToReturn->m_NeighborZP;
}
- while ((RelZ < 0) && (ToReturn != NULL))
+ while ((RelZ < 0) && (ToReturn != nullptr))
{
RelZ += Width;
ToReturn = ToReturn->m_NeighborZM;
}
- if (ToReturn != NULL)
+ if (ToReturn != nullptr)
{
a_RelX = RelX;
a_RelZ = RelZ;
@@ -2824,7 +2824,7 @@ void cChunk::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cons
{
// We can operate on entity pointers, we're inside the ChunkMap's CS lock which guards the list
cBlockEntity * Entity = GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ);
- if (Entity == NULL)
+ if (Entity == nullptr)
{
return;
}
@@ -3161,7 +3161,7 @@ void cChunk::BroadcastUseBed(const cEntity & a_Entity, int a_BlockX, int a_Block
void cChunk::SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client)
{
cBlockEntity * Entity = GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ);
- if (Entity == NULL)
+ if (Entity == nullptr)
{
return;
}