2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
6 ///////////////////////////////////////////////////////////////////////////////
7 // $Header: r:/t2repos/thief2/src/sound/psnd.h,v 1.22 1999/08/05 18:20:32 Justin Exp $
9 // Sound propagation header
31 ///////////////////////////////////////////////////////////////////////////////
34 #define EFF_PRI_MAX 65535
36 const int kMinUpdateFrequency
= 16;
37 const int kMaxUpdateFrequency
= 1;
38 const int kDeferredUpdateFrequency
= 16;
40 ////////////////////////////////////////////////////////////////////////////////
42 typedef class cPropSndInst cPropSndInst
;
43 typedef class cPropSndInstHigh cPropSndInstHigh
;
44 typedef class cPropSndInstLow cPropSndInstLow
;
46 typedef cHashTableFunctions
<long> LongHashFunctions
;
47 typedef cHashTable
<long, mxs_real
, LongHashFunctions
> cSoundBlockingTable
;
49 ////////////////////////////////////////////////////////////////////////////////
57 // Constructor / Destructor
66 int GenerateSound(ObjID objID
, ObjID schemaID
, const char *sampleName
, float atten_factor
,
67 sfx_parm
*parms
, int flags
, void *data
= NULL
);
68 int GenerateSound(mxs_vector
&vec
, ObjID src_obj
, ObjID schemaID
, const char *sampleName
, float atten_factor
,
69 sfx_parm
*parms
, int flags
, void *data
= NULL
);
70 int GenerateSound(const char *sampleName
, sfx_parm
*parms
);
73 int GenerateSoundHandle(int handle
, ObjID objID
, ObjID schemaID
, const char *sampleName
, float atten_factor
,
74 sfx_parm
*parms
, int flags
, void *data
= NULL
);
75 int GenerateSoundHandle(int handle
, mxs_vector
&vec
, ObjID src_obj
, ObjID schemaID
, const char *sampleName
,
76 float atten_factor
, sfx_parm
*parms
, int flags
, void *data
= NULL
);
78 // Stops the sound, all sounds, and checks for any playing sounds
79 void SoundHalt(int handle
);
80 void SoundHaltObj(ObjID objID
);
84 // Informs each non-player object about sounds this frame
85 void ApplySoundInfo();
86 void ClearSoundInfo();
88 // Cleans up game-mode created objects
91 // Informs the active sound system that the sound has ended
92 void EndActiveSound(cSoundInfo
*pSoundInfo
);
94 // Valid handle checking
96 void RegisterSound(int handle
, cPlayerSoundList
*pSoundList
);
97 int FindSound(cPlayerSoundList
*pSoundList
);
98 cPlayerSoundList
*GetSound(int handle
);
99 void RemoveSound(int handle
);
101 // Sound blocking functions
102 void ClearBlockingFactors();
103 void SetBlockingFactor(short roomID1
, short roomID2
, mxs_real factor
, BOOL blockAdjacent
= TRUE
);
104 mxs_real
GetBlockingFactor(short roomID1
, short roomID2
);
105 void RemoveBlockingFactor(short roomID1
, short roomID2
, BOOL blockAdjacent
= TRUE
);
107 PrioritizationResult
Prioritize(const cPlayerSoundList
* pPlayerList
);
109 // Networking functions
110 BOOL
ShouldPlaySound(const sfx_parm
*pParms
, int flags
, BOOL onObject
, ObjID srcObject
) const;
111 BOOL
ShouldNetworkSound(const sfx_parm
*pParms
, int flags
, BOOL onObject
, ObjID srcObject
) const;
114 void SetDrawSoundPath(BOOL state
);
116 void DrawActiveSounds();
117 void SpewActiveSounds();
121 // Prioritization functions.
122 BOOL
TypeCapReached(uchar type
);
123 int EffectivePriority(const cPlayerSoundList
*pPlayerList
);
124 cPlayerSoundList
* LowestPrioritySoundOfType(uchar type
, int *itsEffectivePriority
);
125 cPlayerSoundList
* LowestPrioritySound(int *itsEffectivePriority
);
127 void BumpActiveSound(cPlayerSoundList
*pPlayerList
);
130 void BlockAdjacentRooms(short roomID1
, short roomID2
, mxs_real factor
);
132 cPlayerSoundList
*GeneratePlayerSoundList(int handle
);
134 cPlayerSoundList
*m_SoundList
[kMaxActiveSounds
];
136 cSoundBlockingTable m_SoundBlockingTable
;
138 cPropSndInstHigh m_SoundInstHigh
;
140 cPropSndInst
*m_SoundInstance
;
141 cRoomPropAgent m_PropAgent
;
147 ////////////////////////////////////////
149 inline void cPropSnd::ApplySoundInfo()
151 Assert_(m_SoundInstance
);
152 m_SoundInstance
->ApplySoundInfo();
155 ////////////////////////////////////////
157 inline void cPropSnd::ClearSoundInfo()
159 Assert_(m_SoundInstance
);
160 m_SoundInstance
->ClearSoundInfo();
163 ////////////////////////////////////////
165 inline void cPropSnd::Cleanup()
167 Assert_(m_SoundInstance
);
168 m_SoundInstance
->Cleanup();
171 ////////////////////////////////////////////////////////////////////////////////
173 inline void cPropSnd::RegisterSound(int handle
, cPlayerSoundList
*pSoundList
)
175 Assert_((handle
>= 0) && (handle
< kMaxActiveSounds
));
176 Assert_(m_SoundList
[handle
] == NULL
);
178 m_SoundList
[handle
] = pSoundList
;
181 ////////////////////////////////////////
183 inline cPlayerSoundList
*cPropSnd::GetSound(int handle
)
185 Assert_((handle
>= 0) && (handle
< kMaxActiveSounds
));
187 return m_SoundList
[handle
];
190 ////////////////////////////////////////
192 inline void cPropSnd::RemoveSound(int handle
)
194 Assert_((handle
>= 0) && (handle
< kMaxActiveSounds
));
196 m_SoundList
[handle
] = NULL
;
199 ////////////////////////////////////////////////////////////////////////////////
201 inline void cPropSnd::EndActiveSound(cSoundInfo
*pSoundInfo
)
203 m_SoundInstance
->EndActiveSound(pSoundInfo
);
206 ////////////////////////////////////////////////////////////////////////////////
208 inline cPlayerSoundList
*cPropSnd::GeneratePlayerSoundList(int handle
)
210 return m_SoundInstance
->GeneratePlayerSoundList(handle
);
212 ////////////////////////////////////////////////////////////////////////////////
214 inline void cPropSnd::ClearBlockingFactors()
216 m_SoundBlockingTable
.Clear();
219 ////////////////////////////////////////////////////////////////////////////////
222 inline void cPropSnd::SetDrawSoundPath(BOOL state
)
224 Assert_(m_SoundInstance
);
225 m_SoundInstance
->SetDrawSoundPath(state
);
228 inline void cPropSnd::DrawActiveSounds()
230 Assert_(m_SoundInstance
);
231 m_SoundInstance
->DrawActiveSounds();
236 ////////////////////////////////////////////////////////////////////////////////
238 EXTERN cPropSnd
*g_pPropSnd
;
239 EXTERN
int g_SndWatchHandle
;
242 ////////////////////////////////////////////////////////////////////////////////