LCOV - code coverage report
Current view: top level - source/simulation2/system - SimContext.cpp (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 24 24 100.0 %
Date: 2026-12-03 01:19:39 Functions: 9 9 100.0 %

          Line data    Source code
       1             : /* Copyright (C) 2026 Wildfire Games.
       2             :  * This file is part of 0 A.D.
       3             :  *
       4             :  * 0 A.D. is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 2 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * 0 A.D. is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License
      15             :  * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #include "precompiled.h"
      19             : 
      20             : #include "SimContext.h"
      21             : 
      22             : #include "ps/Game.h"
      23             : #include "simulation2/system/Component.h"
      24             : 
      25             : #include <cstddef>
      26             : 
      27         150 : CSimContext::CSimContext(CTerrain* terrain /*= nullptr*/, CUnitManager* unitManager /*= nullptr*/) :
      28         150 :     m_UnitManager{unitManager},
      29         150 :     m_Terrain{terrain}
      30             : {
      31         150 : }
      32             : 
      33         150 : CSimContext::~CSimContext()
      34             : {
      35         150 : }
      36             : 
      37      251731 : CComponentManager& CSimContext::GetComponentManager() const
      38             : {
      39      251731 :     return *m_ComponentManager;
      40             : }
      41             : 
      42         315 : bool CSimContext::HasUnitManager() const
      43             : {
      44         315 :     return m_UnitManager != NULL;
      45             : }
      46             : 
      47         195 : CUnitManager& CSimContext::GetUnitManager() const
      48             : {
      49         195 :     ENSURE(m_UnitManager);
      50         195 :     return *m_UnitManager;
      51             : }
      52             : 
      53          28 : CTerrain& CSimContext::GetTerrain() const
      54             : {
      55          28 :     ENSURE(m_Terrain);
      56          28 :     return *m_Terrain;
      57             : }
      58             : 
      59         150 : void CSimContext::SetComponentManager(CComponentManager* man)
      60             : {
      61         150 :     ENSURE(!m_ComponentManager);
      62         150 :     m_ComponentManager = man;
      63         150 : }
      64             : 
      65        3086 : Script::Interface& CSimContext::GetScriptInterface() const
      66             : {
      67        3086 :     return GetComponentManager().GetScriptInterface();
      68             : }
      69             : 
      70        5607 : int CSimContext::GetCurrentDisplayedPlayer() const
      71             : {
      72        5607 :     return g_Game ? g_Game->GetViewedPlayerID() : -1;
      73             : }

Generated by: LCOV version 1.16