1
0

NULL -> nullptr

This commit is contained in:
Tiger Wang 2014-12-16 23:18:59 +00:00
parent 17be0e3b7a
commit 8d9049603b
5 changed files with 22 additions and 18 deletions

View File

@ -150,7 +150,7 @@ void cMobSpawnerEntity::SpawnEntity(void)
int RelZ = (int) (m_RelZ + (double)(Random.NextFloat() - Random.NextFloat()) * 4.0); int RelZ = (int) (m_RelZ + (double)(Random.NextFloat() - Random.NextFloat()) * 4.0);
cChunk * Chunk = a_Chunk->GetRelNeighborChunkAdjustCoords(RelX, RelZ); cChunk * Chunk = a_Chunk->GetRelNeighborChunkAdjustCoords(RelX, RelZ);
if ((Chunk == NULL) || !Chunk->IsValid()) if ((Chunk == nullptr) || !Chunk->IsValid())
{ {
continue; continue;
} }
@ -162,7 +162,7 @@ void cMobSpawnerEntity::SpawnEntity(void)
double PosZ = Chunk->GetPosZ() * cChunkDef::Width + RelZ; double PosZ = Chunk->GetPosZ() * cChunkDef::Width + RelZ;
cMonster * Monster = cMonster::NewMonsterFromType(m_MobType); cMonster * Monster = cMonster::NewMonsterFromType(m_MobType);
if (Monster == NULL) if (Monster == nullptr)
{ {
continue; continue;
} }

View File

