Browse Source

Add ambient_fmodstream implementation.

CAd
Night Owl 7 years ago
parent
commit
3ebd7536db
  1. 17
      cl_dll/hud.cpp
  2. 7
      dlls/client.cpp
  3. 2
      dlls/player.cpp
  4. 51
      dlls/triggers.cpp

17
cl_dll/hud.cpp

@ -78,6 +78,20 @@ int __MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf ) @@ -78,6 +78,20 @@ 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 )
{
BEGIN_READ( pbuf, iSize );
gEngfuncs.pfnPrimeMusicStream( READ_STRING(), 1 );
return 1;
}
void __CmdFunc_StopMP3( void )
{
gEngfuncs.pfnPrimeMusicStream( 0, 0 );
}
// TFFree Command Menu
void __CmdFunc_OpenCommandMenu( void )
{
@ -183,6 +197,9 @@ void CHud::Init( void ) @@ -183,6 +197,9 @@ void CHud::Init( void )
// VGUI Menus
HOOK_MESSAGE( VGUIMenu );
HOOK_MESSAGE( PlayMP3 );
HOOK_COMMAND( "stopaudio", StopMP3 );
CVAR_CREATE( "hud_classautokill", "1", FCVAR_ARCHIVE | FCVAR_USERINFO ); // controls whether or not to suicide immediately on TF class switch
CVAR_CREATE( "hud_takesshots", "0", FCVAR_ARCHIVE ); // controls whether or not to automatically take screenshots at the end of a round
hud_textmode = CVAR_CREATE ( "hud_textmode", "0", FCVAR_ARCHIVE );

7
dlls/client.cpp

@ -49,6 +49,7 @@ extern void CopyToBodyQue( entvars_t* pev ); @@ -49,6 +49,7 @@ extern void CopyToBodyQue( entvars_t* pev );
extern int giPrecacheGrunt;
extern int gmsgSayText;
extern int gmsgBhopcap;
extern int gmsgPlayMP3;
extern cvar_t allow_spectators;
@ -487,6 +488,12 @@ void ClientCommand( edict_t *pEntity ) @@ -487,6 +488,12 @@ void ClientCommand( edict_t *pEntity )
{
GetClassPtr( (CBasePlayer *)pev )->ForceClientDllUpdate();
}
else if( FStrEq(pcmd, "playaudio" ) )
{
MESSAGE_BEGIN( MSG_ONE, gmsgPlayMP3, NULL, ENT( pev ) );
WRITE_STRING( (char *)CMD_ARGV( 1 ) );
MESSAGE_END();
}
else if( FStrEq(pcmd, "give" ) )
{
if( g_flWeaponCheat != 0.0 )

2
dlls/player.cpp

@ -185,6 +185,7 @@ int gmsgShowMenu = 0; @@ -185,6 +185,7 @@ int gmsgShowMenu = 0;
int gmsgGeigerRange = 0;
int gmsgTeamNames = 0;
int gmsgBhopcap = 0;
int gmsgPlayMP3 = 0;
int gmsgStatusText = 0;
int gmsgStatusValue = 0;
@ -232,6 +233,7 @@ void LinkUserMessages( void ) @@ -232,6 +233,7 @@ void LinkUserMessages( void )
gmsgAmmoX = REG_USER_MSG( "AmmoX", 2 );
gmsgTeamNames = REG_USER_MSG( "TeamNames", -1 );
gmsgBhopcap = REG_USER_MSG( "Bhopcap", 1 );
gmsgPlayMP3 = REG_USER_MSG( "PlayMP3", -1 );
gmsgStatusText = REG_USER_MSG( "StatusText", -1 );
gmsgStatusValue = REG_USER_MSG( "StatusValue", 3 );

51
dlls/triggers.cpp

@ -771,6 +771,57 @@ void CTargetCDAudio::Play( void ) @@ -771,6 +771,57 @@ void CTargetCDAudio::Play( void )
UTIL_Remove( this );
}
#define SF_REMOVE_ON_FIRE 1
class CTargetFMODAudio : public CPointEntity
{
public:
void Spawn( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
BOOL m_bPlaying;
};
LINK_ENTITY_TO_CLASS( ambient_fmodstream, CTargetFMODAudio )
LINK_ENTITY_TO_CLASS( trigger_mp3audio, CTargetFMODAudio )
void CTargetFMODAudio::Spawn( void )
{
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NONE;
m_bPlaying = FALSE; // start out not playing
}
void CTargetFMODAudio::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
char command[64];
if( !pActivator->IsPlayer()) // activator should be a player
return;
if( !m_bPlaying ) // if we're not playing, start playing!
{
m_bPlaying = TRUE;
}
else
{
// if we're already playing, stop the mp3
m_bPlaying = FALSE;
CLIENT_COMMAND( pActivator->edict(), "stopaudio\n" );
return;
}
// issue the play/loop command
sprintf( command, "playaudio %s\n", STRING( pev->message ) );
CLIENT_COMMAND( pActivator->edict(), command );
// remove if set
if( FBitSet( pev->spawnflags, SF_REMOVE_ON_FIRE ) )
UTIL_Remove( this );
}
//=====================================
//
// trigger_hurt - hurts anything that touches it. if the trigger has a targetname, firing it will toggle state

Loading…
Cancel
Save