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/Level.h | 120 ++++++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 60 deletions(-) (limited to 'Minecraft.World/Level.h') diff --git a/Minecraft.World/Level.h b/Minecraft.World/Level.h index ecafc02b..abf2489d 100644 --- a/Minecraft.World/Level.h +++ b/Minecraft.World/Level.h @@ -92,22 +92,22 @@ public: public: CRITICAL_SECTION m_entitiesCS; // 4J added - vector > entities; + vector > entities; protected: - vector > entitiesToRemove; + vector > entitiesToRemove; public: bool hasEntitiesToRemove(); // 4J added bool m_bDisableAddNewTileEntities; // 4J Added CRITICAL_SECTION m_tileEntityListCS; // 4J added - vector > tileEntityList; + vector > tileEntityList; private: - vector > pendingTileEntities; - vector > tileEntitiesToUnload; + vector > pendingTileEntities; + vector > tileEntitiesToUnload; bool updatingTileEntities; public: - vector > players; - vector > globalEntities; + vector > players; + vector > globalEntities; private: int cloudColor; @@ -140,16 +140,16 @@ protected: public: ChunkSource *chunkSource; // 4J - changed to public protected: - // This is the only shared_ptr ref to levelStorage - we need to keep this as long as at least one Level references it, + // This is the only std::shared_ptr ref to levelStorage - we need to keep this as long as at least one Level references it, // to be able to cope with moving from dimension to dimension where the Level(Level *level, Dimension *dimension) ctor is used - shared_ptr levelStorage; + std::shared_ptr levelStorage; LevelData *levelData; public: bool isFindingSpawn; SavedDataStorage *savedDataStorage; - shared_ptr villages; + std::shared_ptr villages; VillageSiege *villageSiege; public: @@ -160,13 +160,13 @@ private: // 4J Stu - Added these ctors to handle init of member variables void _init(); - void _init(shared_ptrlevelStorage, const wstring& levelName, LevelSettings *levelSettings, Dimension *fixedDimension, bool doCreateChunkSource = true); + void _init(std::shared_ptrlevelStorage, const wstring& levelName, LevelSettings *levelSettings, Dimension *fixedDimension, bool doCreateChunkSource = true); public: - Level(shared_ptrlevelStorage, const wstring& name, Dimension *dimension, LevelSettings *levelSettings, bool doCreateChunkSource = true); + Level(std::shared_ptrlevelStorage, const wstring& name, Dimension *dimension, LevelSettings *levelSettings, bool doCreateChunkSource = true); Level(Level *level, Dimension *dimension); - Level(shared_ptrlevelStorage, const wstring& levelName, LevelSettings *levelSettings); - Level(shared_ptrlevelStorage, const wstring& levelName, LevelSettings *levelSettings, Dimension *fixedDimension, bool doCreateChunkSource = true); + Level(std::shared_ptrlevelStorage, const wstring& levelName, LevelSettings *levelSettings); + Level(std::shared_ptrlevelStorage, const wstring& levelName, LevelSettings *levelSettings, Dimension *fixedDimension, bool doCreateChunkSource = true); virtual ~Level(); @@ -278,7 +278,7 @@ public: HitResult *clip(Vec3 *a, Vec3 *b, bool liquid); HitResult *clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly); - virtual void playSound(shared_ptr entity, int iSound, float volume, float pitch); + virtual void playSound(std::shared_ptr entity, int iSound, float volume, float pitch); virtual void playSound(double x, double y, double z, int iSound, float volume, float pitch, float fClipSoundDist=16.0f); virtual void playLocalSound(double x, double y, double z, int iSound, float volume, float pitch, float fClipSoundDist=16.0f); @@ -287,17 +287,17 @@ public: void playMusic(double x, double y, double z, const wstring& string, float volume); // 4J removed - void addParticle(const wstring& id, double x, double y, double z, double xd, double yd, double zd); void addParticle(ePARTICLE_TYPE id, double x, double y, double z, double xd, double yd, double zd); // 4J added - virtual bool addGlobalEntity(shared_ptr e); - virtual bool addEntity(shared_ptr e); + virtual bool addGlobalEntity(std::shared_ptr e); + virtual bool addEntity(std::shared_ptr e); protected: - virtual void entityAdded(shared_ptr e); - virtual void entityRemoved(shared_ptr e); - virtual void playerRemoved(shared_ptr e); // 4J added + virtual void entityAdded(std::shared_ptr e); + virtual void entityRemoved(std::shared_ptr e); + virtual void playerRemoved(std::shared_ptr e); // 4J added public: - virtual void removeEntity(shared_ptr e); - void removeEntityImmediately(shared_ptr e); + virtual void removeEntity(std::shared_ptr e); + void removeEntityImmediately(std::shared_ptr e); void addListener(LevelListener *listener); void removeListener(LevelListener *listener); @@ -305,11 +305,11 @@ private: AABBList boxes; public: - AABBList *getCubes(shared_ptr source, AABB *box, bool noEntities=false, bool blockAtEdge=false); // 4J - added noEntities & blockAtEdge parameters + AABBList *getCubes(std::shared_ptr source, AABB *box, bool noEntities=false, bool blockAtEdge=false); // 4J - added noEntities & blockAtEdge parameters AABBList *getTileCubes(AABB *box, bool blockAtEdge); // 4J Stu - Brought forward from 12w36 to fix #46282 - TU5: Gameplay: Exiting the minecart in a tight corridor damages the player int getOldSkyDarken(float a); // 4J - change brought forward from 1.8.2 float getSkyDarken(float a); // 4J - change brought forward from 1.8.2 - Vec3 *getSkyColor(shared_ptr source, float a); + Vec3 *getSkyColor(std::shared_ptr source, float a); float getTimeOfDay(float a); int getMoonPhase(float a); float getSunAngle(float a); @@ -324,29 +324,29 @@ public: virtual void addToTickNextTick(int x, int y, int z, int tileId, int tickDelay); virtual void forceAddTileTick(int x, int y, int z, int tileId, int tickDelay); virtual void tickEntities(); - void addAllPendingTileEntities(vector< shared_ptr >& entities); - void tick(shared_ptr e); - virtual void tick(shared_ptr e, bool actual); + void addAllPendingTileEntities(vector< std::shared_ptr >& entities); + void tick(std::shared_ptr e); + virtual void tick(std::shared_ptr e, bool actual); bool isUnobstructed(AABB *aabb); - bool isUnobstructed(AABB *aabb, shared_ptr ignore); + bool isUnobstructed(AABB *aabb, std::shared_ptr ignore); bool containsAnyBlocks(AABB *box); bool containsAnyLiquid(AABB *box); bool containsAnyLiquid_NoLoad(AABB *box); // 4J added bool containsFireTile(AABB *box); - bool checkAndHandleWater(AABB *box, Material *material, shared_ptr e); + bool checkAndHandleWater(AABB *box, Material *material, std::shared_ptr e); bool containsMaterial(AABB *box, Material *material); bool containsLiquid(AABB *box, Material *material); // 4J Stu - destroyBlocks param brought forward as part of fix for tnt cannons - shared_ptr explode(shared_ptr source, double x, double y, double z, float r, bool destroyBlocks); - virtual shared_ptr explode(shared_ptr source, double x, double y, double z, float r, bool fire, bool destroyBlocks); + std::shared_ptr explode(std::shared_ptr source, double x, double y, double z, float r, bool destroyBlocks); + virtual std::shared_ptr explode(std::shared_ptr source, double x, double y, double z, float r, bool fire, bool destroyBlocks); float getSeenPercent(Vec3 *center, AABB *bb); - bool extinguishFire(shared_ptr player, int x, int y, int z, int face); + bool extinguishFire(std::shared_ptr player, int x, int y, int z, int face); wstring gatherStats(); wstring gatherChunkSourceStats(); - virtual shared_ptr getTileEntity(int x, int y, int z); - void setTileEntity(int x, int y, int z, shared_ptr tileEntity); + virtual std::shared_ptr getTileEntity(int x, int y, int z); + void setTileEntity(int x, int y, int z, std::shared_ptr tileEntity); void removeTileEntity(int x, int y, int z); - void markForRemoval(shared_ptr entity); + void markForRemoval(std::shared_ptr entity); virtual bool isSolidRenderTile(int x, int y, int z); virtual bool isSolidBlockingTile(int x, int y, int z); bool isSolidBlockingTileInLoadedChunk(int x, int y, int z, bool valueIfNotLoaded); @@ -413,38 +413,38 @@ public: virtual vector *fetchTicksInChunk(LevelChunk *chunk, bool remove); private: - vector > es; + vector > es; public: bool isClientSide; - vector > *getEntities(shared_ptr except, AABB *bb); - vector > *getEntitiesOfClass(const type_info& baseClass, AABB *bb); - shared_ptr getClosestEntityOfClass(const type_info& baseClass, AABB *bb, shared_ptr source); - vector > getAllEntities(); - void tileEntityChanged(int x, int y, int z, shared_ptr te); + vector > *getEntities(std::shared_ptr except, AABB *bb); + vector > *getEntitiesOfClass(const type_info& baseClass, AABB *bb); + std::shared_ptr getClosestEntityOfClass(const type_info& baseClass, AABB *bb, std::shared_ptr source); + vector > getAllEntities(); + void tileEntityChanged(int x, int y, int z, std::shared_ptr te); // unsigned int countInstanceOf(BaseObject::Class *clas); unsigned int countInstanceOf(eINSTANCEOF clas, bool singleType, unsigned int *protectedCount = NULL, unsigned int *couldWanderCount = NULL); // 4J added unsigned int countInstanceOfInRange(eINSTANCEOF clas, bool singleType, int range, int x, int y, int z); // 4J Added - void addEntities(vector > *list); - virtual void removeEntities(vector > *list); - bool mayPlace(int tileId, int x, int y, int z, bool ignoreEntities, int face, shared_ptr ignoreEntity); + void addEntities(vector > *list); + virtual void removeEntities(vector > *list); + bool mayPlace(int tileId, int x, int y, int z, bool ignoreEntities, int face, std::shared_ptr ignoreEntity); int getSeaLevel(); - Path *findPath(shared_ptr from, shared_ptr to, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat); - Path *findPath(shared_ptr from, int xBest, int yBest, int zBest, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat); + Path *findPath(std::shared_ptr from, std::shared_ptr to, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat); + Path *findPath(std::shared_ptr from, int xBest, int yBest, int zBest, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat); bool getDirectSignal(int x, int y, int z, int dir); bool hasDirectSignal(int x, int y, int z); bool getSignal(int x, int y, int z, int dir); bool hasNeighborSignal(int x, int y, int z); // 4J Added maxYDist param - shared_ptr getNearestPlayer(shared_ptr source, double maxDist, double maxYDist = -1); - shared_ptr getNearestPlayer(double x, double y, double z, double maxDist, double maxYDist = -1); - shared_ptr getNearestPlayer(double x, double z, double maxDist); - shared_ptr getNearestAttackablePlayer(shared_ptr source, double maxDist); - shared_ptr getNearestAttackablePlayer(double x, double y, double z, double maxDist); - - shared_ptr getPlayerByName(const wstring& name); - shared_ptr getPlayerByUUID(const wstring& name); // 4J Added + std::shared_ptr getNearestPlayer(std::shared_ptr source, double maxDist, double maxYDist = -1); + std::shared_ptr getNearestPlayer(double x, double y, double z, double maxDist, double maxYDist = -1); + std::shared_ptr getNearestPlayer(double x, double z, double maxDist); + std::shared_ptr getNearestAttackablePlayer(std::shared_ptr source, double maxDist); + std::shared_ptr getNearestAttackablePlayer(double x, double y, double z, double maxDist); + + std::shared_ptr getPlayerByName(const wstring& name); + std::shared_ptr getPlayerByUUID(const wstring& name); // 4J Added byteArray getBlocksAndData(int x, int y, int z, int xs, int ys, int zs, bool includeLighting = true); void setBlocksAndData(int x, int y, int z, int xs, int ys, int zs, byteArray data, bool includeLighting = true); virtual void disconnect(bool sendDisconnect = true); @@ -456,9 +456,9 @@ public: Pos *getSharedSpawnPos(); void setSpawnPos(int x, int y, int z); void setSpawnPos(Pos *spawnPos); - void ensureAdded(shared_ptr entity); - virtual bool mayInteract(shared_ptr player, int xt, int yt, int zt, int content); - virtual void broadcastEntityEvent(shared_ptr e, byte event); + void ensureAdded(std::shared_ptr entity); + virtual bool mayInteract(std::shared_ptr player, int xt, int yt, int zt, int content); + virtual void broadcastEntityEvent(std::shared_ptr e, byte event); ChunkSource *getChunkSource(); virtual void tileEvent(int x, int y, int z, int tile, int b0, int b1); LevelStorage *getLevelStorage(); @@ -476,11 +476,11 @@ public: bool isRaining(); bool isRainingAt(int x, int y, int z); bool isHumidAt(int x, int y, int z); - void setSavedData(const wstring& id, shared_ptr data); - shared_ptr getSavedData(const type_info& clazz, const wstring& id); + void setSavedData(const wstring& id, std::shared_ptr data); + std::shared_ptr getSavedData(const type_info& clazz, const wstring& id); int getFreeAuxValueFor(const wstring& id); void levelEvent(int type, int x, int y, int z, int data); - void levelEvent(shared_ptr source, int type, int x, int y, int z, int data); + void levelEvent(std::shared_ptr source, int type, int x, int y, int z, int data); int getMaxBuildHeight(); int getHeight(); Random *getRandomFor(int x, int z, int blend); -- cgit v1.2.3