1.1 --- a/extensions/sdktools/vsound.cpp Sun May 27 11:39:50 2012 -0400
1.2 +++ b/extensions/sdktools/vsound.cpp Sun May 27 16:08:03 2012 -0400
1.3 @@ -33,8 +33,13 @@
1.4 #include <IForwardSys.h>
1.5
1.6 SH_DECL_HOOK8_void(IVEngineServer, EmitAmbientSound, SH_NOATTRIB, 0, int, const Vector &, const char *, float, soundlevel_t, int, int, float);
1.7 +#if SOURCE_ENGINE >= SE_PORTAL2
1.8 +SH_DECL_HOOK17(IEngineSound, EmitSound, SH_NOATTRIB, 0, int, IRecipientFilter &, int, int, const char *, unsigned int, const char *, float, float, int, int, int, const Vector *, const Vector *, CUtlVector<Vector> *, bool, float, int);
1.9 +SH_DECL_HOOK17(IEngineSound, EmitSound, SH_NOATTRIB, 1, int, IRecipientFilter &, int, int, const char *, unsigned int, const char *, float, soundlevel_t, int, int, int, const Vector *, const Vector *, CUtlVector<Vector> *, bool, float, int);
1.10 +#else
1.11 SH_DECL_HOOK14_void(IEngineSound, EmitSound, SH_NOATTRIB, 0, IRecipientFilter &, int, int, const char *, float, float, int, int, const Vector *, const Vector *, CUtlVector<Vector> *, bool, float, int);
1.12 SH_DECL_HOOK14_void(IEngineSound, EmitSound, SH_NOATTRIB, 1, IRecipientFilter &, int, int, const char *, float, soundlevel_t, int, int, const Vector *, const Vector *, CUtlVector<Vector> *, bool, float, int);
1.13 +#endif
1.14
1.15 bool g_InSoundHook = false;
1.16
1.17 @@ -252,10 +257,17 @@
1.18 }
1.19 }
1.20
1.21 +#if SOURCE_ENGINE >= SE_PORTAL2
1.22 +int SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChannel, const char *pSoundEntry, unsigned int nSoundEntryHash, const char *pSample,
1.23 + float flVolume, soundlevel_t iSoundlevel, int nSeed, int iFlags, int iPitch, const Vector *pOrigin,
1.24 + const Vector *pDirection, CUtlVector<Vector> *pUtlVecOrigins, bool bUpdatePositions,
1.25 + float soundtime, int speakerentity)
1.26 +#else
1.27 void SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChannel, const char *pSample,
1.28 float flVolume, soundlevel_t iSoundlevel, int iFlags, int iPitch, const Vector *pOrigin,
1.29 const Vector *pDirection, CUtlVector<Vector> *pUtlVecOrigins, bool bUpdatePositions,
1.30 float soundtime, int speakerentity)
1.31 +#endif
1.32 {
1.33 SoundHookIter iter;
1.34 IPluginFunction *pFunc;
1.35 @@ -287,12 +299,26 @@
1.36 case Pl_Handled:
1.37 case Pl_Stop:
1.38 {
1.39 +#if SOURCE_ENGINE >= SE_PORTAL2
1.40 + RETURN_META_VALUE(MRES_SUPERCEDE, -1);
1.41 +#else
1.42 RETURN_META(MRES_SUPERCEDE);
1.43 +#endif
1.44 }
1.45 case Pl_Changed:
1.46 {
1.47 CellRecipientFilter crf;
1.48 crf.Initialize(players, size);
1.49 +#if SOURCE_ENGINE >= SE_PORTAL2
1.50 + RETURN_META_VALUE_NEWPARAMS(
1.51 + MRES_IGNORED,
1.52 + -1,
1.53 + static_cast<int (IEngineSound::*)(IRecipientFilter &, int, int, const char*, unsigned int, const char*, float, soundlevel_t,
1.54 + int, int, int, const Vector *, const Vector *, CUtlVector<Vector> *, bool, float, int)>(&IEngineSound::EmitSound),
1.55 + (crf, iEntIndex, iChannel, buffer, -1, buffer, flVolume, iSoundlevel, nSeed, iFlags, iPitch, pOrigin,
1.56 + pDirection, pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity)
1.57 + );
1.58 +#else
1.59 RETURN_META_NEWPARAMS(
1.60 MRES_IGNORED,
1.61 static_cast<void (IEngineSound::*)(IRecipientFilter &, int, int, const char*, float, soundlevel_t,
1.62 @@ -300,15 +326,27 @@
1.63 (crf, iEntIndex, iChannel, buffer, flVolume, iSoundlevel, iFlags, iPitch, pOrigin,
1.64 pDirection, pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity)
1.65 );
1.66 +#endif
1.67 }
1.68 }
1.69 }
1.70 +
1.71 +#if SOURCE_ENGINE >= SE_PORTAL2
1.72 + RETURN_META_VALUE(MRES_IGNORED, -1 );
1.73 +#endif
1.74 }
1.75
1.76 +#if SOURCE_ENGINE >= SE_PORTAL2
1.77 +int SoundHooks::OnEmitSound2(IRecipientFilter &filter, int iEntIndex, int iChannel, const char *pSoundEntry, unsigned int nSoundEntryHash, const char *pSample,
1.78 + float flVolume, float flAttenuation, int nSeed, int iFlags, int iPitch, const Vector *pOrigin,
1.79 + const Vector *pDirection, CUtlVector<Vector> *pUtlVecOrigins, bool bUpdatePositions,
1.80 + float soundtime, int speakerentity)
1.81 +#else
1.82 void SoundHooks::OnEmitSound2(IRecipientFilter &filter, int iEntIndex, int iChannel, const char *pSample,
1.83 float flVolume, float flAttenuation, int iFlags, int iPitch, const Vector *pOrigin,
1.84 const Vector *pDirection, CUtlVector<Vector> *pUtlVecOrigins, bool bUpdatePositions,
1.85 float soundtime, int speakerentity)
1.86 +#endif
1.87 {
1.88 SoundHookIter iter;
1.89 IPluginFunction *pFunc;
1.90 @@ -341,22 +379,41 @@
1.91 case Pl_Handled:
1.92 case Pl_Stop:
1.93 {
1.94 +#if SOURCE_ENGINE >= SE_PORTAL2
1.95 + RETURN_META_VALUE(MRES_SUPERCEDE, -1);
1.96 +#else
1.97 RETURN_META(MRES_SUPERCEDE);
1.98 +#endif
1.99 }
1.100 case Pl_Changed:
1.101 {
1.102 CellRecipientFilter crf;
1.103 crf.Initialize(players, size);
1.104 +#if SOURCE_ENGINE >= SE_PORTAL2
1.105 + RETURN_META_VALUE_NEWPARAMS(
1.106 + MRES_IGNORED,
1.107 + -1,
1.108 + static_cast<int (IEngineSound::*)(IRecipientFilter &, int, int, const char *, unsigned int, const char *, float, float,
1.109 + int, int, int, const Vector *, const Vector *, CUtlVector<Vector> *, bool, float, int)>(&IEngineSound::EmitSound),
1.110 + (crf, iEntIndex, iChannel, buffer, -1, buffer, flVolume, SNDLVL_TO_ATTN(static_cast<soundlevel_t>(sndlevel)),
1.111 + nSeed, iFlags, iPitch, pOrigin, pDirection, pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity)
1.112 + );
1.113 +#else
1.114 RETURN_META_NEWPARAMS(
1.115 MRES_IGNORED,
1.116 - static_cast<void (IEngineSound::*)(IRecipientFilter &, int, int, const char*, float, float,
1.117 + static_cast<void (IEngineSound::*)(IRecipientFilter &, int, int, const char *, float, float,
1.118 int, int, const Vector *, const Vector *, CUtlVector<Vector> *, bool, float, int)>(&IEngineSound::EmitSound),
1.119 (crf, iEntIndex, iChannel, buffer, flVolume, SNDLVL_TO_ATTN(static_cast<soundlevel_t>(sndlevel)),
1.120 iFlags, iPitch, pOrigin, pDirection, pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity)
1.121 );
1.122 +#endif
1.123 }
1.124 }
1.125 }
1.126 +
1.127 +#if SOURCE_ENGINE >= SE_PORTAL2
1.128 + RETURN_META_VALUE(MRES_IGNORED, -1 );
1.129 +#endif
1.130 }
1.131
1.132 /************************
1.133 @@ -452,7 +509,11 @@
1.134 char *name;
1.135 pContext->LocalToString(params[3], &name);
1.136
1.137 +#if SOURCE_ENGINE >= SE_PORTAL2
1.138 + engsound->StopSound(entity, channel, name, -1);
1.139 +#else
1.140 engsound->StopSound(entity, channel, name);
1.141 +#endif
1.142
1.143 return 1;
1.144 }
1.145 @@ -547,6 +608,53 @@
1.146 player[0] = cl_array[i];
1.147 crf.Reset();
1.148 crf.Initialize(player, 1);
1.149 +#if SOURCE_ENGINE >= SE_PORTAL2
1.150 + if (g_InSoundHook)
1.151 + {
1.152 + SH_CALL(enginesoundPatch,
1.153 + static_cast<int (IEngineSound::*)(IRecipientFilter &, int, int, const char*, unsigned int, const char*, float,
1.154 + soundlevel_t, int, int, int, const Vector *, const Vector *, CUtlVector<Vector> *, bool, float, int)>
1.155 +
1.156 + (&IEngineSound::EmitSound))
1.157 + (crf,
1.158 + player[0],
1.159 + channel,
1.160 + sample,
1.161 + -1,
1.162 + sample,
1.163 + vol,
1.164 + (soundlevel_t)level,
1.165 + 0,
1.166 + flags,
1.167 + pitch,
1.168 + pOrigin,
1.169 + pDir,
1.170 + pOrigVec,
1.171 + updatePos,
1.172 + soundtime,
1.173 + speakerentity);
1.174 + }
1.175 + else
1.176 + {
1.177 + engsound->EmitSound(crf,
1.178 + player[0],
1.179 + channel,
1.180 + sample,
1.181 + -1,
1.182 + sample,
1.183 + vol,
1.184 + (soundlevel_t)level,
1.185 + 0,
1.186 + flags,
1.187 + pitch,
1.188 + pOrigin,
1.189 + pDir,
1.190 + pOrigVec,
1.191 + updatePos,
1.192 + soundtime,
1.193 + speakerentity);
1.194 + }
1.195 +#else
1.196 if (g_InSoundHook)
1.197 {
1.198 SH_CALL(enginesoundPatch,
1.199 @@ -585,8 +693,55 @@
1.200 soundtime,
1.201 speakerentity);
1.202 }
1.203 +#endif
1.204 }
1.205 } else {
1.206 +#if SOURCE_ENGINE >= SE_PORTAL2
1.207 + if (g_InSoundHook)
1.208 + {
1.209 + SH_CALL(enginesoundPatch,
1.210 + static_cast<int (IEngineSound::*)(IRecipientFilter &, int, int, const char*, unsigned int, const char*, float,
1.211 + soundlevel_t, int, int, int, const Vector *, const Vector *, CUtlVector<Vector> *, bool, float, int)>
1.212 + (&IEngineSound::EmitSound))
1.213 + (crf,
1.214 + entity,
1.215 + channel,
1.216 + sample,
1.217 + -1,
1.218 + sample,
1.219 + vol,
1.220 + (soundlevel_t)level,
1.221 + 0,
1.222 + flags,
1.223 + pitch,
1.224 + pOrigin,
1.225 + pDir,
1.226 + pOrigVec,
1.227 + updatePos,
1.228 + soundtime,
1.229 + speakerentity);
1.230 + }
1.231 + else
1.232 + {
1.233 + engsound->EmitSound(crf,
1.234 + entity,
1.235 + channel,
1.236 + sample,
1.237 + -1,
1.238 + sample,
1.239 + vol,
1.240 + (soundlevel_t)level,
1.241 + 0,
1.242 + flags,
1.243 + pitch,
1.244 + pOrigin,
1.245 + pDir,
1.246 + pOrigVec,
1.247 + updatePos,
1.248 + soundtime,
1.249 + speakerentity);
1.250 + }
1.251 +#else
1.252 if (g_InSoundHook)
1.253 {
1.254 SH_CALL(enginesoundPatch,
1.255 @@ -625,6 +780,7 @@
1.256 soundtime,
1.257 speakerentity);
1.258 }
1.259 +#endif
1.260 }
1.261
1.262 return 1;
1.263 @@ -712,6 +868,9 @@
1.264 sentence,
1.265 vol,
1.266 (soundlevel_t)level,
1.267 +#if SOURCE_ENGINE >= SE_PORTAL2
1.268 + 0,
1.269 +#endif
1.270 flags,
1.271 pitch,
1.272 pOrigin,