From 9a33e5318c8ef267f45a56f0b8f7779081ae32d3 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 14 Jun 2017 02:29:13 +0500 Subject: [PATCH] Fix mp3-player. --- cl_dll/hs/timer.cpp | 1 + cl_dll/hud.cpp | 9 +++++++-- cl_dll/hud_msg.cpp | 15 ++++++++------- cl_dll/hud_redraw.cpp | 7 ++++--- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/cl_dll/hs/timer.cpp b/cl_dll/hs/timer.cpp index 2ce3cda5..636e8d66 100644 --- a/cl_dll/hs/timer.cpp +++ b/cl_dll/hs/timer.cpp @@ -61,6 +61,7 @@ int CHudTimer::Draw( float flTime ) if (smbSoundCounter == 5) //Note: the counter will still continue until 120 seconds turns into 119. { char * songchoice = "media/hurryup.mp3"; + gEngfuncs.pfnPrimeMusicStream( songchoice, 0 ); //gMP3.PlayMP3NL( songchoice ); } //Draw BG diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index e2729976..93acdf70 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -77,7 +77,7 @@ int __MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf ) { return gHUD.MsgFunc_GameMode( pszName, iSize, pbuf ); } -/* + int __MsgFunc_PlayMP3(const char *pszName, int iSize, void *pbuf ) { return gHUD.MsgFunc_PlayMP3( pszName, iSize, pbuf ); @@ -92,7 +92,7 @@ int __MsgFunc_StopMP3(const char *pszName, int iSize, void *pbuf ) { return gHUD.MsgFunc_StopMP3( pszName, iSize, pbuf ); } -*/ + int __MsgFunc_AddELight(const char *pszName, int iSize, void *pbuf ) { return gHUD.MsgFunc_AddELight( pszName, iSize, pbuf ); @@ -200,6 +200,11 @@ void CHud::Init( void ) HOOK_COMMAND( "stopaudio", StopMP3 ); }*/ + HOOK_MESSAGE( PlayMP3 ); + HOOK_MESSAGE( PlayBGM ); + HOOK_MESSAGE( StopMP3 ); + HOOK_COMMAND( "stopaudio", StopMP3 ); + // TFFree CommandMenu HOOK_COMMAND( "+commandmenu", OpenCommandMenu ); HOOK_COMMAND( "-commandmenu", CloseCommandMenu ); diff --git a/cl_dll/hud_msg.cpp b/cl_dll/hud_msg.cpp index 6aaddc11..43bbfefa 100644 --- a/cl_dll/hud_msg.cpp +++ b/cl_dll/hud_msg.cpp @@ -116,13 +116,13 @@ int CHud::MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf ) this->m_StatusIcons.DisableIcon( "dmg_concuss" ); return 1; } -/* + int CHud::MsgFunc_PlayMP3( const char *pszName, int iSize, void *pbuf ) //AJH -Killar MP3 { BEGIN_READ( pbuf, iSize ); - gMP3.PlayMP3( READ_STRING() ); - + //gMP3.PlayMP3( READ_STRING() ); + gEngfuncs.pfnPrimeMusicStream( READ_STRING(), 1 ); return 1; } @@ -131,18 +131,19 @@ int CHud::MsgFunc_PlayBGM( const char *pszName, int iSize, void *pbuf ) //AJH -K BEGIN_READ( pbuf, iSize ); if( CVAR_GET_FLOAT( "hud_bgm" ) > 0 ) - gMP3.PlayMP3( READ_STRING() ); + //gMP3.PlayMP3( READ_STRING() ); + gEngfuncs.pfnPrimeMusicStream( READ_STRING(), 1 ); return 1; } int CHud::MsgFunc_StopMP3( const char *pszName, int iSize, void *pbuf ) //AJH -Killar MP3 { - gMP3.StopMP3(); - + //gMP3.StopMP3(); + gEngfuncs.pfnPrimeMusicStream( 0, 0 ); return 1; } -*/ + int CHud::MsgFunc_AddELight( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index 5685d8e7..9ef655a2 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -96,7 +96,7 @@ int CHud::Redraw( float flTime, int intermission ) if( !m_iIntermission && intermission ) { int ranmus; -/* + ranmus = gEngfuncs.pfnRandomLong( 0, 9 ); char *songchoice; @@ -134,8 +134,9 @@ int CHud::Redraw( float flTime, int intermission ) break; } - gMP3.PlayMP3NL( songchoice ); -*/ + //gMP3.PlayMP3NL( songchoice ); + gEngfuncs.pfnPrimeMusicStream( songchoice, 0 ); + // Take a screenshot if the client's got the cvar set if( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 ) m_flShotTime = flTime + 1.0; // Take a screenshot in a second