diff --git a/source/scriptinterface/ScriptContext.cpp b/source/scriptinterface/ScriptContext.cpp index 922249fbb7..6331f6d665 100644 --- a/source/scriptinterface/ScriptContext.cpp +++ b/source/scriptinterface/ScriptContext.cpp @@ -77,7 +77,7 @@ void GCSliceCallbackHook(JSContext* UNUSED(cx), JS::GCProgress progress, const J #endif } -shared_ptr ScriptContext::CreateContext(int contextSize, int heapGrowthBytesGCTrigger) +std::shared_ptr ScriptContext::CreateContext(int contextSize, int heapGrowthBytesGCTrigger) { return std::make_shared(contextSize, heapGrowthBytesGCTrigger); } diff --git a/source/scriptinterface/ScriptContext.h b/source/scriptinterface/ScriptContext.h index 8de47305aa..ce39e06dbc 100644 --- a/source/scriptinterface/ScriptContext.h +++ b/source/scriptinterface/ScriptContext.h @@ -50,7 +50,7 @@ public: * @param contextSize Maximum size in bytes of the new context * @param heapGrowthBytesGCTrigger Size in bytes of cumulated allocations after which a GC will be triggered */ - static shared_ptr CreateContext( + static std::shared_ptr CreateContext( int contextSize = DEFAULT_CONTEXT_SIZE, int heapGrowthBytesGCTrigger = DEFAULT_HEAP_GROWTH_BYTES_GCTRIGGER); diff --git a/source/scriptinterface/ScriptInterface.cpp b/source/scriptinterface/ScriptInterface.cpp index bfddde9f1c..5c24179a98 100644 --- a/source/scriptinterface/ScriptInterface.cpp +++ b/source/scriptinterface/ScriptInterface.cpp @@ -54,12 +54,12 @@ struct ScriptInterface_impl { - ScriptInterface_impl(const char* nativeScopeName, const shared_ptr& context); + ScriptInterface_impl(const char* nativeScopeName, const std::shared_ptr& context); ~ScriptInterface_impl(); // Take care to keep this declaration before heap rooted members. Destructors of heap rooted // members have to be called before the context destructor. - shared_ptr m_context; + std::shared_ptr m_context; friend ScriptRequest; private: @@ -302,7 +302,7 @@ bool ScriptInterface::Math_random(JSContext* cx, uint argc, JS::Value* vp) return true; } -ScriptInterface_impl::ScriptInterface_impl(const char* nativeScopeName, const shared_ptr& context) : +ScriptInterface_impl::ScriptInterface_impl(const char* nativeScopeName, const std::shared_ptr& context) : m_context(context), m_cx(context->GetGeneralJSContext()), m_glob(context->GetGeneralJSContext()), m_nativeScope(context->GetGeneralJSContext()) { JS::RealmCreationOptions creationOpt; @@ -342,7 +342,7 @@ ScriptInterface_impl::~ScriptInterface_impl() m_context->UnRegisterRealm(JS::GetObjectRealmOrNull(m_glob)); } -ScriptInterface::ScriptInterface(const char* nativeScopeName, const char* debugName, const shared_ptr& context) : +ScriptInterface::ScriptInterface(const char* nativeScopeName, const char* debugName, const std::shared_ptr& context) : m(std::make_unique(nativeScopeName, context)) { // Profiler stats table isn't thread-safe, so only enable this on the main thread @@ -436,7 +436,7 @@ JSContext* ScriptInterface::GetGeneralJSContext() const return m->m_context->GetGeneralJSContext(); } -shared_ptr ScriptInterface::GetContext() const +std::shared_ptr ScriptInterface::GetContext() const { return m->m_context; } diff --git a/source/scriptinterface/ScriptInterface.h b/source/scriptinterface/ScriptInterface.h index e5c884a65e..6bb744b606 100644 --- a/source/scriptinterface/ScriptInterface.h +++ b/source/scriptinterface/ScriptInterface.h @@ -83,7 +83,7 @@ public: * @param debugName Name of this interface for CScriptStats purposes. * @param context ScriptContext to use when initializing this interface. */ - ScriptInterface(const char* nativeScopeName, const char* debugName, const shared_ptr& context); + ScriptInterface(const char* nativeScopeName, const char* debugName, const std::shared_ptr& context); ~ScriptInterface(); @@ -128,7 +128,7 @@ public: * ScriptInterface::Request and use the context from that. */ JSContext* GetGeneralJSContext() const; - shared_ptr GetContext() const; + std::shared_ptr GetContext() const; /** * Load global scripts that most script interfaces need, diff --git a/source/simulation2/Simulation2.cpp b/source/simulation2/Simulation2.cpp index a71b557ce0..6864dfa3c7 100644 --- a/source/simulation2/Simulation2.cpp +++ b/source/simulation2/Simulation2.cpp @@ -54,7 +54,7 @@ class CSimulation2Impl { public: - CSimulation2Impl(CUnitManager* unitManager, shared_ptr cx, CTerrain* terrain) : + CSimulation2Impl(CUnitManager* unitManager, std::shared_ptr cx, CTerrain* terrain) : m_SimContext(), m_ComponentManager(m_SimContext, cx), m_EnableOOSLog(false), m_EnableSerializationTest(false), m_RejoinTestTurn(-1), m_TestingRejoin(false), m_MapSettings(cx->GetGeneralJSContext()), m_InitAttributes(cx->GetGeneralJSContext()) @@ -636,7 +636,7 @@ void CSimulation2Impl::DumpState() //////////////////////////////////////////////////////////////// -CSimulation2::CSimulation2(CUnitManager* unitManager, shared_ptr cx, CTerrain* terrain) : +CSimulation2::CSimulation2(CUnitManager* unitManager, std::shared_ptr cx, CTerrain* terrain) : m(new CSimulation2Impl(unitManager, cx, terrain)) { } diff --git a/source/simulation2/Simulation2.h b/source/simulation2/Simulation2.h index 61262a3fd6..380b44b8d1 100644 --- a/source/simulation2/Simulation2.h +++ b/source/simulation2/Simulation2.h @@ -50,7 +50,7 @@ class CSimulation2 public: // TODO: CUnitManager should probably be handled automatically by this // module, but for now we'll have it passed in externally instead - CSimulation2(CUnitManager* unitManager, shared_ptr cx, CTerrain* terrain); + CSimulation2(CUnitManager* unitManager, std::shared_ptr cx, CTerrain* terrain); ~CSimulation2(); void EnableSerializationTest(); diff --git a/source/simulation2/components/CCmpAIManager.cpp b/source/simulation2/components/CCmpAIManager.cpp index 58a7f761c9..fd30387230 100644 --- a/source/simulation2/components/CCmpAIManager.cpp +++ b/source/simulation2/components/CCmpAIManager.cpp @@ -87,7 +87,7 @@ private: NONCOPYABLE(CAIPlayer); public: CAIPlayer(CAIWorker& worker, const std::wstring& aiName, player_id_t player, u8 difficulty, const std::wstring& behavior, - shared_ptr scriptInterface) : + std::shared_ptr scriptInterface) : m_Worker(worker), m_AIName(aiName), m_Player(player), m_Difficulty(difficulty), m_Behavior(behavior), m_ScriptInterface(scriptInterface), m_Obj(scriptInterface->GetGeneralJSContext()) { @@ -203,7 +203,7 @@ private: // Take care to keep this declaration before heap rooted members. Destructors of heap rooted // members have to be called before the context destructor. - shared_ptr m_ScriptInterface; + std::shared_ptr m_ScriptInterface; JS::PersistentRootedValue m_Obj; std::vector m_Commands; @@ -365,7 +365,7 @@ public: const size_t img_size = w * h * bpp/8; const size_t hdr_size = tex_hdr_size(filename); - shared_ptr buf; + std::shared_ptr buf; AllocateAligned(buf, hdr_size+img_size, maxSectorSize); Tex t; if (t.wrap(w, h, bpp, flags, buf, hdr_size) < 0) @@ -455,7 +455,7 @@ public: bool AddPlayer(const std::wstring& aiName, player_id_t player, u8 difficulty, const std::wstring& behavior) { - shared_ptr ai = std::make_shared(*this, aiName, player, difficulty, behavior, m_ScriptInterface); + std::shared_ptr ai = std::make_shared(*this, aiName, player, difficulty, behavior, m_ScriptInterface); if (!ai->Initialise()) return false; @@ -816,17 +816,17 @@ private: // Take care to keep this declaration before heap rooted members. Destructors of heap rooted // members have to be called before the context destructor. - shared_ptr m_ScriptContext; + std::shared_ptr m_ScriptContext; - shared_ptr m_ScriptInterface; + std::shared_ptr m_ScriptInterface; boost::rand48 m_RNG; u32 m_TurnNum; JS::PersistentRootedValue m_EntityTemplates; bool m_HasLoadedEntityTemplates; - std::map > m_PlayerMetadata; - std::vector > m_Players; // use shared_ptr just to avoid copying + std::map> m_PlayerMetadata; + std::vector> m_Players; // use shared_ptr just to avoid copying bool m_HasSharedComponent; JS::PersistentRootedValue m_SharedAIObj; diff --git a/source/simulation2/helpers/LongPathfinder.cpp b/source/simulation2/helpers/LongPathfinder.cpp index 64e7dceb9f..287fadfde6 100644 --- a/source/simulation2/helpers/LongPathfinder.cpp +++ b/source/simulation2/helpers/LongPathfinder.cpp @@ -722,7 +722,7 @@ void LongPathfinder::ComputeJPSPath(const HierarchicalPathfinder& hierPath, enti // Needs to lock for construction, or several threads might try doing that at the same time. static std::mutex JPCMutex; std::unique_lock lock(JPCMutex); - std::map >::const_iterator it = m_JumpPointCache.find(passClass); + std::map>::const_iterator it = m_JumpPointCache.find(passClass); if (it != m_JumpPointCache.end()) state.jpc = it->second.get(); diff --git a/source/simulation2/helpers/LongPathfinder.h b/source/simulation2/helpers/LongPathfinder.h index 8620c89fd8..fc3fec9b3f 100644 --- a/source/simulation2/helpers/LongPathfinder.h +++ b/source/simulation2/helpers/LongPathfinder.h @@ -282,7 +282,7 @@ private: // This is thread-safe as it is order independent (no change in the output of the function for a given set of params). // Obviously, this means that the cache should actually be a cache and not return different results // from what would happen if things hadn't been cached. - mutable std::map > m_JumpPointCache; + mutable std::map> m_JumpPointCache; }; #endif // INCLUDED_LONGPATHFINDER diff --git a/source/simulation2/system/ComponentManager.cpp b/source/simulation2/system/ComponentManager.cpp index 32a9200879..0cfad073db 100644 --- a/source/simulation2/system/ComponentManager.cpp +++ b/source/simulation2/system/ComponentManager.cpp @@ -54,7 +54,7 @@ public: JS::PersistentRootedValue msg; }; -CComponentManager::CComponentManager(CSimContext& context, shared_ptr cx, bool skipScriptFunctions) : +CComponentManager::CComponentManager(CSimContext& context, std::shared_ptr cx, bool skipScriptFunctions) : m_NextScriptComponentTypeId(CID__LastNative), m_ScriptInterface("Engine", "Simulation", cx), m_SimContext(context), m_CurrentlyHotloading(false) diff --git a/source/simulation2/system/ComponentManager.h b/source/simulation2/system/ComponentManager.h index b2f3dac2a6..d0bfac8bf7 100644 --- a/source/simulation2/system/ComponentManager.h +++ b/source/simulation2/system/ComponentManager.h @@ -74,7 +74,7 @@ private: }; public: - CComponentManager(CSimContext&, shared_ptr cx, bool skipScriptFunctions = false); + CComponentManager(CSimContext&, std::shared_ptr cx, bool skipScriptFunctions = false); ~CComponentManager(); void LoadComponentTypes(); diff --git a/source/simulation2/system/ComponentTest.h b/source/simulation2/system/ComponentTest.h index 5542758a43..613441b86d 100644 --- a/source/simulation2/system/ComponentTest.h +++ b/source/simulation2/system/ComponentTest.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -55,7 +55,7 @@ class ComponentTestHelper bool m_isSystemEntityInit = false; public: - ComponentTestHelper(shared_ptr scriptContext) : + ComponentTestHelper(std::shared_ptr scriptContext) : m_Context(), m_ComponentManager(m_Context, scriptContext), m_Cmp(NULL) { m_ComponentManager.LoadComponentTypes(); diff --git a/source/simulation2/tests/test_Simulation2.h b/source/simulation2/tests/test_Simulation2.h index 808fb3c200..d941ed6bd2 100644 --- a/source/simulation2/tests/test_Simulation2.h +++ b/source/simulation2/tests/test_Simulation2.h @@ -31,7 +31,7 @@ class TestSimulation2 : public CxxTest::TestSuite { void copyFile(const VfsPath& src, const VfsPath& dst) { - shared_ptr data; + std::shared_ptr data; size_t size = 0; TS_ASSERT_OK(g_VFS->LoadFile(src, data, size)); TS_ASSERT_OK(g_VFS->CreateFile(dst, data, size));