From 7074f35e4ba831e358117842b99ee35b87f85ae5 Mon Sep 17 00:00:00 2001 From: void_17 Date: Mon, 2 Mar 2026 15:58:20 +0700 Subject: shared_ptr -> std::shared_ptr This is one of the first commits in a plan to remove all `using namespace std;` lines in the entire codebase as it is considered anti-pattern today. --- Minecraft.World/Entity.cpp | 72 +++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'Minecraft.World/Entity.cpp') diff --git a/Minecraft.World/Entity.cpp b/Minecraft.World/Entity.cpp index 4c9d5cf6..6b602f6e 100644 --- a/Minecraft.World/Entity.cpp +++ b/Minecraft.World/Entity.cpp @@ -309,7 +309,7 @@ void Entity::_init(bool useSmallId) fireImmune = false; // values that need to be sent to clients in SMP - entityData = shared_ptr(new SynchedEntityData()); + entityData = std::shared_ptr(new SynchedEntityData()); xRideRotA = yRideRotA = 0.0; inChunk = false; @@ -350,7 +350,7 @@ Entity::~Entity() delete bb; } -shared_ptr Entity::getEntityData() +std::shared_ptr Entity::getEntityData() { return entityData; } @@ -372,7 +372,7 @@ void Entity::resetPos() { if (level == NULL) return; - shared_ptr sharedThis = shared_from_this(); + std::shared_ptr sharedThis = shared_from_this(); while (true && y > 0) { setPos(x, y, z); @@ -392,7 +392,7 @@ void Entity::remove() void Entity::setSize(float w, float h) { - if (w != bbWidth || h != bbHeight) + if (w != bbWidth || h != bbHeight) { float oldW = bbWidth; @@ -403,7 +403,7 @@ void Entity::setSize(float w, float h) bb->z1 = bb->z0 + bbWidth; bb->y1 = bb->y0 + bbHeight; - if (bbWidth > oldW && !firstTick && !level->isClientSide) + if (bbWidth > oldW && !firstTick && !level->isClientSide) { move(oldW - bbWidth, 0, oldW - bbWidth); } @@ -421,7 +421,7 @@ void Entity::setPos(EntityPos *pos) void Entity::setRot(float yRot, float xRot) { - /* JAVA: + /* JAVA: this->yRot = yRot % 360.0f; this->xRot = xRot % 360.0f; @@ -531,7 +531,7 @@ void Entity::baseTick() fallDistance = 0; wasInWater = true; onFire = 0; - } + } else { wasInWater = false; @@ -541,7 +541,7 @@ void Entity::baseTick() { onFire = 0; } - else + else { if (onFire > 0) { @@ -958,7 +958,7 @@ void Entity::playStepSound(int xt, int yt, int zt, int t) } } else - { + { if (level->getTile(xt, yt + 1, zt) == Tile::topSnow_Id) { soundType = Tile::topSnow->soundType; @@ -1020,7 +1020,7 @@ void Entity::checkFallDamage(double ya, bool onGround) causeFallDamage(fallDistance); fallDistance = 0; } - } + } else { if (ya < 0) fallDistance -= (float) ya; @@ -1169,7 +1169,7 @@ void Entity::moveTo(double x, double y, double z, float yRot, float xRot) this->setPos(this->x, this->y, this->z); } -float Entity::distanceTo(shared_ptr e) +float Entity::distanceTo(std::shared_ptr e) { float xd = (float) (x - e->x); float yd = (float) (y - e->y); @@ -1193,7 +1193,7 @@ double Entity::distanceTo(double x2, double y2, double z2) return sqrt(xd * xd + yd * yd + zd * zd); } -double Entity::distanceToSqr(shared_ptr e) +double Entity::distanceToSqr(std::shared_ptr e) { double xd = x - e->x; double yd = y - e->y; @@ -1201,11 +1201,11 @@ double Entity::distanceToSqr(shared_ptr e) return xd * xd + yd * yd + zd * zd; } -void Entity::playerTouch(shared_ptr player) +void Entity::playerTouch(std::shared_ptr player) { } -void Entity::push(shared_ptr e) +void Entity::push(std::shared_ptr e) { if (e->rider.lock().get() == this || e->riding.get() == this) return; @@ -1277,7 +1277,7 @@ bool Entity::isShootable() return false; } -void Entity::awardKillScore(shared_ptr victim, int score) +void Entity::awardKillScore(std::shared_ptr victim, int score) { } @@ -1437,19 +1437,19 @@ float Entity::getShadowHeightOffs() return bbHeight / 2; } -shared_ptr Entity::spawnAtLocation(int resource, int count) +std::shared_ptr Entity::spawnAtLocation(int resource, int count) { return spawnAtLocation(resource, count, 0); } -shared_ptr Entity::spawnAtLocation(int resource, int count, float yOffs) +std::shared_ptr Entity::spawnAtLocation(int resource, int count, float yOffs) { - return spawnAtLocation(shared_ptr( new ItemInstance(resource, count, 0) ), yOffs); + return spawnAtLocation(std::shared_ptr( new ItemInstance(resource, count, 0) ), yOffs); } -shared_ptr Entity::spawnAtLocation(shared_ptr itemInstance, float yOffs) +std::shared_ptr Entity::spawnAtLocation(std::shared_ptr itemInstance, float yOffs) { - shared_ptr ie = shared_ptr( new ItemEntity(level, x, y + yOffs, z, itemInstance) ); + std::shared_ptr ie = std::shared_ptr( new ItemEntity(level, x, y + yOffs, z, itemInstance) ); ie->throwTime = 10; level->addEntity(ie); return ie; @@ -1478,12 +1478,12 @@ bool Entity::isInWall() return false; } -bool Entity::interact(shared_ptr player) +bool Entity::interact(std::shared_ptr player) { return false; } -AABB *Entity::getCollideAgainstBox(shared_ptr entity) +AABB *Entity::getCollideAgainstBox(std::shared_ptr entity) { return NULL; } @@ -1531,10 +1531,10 @@ void Entity::rideTick() void Entity::positionRider() { - shared_ptr lockedRider = rider.lock(); + std::shared_ptr lockedRider = rider.lock(); if( lockedRider ) { - shared_ptr player = dynamic_pointer_cast(lockedRider); + std::shared_ptr player = dynamic_pointer_cast(lockedRider); if (!(player && player->isLocalPlayer())) { lockedRider->xOld = xOld; @@ -1555,7 +1555,7 @@ double Entity::getRideHeight() return bbHeight * .75; } -void Entity::ride(shared_ptr e) +void Entity::ride(std::shared_ptr e) { xRideRotA = 0; yRideRotA = 0; @@ -1580,7 +1580,7 @@ void Entity::ride(shared_ptr e) } // 4J Stu - Brought forward from 12w36 to fix #46282 - TU5: Gameplay: Exiting the minecart in a tight corridor damages the player -void Entity::findStandUpPosition(shared_ptr vehicle) +void Entity::findStandUpPosition(std::shared_ptr vehicle) { AABB *boundingBox; double fallbackX = vehicle->x; @@ -1690,7 +1690,7 @@ ItemInstanceArray Entity::getEquipmentSlots() // ItemInstance[] } // 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game -void Entity::setEquippedSlot(int slot, shared_ptr item) +void Entity::setEquippedSlot(int slot, std::shared_ptr item) { } @@ -1739,7 +1739,7 @@ bool Entity::isInvisible() return getSharedFlag(FLAG_INVISIBLE); } -bool Entity::isInvisibleTo(shared_ptr plr) +bool Entity::isInvisibleTo(std::shared_ptr plr) { return isInvisible(); } @@ -1777,7 +1777,7 @@ bool Entity::getSharedFlag(int flag) void Entity::setSharedFlag(int flag, bool value) { byte currentValue = entityData->getByte(DATA_SHARED_FLAGS_ID); - if (value) + if (value) { entityData->set(DATA_SHARED_FLAGS_ID, (byte) (currentValue | (1 << flag))); } @@ -1806,7 +1806,7 @@ void Entity::thunderHit(const LightningBolt *lightningBolt) if (onFire == 0) setOnFire(8); } -void Entity::killed(shared_ptr mob) +void Entity::killed(std::shared_ptr mob) { } @@ -1892,12 +1892,12 @@ wstring Entity::getAName() //return I18n.get("entity." + id + ".name"); } -vector > *Entity::getSubEntities() +vector > *Entity::getSubEntities() { return NULL; } -bool Entity::is(shared_ptr other) +bool Entity::is(std::shared_ptr other) { return shared_from_this() == other; } @@ -1921,18 +1921,18 @@ bool Entity::isInvulnerable() return false; } -void Entity::copyPosition(shared_ptr target) +void Entity::copyPosition(std::shared_ptr target) { moveTo(target->x, target->y, target->z, target->yRot, target->xRot); } -void Entity::setAnimOverrideBitmask(unsigned int uiBitmask) +void Entity::setAnimOverrideBitmask(unsigned int uiBitmask) { m_uiAnimOverrideBitmask=uiBitmask; app.DebugPrintf("!!! Setting anim override bitmask to %d\n",uiBitmask); } -unsigned int Entity::getAnimOverrideBitmask() -{ +unsigned int Entity::getAnimOverrideBitmask() +{ if(app.GetGameSettings(eGameSetting_CustomSkinAnim)==0 ) { // We have a force animation for some skins (claptrap) -- cgit v1.2.3