1
This commit is contained in:
22
soundemittersystem/cbase.h
Normal file
22
soundemittersystem/cbase.h
Normal file
@ -0,0 +1,22 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CBASE_H
|
||||
#define CBASE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// Shared header file
|
||||
#include "basetypes.h"
|
||||
#include "tier1/strtools.h"
|
||||
#include "vstdlib/random.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
extern IUniformRandomStream *random;
|
||||
#endif
|
||||
|
||||
#endif // CBASE_H
|
76
soundemittersystem/soundemittersystem.vpc
Normal file
76
soundemittersystem/soundemittersystem.vpc
Normal file
@ -0,0 +1,76 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// SOUNDEMITTERSYSTEM.VPC
|
||||
//
|
||||
// Project Script
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$Macro SRCDIR ".."
|
||||
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
|
||||
|
||||
$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
$Linker
|
||||
{
|
||||
$SystemLibraries "iconv" [$OSXALL]
|
||||
}
|
||||
$Compiler
|
||||
{
|
||||
$AdditionalIncludeDirectories ".\;$BASE;$SRCDIR\game\shared"
|
||||
$PreprocessorDefinitions "$BASE;SOUNDEMITTERSYSTEM_EXPORTS;_WINDOWS;PROTECTED_THINGS_ENABLE"
|
||||
$PreprocessorDefinitions "$BASE;fopen=dont_use_fopen" [$WINDOWS]
|
||||
}
|
||||
}
|
||||
|
||||
$Project "SoundEmitterSystem"
|
||||
{
|
||||
$Folder "Source Files"
|
||||
{
|
||||
$File "$SRCDIR\game\shared\interval.cpp"
|
||||
$File "soundemittersystembase.cpp"
|
||||
$File "$SRCDIR\public\SoundParametersInternal.cpp"
|
||||
}
|
||||
|
||||
$Folder "Header Files"
|
||||
{
|
||||
$File "soundemittersystembase.h"
|
||||
$File "cbase.h"
|
||||
$File "$SRCDIR\game\shared\interval.h"
|
||||
}
|
||||
|
||||
$Folder "Public Header Files"
|
||||
{
|
||||
$File "$SRCDIR\public\tier0\basetypes.h"
|
||||
$File "$SRCDIR\public\Color.h"
|
||||
$File "$SRCDIR\public\tier0\commonmacros.h"
|
||||
$File "$SRCDIR\public\tier0\dbg.h"
|
||||
$File "$SRCDIR\public\tier0\fasttimer.h"
|
||||
$File "$SRCDIR\public\filesystem.h"
|
||||
$File "$SRCDIR\public\appframework\IAppSystem.h"
|
||||
$File "$SRCDIR\public\tier0\icommandline.h"
|
||||
$File "$SRCDIR\public\engine\IEngineSound.h"
|
||||
$File "$SRCDIR\public\vstdlib\IKeyValuesSystem.h"
|
||||
$File "$SRCDIR\public\tier1\interface.h"
|
||||
$File "$SRCDIR\public\irecipientfilter.h"
|
||||
$File "$SRCDIR\public\SoundEmitterSystem\isoundemittersystembase.h"
|
||||
$File "$SRCDIR\public\tier1\KeyValues.h"
|
||||
$File "$SRCDIR\public\tier0\mem.h"
|
||||
$File "$SRCDIR\public\tier0\memdbgoff.h"
|
||||
$File "$SRCDIR\public\tier0\memdbgon.h"
|
||||
$File "$SRCDIR\public\tier0\platform.h"
|
||||
$File "$SRCDIR\public\tier0\protected_things.h"
|
||||
$File "$SRCDIR\public\vstdlib\random.h"
|
||||
$File "$SRCDIR\public\soundchars.h"
|
||||
$File "$SRCDIR\public\soundflags.h"
|
||||
$File "$SRCDIR\public\string_t.h"
|
||||
$File "$SRCDIR\public\tier1\strtools.h"
|
||||
$File "$SRCDIR\public\tier1\utlbuffer.h"
|
||||
$File "$SRCDIR\public\tier1\utldict.h"
|
||||
$File "$SRCDIR\public\tier1\utlmemory.h"
|
||||
$File "$SRCDIR\public\tier1\utlrbtree.h"
|
||||
$File "$SRCDIR\public\tier1\utlsymbol.h"
|
||||
$File "$SRCDIR\public\tier1\utlvector.h"
|
||||
$File "$SRCDIR\public\vstdlib\vstdlib.h"
|
||||
}
|
||||
}
|
1663
soundemittersystem/soundemittersystembase.cpp
Normal file
1663
soundemittersystem/soundemittersystembase.cpp
Normal file
File diff suppressed because it is too large
Load Diff
183
soundemittersystem/soundemittersystembase.h
Normal file
183
soundemittersystem/soundemittersystembase.h
Normal file
@ -0,0 +1,183 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef SOUNDEMITTERSYSTEMBASE_H
|
||||
#define SOUNDEMITTERSYSTEMBASE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "SoundEmitterSystem/isoundemittersystembase.h"
|
||||
#include "soundflags.h"
|
||||
#include "interval.h"
|
||||
#include "UtlSortVector.h"
|
||||
#include <tier1/utlstring.h>
|
||||
#include <tier1/utlhashtable.h>
|
||||
|
||||
soundlevel_t TextToSoundLevel( const char *key );
|
||||
|
||||
struct CSoundEntry
|
||||
{
|
||||
CUtlConstString m_Name;
|
||||
CSoundParametersInternal m_SoundParams;
|
||||
uint16 m_nScriptFileIndex;
|
||||
bool m_bRemoved : 1;
|
||||
bool m_bIsOverride : 1;
|
||||
|
||||
bool IsOverride() const
|
||||
{
|
||||
return m_bIsOverride;
|
||||
}
|
||||
};
|
||||
|
||||
struct CSoundEntryHashFunctor : CaselessStringHashFunctor
|
||||
{
|
||||
using CaselessStringHashFunctor::operator();
|
||||
unsigned int operator()( CSoundEntry *e ) const
|
||||
{
|
||||
return CaselessStringHashFunctor::operator()( e->m_Name.Get() );
|
||||
}
|
||||
};
|
||||
|
||||
struct CSoundEntryEqualFunctor : CaselessStringEqualFunctor
|
||||
{
|
||||
using CaselessStringEqualFunctor::operator();
|
||||
bool operator()( CSoundEntry *lhs, CSoundEntry *rhs ) const
|
||||
{
|
||||
return CaselessStringEqualFunctor::operator()( lhs->m_Name.Get(), rhs->m_Name.Get() );
|
||||
}
|
||||
bool operator()( CSoundEntry *lhs, const char *rhs ) const
|
||||
{
|
||||
return CaselessStringEqualFunctor::operator()( lhs->m_Name.Get(), rhs );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Base class for sound emitter system handling (can be used by tools)
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSoundEmitterSystemBase : public ISoundEmitterSystemBase
|
||||
{
|
||||
public:
|
||||
CSoundEmitterSystemBase();
|
||||
virtual ~CSoundEmitterSystemBase() { }
|
||||
|
||||
// Methods of IAppSystem
|
||||
virtual bool Connect( CreateInterfaceFn factory );
|
||||
virtual void Disconnect();
|
||||
virtual void *QueryInterface( const char *pInterfaceName );
|
||||
virtual InitReturnVal_t Init();
|
||||
virtual void Shutdown();
|
||||
|
||||
public:
|
||||
|
||||
virtual bool ModInit();
|
||||
virtual void ModShutdown();
|
||||
|
||||
virtual int GetSoundIndex( const char *pName ) const;
|
||||
virtual bool IsValidIndex( int index );
|
||||
virtual int GetSoundCount( void );
|
||||
|
||||
virtual const char *GetSoundName( int index );
|
||||
virtual bool GetParametersForSound( const char *soundname, CSoundParameters& params, gender_t gender, bool isbeingemitted = false );
|
||||
virtual const char *GetWaveName( CUtlSymbol& sym );
|
||||
|
||||
virtual CUtlSymbol AddWaveName( const char *name );
|
||||
|
||||
virtual soundlevel_t LookupSoundLevel( const char *soundname );
|
||||
virtual const char *GetWavFileForSound( const char *soundname, char const *actormodel );
|
||||
virtual const char *GetWavFileForSound( const char *soundname, gender_t gender );
|
||||
|
||||
virtual int CheckForMissingWavFiles( bool verbose );
|
||||
virtual const char *GetSourceFileForSound( int index ) const;
|
||||
// Iteration methods
|
||||
virtual int First() const;
|
||||
virtual int Next( int i ) const;
|
||||
virtual int InvalidIndex() const;
|
||||
|
||||
virtual CSoundParametersInternal *InternalGetParametersForSound( int index );
|
||||
|
||||
|
||||
// The host application is responsible for dealing with dirty sound scripts, etc.
|
||||
virtual bool AddSound( const char *soundname, const char *scriptfile, const CSoundParametersInternal& params );
|
||||
virtual void RemoveSound( const char *soundname );
|
||||
|
||||
virtual void MoveSound( const char *soundname, const char *newscript );
|
||||
|
||||
virtual void RenameSound( const char *soundname, const char *newname );
|
||||
virtual void UpdateSoundParameters( const char *soundname, const CSoundParametersInternal& params );
|
||||
|
||||
virtual int GetNumSoundScripts() const;
|
||||
virtual char const *GetSoundScriptName( int index ) const;
|
||||
virtual bool IsSoundScriptDirty( int index ) const;
|
||||
virtual int FindSoundScript( const char *name ) const;
|
||||
|
||||
virtual void SaveChangesToSoundScript( int scriptindex );
|
||||
|
||||
virtual void ExpandSoundNameMacros( CSoundParametersInternal& params, char const *wavename );
|
||||
virtual gender_t GetActorGender( char const *actormodel );
|
||||
virtual void GenderExpandString( char const *actormodel, char const *in, char *out, int maxlen );
|
||||
virtual void GenderExpandString( gender_t gender, char const *in, char *out, int maxlen );
|
||||
virtual bool IsUsingGenderToken( char const *soundname );
|
||||
virtual unsigned int GetManifestFileTimeChecksum();
|
||||
|
||||
virtual bool GetParametersForSoundEx( const char *soundname, HSOUNDSCRIPTHANDLE& handle, CSoundParameters& params, gender_t gender, bool isbeingemitted = false );
|
||||
virtual soundlevel_t LookupSoundLevelByHandle( char const *soundname, HSOUNDSCRIPTHANDLE& handle );
|
||||
|
||||
|
||||
// Called from both client and server (single player) or just one (server only in dedicated server and client only if connected to a remote server)
|
||||
// Called by LevelInitPreEntity to override sound scripts for the mod with level specific overrides based on custom mapnames, etc.
|
||||
virtual void AddSoundOverrides( char const *scriptfile, bool bPreload = false );
|
||||
|
||||
// Called by either client or server in LevelShutdown to clear out custom overrides
|
||||
virtual void ClearSoundOverrides();
|
||||
|
||||
virtual void ReloadSoundEntriesInList( IFileList *pFilesToReload );
|
||||
|
||||
// Called by either client or server to force ModShutdown and ModInit
|
||||
virtual void Flush();
|
||||
|
||||
private:
|
||||
|
||||
bool InternalModInit();
|
||||
void InternalModShutdown();
|
||||
|
||||
void AddSoundsFromFile( const char *filename, bool bPreload, bool bIsOverride = false, bool bRefresh = false );
|
||||
|
||||
bool InitSoundInternalParameters( const char *soundname, KeyValues *kv, CSoundParametersInternal& params );
|
||||
|
||||
void LoadGlobalActors();
|
||||
|
||||
float TranslateAttenuation( const char *key );
|
||||
soundlevel_t TranslateSoundLevel( const char *key );
|
||||
int TranslateChannel( const char *name );
|
||||
|
||||
int FindBestSoundForGender( SoundFile *pSoundnames, int c, gender_t gender );
|
||||
void EnsureAvailableSlotsForGender( SoundFile *pSoundnames, int c, gender_t gender );
|
||||
void AddSoundName( CSoundParametersInternal& params, char const *wavename, gender_t gender );
|
||||
|
||||
CUtlHashtable< CUtlConstString, gender_t, CaselessStringHashFunctor, UTLConstStringCaselessStringEqualFunctor<char> > m_ActorGenders;
|
||||
CUtlStableHashtable< CSoundEntry*, empty_t, CSoundEntryHashFunctor, CSoundEntryEqualFunctor, uint16, const char* > m_Sounds;
|
||||
|
||||
CUtlVector< CSoundEntry * > m_SavedOverrides;
|
||||
CUtlVector< FileNameHandle_t > m_OverrideFiles;
|
||||
|
||||
struct CSoundScriptFile
|
||||
{
|
||||
FileNameHandle_t hFilename;
|
||||
bool dirty;
|
||||
};
|
||||
|
||||
CUtlVector< CSoundScriptFile > m_SoundKeyValues;
|
||||
int m_nInitCount;
|
||||
unsigned int m_uManifestPlusScriptChecksum;
|
||||
|
||||
CUtlSymbolTable m_Waves;
|
||||
};
|
||||
|
||||
#endif // SOUNDEMITTERSYSTEMBASE_H
|
3
soundemittersystem/xbox/xbox.def
Normal file
3
soundemittersystem/xbox/xbox.def
Normal file
@ -0,0 +1,3 @@
|
||||
LIBRARY SoundEmitterSystem_360.dll
|
||||
EXPORTS
|
||||
CreateInterface @1
|
Reference in New Issue
Block a user