From a56cfd1f42663856e346a26cbad401aec07bed91 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Thu, 20 Jul 2017 12:19:18 +0100 Subject: [PATCH] Remove smart pointer macros --- src/Bindings/LuaServerHandle.h | 4 ++-- src/Bindings/LuaState.h | 14 +++++++------- src/Bindings/LuaTCPLink.h | 2 +- src/Bindings/LuaUDPEndpoint.h | 2 +- src/Bindings/PluginManager.h | 4 ++-- src/ClientHandle.h | 2 +- src/Generating/ComposableGenerator.h | 10 +++++----- src/Generating/GridStructGen.h | 2 +- src/Generating/HeiGen.cpp | 2 +- src/Generating/HeiGen.h | 2 +- src/Generating/PiecePool.h | 4 ++-- src/Generating/PieceStructuresGen.h | 2 +- src/Generating/PrefabPiecePool.cpp | 2 +- src/Generating/PrefabPiecePool.h | 2 +- src/Generating/ShapeGen.cpp | 2 +- src/Generating/VillageGen.cpp | 2 +- src/Generating/VillageGen.h | 2 +- src/Globals.h | 5 ----- src/HTTP/HTTPMessage.h | 2 +- src/HTTP/TransferEncodingParser.h | 2 +- src/HTTP/UrlClient.cpp | 12 ++++++------ src/HTTP/UrlClient.h | 2 +- src/OSSupport/HostnameLookup.h | 2 +- src/OSSupport/IPLookup.h | 2 +- src/OSSupport/Network.h | 18 +++++++++--------- src/OSSupport/NetworkSingleton.h | 4 ++-- src/OSSupport/ServerHandleImpl.h | 4 ++-- src/OSSupport/TCPLinkImpl.h | 8 ++++---- src/OSSupport/UDPEndpointImpl.h | 2 +- src/PolarSSL++/CryptoKey.h | 2 +- src/PolarSSL++/CtrDrbgContext.cpp | 2 +- src/PolarSSL++/CtrDrbgContext.h | 4 ++-- src/PolarSSL++/RsaPrivateKey.h | 2 +- src/PolarSSL++/SslContext.cpp | 2 +- src/PolarSSL++/SslContext.h | 4 ++-- src/PolarSSL++/X509Cert.h | 2 +- src/Protocol/MojangAPI.h | 2 +- src/Server.h | 2 +- src/SetChunkData.h | 2 +- src/WebAdmin.cpp | 2 +- src/WebAdmin.h | 8 ++++---- src/World.cpp | 6 +++--- src/World.h | 6 +++--- src/WorldStorage/WSSAnvil.cpp | 2 +- 44 files changed, 83 insertions(+), 88 deletions(-) diff --git a/src/Bindings/LuaServerHandle.h b/src/Bindings/LuaServerHandle.h index 1aad45f52..59acdc0e7 100644 --- a/src/Bindings/LuaServerHandle.h +++ b/src/Bindings/LuaServerHandle.h @@ -18,10 +18,10 @@ // fwd: class cLuaTCPLink; -typedef SharedPtr cLuaTCPLinkPtr; +typedef std::shared_ptr cLuaTCPLinkPtr; typedef std::vector cLuaTCPLinkPtrs; class cLuaServerHandle; -typedef SharedPtr cLuaServerHandlePtr; +typedef std::shared_ptr cLuaServerHandlePtr; diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index d8f39b09e..9e354392b 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -270,8 +270,8 @@ public: Use a smart pointer for a copyable object. */ cTrackedRef(cTrackedRef &&) = delete; }; - typedef UniquePtr cTrackedRefPtr; - typedef SharedPtr cTrackedRefSharedPtr; + typedef std::unique_ptr cTrackedRefPtr; + typedef std::shared_ptr cTrackedRefSharedPtr; /** Represents a stored callback to Lua that C++ code can call. @@ -324,8 +324,8 @@ public: Use cCallbackPtr for a copyable object. */ cCallback(cCallback &&) = delete; }; - typedef UniquePtr cCallbackPtr; - typedef SharedPtr cCallbackSharedPtr; + typedef std::unique_ptr cCallbackPtr; + typedef std::shared_ptr cCallbackSharedPtr; /** Same thing as cCallback, but GetStackValue() won't fail if the callback value is nil. @@ -354,7 +354,7 @@ public: Use cCallbackPtr for a copyable object. */ cOptionalCallback(cOptionalCallback &&) = delete; }; - typedef UniquePtr cOptionalCallbackPtr; + typedef std::unique_ptr cOptionalCallbackPtr; /** Represents a stored Lua table with callback functions that C++ code can call. @@ -416,7 +416,7 @@ public: Returns true on success, false on failure (not a table at the specified stack pos). */ bool RefStack(cLuaState & a_LuaState, int a_StackPos); }; - typedef UniquePtr cTableRefPtr; + typedef std::unique_ptr cTableRefPtr; /** Represents a parameter that is optional - calling a GetStackValue() with this object will not fail if the value on the Lua stack is nil. @@ -539,7 +539,7 @@ public: /** The stack index where the table resides in the Lua state. */ int m_StackPos; }; - typedef UniquePtr cStackTablePtr; + typedef std::unique_ptr cStackTablePtr; /** Creates a new instance. The LuaState is not initialized. diff --git a/src/Bindings/LuaTCPLink.h b/src/Bindings/LuaTCPLink.h index 4211c3b64..6e5a78b4d 100644 --- a/src/Bindings/LuaTCPLink.h +++ b/src/Bindings/LuaTCPLink.h @@ -18,7 +18,7 @@ // fwd: class cLuaServerHandle; -typedef WeakPtr cLuaServerHandleWPtr; +typedef std::weak_ptr cLuaServerHandleWPtr; diff --git a/src/Bindings/LuaUDPEndpoint.h b/src/Bindings/LuaUDPEndpoint.h index 04c6ea134..0b37f2903 100644 --- a/src/Bindings/LuaUDPEndpoint.h +++ b/src/Bindings/LuaUDPEndpoint.h @@ -18,7 +18,7 @@ // fwd: class cLuaUDPEndpoint; -typedef SharedPtr cLuaUDPEndpointPtr; +typedef std::shared_ptr cLuaUDPEndpointPtr; diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 7c818ca2d..f38ac8fa1 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -29,7 +29,7 @@ class cSettingsRepositoryInterface; class cDeadlockDetect; struct TakeDamageInfo; -typedef SharedPtr cPluginPtr; +typedef std::shared_ptr cPluginPtr; typedef std::vector cPluginPtrs; @@ -187,7 +187,7 @@ public: ) = 0; }; - typedef SharedPtr cCommandHandlerPtr; + typedef std::shared_ptr cCommandHandlerPtr; /** The interface used for enumerating and extern-calling plugins */ diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 4c37262c2..cc7f9f6f0 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -44,7 +44,7 @@ class cWorld; class cCompositeChat; class cStatManager; class cClientHandle; -typedef SharedPtr cClientHandlePtr; +typedef std::shared_ptr cClientHandlePtr; diff --git a/src/Generating/ComposableGenerator.h b/src/Generating/ComposableGenerator.h index 056303db1..0b7e795d2 100644 --- a/src/Generating/ComposableGenerator.h +++ b/src/Generating/ComposableGenerator.h @@ -30,11 +30,11 @@ class cTerrainShapeGen; class cTerrainHeightGen; class cTerrainCompositionGen; class cFinishGen; -typedef SharedPtr cBiomeGenPtr; -typedef SharedPtr cTerrainShapeGenPtr; -typedef SharedPtr cTerrainHeightGenPtr; -typedef SharedPtr cTerrainCompositionGenPtr; -typedef SharedPtr cFinishGenPtr; +typedef std::shared_ptr cBiomeGenPtr; +typedef std::shared_ptr cTerrainShapeGenPtr; +typedef std::shared_ptr cTerrainHeightGenPtr; +typedef std::shared_ptr cTerrainCompositionGenPtr; +typedef std::shared_ptr cFinishGenPtr; diff --git a/src/Generating/GridStructGen.h b/src/Generating/GridStructGen.h index 30cb9d670..49d138217 100644 --- a/src/Generating/GridStructGen.h +++ b/src/Generating/GridStructGen.h @@ -74,7 +74,7 @@ public: /** Returns the cost of keeping this structure in the cache */ virtual size_t GetCacheCost(void) const { return 1; } } ; - typedef SharedPtr cStructurePtr; + typedef std::shared_ptr cStructurePtr; typedef std::list cStructurePtrs; diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index b724a1dde..42df16e73 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -68,7 +68,7 @@ public: protected: int m_Seed; - SharedPtr m_Gen; + std::shared_ptr m_Gen; }; diff --git a/src/Generating/HeiGen.h b/src/Generating/HeiGen.h index 0f7b59093..24fe7e82e 100644 --- a/src/Generating/HeiGen.h +++ b/src/Generating/HeiGen.h @@ -79,7 +79,7 @@ public: bool GetHeightAt(int a_ChunkX, int a_ChunkZ, int a_RelX, int a_RelZ, HEIGHTTYPE & a_Height); protected: - typedef SharedPtr cHeiGenCachePtr; + typedef std::shared_ptr cHeiGenCachePtr; typedef std::vector cHeiGenCachePtrs; diff --git a/src/Generating/PiecePool.h b/src/Generating/PiecePool.h index 84f511950..0c1a701f9 100644 --- a/src/Generating/PiecePool.h +++ b/src/Generating/PiecePool.h @@ -118,7 +118,7 @@ public: virtual void AssignGens(int a_Seed, cBiomeGenPtr & a_BiomeGen, cTerrainHeightGenPtr & a_TerrainHeightGen, int a_SeaLevel) {} }; - typedef SharedPtr cVerticalStrategyPtr; + typedef std::shared_ptr cVerticalStrategyPtr; /** Base class (interface) for the vertical limit of piece placement. @@ -145,7 +145,7 @@ public: virtual void AssignGens(int a_Seed, cBiomeGenPtr & a_BiomeGen, cTerrainHeightGenPtr & a_TerrainHeightGen, int a_SeaLevel) {} }; - typedef SharedPtr cVerticalLimitPtr; + typedef std::shared_ptr cVerticalLimitPtr; /** The strategy used for vertical placement of this piece when it is used as a starting piece. */ diff --git a/src/Generating/PieceStructuresGen.h b/src/Generating/PieceStructuresGen.h index 0e36fe9d5..e3bd1bb59 100644 --- a/src/Generating/PieceStructuresGen.h +++ b/src/Generating/PieceStructuresGen.h @@ -44,7 +44,7 @@ protected: Forward-declared so that its implementation changes don't affect the header. */ class cGen; - typedef SharedPtr cGenPtr; + typedef std::shared_ptr cGenPtr; typedef std::vector cGenPtrs; diff --git a/src/Generating/PrefabPiecePool.cpp b/src/Generating/PrefabPiecePool.cpp index 9c4e24e92..551b81376 100644 --- a/src/Generating/PrefabPiecePool.cpp +++ b/src/Generating/PrefabPiecePool.cpp @@ -372,7 +372,7 @@ bool cPrefabPiecePool::LoadCubesetPieceVer1(const AString & a_FileName, cLuaStat -UniquePtr cPrefabPiecePool::LoadPrefabFromCubesetVer1( +std::unique_ptr cPrefabPiecePool::LoadPrefabFromCubesetVer1( const AString & a_FileName, cLuaState & a_LuaState, const AString & a_PieceName, diff --git a/src/Generating/PrefabPiecePool.h b/src/Generating/PrefabPiecePool.h index 14df221c6..425b64607 100644 --- a/src/Generating/PrefabPiecePool.h +++ b/src/Generating/PrefabPiecePool.h @@ -190,7 +190,7 @@ protected: Returns the prefab on success, nullptr on failure. a_PieceName is the identification of the piece, used for logging only. If a_LogWarnings is true, logs a warning to console when loading fails. */ - UniquePtr LoadPrefabFromCubesetVer1( + std::unique_ptr LoadPrefabFromCubesetVer1( const AString & a_FileName, cLuaState & a_LuaState, const AString & a_PieceName, diff --git a/src/Generating/ShapeGen.cpp b/src/Generating/ShapeGen.cpp index e3de6e733..2e764a530 100644 --- a/src/Generating/ShapeGen.cpp +++ b/src/Generating/ShapeGen.cpp @@ -66,7 +66,7 @@ protected: cTerrainHeightGenPtr m_HeightGen; }; -typedef SharedPtr cTerrainHeightToShapeGenPtr; +typedef std::shared_ptr cTerrainHeightToShapeGenPtr; diff --git a/src/Generating/VillageGen.cpp b/src/Generating/VillageGen.cpp index 1b6f012db..bf1fee2e8 100644 --- a/src/Generating/VillageGen.cpp +++ b/src/Generating/VillageGen.cpp @@ -381,7 +381,7 @@ cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_GridX, int a_Gr { auto biome = Biomes[i]; availablePools.erase(std::remove_if(availablePools.begin(), availablePools.end(), - [biome](SharedPtr a_Pool) + [biome](std::shared_ptr & a_Pool) { return !a_Pool->IsBiomeAllowed(biome); }), diff --git a/src/Generating/VillageGen.h b/src/Generating/VillageGen.h index a7fc1b255..9de8552b1 100644 --- a/src/Generating/VillageGen.h +++ b/src/Generating/VillageGen.h @@ -44,7 +44,7 @@ public: protected: class cVillage; // fwd: VillageGen.cpp - typedef std::vector > cVillagePiecePools; + typedef std::vector> cVillagePiecePools; /** The noise used for generating random numbers */ cNoise m_RandNoise; diff --git a/src/Globals.h b/src/Globals.h index dcac8dd94..eba3e6d98 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -421,11 +421,6 @@ template class SizeChecker; #define assert_test(x) ( !!(x) || (assert(!#x), exit(1), 0)) #endif -// Unified ptr types from before C++11. Also no silly undercores. -#define SharedPtr std::shared_ptr -#define WeakPtr std::weak_ptr -#define UniquePtr std::unique_ptr - diff --git a/src/HTTP/HTTPMessage.h b/src/HTTP/HTTPMessage.h index 9afcd5b97..659fd5331 100644 --- a/src/HTTP/HTTPMessage.h +++ b/src/HTTP/HTTPMessage.h @@ -96,7 +96,7 @@ public: // Force a virtual destructor in descendants: virtual ~cUserData() {} }; - typedef SharedPtr cUserDataPtr; + typedef std::shared_ptr cUserDataPtr; /** Creates a new instance of the class, containing the method and URL provided by the client. */ diff --git a/src/HTTP/TransferEncodingParser.h b/src/HTTP/TransferEncodingParser.h index ce3d01df7..328186029 100644 --- a/src/HTTP/TransferEncodingParser.h +++ b/src/HTTP/TransferEncodingParser.h @@ -11,7 +11,7 @@ // fwd: class cTransferEncodingParser; -typedef SharedPtr cTransferEncodingParserPtr; +typedef std::shared_ptr cTransferEncodingParserPtr; diff --git a/src/HTTP/UrlClient.cpp b/src/HTTP/UrlClient.cpp index 29d5e28d7..f7d12028d 100644 --- a/src/HTTP/UrlClient.cpp +++ b/src/HTTP/UrlClient.cpp @@ -16,7 +16,7 @@ // fwd: class cSchemeHandler; -typedef SharedPtr cSchemeHandlerPtr; +typedef std::shared_ptr cSchemeHandlerPtr; @@ -40,7 +40,7 @@ public: { // Create a new instance of cUrlClientRequest, wrapped in a SharedPtr, so that it has a controlled lifetime. // Cannot use std::make_shared, because the constructor is not public - SharedPtr ptr (new cUrlClientRequest( + std::shared_ptr ptr (new cUrlClientRequest( a_Method, a_URL, std::move(a_Callbacks), std::move(a_Headers), a_Body, std::move(a_Options) )); return ptr->DoRequest(ptr); @@ -128,10 +128,10 @@ protected: /** SharedPtr to self, so that this object can keep itself alive for as long as it needs, and pass self as callbacks to cNetwork functions. */ - SharedPtr m_Self; + std::shared_ptr m_Self; /** The handler that "talks" the protocol specified in m_UrlScheme, handles all the sending and receiving. */ - SharedPtr m_SchemeHandler; + std::shared_ptr m_SchemeHandler; /** The link handling the request. */ cTCPLinkPtr m_Link; @@ -161,7 +161,7 @@ protected: } - std::pair DoRequest(SharedPtr a_Self); + std::pair DoRequest(std::shared_ptr a_Self); // cNetwork::cConnectCallbacks override: TCP link connected: @@ -569,7 +569,7 @@ void cUrlClientRequest::OnRemoteClosed() -std::pair cUrlClientRequest::DoRequest(SharedPtr a_Self) +std::pair cUrlClientRequest::DoRequest(std::shared_ptr a_Self) { // We need a shared pointer to self, care must be taken not to pass any other ptr: ASSERT(a_Self.get() == this); diff --git a/src/HTTP/UrlClient.h b/src/HTTP/UrlClient.h index ac772235e..02c7cb89c 100644 --- a/src/HTTP/UrlClient.h +++ b/src/HTTP/UrlClient.h @@ -86,7 +86,7 @@ public: for such a response; instead, the redirect is silently attempted. */ virtual void OnRedirecting(const AString & a_NewLocation) {} }; - typedef UniquePtr cCallbacksPtr; + typedef std::unique_ptr cCallbacksPtr; /** Used for HTTP status codes. */ diff --git a/src/OSSupport/HostnameLookup.h b/src/OSSupport/HostnameLookup.h index 559dfad5f..9189ef021 100644 --- a/src/OSSupport/HostnameLookup.h +++ b/src/OSSupport/HostnameLookup.h @@ -37,7 +37,7 @@ protected: void Callback(int a_ErrCode, struct addrinfo * a_Addr); }; -typedef SharedPtr cHostnameLookupPtr; +typedef std::shared_ptr cHostnameLookupPtr; typedef std::vector cHostnameLookupPtrs; diff --git a/src/OSSupport/IPLookup.h b/src/OSSupport/IPLookup.h index 600ce0af2..4e3065f1c 100644 --- a/src/OSSupport/IPLookup.h +++ b/src/OSSupport/IPLookup.h @@ -39,7 +39,7 @@ protected: /** Callback that is called by LibEvent when there's an event for the request. */ void Callback(int a_Result, const char * a_Address); }; -typedef SharedPtr cIPLookupPtr; +typedef std::shared_ptr cIPLookupPtr; typedef std::vector cIPLookupPtrs; diff --git a/src/OSSupport/Network.h b/src/OSSupport/Network.h index 78c5e92f0..babf0c078 100644 --- a/src/OSSupport/Network.h +++ b/src/OSSupport/Network.h @@ -15,15 +15,15 @@ // fwd: class cTCPLink; -typedef SharedPtr cTCPLinkPtr; +typedef std::shared_ptr cTCPLinkPtr; typedef std::vector cTCPLinkPtrs; class cServerHandle; -typedef SharedPtr cServerHandlePtr; +typedef std::shared_ptr cServerHandlePtr; typedef std::vector cServerHandlePtrs; class cCryptoKey; -typedef SharedPtr cCryptoKeyPtr; +typedef std::shared_ptr cCryptoKeyPtr; class cX509Cert; -typedef SharedPtr cX509CertPtr; +typedef std::shared_ptr cX509CertPtr; @@ -61,7 +61,7 @@ public: /** Called when an error is detected on the connection. */ virtual void OnError(int a_ErrorCode, const AString & a_ErrorMsg) = 0; }; - typedef SharedPtr cCallbacksPtr; + typedef std::shared_ptr cCallbacksPtr; // Force a virtual destructor for all descendants: @@ -215,7 +215,7 @@ protected: } }; -typedef SharedPtr cUDPEndpointPtr; +typedef std::shared_ptr cUDPEndpointPtr; @@ -238,7 +238,7 @@ public: /** Called when the Connect call fails. */ virtual void OnError(int a_ErrorCode, const AString & a_ErrorMsg) = 0; }; - typedef SharedPtr cConnectCallbacksPtr; + typedef std::shared_ptr cConnectCallbacksPtr; /** Callbacks used when listening for incoming connections as a server. */ @@ -262,7 +262,7 @@ public: /** Called when the socket fails to listen on the specified port. */ virtual void OnError(int a_ErrorCode, const AString & a_ErrorMsg) = 0; }; - typedef SharedPtr cListenCallbacksPtr; + typedef std::shared_ptr cListenCallbacksPtr; /** Callbacks used when resolving names to IPs. */ @@ -298,7 +298,7 @@ public: Only called if there was no error reported. */ virtual void OnFinished(void) = 0; }; - typedef SharedPtr cResolveNameCallbacksPtr; + typedef std::shared_ptr cResolveNameCallbacksPtr; /** Queues a TCP connection to be made to the specified host. diff --git a/src/OSSupport/NetworkSingleton.h b/src/OSSupport/NetworkSingleton.h index 59ec713c4..7da3f7569 100644 --- a/src/OSSupport/NetworkSingleton.h +++ b/src/OSSupport/NetworkSingleton.h @@ -27,10 +27,10 @@ // fwd: struct event_base; class cTCPLinkImpl; -typedef SharedPtr cTCPLinkImplPtr; +typedef std::shared_ptr cTCPLinkImplPtr; typedef std::vector cTCPLinkImplPtrs; class cServerHandleImpl; -typedef SharedPtr cServerHandleImplPtr; +typedef std::shared_ptr cServerHandleImplPtr; typedef std::vector cServerHandleImplPtrs; diff --git a/src/OSSupport/ServerHandleImpl.h b/src/OSSupport/ServerHandleImpl.h index 8a22df18b..1edd59dc1 100644 --- a/src/OSSupport/ServerHandleImpl.h +++ b/src/OSSupport/ServerHandleImpl.h @@ -21,10 +21,10 @@ // fwd: class cTCPLinkImpl; -typedef SharedPtr cTCPLinkImplPtr; +typedef std::shared_ptr cTCPLinkImplPtr; typedef std::vector cTCPLinkImplPtrs; class cServerHandleImpl; -typedef SharedPtr cServerHandleImplPtr; +typedef std::shared_ptr cServerHandleImplPtr; typedef std::vector cServerHandleImplPtrs; diff --git a/src/OSSupport/TCPLinkImpl.h b/src/OSSupport/TCPLinkImpl.h index d582e2f8d..0437353fb 100644 --- a/src/OSSupport/TCPLinkImpl.h +++ b/src/OSSupport/TCPLinkImpl.h @@ -22,9 +22,9 @@ // fwd: class cServerHandleImpl; -typedef SharedPtr cServerHandleImplPtr; +typedef std::shared_ptr cServerHandleImplPtr; class cTCPLinkImpl; -typedef SharedPtr cTCPLinkImplPtr; +typedef std::shared_ptr cTCPLinkImplPtr; typedef std::vector cTCPLinkImplPtrs; @@ -79,8 +79,8 @@ protected: // fwd: class cLinkTlsContext; - typedef SharedPtr cLinkTlsContextPtr; - typedef WeakPtr cLinkTlsContextWPtr; + typedef std::shared_ptr cLinkTlsContextPtr; + typedef std::weak_ptr cLinkTlsContextWPtr; /** Wrapper around cSslContext that is used when this link is being encrypted by SSL. */ class cLinkTlsContext : diff --git a/src/OSSupport/UDPEndpointImpl.h b/src/OSSupport/UDPEndpointImpl.h index 56116df17..a6ca37c27 100644 --- a/src/OSSupport/UDPEndpointImpl.h +++ b/src/OSSupport/UDPEndpointImpl.h @@ -18,7 +18,7 @@ // fwd: class cUDPEndpointImpl; -typedef SharedPtr cUDPEndpointImplPtr; +typedef std::shared_ptr cUDPEndpointImplPtr; diff --git a/src/PolarSSL++/CryptoKey.h b/src/PolarSSL++/CryptoKey.h index fc8034d16..db15cefb4 100644 --- a/src/PolarSSL++/CryptoKey.h +++ b/src/PolarSSL++/CryptoKey.h @@ -69,7 +69,7 @@ protected: pk_context * GetInternal(void) { return &m_Pk; } } ; -typedef SharedPtr cCryptoKeyPtr; +typedef std::shared_ptr cCryptoKeyPtr; diff --git a/src/PolarSSL++/CtrDrbgContext.cpp b/src/PolarSSL++/CtrDrbgContext.cpp index daacc70cc..c2243db38 100644 --- a/src/PolarSSL++/CtrDrbgContext.cpp +++ b/src/PolarSSL++/CtrDrbgContext.cpp @@ -21,7 +21,7 @@ cCtrDrbgContext::cCtrDrbgContext(void) : -cCtrDrbgContext::cCtrDrbgContext(const SharedPtr & a_EntropyContext) : +cCtrDrbgContext::cCtrDrbgContext(const std::shared_ptr & a_EntropyContext) : m_EntropyContext(a_EntropyContext), m_IsValid(false) { diff --git a/src/PolarSSL++/CtrDrbgContext.h b/src/PolarSSL++/CtrDrbgContext.h index 16b4a44b0..20d687015 100644 --- a/src/PolarSSL++/CtrDrbgContext.h +++ b/src/PolarSSL++/CtrDrbgContext.h @@ -33,7 +33,7 @@ public: cCtrDrbgContext(void); /** Constructs the context with the specified entropy context. */ - cCtrDrbgContext(const SharedPtr & a_EntropyContext); + cCtrDrbgContext(const std::shared_ptr & a_EntropyContext); /** Initializes the context. a_Custom is optional additional data to use for entropy, nullptr is accepted. @@ -45,7 +45,7 @@ public: protected: /** The entropy source used for generating the random */ - SharedPtr m_EntropyContext; + std::shared_ptr m_EntropyContext; /** The random generator context */ ctr_drbg_context m_CtrDrbg; diff --git a/src/PolarSSL++/RsaPrivateKey.h b/src/PolarSSL++/RsaPrivateKey.h index 32422da8d..595ba5663 100644 --- a/src/PolarSSL++/RsaPrivateKey.h +++ b/src/PolarSSL++/RsaPrivateKey.h @@ -59,7 +59,7 @@ protected: rsa_context * GetInternal(void) { return &m_Rsa; } } ; -typedef SharedPtr cRsaPrivateKeyPtr; +typedef std::shared_ptr cRsaPrivateKeyPtr; diff --git a/src/PolarSSL++/SslContext.cpp b/src/PolarSSL++/SslContext.cpp index 74b45ea33..557f81db4 100644 --- a/src/PolarSSL++/SslContext.cpp +++ b/src/PolarSSL++/SslContext.cpp @@ -36,7 +36,7 @@ cSslContext::~cSslContext() -int cSslContext::Initialize(bool a_IsClient, const SharedPtr & a_CtrDrbg) +int cSslContext::Initialize(bool a_IsClient, const std::shared_ptr & a_CtrDrbg) { // Check double-initialization: if (m_IsValid) diff --git a/src/PolarSSL++/SslContext.h b/src/PolarSSL++/SslContext.h index 27f9dd674..0588122ba 100644 --- a/src/PolarSSL++/SslContext.h +++ b/src/PolarSSL++/SslContext.h @@ -44,7 +44,7 @@ public: /** Initializes the context for use as a server or client. Returns 0 on success, PolarSSL error on failure. */ - int Initialize(bool a_IsClient, const SharedPtr & a_CtrDrbg = SharedPtr()); + int Initialize(bool a_IsClient, const std::shared_ptr & a_CtrDrbg = {}); /** Returns true if the object has been initialized properly. */ bool IsValid(void) const { return m_IsValid; } @@ -98,7 +98,7 @@ protected: bool m_IsValid; /** The random generator to use */ - SharedPtr m_CtrDrbg; + std::shared_ptr m_CtrDrbg; /** The SSL context that PolarSSL uses. */ ssl_context m_Ssl; diff --git a/src/PolarSSL++/X509Cert.h b/src/PolarSSL++/X509Cert.h index 8c3468f03..45f714d14 100644 --- a/src/PolarSSL++/X509Cert.h +++ b/src/PolarSSL++/X509Cert.h @@ -34,7 +34,7 @@ protected: x509_crt * GetInternal(void) { return &m_Cert; } } ; -typedef SharedPtr cX509CertPtr; +typedef std::shared_ptr cX509CertPtr; diff --git a/src/Protocol/MojangAPI.h b/src/Protocol/MojangAPI.h index 65eb1b102..3cd0376be 100644 --- a/src/Protocol/MojangAPI.h +++ b/src/Protocol/MojangAPI.h @@ -183,7 +183,7 @@ protected: cCriticalSection m_CSRankMgr; /** The thread that periodically updates the stale data in the DB from the Mojang servers. */ - SharedPtr m_UpdateThread; + std::shared_ptr m_UpdateThread; /** Loads the caches from a disk storage. */ diff --git a/src/Server.h b/src/Server.h index bb9b7f511..68741b144 100644 --- a/src/Server.h +++ b/src/Server.h @@ -35,7 +35,7 @@ // fwd: class cPlayer; class cClientHandle; -typedef SharedPtr cClientHandlePtr; +typedef std::shared_ptr cClientHandlePtr; typedef std::list cClientHandlePtrs; typedef std::list cClientHandles; class cCommandOutputCallback; diff --git a/src/SetChunkData.h b/src/SetChunkData.h index 63aec445b..b0c59e40b 100644 --- a/src/SetChunkData.h +++ b/src/SetChunkData.h @@ -116,7 +116,7 @@ protected: bool m_ShouldMarkDirty; }; -typedef SharedPtr cSetChunkDataPtr; // TODO: Change to unique_ptr once we go C++11 +typedef std::unique_ptr cSetChunkDataPtr; typedef std::vector cSetChunkDataPtrs; diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index ba74613d6..eefe57b73 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -540,7 +540,7 @@ void cWebAdmin::AddWebTab( const AString & a_Title, const AString & a_UrlPath, const AString & a_PluginName, - SharedPtr a_Callback + std::shared_ptr a_Callback ) { cCSLock lock(m_CS); diff --git a/src/WebAdmin.h b/src/WebAdmin.h index a4effdbeb..b24a279e1 100644 --- a/src/WebAdmin.h +++ b/src/WebAdmin.h @@ -142,9 +142,9 @@ public: AString m_Title; AString m_UrlPath; AString m_PluginName; - SharedPtr m_Callback; + std::shared_ptr m_Callback; - cWebTab(const AString & a_Title, const AString & a_UrlPath, const AString & a_PluginName, SharedPtr a_Callback): + cWebTab(const AString & a_Title, const AString & a_UrlPath, const AString & a_PluginName, std::shared_ptr a_Callback): m_Title(a_Title), m_UrlPath(a_UrlPath), m_PluginName(a_PluginName), @@ -152,7 +152,7 @@ public: { } }; - typedef SharedPtr cWebTabPtr; + typedef std::shared_ptr cWebTabPtr; typedef std::vector cWebTabPtrs; @@ -214,7 +214,7 @@ public: const AString & a_Title, const AString & a_UrlPath, const AString & a_PluginName, - SharedPtr a_Callback + std::shared_ptr a_Callback ); /** Removes the WebTab with the specified URL path. diff --git a/src/World.cpp b/src/World.cpp index 3f26fe809..a33f1fa97 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2889,7 +2889,7 @@ void cWorld::MarkChunkSaved (int a_ChunkX, int a_ChunkZ) -void cWorld::QueueSetChunkData(const cSetChunkDataPtr & a_SetChunkData) +void cWorld::QueueSetChunkData(cSetChunkDataPtr a_SetChunkData) { // Validate biomes, if needed: if (!a_SetChunkData->AreBiomesValid()) @@ -2908,7 +2908,7 @@ void cWorld::QueueSetChunkData(const cSetChunkDataPtr & a_SetChunkData) // Store a copy of the data in the queue: // TODO: If the queue is too large, wait for it to get processed. Not likely, though. cCSLock Lock(m_CSSetChunkDataQueue); - m_SetChunkDataQueue.push_back(a_SetChunkData); + m_SetChunkDataQueue.push_back(std::move(a_SetChunkData)); } @@ -4092,7 +4092,7 @@ void cWorld::cChunkGeneratorCallbacks::OnChunkGenerated(cChunkDesc & a_ChunkDesc true )); SetChunkData->RemoveInvalidBlockEntities(); - m_World->QueueSetChunkData(SetChunkData); + m_World->QueueSetChunkData(std::move(SetChunkData)); } diff --git a/src/World.h b/src/World.h index 7d8d8bf7f..f1f0b307f 100644 --- a/src/World.h +++ b/src/World.h @@ -39,7 +39,7 @@ class cRedstoneSimulator; class cItem; class cPlayer; class cClientHandle; -typedef SharedPtr cClientHandlePtr; +typedef std::shared_ptr cClientHandlePtr; typedef std::list cClientHandlePtrs; typedef std::list cClientHandles; class cEntity; @@ -63,7 +63,7 @@ class cDeadlockDetect; typedef std::list< cPlayer * > cPlayerList; typedef std::list< std::pair< cPlayer *, cWorld * > > cAwaitingPlayerList; -typedef SharedPtr cSetChunkDataPtr; // TODO: Change to unique_ptr once we go C++11 +typedef std::unique_ptr cSetChunkDataPtr; typedef std::vector cSetChunkDataPtrs; typedef cItemCallback cPlayerListCallback; @@ -237,7 +237,7 @@ public: /** Puts the chunk data into a queue to be set into the chunkmap in the tick thread. If the chunk data doesn't contain valid biomes, the biomes are calculated before adding the data into the queue. */ - void QueueSetChunkData(const cSetChunkDataPtr & a_SetChunkData); + void QueueSetChunkData(cSetChunkDataPtr a_SetChunkData); void ChunkLighted( int a_ChunkX, int a_ChunkZ, diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 3715548e7..70f268f64 100755 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -470,7 +470,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT std::move(Entities), std::move(BlockEntities), false )); - m_World->QueueSetChunkData(SetChunkData); + m_World->QueueSetChunkData(std::move(SetChunkData)); return true; }