mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-23 18:15:36 +00:00
refactor: replace NULL with nullptr across C++ codebase
Excludes vendored C libs (zlib, Miles, DirectXMath, boost, Iggy).
This commit is contained in:
@@ -103,7 +103,7 @@ ServerPlayer::ServerPlayer(MinecraftServer* server, Level* level,
|
||||
}
|
||||
attemptCount++;
|
||||
playerNear =
|
||||
(level->getNearestPlayer(xx + 0.5, yy, zz + 0.5, 3) != NULL);
|
||||
(level->getNearestPlayer(xx + 0.5, yy, zz + 0.5, 3) != nullptr);
|
||||
} while ((waterDepth > 1) && (!playerNear) && (attemptCount < 20));
|
||||
xx = xx2;
|
||||
yy = yy2;
|
||||
@@ -184,7 +184,7 @@ void ServerPlayer::readAdditionalSaveData(CompoundTag* entityTag) {
|
||||
}
|
||||
|
||||
GameRulesInstance* grs = gameMode->getGameRules();
|
||||
if (entityTag->contains(L"GameRules") && grs != NULL) {
|
||||
if (entityTag->contains(L"GameRules") && grs != nullptr) {
|
||||
byteArray ba = entityTag->getByteArray(L"GameRules");
|
||||
ByteArrayInputStream bais(ba);
|
||||
DataInputStream dis(&bais);
|
||||
@@ -199,12 +199,12 @@ void ServerPlayer::addAdditonalSaveData(CompoundTag* entityTag) {
|
||||
Player::addAdditonalSaveData(entityTag);
|
||||
|
||||
GameRulesInstance* grs = gameMode->getGameRules();
|
||||
if (grs != NULL) {
|
||||
if (grs != nullptr) {
|
||||
ByteArrayOutputStream baos;
|
||||
DataOutputStream dos(&baos);
|
||||
grs->write(&dos);
|
||||
entityTag->putByteArray(L"GameRules", baos.buf);
|
||||
baos.buf.data = NULL;
|
||||
baos.buf.data = nullptr;
|
||||
dos.close();
|
||||
baos.close();
|
||||
}
|
||||
@@ -292,7 +292,7 @@ void ServerPlayer::doTickA() {
|
||||
|
||||
for (unsigned int i = 0; i < inventory->getContainerSize(); i++) {
|
||||
std::shared_ptr<ItemInstance> ie = inventory->getItem(i);
|
||||
if (ie != NULL) {
|
||||
if (ie != nullptr) {
|
||||
// 4J - removed condition. These were getting lower priority than
|
||||
// tile update packets etc. on the slow outbound queue, and so were
|
||||
// extremely slow to send sometimes, particularly at the start of a
|
||||
@@ -307,7 +307,7 @@ void ServerPlayer::doTickA() {
|
||||
->getUpdatePacket(ie, level,
|
||||
std::dynamic_pointer_cast<Player>(
|
||||
shared_from_this())));
|
||||
if (packet != NULL) {
|
||||
if (packet != nullptr) {
|
||||
connection->send(packet);
|
||||
}
|
||||
}
|
||||
@@ -344,7 +344,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) {
|
||||
}
|
||||
}
|
||||
|
||||
// if (nearest != NULL) // 4J - removed as we don't have
|
||||
// if (nearest != nullptr) // 4J - removed as we don't have
|
||||
// references here
|
||||
if (nearestValid) {
|
||||
bool okToSend = false;
|
||||
@@ -368,7 +368,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) {
|
||||
// canSendToPlayer,
|
||||
// connection->countDelayedPackets(),
|
||||
// g_NetworkManager.GetHostPlayer()->GetSendQueueSizeMessages(
|
||||
// NULL, true ),
|
||||
// nullptr, true ),
|
||||
// connection->done);
|
||||
// }
|
||||
|
||||
@@ -376,7 +376,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) {
|
||||
(canSendToPlayer &&
|
||||
(connection->countDelayedPackets() < 4) &&
|
||||
(g_NetworkManager.GetHostPlayer()
|
||||
->GetSendQueueSizeMessages(NULL, true) < 4) &&
|
||||
->GetSendQueueSizeMessages(nullptr, true) < 4) &&
|
||||
//(tickCount - lastBrupSendTickCount) >
|
||||
//(connection->getNetworkPlayer()->GetCurrentRtt()>>4) &&
|
||||
!connection->done)) {
|
||||
@@ -619,7 +619,7 @@ void ServerPlayer::die(DamageSource* source) {
|
||||
}
|
||||
|
||||
std::shared_ptr<LivingEntity> killer = getKillCredit();
|
||||
if (killer != NULL) killer->awardKillScore(shared_from_this(), deathScore);
|
||||
if (killer != nullptr) killer->awardKillScore(shared_from_this(), deathScore);
|
||||
// awardStat(Stats::deaths, 1);
|
||||
}
|
||||
|
||||
@@ -636,11 +636,11 @@ bool ServerPlayer::hurt(DamageSource* dmgSource, float dmg) {
|
||||
dmgSource != DamageSource::outOfWorld)
|
||||
return false;
|
||||
|
||||
if (dynamic_cast<EntityDamageSource*>(dmgSource) != NULL) {
|
||||
if (dynamic_cast<EntityDamageSource*>(dmgSource) != nullptr) {
|
||||
// 4J Stu - Fix for #46422 - TU5: Crash: Gameplay: Crash when being hit
|
||||
// by a trap using a dispenser getEntity returns the owner of
|
||||
// projectiles, and this would never be the arrow. The owner is
|
||||
// sometimes NULL.
|
||||
// sometimes nullptr.
|
||||
std::shared_ptr<Entity> source = dmgSource->getDirectEntity();
|
||||
|
||||
if (source->instanceof
|
||||
@@ -650,10 +650,10 @@ bool ServerPlayer::hurt(DamageSource* dmgSource, float dmg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((source != NULL) && source->instanceof (eTYPE_ARROW)) {
|
||||
if ((source != nullptr) && source->instanceof (eTYPE_ARROW)) {
|
||||
std::shared_ptr<Arrow> arrow =
|
||||
std::dynamic_pointer_cast<Arrow>(source);
|
||||
if ((arrow->owner != NULL) && arrow->owner->instanceof
|
||||
if ((arrow->owner != nullptr) && arrow->owner->instanceof
|
||||
(eTYPE_PLAYER) &&
|
||||
!canHarmPlayer(
|
||||
std::dynamic_pointer_cast<Player>(arrow->owner))) {
|
||||
@@ -684,7 +684,7 @@ bool ServerPlayer::hurt(DamageSource* dmgSource, float dmg) {
|
||||
m_lastDamageSource = eTelemetryPlayerDeathSource_Cactus;
|
||||
else {
|
||||
std::shared_ptr<Entity> source = dmgSource->getEntity();
|
||||
if (source != NULL) {
|
||||
if (source != nullptr) {
|
||||
switch (source->GetType()) {
|
||||
case eTYPE_PLAYER:
|
||||
case eTYPE_SERVERPLAYER:
|
||||
@@ -724,11 +724,11 @@ bool ServerPlayer::hurt(DamageSource* dmgSource, float dmg) {
|
||||
break;
|
||||
case eTYPE_ARROW:
|
||||
if ((std::dynamic_pointer_cast<Arrow>(source))->owner !=
|
||||
NULL) {
|
||||
nullptr) {
|
||||
std::shared_ptr<Entity> attacker =
|
||||
(std::dynamic_pointer_cast<Arrow>(source))
|
||||
->owner;
|
||||
if (attacker != NULL) {
|
||||
if (attacker != nullptr) {
|
||||
switch (attacker->GetType()) {
|
||||
case eTYPE_SKELETON:
|
||||
m_lastDamageSource =
|
||||
@@ -771,7 +771,7 @@ bool ServerPlayer::canHarmPlayer(std::wstring targetName) {
|
||||
|
||||
std::shared_ptr<ServerPlayer> owner =
|
||||
server->getPlayers()->getPlayer(targetName);
|
||||
if (owner != NULL) {
|
||||
if (owner != nullptr) {
|
||||
if ((shared_from_this() != owner) && canHarmPlayer(owner))
|
||||
canHarm = false;
|
||||
} else {
|
||||
@@ -805,7 +805,7 @@ void ServerPlayer::changeDimension(int i) {
|
||||
app.DebugPrintf("Sending packet to %d\n",
|
||||
thisPlayer->GetUserIndex());
|
||||
}
|
||||
if (thisPlayer != NULL) {
|
||||
if (thisPlayer != nullptr) {
|
||||
for (AUTO_VAR(it, MinecraftServer::getInstance()
|
||||
->getPlayers()
|
||||
->players.begin());
|
||||
@@ -815,7 +815,7 @@ void ServerPlayer::changeDimension(int i) {
|
||||
std::shared_ptr<ServerPlayer> servPlayer = *it;
|
||||
INetworkPlayer* checkPlayer =
|
||||
servPlayer->connection->getNetworkPlayer();
|
||||
if (thisPlayer != checkPlayer && checkPlayer != NULL &&
|
||||
if (thisPlayer != checkPlayer && checkPlayer != nullptr &&
|
||||
thisPlayer->IsSameSystem(checkPlayer) &&
|
||||
!servPlayer->wonGame) {
|
||||
servPlayer->wonGame = true;
|
||||
@@ -834,7 +834,7 @@ void ServerPlayer::changeDimension(int i) {
|
||||
awardStat(GenericStats::theEnd(), GenericStats::param_theEnd());
|
||||
|
||||
Pos* pos = server->getLevel(i)->getDimensionSpecificSpawn();
|
||||
if (pos != NULL) {
|
||||
if (pos != nullptr) {
|
||||
connection->teleport(pos->x, pos->y, pos->z, 0, 0);
|
||||
delete pos;
|
||||
}
|
||||
@@ -855,9 +855,9 @@ void ServerPlayer::changeDimension(int i) {
|
||||
// 4J Added delay param
|
||||
void ServerPlayer::broadcast(std::shared_ptr<TileEntity> te,
|
||||
bool delay /*= false*/) {
|
||||
if (te != NULL) {
|
||||
if (te != nullptr) {
|
||||
std::shared_ptr<Packet> p = te->getUpdatePacket();
|
||||
if (p != NULL) {
|
||||
if (p != nullptr) {
|
||||
p->shouldDelay = delay;
|
||||
if (delay)
|
||||
connection->queueSend(p);
|
||||
@@ -897,7 +897,7 @@ void ServerPlayer::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList,
|
||||
new AnimatePacket(shared_from_this(), AnimatePacket::WAKE_UP)));
|
||||
}
|
||||
Player::stopSleepInBed(forcefulWakeUp, updateLevelList, saveRespawnPoint);
|
||||
if (connection != NULL) connection->teleport(x, y, z, yRot, xRot);
|
||||
if (connection != nullptr) connection->teleport(x, y, z, yRot, xRot);
|
||||
}
|
||||
|
||||
void ServerPlayer::ride(std::shared_ptr<Entity> e) {
|
||||
@@ -923,7 +923,7 @@ void ServerPlayer::doCheckFallDamage(double ya, bool onGround) {
|
||||
void ServerPlayer::openTextEdit(std::shared_ptr<TileEntity> sign) {
|
||||
std::shared_ptr<SignTileEntity> signTE =
|
||||
std::dynamic_pointer_cast<SignTileEntity>(sign);
|
||||
if (signTE != NULL) {
|
||||
if (signTE != nullptr) {
|
||||
signTE->setAllowedPlayerEditor(
|
||||
std::dynamic_pointer_cast<Player>(shared_from_this()));
|
||||
connection->send(
|
||||
@@ -965,7 +965,7 @@ bool ServerPlayer::openFireworks(int x, int y, int z) {
|
||||
containerMenu = new FireworksMenu(inventory, level, x, y, z);
|
||||
containerMenu->containerId = containerCounter;
|
||||
containerMenu->addSlotListener(this);
|
||||
} else if (dynamic_cast<CraftingMenu*>(containerMenu) != NULL) {
|
||||
} else if (dynamic_cast<CraftingMenu*>(containerMenu) != nullptr) {
|
||||
closeContainer();
|
||||
|
||||
nextContainerCounter();
|
||||
@@ -1190,7 +1190,7 @@ bool ServerPlayer::openTrading(std::shared_ptr<Merchant> traderTarget,
|
||||
|
||||
MerchantRecipeList* offers = traderTarget->getOffers(
|
||||
std::dynamic_pointer_cast<Player>(shared_from_this()));
|
||||
if (offers != NULL) {
|
||||
if (offers != nullptr) {
|
||||
ByteArrayOutputStream rawOutput;
|
||||
DataOutputStream output(&rawOutput);
|
||||
|
||||
@@ -1304,7 +1304,7 @@ void ServerPlayer::doCloseContainer() {
|
||||
|
||||
void ServerPlayer::setPlayerInput(float xxa, float yya, bool jumping,
|
||||
bool sneaking) {
|
||||
if (riding != NULL) {
|
||||
if (riding != nullptr) {
|
||||
if (xxa >= -1 && xxa <= 1) this->xxa = xxa;
|
||||
if (yya >= -1 && yya <= 1) this->yya = yya;
|
||||
this->jumping = jumping;
|
||||
@@ -1313,7 +1313,7 @@ void ServerPlayer::setPlayerInput(float xxa, float yya, bool jumping,
|
||||
}
|
||||
|
||||
void ServerPlayer::awardStat(Stat* stat, byteArray param) {
|
||||
if (stat == NULL) {
|
||||
if (stat == nullptr) {
|
||||
delete[] param.data;
|
||||
return;
|
||||
}
|
||||
@@ -1329,7 +1329,7 @@ void ServerPlayer::awardStat(Stat* stat, byteArray param) {
|
||||
}
|
||||
|
||||
void ServerPlayer::disconnect() {
|
||||
if (rider.lock() != NULL) rider.lock()->ride(shared_from_this());
|
||||
if (rider.lock() != nullptr) rider.lock()->ride(shared_from_this());
|
||||
if (m_isSleeping) {
|
||||
stopSleepInBed(true, false, false);
|
||||
}
|
||||
@@ -1633,7 +1633,7 @@ void ServerPlayer::startUsingItem(std::shared_ptr<ItemInstance> instance,
|
||||
int duration) {
|
||||
Player::startUsingItem(instance, duration);
|
||||
|
||||
if (instance != NULL && instance->getItem() != NULL &&
|
||||
if (instance != nullptr && instance->getItem() != nullptr &&
|
||||
instance->getItem()->getUseAnimation(instance) == UseAnim_eat) {
|
||||
getLevel()->getTracker()->broadcastAndSend(
|
||||
shared_from_this(),
|
||||
@@ -1688,7 +1688,7 @@ void ServerPlayer::magicCrit(std::shared_ptr<Entity> entity) {
|
||||
}
|
||||
|
||||
void ServerPlayer::onUpdateAbilities() {
|
||||
if (connection == NULL) return;
|
||||
if (connection == nullptr) return;
|
||||
connection->send(std::shared_ptr<PlayerAbilitiesPacket>(
|
||||
new PlayerAbilitiesPacket(&abilities)));
|
||||
}
|
||||
@@ -1788,7 +1788,7 @@ int ServerPlayer::getPlayerViewDistanceModifier() {
|
||||
if (!connection->isLocal()) {
|
||||
INetworkPlayer* player = connection->getNetworkPlayer();
|
||||
|
||||
if (player != NULL) {
|
||||
if (player != nullptr) {
|
||||
int rtt = player->GetCurrentRtt();
|
||||
|
||||
value = rtt >> 6;
|
||||
@@ -1801,7 +1801,7 @@ int ServerPlayer::getPlayerViewDistanceModifier() {
|
||||
}
|
||||
|
||||
void ServerPlayer::handleCollectItem(std::shared_ptr<ItemInstance> item) {
|
||||
if (gameMode->getGameRules() != NULL)
|
||||
if (gameMode->getGameRules() != nullptr)
|
||||
gameMode->getGameRules()->onCollectItem(item);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user