From a744f8f471d9932cde76dcec61cfc9ca12d1cf8a Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Fri, 6 Mar 2026 20:38:50 -0600 Subject: [PATCH] refactor: deglob `std::weak_ptr` --- Common/GameRules/ConsoleSchematicFile.h | 2 +- Minecraft.Client/Level/MultiPlayerLevel.cpp | 2 +- .../Platform/Durango/Network/ChatIntegrationLayer.cpp | 10 +++++----- Minecraft.Client/Platform/PS3/PS3Extras/Ps3Types.h | 4 ++-- Minecraft.World/AI/Control/Sensing.cpp | 4 ++-- Minecraft.World/AI/Control/Sensing.h | 4 ++-- Minecraft.World/AI/Goals/ArrowAttackGoal.cpp | 6 +++--- Minecraft.World/AI/Goals/ArrowAttackGoal.h | 2 +- Minecraft.World/AI/Goals/AvoidPlayerGoal.cpp | 8 ++++---- Minecraft.World/AI/Goals/AvoidPlayerGoal.h | 2 +- Minecraft.World/AI/Goals/BegGoal.cpp | 6 +++--- Minecraft.World/AI/Goals/BegGoal.h | 2 +- Minecraft.World/AI/Goals/BreedGoal.cpp | 6 +++--- Minecraft.World/AI/Goals/BreedGoal.h | 2 +- Minecraft.World/AI/Goals/DefendVillageTargetGoal.cpp | 2 +- Minecraft.World/AI/Goals/DefendVillageTargetGoal.h | 2 +- Minecraft.World/AI/Goals/FollowOwnerGoal.cpp | 6 +++--- Minecraft.World/AI/Goals/FollowOwnerGoal.h | 2 +- Minecraft.World/AI/Goals/FollowParentGoal.cpp | 4 ++-- Minecraft.World/AI/Goals/FollowParentGoal.h | 2 +- Minecraft.World/AI/Goals/LeapAtTargetGoal.cpp | 4 ++-- Minecraft.World/AI/Goals/LeapAtTargetGoal.h | 2 +- Minecraft.World/AI/Goals/LookAtPlayerGoal.cpp | 4 ++-- Minecraft.World/AI/Goals/LookAtPlayerGoal.h | 2 +- Minecraft.World/AI/Goals/LookAtTradingPlayerGoal.cpp | 2 +- Minecraft.World/AI/Goals/MakeLoveGoal.cpp | 10 +++++----- Minecraft.World/AI/Goals/MakeLoveGoal.h | 4 ++-- Minecraft.World/AI/Goals/MeleeAttackGoal.cpp | 4 ++-- Minecraft.World/AI/Goals/MeleeAttackGoal.h | 2 +- Minecraft.World/AI/Goals/MoveIndoorsGoal.cpp | 6 +++--- Minecraft.World/AI/Goals/MoveIndoorsGoal.h | 2 +- Minecraft.World/AI/Goals/MoveThroughVillageGoal.cpp | 2 +- Minecraft.World/AI/Goals/MoveThroughVillageGoal.h | 4 ++-- Minecraft.World/AI/Goals/MoveTowardsTargetGoal.cpp | 4 ++-- Minecraft.World/AI/Goals/MoveTowardsTargetGoal.h | 2 +- .../AI/Goals/NearestAttackableTargetGoal.cpp | 4 ++-- Minecraft.World/AI/Goals/NearestAttackableTargetGoal.h | 2 +- Minecraft.World/AI/Goals/OcelotAttackGoal.cpp | 6 +++--- Minecraft.World/AI/Goals/OcelotAttackGoal.h | 2 +- Minecraft.World/AI/Goals/OfferFlowerGoal.cpp | 4 ++-- Minecraft.World/AI/Goals/OfferFlowerGoal.h | 2 +- Minecraft.World/AI/Goals/OwnerHurtByTargetGoal.cpp | 2 +- Minecraft.World/AI/Goals/OwnerHurtByTargetGoal.h | 2 +- Minecraft.World/AI/Goals/OwnerHurtTargetGoal.cpp | 2 +- Minecraft.World/AI/Goals/OwnerHurtTargetGoal.h | 2 +- Minecraft.World/AI/Goals/PlayGoal.cpp | 6 +++--- Minecraft.World/AI/Goals/PlayGoal.h | 2 +- Minecraft.World/AI/Goals/RestrictOpenDoorGoal.cpp | 2 +- Minecraft.World/AI/Goals/RestrictOpenDoorGoal.h | 2 +- Minecraft.World/AI/Goals/SwellGoal.cpp | 6 +++--- Minecraft.World/AI/Goals/SwellGoal.h | 2 +- Minecraft.World/AI/Goals/TakeFlowerGoal.cpp | 6 +++--- Minecraft.World/AI/Goals/TakeFlowerGoal.h | 2 +- Minecraft.World/AI/Goals/TemptGoal.cpp | 6 +++--- Minecraft.World/AI/Goals/TemptGoal.h | 2 +- .../Blocks/TileEntities/ChestTileEntity.cpp | 8 ++++---- Minecraft.World/Blocks/TileEntities/ChestTileEntity.h | 8 ++++---- Minecraft.World/Entities/Entity.cpp | 6 +++--- Minecraft.World/Entities/Entity.h | 2 +- Minecraft.World/Entities/Mobs/Animal.h | 2 +- Minecraft.World/Entities/Mobs/Boat.cpp | 2 +- Minecraft.World/Entities/Mobs/Minecart.cpp | 2 +- Minecraft.World/Entities/Mobs/Villager.cpp | 6 +++--- Minecraft.World/Entities/Mobs/Villager.h | 4 ++-- Minecraft.World/Entities/Mobs/VillagerGolem.cpp | 2 +- Minecraft.World/Entities/Mobs/VillagerGolem.h | 2 +- Minecraft.World/Level/Events/VillageSiege.cpp | 2 +- Minecraft.World/Level/Events/VillageSiege.h | 2 +- Minecraft.World/Level/Level.cpp | 4 ++-- Minecraft.World/Player/Player.cpp | 2 +- 70 files changed, 125 insertions(+), 125 deletions(-) diff --git a/Common/GameRules/ConsoleSchematicFile.h b/Common/GameRules/ConsoleSchematicFile.h index f71475fcc..371064960 100644 --- a/Common/GameRules/ConsoleSchematicFile.h +++ b/Common/GameRules/ConsoleSchematicFile.h @@ -56,7 +56,7 @@ public: private: int m_xSize, m_ySize, m_zSize; std::vector > m_tileEntities; - std::vector< pair > m_entities; + std::vector< std::pair > m_entities; public: byteArray m_data; diff --git a/Minecraft.Client/Level/MultiPlayerLevel.cpp b/Minecraft.Client/Level/MultiPlayerLevel.cpp index 02542972d..5ff909bfb 100644 --- a/Minecraft.Client/Level/MultiPlayerLevel.cpp +++ b/Minecraft.Client/Level/MultiPlayerLevel.cpp @@ -818,7 +818,7 @@ void MultiPlayerLevel::removeAllPendingEntityRemovals() { if (e->riding->removed || e->riding->rider.lock() != e) { - e->riding->rider = weak_ptr(); + e->riding->rider = std::(); e->riding = nullptr; } else diff --git a/Minecraft.Client/Platform/Durango/Network/ChatIntegrationLayer.cpp b/Minecraft.Client/Platform/Durango/Network/ChatIntegrationLayer.cpp index 598a60459..12e08b7cc 100644 --- a/Minecraft.Client/Platform/Durango/Network/ChatIntegrationLayer.cpp +++ b/Minecraft.Client/Platform/Durango/Network/ChatIntegrationLayer.cpp @@ -63,7 +63,7 @@ void ChatIntegrationLayer::InitializeChatManager( InitializeCriticalSection(&m_csAddedUsers); - std::weak_ptr weakPtrToThis = shared_from_this(); + std:: weakPtrToThis = shared_from_this(); #ifdef PROFILE m_chatManager->ChatSettings->PerformanceCountersEnabled = true; @@ -74,7 +74,7 @@ void ChatIntegrationLayer::InitializeChatManager( m_tokenResourceAvailabilityChanged = Windows::ApplicationModel::Core::CoreApplication::ResourceAvailabilityChanged += ref new EventHandler< Platform::Object^ >( [weakPtrToThis] (Platform::Object^, Platform::Object^ ) { - // Using a std::weak_ptr instead of 'this' to avoid dangling pointer if caller class is released. + // Using a std:: instead of 'this' to avoid dangling pointer if caller class is released. // Simply unregistering the callback in the destructor isn't enough to prevent a dangling pointer std::shared_ptr sharedPtrToThis(weakPtrToThis.lock()); if( sharedPtrToThis != nullptr ) @@ -103,7 +103,7 @@ void ChatIntegrationLayer::InitializeChatManager( ref new Windows::Foundation::EventHandler( [weakPtrToThis] ( Platform::Object^, Microsoft::Xbox::GameChat::DebugMessageEventArgs^ args ) { - // Using a std::weak_ptr instead of 'this' to avoid dangling pointer if caller class is released. + // Using a std:: instead of 'this' to avoid dangling pointer if caller class is released. // Simply unregistering the callback in the destructor isn't enough to prevent a dangling pointer std::shared_ptr sharedPtrToThis(weakPtrToThis.lock()); if( sharedPtrToThis != nullptr ) @@ -116,7 +116,7 @@ void ChatIntegrationLayer::InitializeChatManager( ref new Windows::Foundation::EventHandler( [weakPtrToThis] ( Platform::Object^, Microsoft::Xbox::GameChat::ChatPacketEventArgs^ args ) { - // Using a std::weak_ptr instead of 'this' to avoid dangling pointer if caller class is released. + // Using a std:: instead of 'this' to avoid dangling pointer if caller class is released. // Simply unregistering the callback in the destructor isn't enough to prevent a dangling pointer std::shared_ptr sharedPtrToThis(weakPtrToThis.lock()); if( sharedPtrToThis != nullptr ) @@ -129,7 +129,7 @@ void ChatIntegrationLayer::InitializeChatManager( ref new Microsoft::Xbox::GameChat::CompareUniqueConsoleIdentifiersHandler( [weakPtrToThis] ( Platform::Object^ obj1, Platform::Object^ obj2 ) { - // Using a std::weak_ptr instead of 'this' to avoid dangling pointer if caller class is released. + // Using a std:: instead of 'this' to avoid dangling pointer if caller class is released. // Simply unregistering the callback in the destructor isn't enough to prevent a dangling pointer std::shared_ptr sharedPtrToThis(weakPtrToThis.lock()); if( sharedPtrToThis != nullptr ) diff --git a/Minecraft.Client/Platform/PS3/PS3Extras/Ps3Types.h b/Minecraft.Client/Platform/PS3/PS3Extras/Ps3Types.h index 241651364..f163be259 100644 --- a/Minecraft.Client/Platform/PS3/PS3Extras/Ps3Types.h +++ b/Minecraft.Client/Platform/PS3/PS3Extras/Ps3Types.h @@ -20,7 +20,7 @@ //#include "winerror.h" -using std::tr1::bad_weak_ptr; +using std::tr1::bad_std::; using std::tr1::const_pointer_cast; using std::tr1::dynamic_pointer_cast; using std::tr1::enable_shared_from_this; @@ -28,7 +28,7 @@ using std::tr1::get_deleter; using std::tr1::std::shared_ptr; using std::tr1::static_pointer_cast; using std::tr1::swap; -using std::tr1::weak_ptr; +using std::tr1::std::; using std::tr1::std::unordered_map; using std::tr1::unordered_set; using boost::hash; diff --git a/Minecraft.World/AI/Control/Sensing.cpp b/Minecraft.World/AI/Control/Sensing.cpp index 4c343bd95..32762c994 100644 --- a/Minecraft.World/AI/Control/Sensing.cpp +++ b/Minecraft.World/AI/Control/Sensing.cpp @@ -29,7 +29,7 @@ bool Sensing::canSee(std::shared_ptr target) //util.Timer.push("canSee"); bool canSee = mob->canSee(target); //util.Timer.pop(); - if (canSee) seen.push_back(weak_ptr(target)); - else unseen.push_back(weak_ptr(target)); + if (canSee) seen.push_back(std::(target)); + else unseen.push_back(std::(target)); return canSee; } \ No newline at end of file diff --git a/Minecraft.World/AI/Control/Sensing.h b/Minecraft.World/AI/Control/Sensing.h index edb8c65ec..d05f13919 100644 --- a/Minecraft.World/AI/Control/Sensing.h +++ b/Minecraft.World/AI/Control/Sensing.h @@ -4,8 +4,8 @@ class Sensing { private: Mob *mob; - std::vector > seen; - std::vector > unseen; + std::vector > seen; + std::vector > unseen; public: Sensing(Mob *mob); diff --git a/Minecraft.World/AI/Goals/ArrowAttackGoal.cpp b/Minecraft.World/AI/Goals/ArrowAttackGoal.cpp index f9e2a01a8..aa49b7d8a 100644 --- a/Minecraft.World/AI/Goals/ArrowAttackGoal.cpp +++ b/Minecraft.World/AI/Goals/ArrowAttackGoal.cpp @@ -12,7 +12,7 @@ ArrowAttackGoal::ArrowAttackGoal(Mob *mob, float speed, int projectileType, int attackInterval) { // 4J Init - target = weak_ptr(); + target = std::(); attackTime = 0; seeTime = 0; @@ -28,7 +28,7 @@ bool ArrowAttackGoal::canUse() { std::shared_ptr bestTarget = mob->getTarget(); if (bestTarget == NULL) return false; - target = weak_ptr(bestTarget); + target = std::(bestTarget); return true; } @@ -39,7 +39,7 @@ bool ArrowAttackGoal::canContinueToUse() void ArrowAttackGoal::stop() { - target = weak_ptr(); + target = std::(); } void ArrowAttackGoal::tick() diff --git a/Minecraft.World/AI/Goals/ArrowAttackGoal.h b/Minecraft.World/AI/Goals/ArrowAttackGoal.h index 0dccdb6f8..37db8b3e8 100644 --- a/Minecraft.World/AI/Goals/ArrowAttackGoal.h +++ b/Minecraft.World/AI/Goals/ArrowAttackGoal.h @@ -10,7 +10,7 @@ public: Level *level; Mob *mob; // Owner of this goal - weak_ptr target; + std:: target; int attackTime; float speed; int seeTime; diff --git a/Minecraft.World/AI/Goals/AvoidPlayerGoal.cpp b/Minecraft.World/AI/Goals/AvoidPlayerGoal.cpp index 123710e97..491333d81 100644 --- a/Minecraft.World/AI/Goals/AvoidPlayerGoal.cpp +++ b/Minecraft.World/AI/Goals/AvoidPlayerGoal.cpp @@ -20,7 +20,7 @@ AvoidPlayerGoal::AvoidPlayerGoal(PathfinderMob *mob, const std::type_info& avoid this->pathNav = mob->getNavigation(); setRequiredControlFlags(Control::MoveControlFlag); - toAvoid = weak_ptr(); + toAvoid = std::(); path = NULL; } @@ -35,7 +35,7 @@ bool AvoidPlayerGoal::canUse() { std::shared_ptr tamableAnimal = dynamic_pointer_cast(mob->shared_from_this()); if (tamableAnimal != NULL && tamableAnimal->isTame()) return false; - toAvoid = weak_ptr(mob->level->getNearestPlayer(mob->shared_from_this(), maxDist)); + toAvoid = std::(mob->level->getNearestPlayer(mob->shared_from_this(), maxDist)); if (toAvoid.lock() == NULL) return false; } else @@ -46,7 +46,7 @@ bool AvoidPlayerGoal::canUse() delete entities; return false; } - toAvoid = weak_ptr(entities->at(0)); + toAvoid = std::(entities->at(0)); delete entities; } @@ -75,7 +75,7 @@ void AvoidPlayerGoal::start() void AvoidPlayerGoal::stop() { - toAvoid = weak_ptr(); + toAvoid = std::(); } void AvoidPlayerGoal::tick() diff --git a/Minecraft.World/AI/Goals/AvoidPlayerGoal.h b/Minecraft.World/AI/Goals/AvoidPlayerGoal.h index 664d16e7c..572aa1360 100644 --- a/Minecraft.World/AI/Goals/AvoidPlayerGoal.h +++ b/Minecraft.World/AI/Goals/AvoidPlayerGoal.h @@ -11,7 +11,7 @@ class AvoidPlayerGoal : public Goal private: PathfinderMob *mob; // Owner of this goal float walkSpeed, sprintSpeed; - weak_ptr toAvoid; + std:: toAvoid; float maxDist; Path *path; PathNavigation *pathNav; diff --git a/Minecraft.World/AI/Goals/BegGoal.cpp b/Minecraft.World/AI/Goals/BegGoal.cpp index 3ade2dae5..6a7d92b11 100644 --- a/Minecraft.World/AI/Goals/BegGoal.cpp +++ b/Minecraft.World/AI/Goals/BegGoal.cpp @@ -8,7 +8,7 @@ BegGoal::BegGoal(Wolf *wolf, float lookDistance) { - player = weak_ptr(); + player = std::(); lookTime = 0; this->wolf = wolf; @@ -19,7 +19,7 @@ BegGoal::BegGoal(Wolf *wolf, float lookDistance) bool BegGoal::canUse() { - player = weak_ptr(level->getNearestPlayer(wolf->shared_from_this(), lookDistance)); + player = std::(level->getNearestPlayer(wolf->shared_from_this(), lookDistance)); if (player.lock() == NULL) return false; wolf->setDespawnProtected(); return playerHoldingInteresting(player.lock()); @@ -42,7 +42,7 @@ void BegGoal::start() void BegGoal::stop() { wolf->setIsInterested(false); - player = weak_ptr(); + player = std::(); } void BegGoal::tick() diff --git a/Minecraft.World/AI/Goals/BegGoal.h b/Minecraft.World/AI/Goals/BegGoal.h index b80a68a58..747bdbc6b 100644 --- a/Minecraft.World/AI/Goals/BegGoal.h +++ b/Minecraft.World/AI/Goals/BegGoal.h @@ -8,7 +8,7 @@ class BegGoal : public Goal { private: Wolf *wolf; // Owner of this goal - weak_ptr player; + std:: player; Level *level; float lookDistance; int lookTime; diff --git a/Minecraft.World/AI/Goals/BreedGoal.cpp b/Minecraft.World/AI/Goals/BreedGoal.cpp index ed1800dd8..96182ca8d 100644 --- a/Minecraft.World/AI/Goals/BreedGoal.cpp +++ b/Minecraft.World/AI/Goals/BreedGoal.cpp @@ -11,7 +11,7 @@ BreedGoal::BreedGoal(Animal *animal, float speed) { - partner = weak_ptr(); + partner = std::(); loveTime = 0; this->animal = animal; @@ -23,7 +23,7 @@ BreedGoal::BreedGoal(Animal *animal, float speed) bool BreedGoal::canUse() { if (!animal->isInLove()) return false; - partner = weak_ptr(getFreePartner()); + partner = std::(getFreePartner()); return partner.lock() != NULL; } @@ -34,7 +34,7 @@ bool BreedGoal::canContinueToUse() void BreedGoal::stop() { - partner = weak_ptr(); + partner = std::(); loveTime = 0; } diff --git a/Minecraft.World/AI/Goals/BreedGoal.h b/Minecraft.World/AI/Goals/BreedGoal.h index 0e07119d5..33fb11e0f 100644 --- a/Minecraft.World/AI/Goals/BreedGoal.h +++ b/Minecraft.World/AI/Goals/BreedGoal.h @@ -10,7 +10,7 @@ class BreedGoal : public Goal private: Animal *animal; // Owner of this goal Level *level; - weak_ptr partner; + std:: partner; int loveTime; float speed; diff --git a/Minecraft.World/AI/Goals/DefendVillageTargetGoal.cpp b/Minecraft.World/AI/Goals/DefendVillageTargetGoal.cpp index b47684cb9..a29da6375 100644 --- a/Minecraft.World/AI/Goals/DefendVillageTargetGoal.cpp +++ b/Minecraft.World/AI/Goals/DefendVillageTargetGoal.cpp @@ -13,7 +13,7 @@ bool DefendVillageTargetGoal::canUse() { std::shared_ptr village = golem->getVillage(); if (village == NULL) return false; - potentialTarget = weak_ptr(village->getClosestAggressor(dynamic_pointer_cast(golem->shared_from_this()))); + potentialTarget = std::(village->getClosestAggressor(dynamic_pointer_cast(golem->shared_from_this()))); return canAttack(potentialTarget.lock(), false); } diff --git a/Minecraft.World/AI/Goals/DefendVillageTargetGoal.h b/Minecraft.World/AI/Goals/DefendVillageTargetGoal.h index d74d95b03..7d40fbc2f 100644 --- a/Minecraft.World/AI/Goals/DefendVillageTargetGoal.h +++ b/Minecraft.World/AI/Goals/DefendVillageTargetGoal.h @@ -8,7 +8,7 @@ class DefendVillageTargetGoal : public TargetGoal { private: VillagerGolem *golem; // Owner of this goal - weak_ptr potentialTarget; + std:: potentialTarget; public: DefendVillageTargetGoal(VillagerGolem *golem); diff --git a/Minecraft.World/AI/Goals/FollowOwnerGoal.cpp b/Minecraft.World/AI/Goals/FollowOwnerGoal.cpp index 9b9ad7ecb..c857ffd72 100644 --- a/Minecraft.World/AI/Goals/FollowOwnerGoal.cpp +++ b/Minecraft.World/AI/Goals/FollowOwnerGoal.cpp @@ -9,7 +9,7 @@ FollowOwnerGoal::FollowOwnerGoal(TamableAnimal *tamable, float speed, float startDistance, float stopDistance) { - owner = weak_ptr(); + owner = std::(); timeToRecalcPath = 0; oldAvoidWater = false; @@ -28,7 +28,7 @@ bool FollowOwnerGoal::canUse() if (owner == NULL) return false; if (tamable->isSitting()) return false; if (tamable->distanceToSqr(owner) < startDistance * startDistance) return false; - this->owner = weak_ptr(owner); + this->owner = std::(owner); return true; } @@ -46,7 +46,7 @@ void FollowOwnerGoal::start() void FollowOwnerGoal::stop() { - owner = weak_ptr(); + owner = std::(); navigation->stop(); tamable->getNavigation()->setAvoidWater(oldAvoidWater); } diff --git a/Minecraft.World/AI/Goals/FollowOwnerGoal.h b/Minecraft.World/AI/Goals/FollowOwnerGoal.h index e7b598fa2..972d9c865 100644 --- a/Minecraft.World/AI/Goals/FollowOwnerGoal.h +++ b/Minecraft.World/AI/Goals/FollowOwnerGoal.h @@ -12,7 +12,7 @@ public: private: TamableAnimal *tamable; // Owner of this goal - weak_ptr owner; + std:: owner; Level *level; float speed; PathNavigation *navigation; diff --git a/Minecraft.World/AI/Goals/FollowParentGoal.cpp b/Minecraft.World/AI/Goals/FollowParentGoal.cpp index a0ca215c9..009b1f8ed 100644 --- a/Minecraft.World/AI/Goals/FollowParentGoal.cpp +++ b/Minecraft.World/AI/Goals/FollowParentGoal.cpp @@ -35,7 +35,7 @@ bool FollowParentGoal::canUse() if (closest == NULL) return false; if (closestDistSqr < 3 * 3) return false; - parent = weak_ptr(closest); + parent = std::(closest); return true; } @@ -54,7 +54,7 @@ void FollowParentGoal::start() void FollowParentGoal::stop() { - parent = weak_ptr(); + parent = std::(); } void FollowParentGoal::tick() diff --git a/Minecraft.World/AI/Goals/FollowParentGoal.h b/Minecraft.World/AI/Goals/FollowParentGoal.h index 0aa64bbfd..72780831c 100644 --- a/Minecraft.World/AI/Goals/FollowParentGoal.h +++ b/Minecraft.World/AI/Goals/FollowParentGoal.h @@ -8,7 +8,7 @@ class FollowParentGoal : public Goal { private: Animal *animal; // Owner of this goal - weak_ptr parent; + std:: parent; float speed; int timeToRecalcPath; diff --git a/Minecraft.World/AI/Goals/LeapAtTargetGoal.cpp b/Minecraft.World/AI/Goals/LeapAtTargetGoal.cpp index 081eaebf8..e554c3e5d 100644 --- a/Minecraft.World/AI/Goals/LeapAtTargetGoal.cpp +++ b/Minecraft.World/AI/Goals/LeapAtTargetGoal.cpp @@ -5,7 +5,7 @@ LeapAtTargetGoal::LeapAtTargetGoal(Mob *mob, float yd) { - target = weak_ptr(); + target = std::(); this->mob = mob; this->yd = yd; @@ -14,7 +14,7 @@ LeapAtTargetGoal::LeapAtTargetGoal(Mob *mob, float yd) bool LeapAtTargetGoal::canUse() { - target = weak_ptr(mob->getTarget()); + target = std::(mob->getTarget()); if (target.lock() == NULL) return false; double d = mob->distanceToSqr(target.lock()); if (d < 2 * 2 || d > 4 * 4) return false; diff --git a/Minecraft.World/AI/Goals/LeapAtTargetGoal.h b/Minecraft.World/AI/Goals/LeapAtTargetGoal.h index 6495e1312..a3561f708 100644 --- a/Minecraft.World/AI/Goals/LeapAtTargetGoal.h +++ b/Minecraft.World/AI/Goals/LeapAtTargetGoal.h @@ -6,7 +6,7 @@ class LeapAtTargetGoal : public Goal { private: Mob *mob; // Owner of this goal - weak_ptr target; + std:: target; float yd; public: diff --git a/Minecraft.World/AI/Goals/LookAtPlayerGoal.cpp b/Minecraft.World/AI/Goals/LookAtPlayerGoal.cpp index 343651030..688aef7be 100644 --- a/Minecraft.World/AI/Goals/LookAtPlayerGoal.cpp +++ b/Minecraft.World/AI/Goals/LookAtPlayerGoal.cpp @@ -29,7 +29,7 @@ bool LookAtPlayerGoal::canUse() { if (mob->getRandom()->nextFloat() >= probability) return false; if (lookAtType == typeid(Player)) lookAt = mob->level->getNearestPlayer(mob->shared_from_this(), lookDistance); - else lookAt = weak_ptr(mob->level->getClosestEntityOfClass(lookAtType, mob->bb->grow(lookDistance, 3, lookDistance), mob->shared_from_this())); + else lookAt = std::(mob->level->getClosestEntityOfClass(lookAtType, mob->bb->grow(lookDistance, 3, lookDistance), mob->shared_from_this())); return lookAt.lock() != NULL; } @@ -47,7 +47,7 @@ void LookAtPlayerGoal::start() void LookAtPlayerGoal::stop() { - lookAt = weak_ptr(); + lookAt = std::(); } void LookAtPlayerGoal::tick() diff --git a/Minecraft.World/AI/Goals/LookAtPlayerGoal.h b/Minecraft.World/AI/Goals/LookAtPlayerGoal.h index 5c05c9d4b..b6aa78d7c 100644 --- a/Minecraft.World/AI/Goals/LookAtPlayerGoal.h +++ b/Minecraft.World/AI/Goals/LookAtPlayerGoal.h @@ -11,7 +11,7 @@ private: Mob *mob; // Owner of this goal protected: - weak_ptr lookAt; + std:: lookAt; private: float lookDistance; diff --git a/Minecraft.World/AI/Goals/LookAtTradingPlayerGoal.cpp b/Minecraft.World/AI/Goals/LookAtTradingPlayerGoal.cpp index 967dfde73..47514888c 100644 --- a/Minecraft.World/AI/Goals/LookAtTradingPlayerGoal.cpp +++ b/Minecraft.World/AI/Goals/LookAtTradingPlayerGoal.cpp @@ -12,7 +12,7 @@ bool LookAtTradingPlayerGoal::canUse() { if (villager->isTrading()) { - lookAt = weak_ptr(dynamic_pointer_cast(villager->getTradingPlayer())); + lookAt = std::(dynamic_pointer_cast(villager->getTradingPlayer())); return true; } return false; diff --git a/Minecraft.World/AI/Goals/MakeLoveGoal.cpp b/Minecraft.World/AI/Goals/MakeLoveGoal.cpp index 75046bf27..60dbaa569 100644 --- a/Minecraft.World/AI/Goals/MakeLoveGoal.cpp +++ b/Minecraft.World/AI/Goals/MakeLoveGoal.cpp @@ -10,8 +10,8 @@ MakeLoveGoal::MakeLoveGoal(Villager *villager) { - village = weak_ptr(); - partner = weak_ptr(); + village = std::(); + partner = std::(); loveMakingTime = 0; this->villager = villager; @@ -32,7 +32,7 @@ bool MakeLoveGoal::canUse() std::shared_ptr mate = level->getClosestEntityOfClass(typeid(Villager), villager->bb->grow(8, 3, 8), villager->shared_from_this()); if (mate == NULL) return false; - partner = weak_ptr(dynamic_pointer_cast(mate)); + partner = std::(dynamic_pointer_cast(mate)); if (partner.lock()->getAge() != 0) return false; return true; @@ -46,8 +46,8 @@ void MakeLoveGoal::start() void MakeLoveGoal::stop() { - village = weak_ptr(); - partner = weak_ptr(); + village = std::(); + partner = std::(); villager->setInLove(false); } diff --git a/Minecraft.World/AI/Goals/MakeLoveGoal.h b/Minecraft.World/AI/Goals/MakeLoveGoal.h index 1e148daac..00350b0f4 100644 --- a/Minecraft.World/AI/Goals/MakeLoveGoal.h +++ b/Minecraft.World/AI/Goals/MakeLoveGoal.h @@ -9,10 +9,10 @@ class MakeLoveGoal : public Goal { private: Villager *villager; // Owner of this goal - weak_ptr partner; + std:: partner; Level *level; int loveMakingTime; - weak_ptr village; + std:: village; public: MakeLoveGoal(Villager *villager); diff --git a/Minecraft.World/AI/Goals/MeleeAttackGoal.cpp b/Minecraft.World/AI/Goals/MeleeAttackGoal.cpp index 31280b98c..7bd611707 100644 --- a/Minecraft.World/AI/Goals/MeleeAttackGoal.cpp +++ b/Minecraft.World/AI/Goals/MeleeAttackGoal.cpp @@ -46,7 +46,7 @@ bool MeleeAttackGoal::canUse() if (bestTarget == NULL) return false; if(!bestTarget->isAlive()) return false; if (attackType != eTYPE_NOTSET && (attackType & bestTarget->GetType()) != attackType) return false; - target = weak_ptr(bestTarget); + target = std::(bestTarget); delete path; path = mob->getNavigation()->createPath(target.lock()); return path != NULL; @@ -71,7 +71,7 @@ void MeleeAttackGoal::start() void MeleeAttackGoal::stop() { - target = weak_ptr(); + target = std::(); mob->getNavigation()->stop(); } diff --git a/Minecraft.World/AI/Goals/MeleeAttackGoal.h b/Minecraft.World/AI/Goals/MeleeAttackGoal.h index c8f5e19d7..6c9352e2c 100644 --- a/Minecraft.World/AI/Goals/MeleeAttackGoal.h +++ b/Minecraft.World/AI/Goals/MeleeAttackGoal.h @@ -11,7 +11,7 @@ class MeleeAttackGoal : public Goal private: Level *level; Mob *mob; // Owner of this goal - weak_ptr target; + std:: target; int attackTime; float speed; diff --git a/Minecraft.World/AI/Goals/MoveIndoorsGoal.cpp b/Minecraft.World/AI/Goals/MoveIndoorsGoal.cpp index 3077d36f5..ce108fd8b 100644 --- a/Minecraft.World/AI/Goals/MoveIndoorsGoal.cpp +++ b/Minecraft.World/AI/Goals/MoveIndoorsGoal.cpp @@ -39,7 +39,7 @@ void MoveIndoorsGoal::start() std::shared_ptr _doorInfo = doorInfo.lock(); if( _doorInfo == NULL ) { - doorInfo = weak_ptr(); + doorInfo = std::(); return; } if (mob->distanceToSqr(_doorInfo->getIndoorX(), _doorInfo->y, _doorInfo->getIndoorZ()) > 16 * 16) @@ -55,11 +55,11 @@ void MoveIndoorsGoal::stop() std::shared_ptr _doorInfo = doorInfo.lock(); if( _doorInfo == NULL ) { - doorInfo = weak_ptr(); + doorInfo = std::(); return; } insideX = _doorInfo->getIndoorX(); insideZ = _doorInfo->getIndoorZ(); - doorInfo = weak_ptr(); + doorInfo = std::(); } \ No newline at end of file diff --git a/Minecraft.World/AI/Goals/MoveIndoorsGoal.h b/Minecraft.World/AI/Goals/MoveIndoorsGoal.h index 4aab62fd0..74bbaa100 100644 --- a/Minecraft.World/AI/Goals/MoveIndoorsGoal.h +++ b/Minecraft.World/AI/Goals/MoveIndoorsGoal.h @@ -9,7 +9,7 @@ class MoveIndoorsGoal : public Goal { private: PathfinderMob *mob; - weak_ptr doorInfo; + std:: doorInfo; int insideX, insideZ; public: diff --git a/Minecraft.World/AI/Goals/MoveThroughVillageGoal.cpp b/Minecraft.World/AI/Goals/MoveThroughVillageGoal.cpp index 1bc8138ad..f0df57528 100644 --- a/Minecraft.World/AI/Goals/MoveThroughVillageGoal.cpp +++ b/Minecraft.World/AI/Goals/MoveThroughVillageGoal.cpp @@ -12,7 +12,7 @@ MoveThroughVillageGoal::MoveThroughVillageGoal(PathfinderMob *mob, float speed, bool onlyAtNight) { path = NULL; - doorInfo = weak_ptr(); + doorInfo = std::(); this->mob = mob; this->speed = speed; diff --git a/Minecraft.World/AI/Goals/MoveThroughVillageGoal.h b/Minecraft.World/AI/Goals/MoveThroughVillageGoal.h index 9899a6d1c..8e4d117f2 100644 --- a/Minecraft.World/AI/Goals/MoveThroughVillageGoal.h +++ b/Minecraft.World/AI/Goals/MoveThroughVillageGoal.h @@ -12,9 +12,9 @@ private: PathfinderMob *mob; float speed; Path *path; - weak_ptr doorInfo; + std:: doorInfo; bool onlyAtNight; - std::vector< weak_ptr > visited; + std::vector< std:: > visited; public: MoveThroughVillageGoal(PathfinderMob *mob, float speed, bool onlyAtNight); diff --git a/Minecraft.World/AI/Goals/MoveTowardsTargetGoal.cpp b/Minecraft.World/AI/Goals/MoveTowardsTargetGoal.cpp index d77193d3e..19a5cea12 100644 --- a/Minecraft.World/AI/Goals/MoveTowardsTargetGoal.cpp +++ b/Minecraft.World/AI/Goals/MoveTowardsTargetGoal.cpp @@ -16,7 +16,7 @@ MoveTowardsTargetGoal::MoveTowardsTargetGoal(PathfinderMob *mob, float speed, fl bool MoveTowardsTargetGoal::canUse() { - target = weak_ptr(mob->getTarget()); + target = std::(mob->getTarget()); if (target.lock() == NULL) return false; if (target.lock()->distanceToSqr(mob->shared_from_this()) > within * within) return false; Vec3 *pos = RandomPos::getPosTowards(dynamic_pointer_cast(mob->shared_from_this()), 16, 7, Vec3::newTemp(target.lock()->x, target.lock()->y, target.lock()->z)); @@ -34,7 +34,7 @@ bool MoveTowardsTargetGoal::canContinueToUse() void MoveTowardsTargetGoal::stop() { - target = weak_ptr(); + target = std::(); } void MoveTowardsTargetGoal::start() diff --git a/Minecraft.World/AI/Goals/MoveTowardsTargetGoal.h b/Minecraft.World/AI/Goals/MoveTowardsTargetGoal.h index 5186b752e..d1201adfd 100644 --- a/Minecraft.World/AI/Goals/MoveTowardsTargetGoal.h +++ b/Minecraft.World/AI/Goals/MoveTowardsTargetGoal.h @@ -6,7 +6,7 @@ class MoveTowardsTargetGoal : public Goal { private: PathfinderMob *mob; - weak_ptr target; + std:: target; double wantedX, wantedY, wantedZ; float speed, within; diff --git a/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.cpp b/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.cpp index ed1b78785..0eba51761 100644 --- a/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.cpp +++ b/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.cpp @@ -41,7 +41,7 @@ bool NearestAttackableTargetGoal::canUse() std::shared_ptr potentialTarget = mob->level->getNearestAttackablePlayer(mob->shared_from_this(), within); if (canAttack(potentialTarget, false)) { - target = weak_ptr(potentialTarget); + target = std::(potentialTarget); return true; } } @@ -55,7 +55,7 @@ bool NearestAttackableTargetGoal::canUse() std::shared_ptr potTarget = dynamic_pointer_cast(*it); if (canAttack(potTarget, false)) { - target = weak_ptr(potTarget); + target = std::(potTarget); return true; } } diff --git a/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.h b/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.h index 9715b3d5f..c5b80f8ff 100644 --- a/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.h +++ b/Minecraft.World/AI/Goals/NearestAttackableTargetGoal.h @@ -17,7 +17,7 @@ public: }; private: - weak_ptr target; + std:: target; const std::type_info& targetType; int randomInterval; DistComp *distComp; diff --git a/Minecraft.World/AI/Goals/OcelotAttackGoal.cpp b/Minecraft.World/AI/Goals/OcelotAttackGoal.cpp index c868e5bdb..329e415a1 100644 --- a/Minecraft.World/AI/Goals/OcelotAttackGoal.cpp +++ b/Minecraft.World/AI/Goals/OcelotAttackGoal.cpp @@ -8,7 +8,7 @@ OzelotAttackGoal::OzelotAttackGoal(Mob *mob) { - target = weak_ptr(); + target = std::(); attackTime = 0; speed = 0; trackTarget = false; @@ -22,7 +22,7 @@ bool OzelotAttackGoal::canUse() { std::shared_ptr bestTarget = mob->getTarget(); if (bestTarget == NULL) return false; - target = weak_ptr(bestTarget); + target = std::(bestTarget); return true; } @@ -35,7 +35,7 @@ bool OzelotAttackGoal::canContinueToUse() void OzelotAttackGoal::stop() { - target = weak_ptr(); + target = std::(); mob->getNavigation()->stop(); } diff --git a/Minecraft.World/AI/Goals/OcelotAttackGoal.h b/Minecraft.World/AI/Goals/OcelotAttackGoal.h index c214b722d..bdc71d385 100644 --- a/Minecraft.World/AI/Goals/OcelotAttackGoal.h +++ b/Minecraft.World/AI/Goals/OcelotAttackGoal.h @@ -7,7 +7,7 @@ class OzelotAttackGoal : public Goal private: Level *level; Mob *mob; - weak_ptr target; + std:: target; int attackTime; float speed; bool trackTarget; diff --git a/Minecraft.World/AI/Goals/OfferFlowerGoal.cpp b/Minecraft.World/AI/Goals/OfferFlowerGoal.cpp index 7f4cbe1f5..9d4e267e3 100644 --- a/Minecraft.World/AI/Goals/OfferFlowerGoal.cpp +++ b/Minecraft.World/AI/Goals/OfferFlowerGoal.cpp @@ -16,7 +16,7 @@ bool OfferFlowerGoal::canUse() { if (!golem->level->isDay()) return false; if (golem->getRandom()->nextInt(8000) != 0) return false; - villager = weak_ptr(dynamic_pointer_cast( golem->level->getClosestEntityOfClass(typeid(Villager), golem->bb->grow(6, 2, 6), golem->shared_from_this()) )); + villager = std::(dynamic_pointer_cast( golem->level->getClosestEntityOfClass(typeid(Villager), golem->bb->grow(6, 2, 6), golem->shared_from_this()) )); return villager.lock() != NULL; } @@ -34,7 +34,7 @@ void OfferFlowerGoal::start() void OfferFlowerGoal::stop() { golem->offerFlower(false); - villager = weak_ptr(); + villager = std::(); } void OfferFlowerGoal::tick() diff --git a/Minecraft.World/AI/Goals/OfferFlowerGoal.h b/Minecraft.World/AI/Goals/OfferFlowerGoal.h index 35622efed..de7d3bca8 100644 --- a/Minecraft.World/AI/Goals/OfferFlowerGoal.h +++ b/Minecraft.World/AI/Goals/OfferFlowerGoal.h @@ -11,7 +11,7 @@ public: private: VillagerGolem *golem; - weak_ptr villager; + std:: villager; int _tick; public: diff --git a/Minecraft.World/AI/Goals/OwnerHurtByTargetGoal.cpp b/Minecraft.World/AI/Goals/OwnerHurtByTargetGoal.cpp index d45f0f2ae..3bb008aa9 100644 --- a/Minecraft.World/AI/Goals/OwnerHurtByTargetGoal.cpp +++ b/Minecraft.World/AI/Goals/OwnerHurtByTargetGoal.cpp @@ -14,7 +14,7 @@ bool OwnerHurtByTargetGoal::canUse() if (!tameAnimal->isTame()) return false; std::shared_ptr owner = tameAnimal->getOwner(); if (owner == NULL) return false; - ownerLastHurtBy = weak_ptr(owner->getLastHurtByMob()); + ownerLastHurtBy = std::(owner->getLastHurtByMob()); return canAttack(ownerLastHurtBy.lock(), false); } diff --git a/Minecraft.World/AI/Goals/OwnerHurtByTargetGoal.h b/Minecraft.World/AI/Goals/OwnerHurtByTargetGoal.h index 48b30313d..2b09089e6 100644 --- a/Minecraft.World/AI/Goals/OwnerHurtByTargetGoal.h +++ b/Minecraft.World/AI/Goals/OwnerHurtByTargetGoal.h @@ -8,7 +8,7 @@ class OwnerHurtByTargetGoal : public TargetGoal { private: TamableAnimal *tameAnimal; // Owner of this goal - weak_ptr ownerLastHurtBy; + std:: ownerLastHurtBy; public: OwnerHurtByTargetGoal(TamableAnimal *tameAnimal); diff --git a/Minecraft.World/AI/Goals/OwnerHurtTargetGoal.cpp b/Minecraft.World/AI/Goals/OwnerHurtTargetGoal.cpp index 29f0965fc..9f4fde7eb 100644 --- a/Minecraft.World/AI/Goals/OwnerHurtTargetGoal.cpp +++ b/Minecraft.World/AI/Goals/OwnerHurtTargetGoal.cpp @@ -14,7 +14,7 @@ bool OwnerHurtTargetGoal::canUse() if (!tameAnimal->isTame()) return false; std::shared_ptr owner = tameAnimal->getOwner(); if (owner == NULL) return false; - ownerLastHurt = weak_ptr(owner->getLastHurtMob()); + ownerLastHurt = std::(owner->getLastHurtMob()); return canAttack(ownerLastHurt.lock(), false); } diff --git a/Minecraft.World/AI/Goals/OwnerHurtTargetGoal.h b/Minecraft.World/AI/Goals/OwnerHurtTargetGoal.h index 710796451..856f2622c 100644 --- a/Minecraft.World/AI/Goals/OwnerHurtTargetGoal.h +++ b/Minecraft.World/AI/Goals/OwnerHurtTargetGoal.h @@ -8,7 +8,7 @@ class OwnerHurtTargetGoal : public TargetGoal { private: TamableAnimal *tameAnimal; // Owner of this goal - weak_ptr ownerLastHurt; + std:: ownerLastHurt; public: OwnerHurtTargetGoal(TamableAnimal *tameAnimal); diff --git a/Minecraft.World/AI/Goals/PlayGoal.cpp b/Minecraft.World/AI/Goals/PlayGoal.cpp index 9cd2e240f..e37131927 100644 --- a/Minecraft.World/AI/Goals/PlayGoal.cpp +++ b/Minecraft.World/AI/Goals/PlayGoal.cpp @@ -11,7 +11,7 @@ PlayGoal::PlayGoal(Villager *mob, float speed) { - followFriend = weak_ptr(); + followFriend = std::(); wantedX = wantedY = wantedZ = 0.0; playTime = 0; @@ -38,7 +38,7 @@ bool PlayGoal::canUse() double distSqr = friendV->distanceToSqr(mob->shared_from_this()); if (distSqr > closestDistSqr) continue; closestDistSqr = distSqr; - followFriend = weak_ptr(friendV); + followFriend = std::(friendV); } delete children; @@ -64,7 +64,7 @@ void PlayGoal::start() void PlayGoal::stop() { mob->setChasing(false); - followFriend = weak_ptr(); + followFriend = std::(); } void PlayGoal::tick() diff --git a/Minecraft.World/AI/Goals/PlayGoal.h b/Minecraft.World/AI/Goals/PlayGoal.h index a1b1a2912..7010bbbd8 100644 --- a/Minecraft.World/AI/Goals/PlayGoal.h +++ b/Minecraft.World/AI/Goals/PlayGoal.h @@ -6,7 +6,7 @@ class PlayGoal : public Goal { private: Villager *mob; - weak_ptr followFriend; + std:: followFriend; float speed; double wantedX, wantedY, wantedZ; int playTime; diff --git a/Minecraft.World/AI/Goals/RestrictOpenDoorGoal.cpp b/Minecraft.World/AI/Goals/RestrictOpenDoorGoal.cpp index 0b1588184..c807603e1 100644 --- a/Minecraft.World/AI/Goals/RestrictOpenDoorGoal.cpp +++ b/Minecraft.World/AI/Goals/RestrictOpenDoorGoal.cpp @@ -39,7 +39,7 @@ void RestrictOpenDoorGoal::stop() { mob->getNavigation()->setCanOpenDoors(true); mob->getNavigation()->setCanPassDoors(true); - doorInfo = weak_ptr(); + doorInfo = std::(); } void RestrictOpenDoorGoal::tick() diff --git a/Minecraft.World/AI/Goals/RestrictOpenDoorGoal.h b/Minecraft.World/AI/Goals/RestrictOpenDoorGoal.h index 184ca513c..f30418cdd 100644 --- a/Minecraft.World/AI/Goals/RestrictOpenDoorGoal.h +++ b/Minecraft.World/AI/Goals/RestrictOpenDoorGoal.h @@ -9,7 +9,7 @@ class RestrictOpenDoorGoal : public Goal { private: PathfinderMob *mob; - weak_ptr doorInfo; + std:: doorInfo; public: RestrictOpenDoorGoal(PathfinderMob *mob); diff --git a/Minecraft.World/AI/Goals/SwellGoal.cpp b/Minecraft.World/AI/Goals/SwellGoal.cpp index 3589a3972..85fae26af 100644 --- a/Minecraft.World/AI/Goals/SwellGoal.cpp +++ b/Minecraft.World/AI/Goals/SwellGoal.cpp @@ -7,7 +7,7 @@ SwellGoal::SwellGoal(Creeper *creeper) { - target = weak_ptr(); + target = std::(); this->creeper = creeper; setRequiredControlFlags(Control::MoveControlFlag); @@ -22,12 +22,12 @@ bool SwellGoal::canUse() void SwellGoal::start() { creeper->getNavigation()->stop(); - target = weak_ptr(creeper->getTarget()); + target = std::(creeper->getTarget()); } void SwellGoal::stop() { - target = weak_ptr(); + target = std::(); } void SwellGoal::tick() diff --git a/Minecraft.World/AI/Goals/SwellGoal.h b/Minecraft.World/AI/Goals/SwellGoal.h index ba6b5379e..c85f17365 100644 --- a/Minecraft.World/AI/Goals/SwellGoal.h +++ b/Minecraft.World/AI/Goals/SwellGoal.h @@ -8,7 +8,7 @@ class SwellGoal : public Goal { private: Creeper *creeper; - weak_ptr target; + std:: target; public: SwellGoal(Creeper *creeper); diff --git a/Minecraft.World/AI/Goals/TakeFlowerGoal.cpp b/Minecraft.World/AI/Goals/TakeFlowerGoal.cpp index f1fc936d0..b9354c10e 100644 --- a/Minecraft.World/AI/Goals/TakeFlowerGoal.cpp +++ b/Minecraft.World/AI/Goals/TakeFlowerGoal.cpp @@ -12,7 +12,7 @@ TakeFlowerGoal::TakeFlowerGoal(Villager *villager) { takeFlower = false; pickupTick = 0; - golem = weak_ptr(); + golem = std::(); this->villager = villager; setRequiredControlFlags(Control::MoveControlFlag | Control::LookControlFlag); @@ -36,7 +36,7 @@ bool TakeFlowerGoal::canUse() std::shared_ptr vg = dynamic_pointer_cast(*it); if (vg->getOfferFlowerTick() > 0) { - golem = weak_ptr(vg); + golem = std::(vg); break; } } @@ -58,7 +58,7 @@ void TakeFlowerGoal::start() void TakeFlowerGoal::stop() { - golem = weak_ptr(); + golem = std::(); villager->getNavigation()->stop(); } diff --git a/Minecraft.World/AI/Goals/TakeFlowerGoal.h b/Minecraft.World/AI/Goals/TakeFlowerGoal.h index 923f35fd1..44fcab6f7 100644 --- a/Minecraft.World/AI/Goals/TakeFlowerGoal.h +++ b/Minecraft.World/AI/Goals/TakeFlowerGoal.h @@ -6,7 +6,7 @@ class TakeFlowerGoal : public Goal { private: Villager *villager; - weak_ptr golem; + std:: golem; int pickupTick; bool takeFlower; diff --git a/Minecraft.World/AI/Goals/TemptGoal.cpp b/Minecraft.World/AI/Goals/TemptGoal.cpp index 3d703db42..0c60dcd84 100644 --- a/Minecraft.World/AI/Goals/TemptGoal.cpp +++ b/Minecraft.World/AI/Goals/TemptGoal.cpp @@ -9,7 +9,7 @@ TemptGoal::TemptGoal(PathfinderMob *mob, float speed, int itemId, bool canScare) { px = py = pz = pRotX = pRotY = 0.0; - player = weak_ptr(); + player = std::(); calmDown = 0; _isRunning = false; oldAvoidWater = false; @@ -28,7 +28,7 @@ bool TemptGoal::canUse() --calmDown; return false; } - player = weak_ptr(mob->level->getNearestPlayer(mob->shared_from_this(), 10)); + player = std::(mob->level->getNearestPlayer(mob->shared_from_this(), 10)); if (player.lock() == NULL) return false; mob->setDespawnProtected(); // If we've got a nearby player, then consider this mob as something we'd miss if it despawned std::shared_ptr item = player.lock()->getSelectedItem(); @@ -71,7 +71,7 @@ void TemptGoal::start() void TemptGoal::stop() { - player = weak_ptr(); + player = std::(); mob->getNavigation()->stop(); calmDown = 100; _isRunning = false; diff --git a/Minecraft.World/AI/Goals/TemptGoal.h b/Minecraft.World/AI/Goals/TemptGoal.h index 78fbe1d84..78a0d4691 100644 --- a/Minecraft.World/AI/Goals/TemptGoal.h +++ b/Minecraft.World/AI/Goals/TemptGoal.h @@ -8,7 +8,7 @@ private: PathfinderMob *mob; float speed; double px, py, pz, pRotX, pRotY; - weak_ptr player; + std:: player; int calmDown ; bool _isRunning; int itemId; diff --git a/Minecraft.World/Blocks/TileEntities/ChestTileEntity.cpp b/Minecraft.World/Blocks/TileEntities/ChestTileEntity.cpp index 5f99d5c1c..27fcee5a8 100644 --- a/Minecraft.World/Blocks/TileEntities/ChestTileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/ChestTileEntity.cpp @@ -158,10 +158,10 @@ void ChestTileEntity::checkNeighbors() if (hasCheckedNeighbors) return; hasCheckedNeighbors = true; - n = weak_ptr(); - e = weak_ptr(); - w = weak_ptr(); - s = weak_ptr(); + n = std::(); + e = std::(); + w = std::(); + s = std::(); if (level->getTile(x - 1, y, z) == Tile::chest_Id) { diff --git a/Minecraft.World/Blocks/TileEntities/ChestTileEntity.h b/Minecraft.World/Blocks/TileEntities/ChestTileEntity.h index d6ef1b8b3..5f82a6114 100644 --- a/Minecraft.World/Blocks/TileEntities/ChestTileEntity.h +++ b/Minecraft.World/Blocks/TileEntities/ChestTileEntity.h @@ -28,10 +28,10 @@ private: public: bool isBonusChest; // 4J added bool hasCheckedNeighbors; - weak_ptr n; - weak_ptr e; - weak_ptr w; - weak_ptr s; + std:: n; + std:: e; + std:: w; + std:: s; float openness, oOpenness; int openCount; diff --git a/Minecraft.World/Entities/Entity.cpp b/Minecraft.World/Entities/Entity.cpp index 73a2d6e26..37ec875e8 100644 --- a/Minecraft.World/Entities/Entity.cpp +++ b/Minecraft.World/Entities/Entity.cpp @@ -257,7 +257,7 @@ void Entity::_init(bool useSmallId) viewScale = 1.0; blocksBuilding = false; - rider = weak_ptr(); + rider = std::(); riding = nullptr; //level = NULL; // Level is assigned to in the original c_tor code @@ -1571,14 +1571,14 @@ void Entity::ride(std::shared_ptr e) { // 4J Stu - Position should already be updated before the SetRidingPacket comes in if(!level->isClientSide) moveTo(riding->x, riding->bb->y0 + riding->bbHeight, riding->z, yRot, xRot); - riding->rider = weak_ptr(); + riding->rider = std::(); } riding = nullptr; return; } if (riding != NULL) { - riding->rider = weak_ptr(); + riding->rider = std::(); } riding = e; e->rider = shared_from_this(); diff --git a/Minecraft.World/Entities/Entity.h b/Minecraft.World/Entities/Entity.h index db771b1b3..85aeda3bd 100644 --- a/Minecraft.World/Entities/Entity.h +++ b/Minecraft.World/Entities/Entity.h @@ -52,7 +52,7 @@ public: double viewScale; bool blocksBuilding; - weak_ptr rider; // Changed to weak to avoid circular dependency between rider/riding entity + std:: rider; // Changed to weak to avoid circular dependency between rider/riding entity std::shared_ptr riding; Level *level; diff --git a/Minecraft.World/Entities/Mobs/Animal.h b/Minecraft.World/Entities/Mobs/Animal.h index 32fa00229..2d8e7b3eb 100644 --- a/Minecraft.World/Entities/Mobs/Animal.h +++ b/Minecraft.World/Entities/Mobs/Animal.h @@ -13,7 +13,7 @@ private: // int inLove; // 4J removed - now synched data int loveTime; - weak_ptr loveCause; + std:: loveCause; public: Animal(Level *level); diff --git a/Minecraft.World/Entities/Mobs/Boat.cpp b/Minecraft.World/Entities/Mobs/Boat.cpp index 526d9126b..f66a03eae 100644 --- a/Minecraft.World/Entities/Mobs/Boat.cpp +++ b/Minecraft.World/Entities/Mobs/Boat.cpp @@ -434,7 +434,7 @@ void Boat::tick() if (rider.lock() != NULL) { - if (rider.lock()->removed) rider = weak_ptr(); + if (rider.lock()->removed) rider = std::(); } } diff --git a/Minecraft.World/Entities/Mobs/Minecart.cpp b/Minecraft.World/Entities/Mobs/Minecart.cpp index dde436888..8210859e0 100644 --- a/Minecraft.World/Entities/Mobs/Minecart.cpp +++ b/Minecraft.World/Entities/Mobs/Minecart.cpp @@ -696,7 +696,7 @@ void Minecart::tick() { rider.lock()->riding = nullptr; } - rider = weak_ptr(); + rider = std::(); } } diff --git a/Minecraft.World/Entities/Mobs/Villager.cpp b/Minecraft.World/Entities/Mobs/Villager.cpp index 3200be6de..555bf4555 100644 --- a/Minecraft.World/Entities/Mobs/Villager.cpp +++ b/Minecraft.World/Entities/Mobs/Villager.cpp @@ -37,9 +37,9 @@ void Villager::_init(int profession) villageUpdateInterval = 0; inLove = false; chasing = false; - village = weak_ptr(); + village = std::(); - tradingPlayer = weak_ptr(); + tradingPlayer = std::(); offers = NULL; updateMerchantTimer = 0; addRecipeOnUpdate = false; @@ -342,7 +342,7 @@ void Villager::die(DamageSource *source) void Villager::setTradingPlayer(std::shared_ptr player) { - tradingPlayer = weak_ptr(player); + tradingPlayer = std::(player); } std::shared_ptr Villager::getTradingPlayer() diff --git a/Minecraft.World/Entities/Mobs/Villager.h b/Minecraft.World/Entities/Mobs/Villager.h index 16fe40d47..d2250c27f 100644 --- a/Minecraft.World/Entities/Mobs/Villager.h +++ b/Minecraft.World/Entities/Mobs/Villager.h @@ -32,9 +32,9 @@ private: bool inLove; bool chasing; - weak_ptr village; + std:: village; - weak_ptr tradingPlayer; + std:: tradingPlayer; MerchantRecipeList *offers; int updateMerchantTimer; bool addRecipeOnUpdate; diff --git a/Minecraft.World/Entities/Mobs/VillagerGolem.cpp b/Minecraft.World/Entities/Mobs/VillagerGolem.cpp index ff49cead2..fb5f72ec6 100644 --- a/Minecraft.World/Entities/Mobs/VillagerGolem.cpp +++ b/Minecraft.World/Entities/Mobs/VillagerGolem.cpp @@ -28,7 +28,7 @@ VillagerGolem::VillagerGolem(Level *level) : Golem(level) health = getMaxHealth(); villageUpdateInterval = 0; - village = weak_ptr(); + village = std::(); attackAnimationTick = 0; offerFlowerTick = 0; diff --git a/Minecraft.World/Entities/Mobs/VillagerGolem.h b/Minecraft.World/Entities/Mobs/VillagerGolem.h index 17a0bf6dd..f677c3fb8 100644 --- a/Minecraft.World/Entities/Mobs/VillagerGolem.h +++ b/Minecraft.World/Entities/Mobs/VillagerGolem.h @@ -16,7 +16,7 @@ protected: private: int villageUpdateInterval; - weak_ptr village; + std:: village; int attackAnimationTick; int offerFlowerTick; diff --git a/Minecraft.World/Level/Events/VillageSiege.cpp b/Minecraft.World/Level/Events/VillageSiege.cpp index 1c539081d..266f3ee9b 100644 --- a/Minecraft.World/Level/Events/VillageSiege.cpp +++ b/Minecraft.World/Level/Events/VillageSiege.cpp @@ -11,7 +11,7 @@ VillageSiege::VillageSiege(Level *level) siegeState = SIEGE_NOT_INITED; siegeCount = 0; nextSpawnTime = 0; - village = weak_ptr(); + village = std::(); spawnX = spawnY = spawnZ = 0; this->level = level; diff --git a/Minecraft.World/Level/Events/VillageSiege.h b/Minecraft.World/Level/Events/VillageSiege.h index 61c1982e3..cee170107 100644 --- a/Minecraft.World/Level/Events/VillageSiege.h +++ b/Minecraft.World/Level/Events/VillageSiege.h @@ -8,7 +8,7 @@ private: int siegeState; int siegeCount; int nextSpawnTime; - weak_ptr village; + std:: village; int spawnX, spawnY, spawnZ; static const int SIEGE_NOT_INITED = -1; diff --git a/Minecraft.World/Level/Level.cpp b/Minecraft.World/Level/Level.cpp index d19c78502..898c78982 100644 --- a/Minecraft.World/Level/Level.cpp +++ b/Minecraft.World/Level/Level.cpp @@ -2273,7 +2273,7 @@ void Level::tickEntities() { if (e->riding->removed || e->riding->rider.lock() != e) { - e->riding->rider = weak_ptr(); + e->riding->rider = std::(); e->riding = nullptr; } else @@ -2521,7 +2521,7 @@ void Level::tick(std::shared_ptr e, bool actual) if (e->rider.lock()->removed || e->rider.lock()->riding != e) { e->rider.lock()->riding = nullptr; - e->rider = weak_ptr(); + e->rider = std::(); } else { diff --git a/Minecraft.World/Player/Player.cpp b/Minecraft.World/Player/Player.cpp index 72ea5c13e..ff5a00e0e 100644 --- a/Minecraft.World/Player/Player.cpp +++ b/Minecraft.World/Player/Player.cpp @@ -603,7 +603,7 @@ void Player::ride(std::shared_ptr e) if (riding != NULL) { - riding->rider = weak_ptr(); + riding->rider = std::(); } riding = nullptr;