LCOV - code coverage report
Current view: top level - source/soundmanager/scripting - SoundGroup.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 0 2 0.0 %
Date: 2026-12-03 01:19:39 Functions: 0 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             : #ifndef INCLUDED_SOUNDGROUP_H
      19             : #define INCLUDED_SOUNDGROUP_H
      20             : 
      21             : #include "lib/code_annotation.h"
      22             : #include "lib/config2.h"
      23             : #include "lib/file/vfs/vfs_path.h"
      24             : #include "simulation2/system/Entity.h"
      25             : 
      26             : #include <cstddef>
      27             : #include <string>
      28             : #include <vector>
      29             : 
      30             : class CSoundData;
      31             : class CVector3D;
      32             : 
      33             : enum eSndGrpFlags
      34             : {
      35             :     eRandOrder = 0x01,
      36             :     eRandGain = 0x02,
      37             :     eRandPitch = 0x04,
      38             :     eLoop = 0x08,
      39             :     eOmnipresent = 0x10,
      40             :     eDistanceless = 0x20,
      41             :     eOwnerOnly = 0x40
      42             : };
      43             : 
      44             : // Loads up a group of sound files with shared properties,
      45             : // and provides a simple interface for playing them.
      46             : class CSoundGroup
      47             : {
      48             :     NONCOPYABLE(CSoundGroup);
      49             : public:
      50             :     CSoundGroup(const VfsPath& pathnameXML);
      51             :     CSoundGroup();
      52             :     ~CSoundGroup();
      53             : 
      54             :     // Play next sound in group
      55             :     // @param position world position of the entity generating the sound
      56             :     // (ignored if the eOmnipresent flag is set)
      57             :     void PlayNext(const CVector3D& position, entity_id_t source);
      58             : 
      59             :     float RadiansOffCenter(const CVector3D& position, bool& onScreen, float& itemRollOff);
      60             : 
      61             :     // Load a group
      62             :     bool LoadSoundGroup(const VfsPath& pathnameXML);
      63             : 
      64             :     void Reload();
      65             : 
      66             :     // Release all remaining loaded handles
      67             :     void ReleaseGroup();
      68             : 
      69             :     // Update SoundGroup, remove dead sounds from intensity count
      70             :     void Update(float TimeSinceLastFrame);
      71             : 
      72             :     // Set a flag using a value from eSndGrpFlags
      73           0 :     inline void SetFlag(int flag) { m_Flags = (unsigned char)(m_Flags | flag); }
      74             : 
      75             :     // Test flag, returns true if flag is set.
      76           0 :     inline bool TestFlag(int flag) { return (m_Flags & flag) != 0; }
      77             : 
      78             : private:
      79             :     void SetGain(float gain);
      80             : 
      81             :     void UploadPropertiesAndPlay(size_t theIndex, const CVector3D& position, entity_id_t source);
      82             : 
      83             :     void SetDefaultValues();
      84             : #if CONFIG2_AUDIO
      85             :     // We store the handles so we can load now and play later
      86             :     std::vector<CSoundData*> m_SoundGroups;
      87             : #endif
      88             :     std::uint32_t m_Seed;
      89             :     // We need the filenames so we can reload when necessary.
      90             :     std::vector<std::wstring> m_Filenames;
      91             :     // The file path for the list of sound file resources
      92             :     VfsPath m_Filepath;
      93             :     size_t m_CurrentSoundIndex;
      94             :     float m_ConeInnerAngle;
      95             :     float m_ConeOuterAngle;
      96             :     float m_ConeOuterGain;
      97             :     // Time elapsed since soundgroup was created
      98             :     float m_CurTime;
      99             :     float m_Decay;
     100             :     float m_Gain;
     101             :     float m_GainUpper;
     102             :     float m_GainLower;
     103             :     // Distance attenuation settings
     104             :     float m_MinDist;
     105             :     float m_MaxDist;
     106             :     // How much stereo separation to apply to sounds based on L-R position relative to the camera.
     107             :     float m_MaxStereoAngle;
     108             :     // The allowable intensity before a sound switch
     109             :     float m_IntensityThreshold;
     110             :     float m_Pitch;
     111             :     float m_PitchLower;
     112             :     float m_PitchUpper;
     113             :     float m_Priority;
     114             :     // Up to eight individual parameters, use with eSndGrpFlags.
     115             :     std::uint8_t m_Flags;
     116             : };
     117             : 
     118             : #endif //#ifndef INCLUDED_SOUNDGROUP_H

Generated by: LCOV version 1.16