mirror of
https://github.com/Haze1337/Sound-Manager.git
synced 2025-12-06 18:08:34 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6688f4ba99 | ||
|
|
58a1046e0a | ||
|
|
2fb7a1d9d7 | ||
|
|
d6f4d4a273 | ||
|
|
65f5ee1dab | ||
|
|
2114add6d5 | ||
|
|
c3c8c97d5d | ||
|
|
0bcaf21b3f | ||
|
|
182766364d | ||
|
|
3287fe8910 | ||
|
|
2cb0b64040 | ||
|
|
de0b9c36b4 |
@ -13,7 +13,7 @@ Plugin for managing sound entities in games Counter-Strike: Source and Counter-S
|
||||
* !stopmusic
|
||||
* !stopsounds
|
||||
|
||||
# Warn:
|
||||
# Warning:
|
||||
|
||||
If the sound has started playing, then you can stop it only by writing `snd_restart` to the console, perhaps in the future I will add the ability to stop active sounds without using this command
|
||||
|
||||
|
||||
@ -2,72 +2,253 @@
|
||||
{
|
||||
"cstrike"
|
||||
{
|
||||
"Addresses"
|
||||
{
|
||||
"CSoundscapeSystem"
|
||||
{
|
||||
"windows"
|
||||
{
|
||||
"signature" "soundscape_flush"
|
||||
"read" "93"
|
||||
}
|
||||
"windows64"
|
||||
{
|
||||
"signature" "soundscape_flush"
|
||||
"read" "107"
|
||||
}
|
||||
"linux"
|
||||
{
|
||||
"signature" "soundscape_flush"
|
||||
"read" "129"
|
||||
}
|
||||
"linux64"
|
||||
{
|
||||
"signature" "soundscape_flush"
|
||||
"read" "144"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"Signatures"
|
||||
{
|
||||
// search for "Error parsing soundscape file %s after %s" to find CSoundscapeSystem::AddSoundscapeFile. Then go to vtable that references it...
|
||||
// go up two functions to find CSoundscapeSystem::FrameUpdatePostEntityThink
|
||||
// then look around the middle for calls to CEnvSoundscape::UpdateForPlayer
|
||||
// You can find stuff like this inside UpdateForPlayer: (which are floats)
|
||||
// local_24 = 0x41200000;
|
||||
// local_20 = 0x41200000;
|
||||
// local_1c = 0x41200000;
|
||||
// local_30 = 0xc1200000;
|
||||
// local_2c = 0xc1200000;
|
||||
// local_28 = 0xc1200000;
|
||||
"CEnvSoundscape::UpdateForPlayer"
|
||||
{
|
||||
"library" "server"
|
||||
"windows" "\x55\x8B\xEC\x81\xEC\x80\x00\x00\x00\x56\x8B\xF1\x80\xBE\x88\x03\x00\x00\x00"
|
||||
"windows" "\x55\x8B\xEC\x81\xEC\x80\x00\x00\x00\x56\x8B\xF1\x57\x8B\x7D"
|
||||
"windows64" "\x40\x53\x56\x57\x48\x81\xEC\x10\x01\x00\x00"
|
||||
"linux" "@_ZN14CEnvSoundscape15UpdateForPlayerER11ss_update_t"
|
||||
"linux64" "@_ZN14CEnvSoundscape15UpdateForPlayerER11ss_update_t"
|
||||
}
|
||||
|
||||
// search "CGameServer::BroadcastSound:" to find CGameServer::BroadcastSound and it includes a call to CGameClient::SendSound somewhere near the bottom
|
||||
"CGameClient::SendSound"
|
||||
{
|
||||
"library" "engine"
|
||||
"windows" "\x55\x8B\xEC\x81\xEC\xC8\x00\x00\x00\x56\x8B\xF1"
|
||||
"windows" "\x55\x8B\xEC\x81\xEC\xCC\x00\x00\x00\x56\x8B\xF1"
|
||||
"windows64" "\x48\x89\x5C\x24\x2A\x48\x89\x74\x24\x2A\x48\x89\x7C\x24\x2A\x4C\x89\x74\x24\x2A\x55\x48\x8D\x6C\x24\x2A\x48\x81\xEC\x30\x01\x00\x00"
|
||||
"linux" "@_ZN11CGameClient9SendSoundER11SoundInfo_tb"
|
||||
}
|
||||
}
|
||||
|
||||
"Offsets"
|
||||
{
|
||||
"AcceptInput"
|
||||
{
|
||||
"windows" "36"
|
||||
"linux" "37"
|
||||
"linux64" "@_ZN11CGameClient9SendSoundER11SoundInfo_tb"
|
||||
}
|
||||
|
||||
// search "cl_soundscape_flush" to find the command handler for "soundscape_flush"
|
||||
"soundscape_flush"
|
||||
{
|
||||
"library" "server"
|
||||
"windows" "\x56\xE8\x2A\x2A\x2A\x2A\x8B\xF0\x85\xF6\x74\x2A\x8B\x16\x8B\xCE\x8B\x92\x2A\x2A\x2A\x2A\xFF\xD2\x84\xC0\x75\x2A\x33\xF6"
|
||||
"windows64" "\x40\x53\x48\x83\xEC\x20\xE8\x2A\x2A\x2A\x2A\x48\x8B\xD8\x48\x85\xC0\x74\x2A\x48\x8B\x00"
|
||||
"linux" "@_ZL16soundscape_flushRK8CCommand"
|
||||
"linux64" "@_ZL16soundscape_flushRK8CCommand"
|
||||
}
|
||||
|
||||
// search "Shared activity collision" to find ActivityList_RegisterSharedActivity and the first function called inside is GetStringID
|
||||
"CStringRegistry::GetStringID"
|
||||
{
|
||||
"library" "server"
|
||||
"windows" "\x55\x8B\xEC\x83\xEC\x0C\x8B\x45\x2A\x89\x4D\x2A\x53\xBB\xFF\xFF\x00\x00"
|
||||
"windows64" "\x48\x89\x5C\x24\x2A\x57\x48\x83\xEC\x30\x4C\x89\x7C\x24"
|
||||
"linux" "@_ZN15CStringRegistry11GetStringIDEPKc"
|
||||
"linux64" "@_ZN15CStringRegistry11GetStringIDEPKc"
|
||||
}
|
||||
}
|
||||
|
||||
"Offsets"
|
||||
{
|
||||
// search "Replay client not found" to find CReplayServer::StartMaster and then look for the "cl_predict" string setting and grab the GetPlayerSlot offset from the next function call.
|
||||
// (windows64 probably means divide it by four 😇)
|
||||
"CBaseClient::GetPlayerSlot"
|
||||
{
|
||||
"windows" "14"
|
||||
"linux" "15"
|
||||
"windows" "14"
|
||||
"windows64" "28"
|
||||
"linux" "15"
|
||||
"linux64" "24"
|
||||
}
|
||||
// find in CSoundscapeSystem::GetSoundscapeIndex
|
||||
"CSoundscapeSystem::m_soundscapes"
|
||||
{
|
||||
"windows" "12"
|
||||
"windows64" "24"
|
||||
"linux" "12"
|
||||
"linux64" "24"
|
||||
}
|
||||
"SoundInfo_t::fVolume"
|
||||
{
|
||||
"windows" "40"
|
||||
"windows64" "44"
|
||||
"linux" "40"
|
||||
"linux64" "44"
|
||||
}
|
||||
"SoundInfo_t::bIsAmbient"
|
||||
{
|
||||
"windows" "85"
|
||||
"windows64" "89"
|
||||
"linux" "85"
|
||||
"linux64" "89"
|
||||
}
|
||||
"ss_update_t::pCurrentSoundscape"
|
||||
{
|
||||
"windows" "4"
|
||||
"windows64" "8"
|
||||
"linux" "4"
|
||||
"windows64" "8"
|
||||
}
|
||||
"CGameClient::thing"
|
||||
{
|
||||
"windows" "4"
|
||||
"windows64" "8"
|
||||
"linux" "4"
|
||||
"windows64" "8"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"csgo"
|
||||
{
|
||||
"Addresses"
|
||||
{
|
||||
"CSoundscapeSystem"
|
||||
{
|
||||
"windows"
|
||||
{
|
||||
"signature" "soundscape_flush"
|
||||
"read" "94"
|
||||
}
|
||||
"linux"
|
||||
{
|
||||
"signature" "soundscape_flush"
|
||||
"read" "133"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"Signatures"
|
||||
{
|
||||
// "Setting invalid soundscape, %s, as the "...
|
||||
/*
|
||||
Find string: Setting invalid soundscape, %s, as the
|
||||
Go to function that uses this string
|
||||
Go to the first xref
|
||||
*/
|
||||
"CEnvSoundscape::UpdateForPlayer"
|
||||
{
|
||||
"library" "server"
|
||||
"windows" "\x55\x8B\xEC\x83\xE4\xF0\x81\xEC\xA8\x00\x00\x00\x56\x8B\xF1\x57\x80\xBE\xDC\x03\x00\x00\x00"
|
||||
"linux" "\x55\x89\xE5\x81\xEC\xE8\x00\x00\x00\x89\x5D\xF4\x8B\x5D\x08\x89\x75\xF8\x8B\x75\x0C\x89\x7D\xFC\x80\xBB\xF4\x03\x00\x00\x00"
|
||||
"linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\xEC\x00\x00\x00\x8B\x5D\x08\x8B\x7D\x0C"
|
||||
}
|
||||
|
||||
// "CGameServer::BroadcastSound: Recipient"...
|
||||
/*
|
||||
Find string: reliable%s %s %d/%d/%d/%s\n
|
||||
Go to function that uses this string
|
||||
*/
|
||||
"CGameClient::SendSound"
|
||||
{
|
||||
"library" "engine"
|
||||
"windows" "\x55\x8B\xEC\x51\x56\x8B\xF1\x8B\x46\x04"
|
||||
"linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x4C\x8B\x5D\x08\x8B\x7D\x0C\x0F\xB6\x75\x10"
|
||||
"linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x2C\x8B\x5D\x08\x8B\x75\x10\x8B\x03"
|
||||
}
|
||||
|
||||
/*
|
||||
Find string: cl_soundscape_flush\n
|
||||
Go to function that uses this string
|
||||
*/
|
||||
"soundscape_flush"
|
||||
{
|
||||
"library" "server"
|
||||
"windows" "\x56\xE8\x2A\x2A\x2A\x2A\x8B\xF0\x85\xF6\x74\x2A\x8B\x16\x8B\xCE\x8B\x92\x58\x01\x00\x00\xFF\xD2\x84\xC0\x75\x2A"
|
||||
"linux" "\x55\x89\xE5\x53\x83\xEC\x04\xE8\x2A\x2A\x2A\x2A\x85\xC0\x74\x2A\x89\xC3\x8B\x00\x8B\x80\x5C\x01\x00\x00\x3D\x2A\x2A\x2A\x2A\x75\x2A\xA1\x2A\x2A\x2A\x2A"
|
||||
}
|
||||
|
||||
/*
|
||||
Find string: Can't find soundscape: %s\n
|
||||
Go to function that uses this string
|
||||
|
||||
if ( !*(_DWORD *)(a1 + 964) )
|
||||
return DevMsg("Found soundscape entity with no soundscape name.\n");
|
||||
v1 = sub_821D00(&dword_17B5380); <<< Jump here
|
||||
*(_DWORD *)(a1 + 968) = v1;
|
||||
result = sub_821D20(&dword_17B5380, v1);
|
||||
if ( !(_BYTE)result )
|
||||
{
|
||||
v3 = *(const char **)(a1 + 964);
|
||||
if ( !v3 )
|
||||
v3 = &nptr;
|
||||
result = DevWarning("Can't find soundscape: %s\n", v3);
|
||||
|
||||
// ----------------------------------------------------- //
|
||||
|
||||
int __cdecl sub_821D00(int a1, int a2)
|
||||
{
|
||||
return sub_8B1670(a1 + 12, a2); << Jump here
|
||||
}
|
||||
*/
|
||||
"CStringRegistry::GetStringID"
|
||||
{
|
||||
"library" "server"
|
||||
"windows" "\x55\x8B\xEC\x8B\x45\x08\x83\xEC\x08\x56\x57\x8B\xF9\x85\xC0"
|
||||
"linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x2C\x8B\x55\x08\x8B\x45\x0C\x8B\x3A"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
"Offsets"
|
||||
{
|
||||
"AcceptInput"
|
||||
{
|
||||
"windows" "41"
|
||||
"linux" "42"
|
||||
}
|
||||
|
||||
"CBaseClient::GetPlayerSlot"
|
||||
{
|
||||
"windows" "16"
|
||||
"linux" "17"
|
||||
"windows" "16"
|
||||
"linux" "17"
|
||||
}
|
||||
"CSoundscapeSystem::m_soundscapes"
|
||||
{
|
||||
"windows" "12"
|
||||
"linux" "12"
|
||||
}
|
||||
"SoundInfo_t::fVolume"
|
||||
{
|
||||
"windows" "40"
|
||||
"linux" "40"
|
||||
}
|
||||
"SoundInfo_t::bIsAmbient"
|
||||
{
|
||||
"windows" "89"
|
||||
"linux" "89"
|
||||
}
|
||||
"ss_update_t::pCurrentSoundscape"
|
||||
{
|
||||
"windows" "4"
|
||||
"linux" "4"
|
||||
}
|
||||
"CGameClient::thing"
|
||||
{
|
||||
"windows" "4"
|
||||
"linux" "4"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@ -5,12 +5,12 @@
|
||||
#pragma newdecls required
|
||||
#pragma semicolon 1
|
||||
|
||||
public Plugin myinfo =
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "Sound Manager",
|
||||
author = "Haze",
|
||||
description = "",
|
||||
version = "1.0",
|
||||
version = "1.0.5",
|
||||
url = ""
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ public Plugin myinfo =
|
||||
#define Mute_AmbientSounds (1 << 1)
|
||||
#define Mute_GunSounds (1 << 2)
|
||||
#define Mute_TriggerSounds (1 << 3)
|
||||
#define Mute_AllPackets (1 << 4)
|
||||
#define Mute_NormalSounds (1 << 4)
|
||||
#define Debug (1 << 5)
|
||||
|
||||
// Engine
|
||||
@ -34,13 +34,21 @@ int gI_LastSoundscape[MAXPLAYERS+1];
|
||||
// Cookie
|
||||
Handle gH_SettingsCookie = null;
|
||||
|
||||
// Dhooks
|
||||
// DHooks
|
||||
Address gP_SoundscapeSystem = Address_Null;
|
||||
Handle gH_AcceptInput = null;
|
||||
Handle gH_GetPlayerSlot = null;
|
||||
Handle gH_GetStringID = null;
|
||||
int gI_AmbientOffset = -1;
|
||||
int gI_m_soundscapesOffset = -1;
|
||||
int gI_VolumeOffset = -1;
|
||||
int gI_CurrentSoundscapeOffset = -1;
|
||||
int gI_CGameClientThing = -1;
|
||||
|
||||
// Other
|
||||
int gI_SilentSoundScape = 0;
|
||||
int gI_AmbientOffset = 0;
|
||||
int gI_SilentSoundScape = -1;
|
||||
char gS_WeaponID[32];
|
||||
|
||||
bool gB_ShouldHookShotgunShot = false;
|
||||
ArrayList gA_LoopingAmbients = null;
|
||||
bool gB_EntitiesFound = false;
|
||||
@ -54,20 +62,16 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
|
||||
gB_LateLoad = late;
|
||||
}
|
||||
|
||||
//CSS: 138: port.LightHum2
|
||||
//CSGO: 199: port.LightHum2
|
||||
public void OnPluginStart()
|
||||
{
|
||||
gEV_Type = GetEngineVersion();
|
||||
if(gEV_Type == Engine_CSS)
|
||||
{
|
||||
gI_SilentSoundScape = 138;
|
||||
gI_AmbientOffset = 85;
|
||||
FormatEx(gS_WeaponID, sizeof(gS_WeaponID), "m_iWeaponID");
|
||||
}
|
||||
else if(gEV_Type == Engine_CSGO)
|
||||
{
|
||||
gI_SilentSoundScape = 199;
|
||||
gI_AmbientOffset = 89;
|
||||
FormatEx(gS_WeaponID, sizeof(gS_WeaponID), "m_weapon");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -91,7 +95,7 @@ public void OnPluginStart()
|
||||
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
|
||||
|
||||
// Dhooks
|
||||
LoadDhooks();
|
||||
LoadDHooks();
|
||||
|
||||
// Sound Hook
|
||||
AddTempEntHook("Shotgun Shot", Hook_ShotgunShot);
|
||||
@ -106,7 +110,7 @@ public void OnPluginStart()
|
||||
}
|
||||
|
||||
Event_RoundStart(null, "", false);
|
||||
|
||||
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(!IsValidClient(i))
|
||||
@ -157,6 +161,11 @@ public void OnClientCookiesCached(int client)
|
||||
{
|
||||
gB_ShouldHookShotgunShot = true;
|
||||
}
|
||||
|
||||
if(gI_Settings[client] & Mute_Soundscapes)
|
||||
{
|
||||
ClientCommand(client, "cl_soundscape_flush"); // maybe auth can take a long time and a soundscape slips through...
|
||||
}
|
||||
}
|
||||
|
||||
public Action OnPlayerRunCmd(int client)
|
||||
@ -189,7 +198,19 @@ public Action OnPlayerRunCmd(int client)
|
||||
{
|
||||
char sSound[PLATFORM_MAX_PATH];
|
||||
GetEntPropString(entity, Prop_Data, "m_iszSound", sSound, PLATFORM_MAX_PATH);
|
||||
EmitSoundToClient(client, sSound, entity, SNDCHAN_STATIC, SNDLEVEL_NONE, SND_STOP, 0.0, SNDPITCH_NORMAL, _, _, _, true);
|
||||
|
||||
int channel = SNDCHAN_STATIC;
|
||||
int level = SNDLEVEL_NONE;
|
||||
float volume = 0.0;
|
||||
int pitch = SNDPITCH_NORMAL;
|
||||
char sSample[PLATFORM_MAX_PATH];
|
||||
|
||||
if (GetGameSoundParams(sSound, channel, level, volume, pitch, sSample, sizeof(sSample), entity))
|
||||
{
|
||||
sSound = sSample;
|
||||
}
|
||||
|
||||
EmitSoundToClient(client, sSound, entity, SNDCHAN_STATIC, SNDLEVEL_NONE, SND_STOP, 0.0, 0, _, _, _, true);
|
||||
|
||||
if(gI_Settings[client] & Debug)
|
||||
{
|
||||
@ -199,12 +220,12 @@ public Action OnPlayerRunCmd(int client)
|
||||
}
|
||||
|
||||
gB_AlreadyMuted[client] = true;
|
||||
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
//-------------------------------------------------------------
|
||||
|
||||
void LoadDhooks()
|
||||
void LoadDHooks()
|
||||
{
|
||||
Handle hGameData = LoadGameConfigFile("SoundManager.games");
|
||||
if(!hGameData)
|
||||
@ -212,20 +233,92 @@ void LoadDhooks()
|
||||
SetFailState("Failed to load SoundManager gamedata.");
|
||||
}
|
||||
|
||||
StartPrepSDKCall_GetStringID(hGameData);
|
||||
HookSoundscapes(hGameData);
|
||||
HookAcceptInput(hGameData);
|
||||
HookAcceptInput();
|
||||
HookSendSound(hGameData);
|
||||
|
||||
if ((gI_AmbientOffset = GameConfGetOffset(hGameData, "SoundInfo_t::bIsAmbient")) == -1)
|
||||
{
|
||||
SetFailState("Could not get SoundInfo_t::bIsAmbient offset");
|
||||
}
|
||||
|
||||
if ((gI_m_soundscapesOffset = GameConfGetOffset(hGameData, "CSoundscapeSystem::m_soundscapes")) == -1)
|
||||
{
|
||||
SetFailState("Could not get CSoundscapeSystem::m_soundscapes offset");
|
||||
}
|
||||
|
||||
if ((gI_VolumeOffset = GameConfGetOffset(hGameData, "SoundInfo_t::fVolume")) == -1)
|
||||
{
|
||||
SetFailState("Could not get SoundInfo_t::fVolume offset");
|
||||
}
|
||||
|
||||
if ((gI_CurrentSoundscapeOffset = GameConfGetOffset(hGameData, "ss_update_t::pCurrentSoundscape")) == -1)
|
||||
{
|
||||
SetFailState("Could not get ss_update_t::pCurrentSoundscape");
|
||||
}
|
||||
|
||||
if ((gI_CGameClientThing = GameConfGetOffset(hGameData, "CGameClient::thing")) == -1)
|
||||
{
|
||||
SetFailState("Could not get CGameClient::thing");
|
||||
}
|
||||
|
||||
delete hGameData;
|
||||
}
|
||||
|
||||
//-------------------------SOUNDSCAPES-------------------------
|
||||
void StartPrepSDKCall_GetStringID(Handle hGameData)
|
||||
{
|
||||
gP_SoundscapeSystem = GameConfGetAddress(hGameData, "CSoundscapeSystem");
|
||||
if(gP_SoundscapeSystem == Address_Null)
|
||||
{
|
||||
SetFailState("Could not get address of CSoundscapeSystem pointer.");
|
||||
}
|
||||
|
||||
StartPrepSDKCall(SDKCall_Raw);
|
||||
PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, "CStringRegistry::GetStringID");
|
||||
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
|
||||
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
|
||||
gH_GetStringID = EndPrepSDKCall();
|
||||
if (gH_GetStringID == null)
|
||||
{
|
||||
SetFailState("Could not initialize call to CStringRegistry::GetStringID.");
|
||||
}
|
||||
}
|
||||
|
||||
int GetSoundscapeIndex(const char[] sString)
|
||||
{
|
||||
return SDKCall(gH_GetStringID, gP_SoundscapeSystem + view_as<Address>(gI_m_soundscapesOffset), sString);
|
||||
}
|
||||
|
||||
public void OnMapStart()
|
||||
{
|
||||
static const char sSilentSoundScapes[][] = {
|
||||
"port.LightHum2",
|
||||
"Nothing"
|
||||
};
|
||||
|
||||
gI_SilentSoundScape = -1;
|
||||
|
||||
if (gH_GetStringID)
|
||||
{
|
||||
for(int i = 0; i < sizeof(sSilentSoundScapes); i++)
|
||||
{
|
||||
gI_SilentSoundScape = GetSoundscapeIndex(sSilentSoundScapes[i]);
|
||||
if(gI_SilentSoundScape != -1)
|
||||
{
|
||||
//PrintToServer("Found: %s (%d)", sSilentSoundScapes[i], gI_SilentSoundScape);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HookSoundscapes(Handle hGameData)
|
||||
{
|
||||
Handle hFunction = DHookCreateDetour(Address_Null, CallConv_THISCALL, ReturnType_Void, ThisPointer_CBaseEntity);
|
||||
Handle hFunction = DHookCreateDetour(Address_Null, CallConv_THISCALL, ReturnType_Void, ThisPointer_CBaseEntity);
|
||||
DHookSetFromConf(hFunction, hGameData, SDKConf_Signature, "CEnvSoundscape::UpdateForPlayer");
|
||||
DHookAddParam(hFunction, HookParamType_ObjectPtr);
|
||||
|
||||
if(!DHookEnableDetour(hFunction, false, DHook_UpdateForPlayer))
|
||||
{
|
||||
SetFailState("Couldn't enable CEnvSoundscape::UpdateForPlayer detour.");
|
||||
@ -236,7 +329,7 @@ void HookSoundscapes(Handle hGameData)
|
||||
struct ss_update_t
|
||||
{
|
||||
CBasePlayer *pPlayer; Offset: 0 | Size: 4
|
||||
CEnvSoundscape pCurrentSoundscape; Offset: 4 | Size: 4
|
||||
CEnvSoundscape *pCurrentSoundscape; Offset: 4 | Size: 4
|
||||
Vector playerPosition; Offset: 8 | Size: 12
|
||||
float currentDistance; Offset: 20 | Size: 4
|
||||
int traceCount; Offset: 24 | Size: 4
|
||||
@ -247,6 +340,13 @@ struct ss_update_t
|
||||
//void CEnvSoundscape::UpdateForPlayer( ss_update_t &update )
|
||||
public MRESReturn DHook_UpdateForPlayer(int pThis, Handle hParams)
|
||||
{
|
||||
#if 0
|
||||
if(gI_SilentSoundScape == -1)
|
||||
{
|
||||
return MRES_Ignored;
|
||||
}
|
||||
#endif
|
||||
|
||||
int client = DHookGetParamObjectPtrVar(hParams, 1, 0, ObjectValueType_CBaseEntityPtr);
|
||||
|
||||
MRESReturn ret = MRES_Ignored;
|
||||
@ -266,7 +366,7 @@ public MRESReturn DHook_UpdateForPlayer(int pThis, Handle hParams)
|
||||
}
|
||||
else
|
||||
{
|
||||
DHookSetParamObjectPtrVar(hParams, 1, 4, ObjectValueType_CBaseEntityPtr, 0);
|
||||
DHookSetParamObjectPtrVar(hParams, 1, gI_CurrentSoundscapeOffset, ObjectValueType_CBaseEntityPtr, 0);
|
||||
}
|
||||
|
||||
gI_LastSoundscape[client] = GetEntProp(client, Prop_Data, "soundscapeIndex");
|
||||
@ -275,11 +375,13 @@ public MRESReturn DHook_UpdateForPlayer(int pThis, Handle hParams)
|
||||
//---------------------------------------------------------------
|
||||
|
||||
//------------------------TRIGGER OUTPUTS------------------------
|
||||
void HookAcceptInput(Handle hGameData)
|
||||
void HookAcceptInput()
|
||||
{
|
||||
Handle hGameData = LoadGameConfigFile("sdktools.games");
|
||||
int offset = GameConfGetOffset(hGameData, "AcceptInput");
|
||||
delete hGameData;
|
||||
|
||||
if(offset == 0)
|
||||
if(offset == -1)
|
||||
{
|
||||
SetFailState("Failed to load \"AcceptInput\", invalid offset.");
|
||||
}
|
||||
@ -288,7 +390,7 @@ void HookAcceptInput(Handle hGameData)
|
||||
DHookAddParam(gH_AcceptInput, HookParamType_CharPtr);
|
||||
DHookAddParam(gH_AcceptInput, HookParamType_CBaseEntity);
|
||||
DHookAddParam(gH_AcceptInput, HookParamType_CBaseEntity);
|
||||
DHookAddParam(gH_AcceptInput, HookParamType_Object, 20);
|
||||
DHookAddParam(gH_AcceptInput, HookParamType_Object, 20, DHookPass_ByVal|DHookPass_ODTOR|DHookPass_OCTOR|DHookPass_OASSIGNOP);
|
||||
DHookAddParam(gH_AcceptInput, HookParamType_Int);
|
||||
}
|
||||
|
||||
@ -310,7 +412,13 @@ public MRESReturn DHook_AcceptInput(int pThis, Handle hReturn, Handle hParams)
|
||||
char sParameter[128];
|
||||
DHookGetParamObjectPtrString(hParams, 4, 0, ObjectValueType_String, sParameter, 128);
|
||||
|
||||
if(StrContains(sParameter, "play") != -1)
|
||||
char sExplode[1][128];
|
||||
ExplodeString(sParameter, " ", sExplode, sizeof(sExplode), sizeof(sExplode[]));
|
||||
|
||||
if(strcmp(sExplode[0], "play") == 0
|
||||
|| strcmp(sExplode[0], "playgamesound") == 0
|
||||
|| strcmp(sExplode[0], "play_hrtf") == 0
|
||||
|| strcmp(sExplode[0], "snd_playsounds") == 0)
|
||||
{
|
||||
if(gI_Settings[client] & Debug)
|
||||
{
|
||||
@ -328,11 +436,10 @@ public MRESReturn DHook_AcceptInput(int pThis, Handle hReturn, Handle hParams)
|
||||
//----------------AMBIENT/NORMAL SOUNDS----------------
|
||||
void HookSendSound(Handle hGameData)
|
||||
{
|
||||
Handle hFunction = DHookCreateDetour(Address_Null, CallConv_THISCALL, ReturnType_Void, ThisPointer_Address);
|
||||
Handle hFunction = DHookCreateDetour(Address_Null, CallConv_THISCALL, ReturnType_Void, ThisPointer_Address);
|
||||
DHookSetFromConf(hFunction, hGameData, SDKConf_Signature, "CGameClient::SendSound");
|
||||
DHookAddParam(hFunction, HookParamType_ObjectPtr);
|
||||
DHookAddParam(hFunction, HookParamType_Bool);
|
||||
|
||||
if(!DHookEnableDetour(hFunction, false, DHook_SendSound))
|
||||
{
|
||||
SetFailState("Couldn't enable CGameClient::SendSound detour.");
|
||||
@ -342,7 +449,6 @@ void HookSendSound(Handle hGameData)
|
||||
PrepSDKCall_SetFromConf(hGameData, SDKConf_Virtual, "CBaseClient::GetPlayerSlot");
|
||||
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
|
||||
gH_GetPlayerSlot = EndPrepSDKCall();
|
||||
|
||||
if(gH_GetPlayerSlot == null)
|
||||
{
|
||||
SetFailState("Could not initialize call to CBaseClient::GetPlayerSlot.");
|
||||
@ -399,12 +505,12 @@ void HookSendSound(Handle hGameData)
|
||||
//void CGameClient::SendSound( SoundInfo_t &sound, bool isReliable )
|
||||
public MRESReturn DHook_SendSound(Address pThis, Handle hParams)
|
||||
{
|
||||
if(DHookGetParamObjectPtrVar(hParams, 1, 40, ObjectValueType_Float) == 0.0)
|
||||
if(DHookGetParamObjectPtrVar(hParams, 1, gI_VolumeOffset, ObjectValueType_Float) == 0.0)
|
||||
{
|
||||
return MRES_Ignored;
|
||||
}
|
||||
|
||||
Address pIClient = pThis + view_as<Address>(4);
|
||||
Address pIClient = pThis + view_as<Address>(gI_CGameClientThing);
|
||||
int client = view_as<int>(SDKCall(gH_GetPlayerSlot, pIClient)) + 1;
|
||||
|
||||
if(!IsValidClient(client))
|
||||
@ -429,7 +535,7 @@ public MRESReturn DHook_SendSound(Address pThis, Handle hParams)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(gI_Settings[client] & Mute_AllPackets)
|
||||
if(gI_Settings[client] & Mute_NormalSounds)
|
||||
{
|
||||
if(gI_Settings[client] & Debug)
|
||||
{
|
||||
@ -471,6 +577,10 @@ public Action Command_Sounds(int client, int args)
|
||||
IntToString(Mute_AmbientSounds, sInfo, 16);
|
||||
menu.AddItem(sInfo, sDisplay);
|
||||
|
||||
FormatEx(sDisplay, 64, "Normal Sounds: [%s]", gI_Settings[client] & Mute_NormalSounds ? "Muted" : "On");
|
||||
IntToString(Mute_NormalSounds, sInfo, 16);
|
||||
menu.AddItem(sInfo, sDisplay);
|
||||
|
||||
FormatEx(sDisplay, 64, "Trigger Sounds: [%s]\n ", gI_Settings[client] & Mute_TriggerSounds ? "Muted" : "On");
|
||||
IntToString(Mute_TriggerSounds, sInfo, 16);
|
||||
menu.AddItem(sInfo, sDisplay);
|
||||
@ -479,10 +589,6 @@ public Action Command_Sounds(int client, int args)
|
||||
IntToString(Mute_GunSounds, sInfo, 16);
|
||||
menu.AddItem(sInfo, sDisplay);
|
||||
|
||||
FormatEx(sDisplay, 64, "Block all sound packets: [%s]", gI_Settings[client] & Mute_AllPackets ? "Yes" : "No");
|
||||
IntToString(Mute_AllPackets, sInfo, 16);
|
||||
menu.AddItem(sInfo, sDisplay);
|
||||
|
||||
if(CheckCommandAccess(client, "soundmanager_debug", ADMFLAG_RCON))
|
||||
{
|
||||
FormatEx(sDisplay, 64, "Debug Prints: [%s]", gI_Settings[client] & Debug ? "Yes" : "No");
|
||||
@ -519,6 +625,13 @@ public int MenuHandler_Sounds(Menu menu, MenuAction action, int param1, int para
|
||||
{
|
||||
CheckShotgunShotHook();
|
||||
}
|
||||
else if(iOption == Mute_Soundscapes)
|
||||
{
|
||||
if(gI_Settings[param1] & Mute_Soundscapes)
|
||||
{
|
||||
ClientCommand(param1, "cl_soundscape_flush");
|
||||
}
|
||||
}
|
||||
|
||||
char sCookie[16];
|
||||
IntToString(gI_Settings[param1], sCookie, 16);
|
||||
@ -597,7 +710,7 @@ public Action Hook_ShotgunShot(const char[] te_name, const int[] Players, int nu
|
||||
TE_WriteVector("m_vecOrigin", vTemp);
|
||||
TE_WriteFloat("m_vecAngles[0]", TE_ReadFloat("m_vecAngles[0]"));
|
||||
TE_WriteFloat("m_vecAngles[1]", TE_ReadFloat("m_vecAngles[1]"));
|
||||
TE_WriteNum("m_iWeaponID", TE_ReadNum("m_iWeaponID"));
|
||||
TE_WriteNum(gS_WeaponID, TE_ReadNum(gS_WeaponID));
|
||||
TE_WriteNum("m_iMode", TE_ReadNum("m_iMode"));
|
||||
TE_WriteNum("m_iSeed", TE_ReadNum("m_iSeed"));
|
||||
TE_WriteNum("m_iPlayer", TE_ReadNum("m_iPlayer"));
|
||||
@ -633,4 +746,4 @@ void CheckShotgunShotHook()
|
||||
bool IsValidClient(int client)
|
||||
{
|
||||
return (client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && !IsClientSourceTV(client));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user