@ -38,7 +38,7 @@ public:
virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop) override virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop) override
{ {
if (a_CanDrop && (a_Digger != NULL) && (a_Digger->GetEquippedWeapon().m_ItemType == E_ITEM_SHEARS)) if (a_CanDrop && (a_Digger != nullptr) && (a_Digger->GetEquippedWeapon().m_ItemType == E_ITEM_SHEARS))
{ {
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
cItems Drops; cItems Drops;

View File

@ -3075,7 +3075,7 @@ void cChunkMap::cChunkLayer::UnloadUnusedChunks(void)
) )
{ {
// The cChunk destructor calls our GetChunk() while removing its entities // The cChunk destructor calls our GetChunk() while removing its entities
// so we still need to be able to return the chunk. Therefore we first delete, then NULLify // so we still need to be able to return the chunk. Therefore we first delete, then nullptrify
// Doing otherwise results in bug http://forum.mc-server.org/showthread.php?tid=355 // Doing otherwise results in bug http://forum.mc-server.org/showthread.php?tid=355
delete m_Chunks[i]; delete m_Chunks[i];
m_Chunks[i] = nullptr; m_Chunks[i] = nullptr;

View File

@ -27,7 +27,7 @@ typedef cItemCallback<cChestEntity> cChestCallback;
void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk, cChunk * a_OtherChunk) void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk, cChunk * a_OtherChunk)
{ {
if ((a_Chunk == NULL) || !a_Chunk->IsValid()) if ((a_Chunk == nullptr) || !a_Chunk->IsValid())
{ {
return; return;
} }
@ -45,13 +45,13 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
BLOCKTYPE Block; BLOCKTYPE Block;
NIBBLETYPE Meta; NIBBLETYPE Meta;
if (a_OtherChunk != NULL) if (a_OtherChunk != nullptr)
{ {
RelX = a_BlockX - a_OtherChunk->GetPosX() * cChunkDef::Width; RelX = a_BlockX - a_OtherChunk->GetPosX() * cChunkDef::Width;
RelZ = a_BlockZ - a_OtherChunk->GetPosZ() * cChunkDef::Width; RelZ = a_BlockZ - a_OtherChunk->GetPosZ() * cChunkDef::Width;
a_OtherChunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta); a_OtherChunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta);
// If a_OtherChunk is passed (not NULL), it is the chunk that had a block change, and a_Chunk will be the neighbouring chunk of that block // If a_OtherChunk is passed (not nullptr), it is the chunk that had a block change, and a_Chunk will be the neighbouring chunk of that block
// Because said neighbouring chunk does not know of this change but still needs to update its redstone, we set it to dirty // Because said neighbouring chunk does not know of this change but still needs to update its redstone, we set it to dirty
a_Chunk->SetIsRedstoneDirty(true); a_Chunk->SetIsRedstoneDirty(true);
} }
@ -100,7 +100,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
} }
), RepeatersDelayList.end()); ), RepeatersDelayList.end());
if (a_OtherChunk != NULL) if (a_OtherChunk != nullptr)
{ {
// DO NOT touch our chunk's data structure if we are being called with coordinates from another chunk - this one caused me massive grief :P // DO NOT touch our chunk's data structure if we are being called with coordinates from another chunk - this one caused me massive grief :P
return; return;
@ -148,7 +148,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) void cIncrementalRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
{ {
m_RedstoneSimulatorChunkData = (cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulatorChunkData *)a_Chunk->GetRedstoneSimulatorData(); m_RedstoneSimulatorChunkData = (cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulatorChunkData *)a_Chunk->GetRedstoneSimulatorData();
if (m_RedstoneSimulatorChunkData == NULL) if (m_RedstoneSimulatorChunkData == nullptr)
{ {
m_RedstoneSimulatorChunkData = new cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulatorChunkData(); m_RedstoneSimulatorChunkData = new cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulatorChunkData();
a_Chunk->SetRedstoneSimulatorData(m_RedstoneSimulatorChunkData); a_Chunk->SetRedstoneSimulatorData(m_RedstoneSimulatorChunkData);
@ -343,7 +343,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R
AddFaceDirection(X, Y, Z, GetHandlerCompileTime<E_BLOCK_TORCH>::type::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on AddFaceDirection(X, Y, Z, GetHandlerCompileTime<E_BLOCK_TORCH>::type::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on
cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(X, Z); cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(X, Z);
if ((Neighbour == NULL) || !Neighbour->IsValid()) if ((Neighbour == nullptr) || !Neighbour->IsValid())
{ {
return; return;
} }
@ -399,7 +399,7 @@ void cIncrementalRedstoneSimulator::HandleRedstoneTorch(int a_RelBlockX, int a_R
AddFaceDirection(X, Y, Z, GetHandlerCompileTime<E_BLOCK_TORCH>::type::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on AddFaceDirection(X, Y, Z, GetHandlerCompileTime<E_BLOCK_TORCH>::type::MetaDataToDirection(m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ)), true); // Inverse true to get the block torch is on
cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(X, Z); cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(X, Z);
if ((Neighbour == NULL) || !Neighbour->IsValid()) if ((Neighbour == nullptr) || !Neighbour->IsValid())
{ {
return; return;
} }
@ -1050,7 +1050,7 @@ void cIncrementalRedstoneSimulator::HandlePressurePlate(int a_RelBlockX, int a_R
// MCS feature - stone pressure plates can only be triggered by players :D // MCS feature - stone pressure plates can only be triggered by players :D
cPlayer * a_Player = this->m_World.FindClosestPlayer(Vector3f(BlockX + 0.5f, (float)a_RelBlockY, BlockZ + 0.5f), 0.5f, false); cPlayer * a_Player = this->m_World.FindClosestPlayer(Vector3f(BlockX + 0.5f, (float)a_RelBlockY, BlockZ + 0.5f), 0.5f, false);
if (a_Player != NULL) if (a_Player != nullptr)
{ {
m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0x1); m_Chunk->SetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ, 0x1);
SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ); SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
@ -1847,7 +1847,7 @@ void cIncrementalRedstoneSimulator::SetAllDirsAsPowered(int a_RelBlockX, int a_R
void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, unsigned char a_PowerLevel) void cIncrementalRedstoneSimulator::SetBlockPowered(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ, int a_RelSourceX, int a_RelSourceY, int a_RelSourceZ, unsigned char a_PowerLevel)
{ {
cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(a_RelBlockX, a_RelBlockZ); // Adjust coordinates for the later call using these values cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(a_RelBlockX, a_RelBlockZ); // Adjust coordinates for the later call using these values
if ((Neighbour == NULL) || !Neighbour->IsValid()) if ((Neighbour == nullptr) || !Neighbour->IsValid())
{ {
return; return;
} }
@ -1922,7 +1922,7 @@ void cIncrementalRedstoneSimulator::SetBlockLinkedPowered(
cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(a_RelBlockX, a_RelBlockZ); cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(a_RelBlockX, a_RelBlockZ);
m_Chunk->GetRelNeighborChunkAdjustCoords(a_RelMiddleX, a_RelMiddleZ); m_Chunk->GetRelNeighborChunkAdjustCoords(a_RelMiddleX, a_RelMiddleZ);
if ((Neighbour == NULL) || !Neighbour->IsValid()) if ((Neighbour == nullptr) || !Neighbour->IsValid())
{ {
return; return;
} }
@ -2030,7 +2030,7 @@ void cIncrementalRedstoneSimulator::SetSourceUnpowered(int a_RelSourceX, int a_R
{ {
if (!a_IsFirstCall) // The neighbouring chunks passed when this parameter is false may be invalid if (!a_IsFirstCall) // The neighbouring chunks passed when this parameter is false may be invalid
{ {
if ((a_Chunk == NULL) || !a_Chunk->IsValid()) if ((a_Chunk == nullptr) || !a_Chunk->IsValid())
{ {
return; return;
} }
@ -2089,7 +2089,7 @@ void cIncrementalRedstoneSimulator::SetInvalidMiddleBlock(int a_RelMiddleX, int
{ {
if (!a_IsFirstCall) // The neighbouring chunks passed when this parameter is false may be invalid if (!a_IsFirstCall) // The neighbouring chunks passed when this parameter is false may be invalid
{ {
if ((a_Chunk == NULL) || !a_Chunk->IsValid()) if ((a_Chunk == nullptr) || !a_Chunk->IsValid())
{ {
return; return;
} }

View File

@ -108,7 +108,7 @@ private:
RepeatersDelayList * m_RepeatersDelayList; RepeatersDelayList * m_RepeatersDelayList;
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override { RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk); } virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override { RedstoneAddBlock(a_BlockX, a_BlockY, a_BlockZ, a_Chunk); }
void RedstoneAddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk, cChunk * a_OtherChunk = NULL); void RedstoneAddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk, cChunk * a_OtherChunk = nullptr);
cChunk * m_Chunk; cChunk * m_Chunk;
// We want a_MyState for devices needing a full FastSetBlock (as opposed to meta) because with our simulation model, we cannot keep setting the block if it is already set correctly // We want a_MyState for devices needing a full FastSetBlock (as opposed to meta) because with our simulation model, we cannot keep setting the block if it is already set correctly
@ -390,4 +390,8 @@ private:
return RelPos; return RelPos;
} }
}; };