summaryrefslogtreecommitdiff
path: root/internal_rewrite/play_sound.cpp
blob: 3042b02534fdf4ad2d5d684b7e959d64a9816680 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "hooks.hpp"
#include "base_cheat.hpp"
void __fastcall hooks::play_sound( void* ecx_, void*, const char* file ) {
	static auto play_sound_o = g_csgo.m_surface->get_old_function< decltype( &play_sound ) >( 82 );

#ifdef HEADER_MODULE
	// static auto is_ready = g_header.patterns.is_ready;
	static auto is_ready = pattern::first_code_match( g_csgo.m_chl.dll( ), xors( "55 8B EC 83 E4 F8 83 EC 08 56 8B 35 00 00 00 00 57 83 BE" ), 0 );
#else
	static auto is_ready = pattern::first_code_match( g_csgo.m_chl.dll( ), xors( "55 8B EC 83 E4 F8 83 EC 08 56 8B 35 00 00 00 00 57 83 BE" ), 0 );
#endif
	static bool was_played = false;
	static float played_tick = 0.f;

	play_sound_o( ecx_, 0, file );

	if( !g_settings.misc.auto_accept || g_csgo.m_engine( )->IsInGame( ) ) {
		was_played = false;
		return;
	}

	if( strstr( file, xors( "competitive_accept_beep.wav" ) ) && !was_played ) {
		was_played = true;
		played_tick = GetTickCount( ) * 0.001f + g_settings.misc.auto_accept_delay;
		g_cheat.m_extra.server_information( );
		g_cheat.m_visuals.reset_local_dmg( );
	}

	if( was_played && GetTickCount( ) * 0.001f > played_tick ) {
		reinterpret_cast< void( __cdecl* )( ) >( is_ready )( );
		was_played = false;
	}
}