Index: ps/trunk/source/graphics/tests/test_LOSTexture.h =================================================================== --- ps/trunk/source/graphics/tests/test_LOSTexture.h +++ ps/trunk/source/graphics/tests/test_LOSTexture.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2024 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -28,7 +28,7 @@ public: void test_basic() { - CSimulation2 sim(NULL, g_ScriptContext, NULL); + CSimulation2 sim{nullptr, *g_ScriptContext, nullptr}; CLOSTexture tex(sim); const ssize_t size = 8; @@ -67,7 +67,7 @@ void test_perf_DISABLED() { - CSimulation2 sim(NULL, g_ScriptContext, NULL); + CSimulation2 sim{nullptr, *g_ScriptContext, nullptr}; CLOSTexture tex(sim); const ssize_t size = 257; Index: ps/trunk/source/graphics/tests/test_Model.h =================================================================== --- ps/trunk/source/graphics/tests/test_Model.h +++ ps/trunk/source/graphics/tests/test_Model.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2023 Wildfire Games. +/* Copyright (C) 2024 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -181,7 +181,7 @@ TestLogger logger; CMaterial material{}; - CSimulation2 simulation{nullptr, g_ScriptContext, nullptr}; + CSimulation2 simulation{nullptr, *g_ScriptContext, nullptr}; CTerrain terrain; terrain.Initialize(4, nullptr); @@ -246,7 +246,7 @@ CSkeletonAnimManager skeletonAnimationManager{colladaManager}; CUnitManager unitManager; - CSimulation2 simulation{&unitManager, g_ScriptContext, nullptr}; + CSimulation2 simulation{&unitManager, *g_ScriptContext, nullptr}; CObjectManager objectManager{ meshManager, skeletonAnimationManager, simulation}; unitManager.SetObjectManager(objectManager); Index: ps/trunk/source/ps/Game.cpp =================================================================== --- ps/trunk/source/ps/Game.cpp +++ ps/trunk/source/ps/Game.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2023 Wildfire Games. +/* Copyright (C) 2024 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -69,7 +69,7 @@ **/ CGame::CGame(bool replayLog): m_World(new CWorld(*this)), - m_Simulation2(new CSimulation2(&m_World->GetUnitManager(), g_ScriptContext, &m_World->GetTerrain())), + m_Simulation2{new CSimulation2{&m_World->GetUnitManager(), *g_ScriptContext, &m_World->GetTerrain()}}, // TODO: we need to remove that global dependency. Maybe the game view // should be created outside only if needed. m_GameView(CRenderer::IsInitialised() ? new CGameView(g_VideoMode.GetBackendDevice(), this) : nullptr), Index: ps/trunk/source/ps/GameSetup/GameSetup.cpp =================================================================== --- ps/trunk/source/ps/GameSetup/GameSetup.cpp +++ ps/trunk/source/ps/GameSetup/GameSetup.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2023 Wildfire Games. +/* Copyright (C) 2024 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -578,7 +578,7 @@ // on anything else.) if (args.Has("dumpSchema")) { - CSimulation2 sim(NULL, g_ScriptContext, NULL); + CSimulation2 sim{NULL, *g_ScriptContext, NULL}; sim.LoadDefaultScripts(); std::ofstream f("entity.rng", std::ios_base::out | std::ios_base::trunc); f << sim.GenerateSchema(); Index: ps/trunk/source/simulation2/Simulation2.h =================================================================== --- ps/trunk/source/simulation2/Simulation2.h +++ ps/trunk/source/simulation2/Simulation2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Wildfire Games. +/* Copyright (C) 2024 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -50,7 +50,7 @@ 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, std::shared_ptr cx, CTerrain* terrain); + CSimulation2(CUnitManager* unitManager, ScriptContext& cx, CTerrain* terrain); ~CSimulation2(); void EnableSerializationTest(); Index: ps/trunk/source/simulation2/Simulation2.cpp =================================================================== --- ps/trunk/source/simulation2/Simulation2.cpp +++ ps/trunk/source/simulation2/Simulation2.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2023 Wildfire Games. +/* Copyright (C) 2024 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -53,10 +53,10 @@ class CSimulation2Impl { public: - 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()) + CSimulation2Impl(CUnitManager* unitManager, ScriptContext& cx, CTerrain* terrain) : + m_ComponentManager{m_SimContext, cx}, + m_MapSettings{cx.GetGeneralJSContext()}, + m_InitAttributes{cx.GetGeneralJSContext()} { m_SimContext.m_UnitManager = unitManager; m_SimContext.m_Terrain = terrain; @@ -131,14 +131,14 @@ uint32_t m_TurnNumber; - bool m_EnableOOSLog; + bool m_EnableOOSLog{false}; OsPath m_OOSLogPath; // Functions and data for the serialization test mode: (see Update() for relevant comments) - bool m_EnableSerializationTest; - int m_RejoinTestTurn; - bool m_TestingRejoin; + bool m_EnableSerializationTest{false}; + int m_RejoinTestTurn{-1}; + bool m_TestingRejoin{false}; // Secondary simulation (NB: order matters for destruction). std::unique_ptr m_SecondaryComponentManager; @@ -634,7 +634,7 @@ //////////////////////////////////////////////////////////////// -CSimulation2::CSimulation2(CUnitManager* unitManager, std::shared_ptr cx, CTerrain* terrain) : +CSimulation2::CSimulation2(CUnitManager* unitManager, ScriptContext& cx, CTerrain* terrain) : m(new CSimulation2Impl(unitManager, cx, terrain)) { } Index: ps/trunk/source/simulation2/components/tests/test_Pathfinder.h =================================================================== --- ps/trunk/source/simulation2/components/tests/test_Pathfinder.h +++ ps/trunk/source/simulation2/components/tests/test_Pathfinder.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2023 Wildfire Games. +/* Copyright (C) 2024 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -137,7 +137,7 @@ { CTerrain terrain; - CSimulation2 sim2(NULL, g_ScriptContext, &terrain); + CSimulation2 sim2{nullptr, *g_ScriptContext, &terrain}; sim2.LoadDefaultScripts(); sim2.ResetState(); @@ -196,7 +196,7 @@ CTerrain terrain; terrain.Initialize(5, NULL); - CSimulation2 sim2(NULL, g_ScriptContext, &terrain); + CSimulation2 sim2{nullptr, *g_ScriptContext, &terrain}; sim2.LoadDefaultScripts(); sim2.ResetState(); @@ -251,7 +251,7 @@ { CTerrain terrain; - CSimulation2 sim2(NULL, g_ScriptContext, &terrain); + CSimulation2 sim2{nullptr, *g_ScriptContext, &terrain}; sim2.LoadDefaultScripts(); sim2.ResetState(); @@ -308,7 +308,7 @@ { CTerrain terrain; - CSimulation2 sim2(NULL, g_ScriptContext, &terrain); + CSimulation2 sim2{nullptr, *g_ScriptContext, &terrain}; sim2.LoadDefaultScripts(); sim2.ResetState(); Index: ps/trunk/source/simulation2/tests/test_CmpTemplateManager.h =================================================================== --- ps/trunk/source/simulation2/tests/test_CmpTemplateManager.h +++ ps/trunk/source/simulation2/tests/test_CmpTemplateManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2023 Wildfire Games. +/* Copyright (C) 2024 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -240,7 +240,7 @@ void test_load_all_DISABLED() // disabled since it's a bit slow and noisy { CTerrain dummy; - CSimulation2 sim(NULL, g_ScriptContext, &dummy); + CSimulation2 sim{nullptr, *g_ScriptContext, &dummy}; sim.LoadDefaultScripts(); sim.ResetState(); Index: ps/trunk/source/simulation2/tests/test_Serializer.h =================================================================== --- ps/trunk/source/simulation2/tests/test_Serializer.h +++ ps/trunk/source/simulation2/tests/test_Serializer.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2023 Wildfire Games. +/* Copyright (C) 2024 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -887,7 +887,7 @@ CTerrain terrain; - CSimulation2 sim2(NULL, g_ScriptContext, &terrain); + CSimulation2 sim2{nullptr, *g_ScriptContext, &terrain}; sim2.LoadDefaultScripts(); sim2.ResetState(); Index: ps/trunk/source/simulation2/tests/test_Simulation2.h =================================================================== --- ps/trunk/source/simulation2/tests/test_Simulation2.h +++ ps/trunk/source/simulation2/tests/test_Simulation2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2024 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -57,7 +57,7 @@ void test_AddEntity() { - CSimulation2 sim(NULL, g_ScriptContext, &m_Terrain); + CSimulation2 sim{nullptr, *g_ScriptContext, &m_Terrain}; TS_ASSERT(sim.LoadScripts(L"simulation/components/addentity/")); sim.ResetState(true, true); @@ -77,7 +77,7 @@ void test_DestroyEntity() { - CSimulation2 sim(NULL, g_ScriptContext, &m_Terrain); + CSimulation2 sim{nullptr, *g_ScriptContext, &m_Terrain}; TS_ASSERT(sim.LoadScripts(L"simulation/components/addentity/")); sim.ResetState(true, true); @@ -133,7 +133,7 @@ void test_hotload_scripts() { - CSimulation2 sim(NULL, g_ScriptContext, &m_Terrain); + CSimulation2 sim{nullptr, *g_ScriptContext, &m_Terrain}; TS_ASSERT_OK(CreateDirectories(DataDir()/"mods"/"_test.sim"/"simulation"/"components"/"hotload"/"", 0700)); Index: ps/trunk/source/tools/atlas/GameInterface/ActorViewer.cpp =================================================================== --- ps/trunk/source/tools/atlas/GameInterface/ActorViewer.cpp +++ ps/trunk/source/tools/atlas/GameInterface/ActorViewer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2023 Wildfire Games. +/* Copyright (C) 2024 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -77,7 +77,7 @@ MeshManager(ColladaManager), SkeletonAnimManager(ColladaManager), UnitManager(), - Simulation2(&UnitManager, g_ScriptContext, &Terrain), + Simulation2{&UnitManager, *g_ScriptContext, &Terrain}, ObjectManager(MeshManager, SkeletonAnimManager, Simulation2), LOSTexture(Simulation2), TerritoryTexture(Simulation2),