Skip to content

Commit

Permalink
NULL -> nullptr
Browse files Browse the repository at this point in the history
  • Loading branch information
tigerw committed Dec 16, 2014
1 parent 17be0e3 commit 8d90496
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/BlockEntities/MobSpawnerEntity.cpp
Expand Up @@ -150,7 +150,7 @@ void cMobSpawnerEntity::SpawnEntity(void)
int RelZ = (int) (m_RelZ + (double)(Random.NextFloat() - Random.NextFloat()) * 4.0);

cChunk * Chunk = a_Chunk->GetRelNeighborChunkAdjustCoords(RelX, RelZ);
if ((Chunk == NULL) || !Chunk->IsValid())
if ((Chunk == nullptr) || !Chunk->IsValid())
{
continue;
}
Expand All @@ -162,7 +162,7 @@ void cMobSpawnerEntity::SpawnEntity(void)
double PosZ = Chunk->GetPosZ() * cChunkDef::Width + RelZ;

cMonster * Monster = cMonster::NewMonsterFromType(m_MobType);
if (Monster == NULL)
if (Monster == nullptr)
{
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/BlockTallGrass.h
Expand Up @@ -38,7 +38,7 @@ class cBlockTallGrassHandler :

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);
cItems Drops;
Expand Down
2 changes: 1 addition & 1 deletion src/ChunkMap.cpp
Expand Up @@ -3075,7 +3075,7 @@ void cChunkMap::cChunkLayer::UnloadUnusedChunks(void)
)
{
// 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
delete m_Chunks[i];
m_Chunks[i] = nullptr;
Expand Down
24 changes: 12 additions & 12 deletions src/Simulator/IncrementalRedstoneSimulator.cpp
Expand Up @@ -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)
{
if ((a_Chunk == NULL) || !a_Chunk->IsValid())
if ((a_Chunk == nullptr) || !a_Chunk->IsValid())
{
return;
}
Expand All @@ -45,13 +45,13 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
BLOCKTYPE Block;
NIBBLETYPE Meta;

if (a_OtherChunk != NULL)
if (a_OtherChunk != nullptr)
{
RelX = a_BlockX - a_OtherChunk->GetPosX() * cChunkDef::Width;
RelZ = a_BlockZ - a_OtherChunk->GetPosZ() * cChunkDef::Width;
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
a_Chunk->SetIsRedstoneDirty(true);
}
Expand Down Expand Up @@ -100,7 +100,7 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
}
), 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
return;
Expand Down Expand Up @@ -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)
{
m_RedstoneSimulatorChunkData = (cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulatorChunkData *)a_Chunk->GetRedstoneSimulatorData();
if (m_RedstoneSimulatorChunkData == NULL)
if (m_RedstoneSimulatorChunkData == nullptr)
{
m_RedstoneSimulatorChunkData = new cIncrementalRedstoneSimulator::cIncrementalRedstoneSimulatorChunkData();
a_Chunk->SetRedstoneSimulatorData(m_RedstoneSimulatorChunkData);
Expand Down Expand Up @@ -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

cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(X, Z);
if ((Neighbour == NULL) || !Neighbour->IsValid())
if ((Neighbour == nullptr) || !Neighbour->IsValid())
{
return;
}
Expand Down Expand Up @@ -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

cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(X, Z);
if ((Neighbour == NULL) || !Neighbour->IsValid())
if ((Neighbour == nullptr) || !Neighbour->IsValid())
{
return;
}
Expand Down Expand Up @@ -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
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);
SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
Expand Down Expand Up @@ -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)
{
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;
}
Expand Down Expand Up @@ -1922,7 +1922,7 @@ void cIncrementalRedstoneSimulator::SetBlockLinkedPowered(

cChunk * Neighbour = m_Chunk->GetRelNeighborChunkAdjustCoords(a_RelBlockX, a_RelBlockZ);
m_Chunk->GetRelNeighborChunkAdjustCoords(a_RelMiddleX, a_RelMiddleZ);
if ((Neighbour == NULL) || !Neighbour->IsValid())
if ((Neighbour == nullptr) || !Neighbour->IsValid())
{
return;
}
Expand Down Expand Up @@ -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_Chunk == NULL) || !a_Chunk->IsValid())
if ((a_Chunk == nullptr) || !a_Chunk->IsValid())
{
return;
}
Expand Down Expand Up @@ -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_Chunk == NULL) || !a_Chunk->IsValid())
if ((a_Chunk == nullptr) || !a_Chunk->IsValid())
{
return;
}
Expand Down
8 changes: 6 additions & 2 deletions src/Simulator/IncrementalRedstoneSimulator.h
Expand Up @@ -108,7 +108,7 @@ class cIncrementalRedstoneSimulator :
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); }
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;

// 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
Expand Down Expand Up @@ -390,4 +390,8 @@ class cIncrementalRedstoneSimulator :

return RelPos;
}
};
};




0 comments on commit 8d90496

Please sign in to comment.