diff --git a/code/nel/include/nel/3d/cluster.h b/code/nel/include/nel/3d/cluster.h index 14b3fb13c..552d7474a 100644 --- a/code/nel/include/nel/3d/cluster.h +++ b/code/nel/include/nel/3d/cluster.h @@ -21,7 +21,6 @@ #include "nel/misc/string_mapper.h" #include "nel/misc/plane.h" #include "nel/misc/aabbox.h" -#include "nel/misc/sheet_id.h" #include "nel/3d/transform.h" @@ -126,9 +125,9 @@ public: //\name Sound related. //@{ void setSoundGroup(const std::string &soundGroup); - void setSoundGroup(const NLMISC::CSheetId &soundGroupId); + void setSoundGroup(const NLMISC::TStringId &soundGroupId); const std::string &getSoundGroup(); - NLMISC::CSheetId getSoundGroupId(); + NLMISC::TStringId getSoundGroupId(); void setEnvironmentFx(const std::string &environmentFx); void setEnvironmentFx(const NLMISC::TStringId &environmentFxId); const std::string &getEnvironmentFx(); @@ -189,7 +188,7 @@ private: std::vector _Volume; /// Sound group name id - NLMISC::CSheetId _SoundGroupId; + NLMISC::TStringId _SoundGroupId; /// Environement Fx name Id (using CStringMapper) NLMISC::TStringId _EnvironmentFxId; diff --git a/code/nel/include/nel/misc/sheet_id.h b/code/nel/include/nel/misc/sheet_id.h index 0edb2952d..869a61af6 100644 --- a/code/nel/include/nel/misc/sheet_id.h +++ b/code/nel/include/nel/misc/sheet_id.h @@ -60,6 +60,12 @@ public : */ explicit CSheetId( const std::string& sheetName ); + /** + * Constructor, uses defaultType as extension when sheetName + * contains no file extension. + */ + explicit CSheetId( const std::string& sheetName, const std::string &defaultType ); + // build from a string and returns true if the build succeed bool buildSheetId(const std::string& sheetName); @@ -141,6 +147,7 @@ public : * Serial */ void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serialString(NLMISC::IStream &f, const std::string &defaultType = "") throw(NLMISC::EStream); /** * Display the list of valid sheet ids with their associated file names @@ -221,7 +228,16 @@ private : static void loadSheetAlias (); static void cbFileChange (const std::string &filename); + /** + * When initialized without sheet_id.bin, the sheet id are assigned + * dynamically. Separate maps are used, because in sheet_id.bin + * mode it uses static maps optimized during load. + */ static bool _DontHaveSheetKnowledge; + static std::map _DevTypeNameToId; + /// outer vector is type, inner vector is sheet id + static std::vector > _DevSheetIdToName; + static std::map _DevSheetNameToId; }; diff --git a/code/nel/include/nel/sound/background_sound.h b/code/nel/include/nel/sound/background_sound.h index 54e91e712..bf83f0413 100644 --- a/code/nel/include/nel/sound/background_sound.h +++ b/code/nel/include/nel/sound/background_sound.h @@ -69,17 +69,7 @@ public: void serial(NLMISC::IStream &s) { - std::string soundName; - if (s.isReading()) - { - s.serial(soundName); - SoundName = NLMISC::CSheetId(soundName);/*NLMISC::CStringMapper::map(soundName)*/; - } - else - { - soundName = SoundName.toString();/* NLMISC::CStringMapper::unmap(SoundName)*/; - s.serial(soundName); - } + SoundName.serialString(s, "sound"); s.serial(Filter); } }; diff --git a/code/nel/include/nel/sound/clustered_sound.h b/code/nel/include/nel/sound/clustered_sound.h index 0736c5a5c..ed674f879 100644 --- a/code/nel/include/nel/sound/clustered_sound.h +++ b/code/nel/include/nel/sound/clustered_sound.h @@ -19,6 +19,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/string_mapper.h" +#include "nel/misc/sheet_id.h" #include #include @@ -249,14 +250,13 @@ private: /// The segment of all the audio path. std::vector > _AudioPath; - typedef CHashMap TClusterSoundCont; + typedef CHashMap TClusterSoundCont; /// The current cluster playing source indexed with sound group id TClusterSoundCont _Sources; - typedef CHashMap TStringStringMap; - //typedef CHashMap TStringStringMap; + typedef CHashMap TStringSheetMap; /// The sound_group to sound assoc - TStringStringMap _SoundGroupToSound; + TStringSheetMap _SoundGroupToSound; }; } // NLSOUND diff --git a/code/nel/include/nel/sound/sound.h b/code/nel/include/nel/sound/sound.h index c4c494912..403034a8d 100644 --- a/code/nel/include/nel/sound/sound.h +++ b/code/nel/include/nel/sound/sound.h @@ -54,7 +54,7 @@ class CSound friend class CAudioMixerUser; public: /// Factory for specialized sound. - static CSound *createSound(const std::string &filename, NLGEORGES::UFormElm& formRoot); + static CSound *createSound(const std::string &name, NLGEORGES::UFormElm& formRoot); enum TSOUND_TYPE { diff --git a/code/nel/include/nel/sound/sound_bank.h b/code/nel/include/nel/sound/sound_bank.h index 8a4573849..05993bb07 100644 --- a/code/nel/include/nel/sound/sound_bank.h +++ b/code/nel/include/nel/sound/sound_bank.h @@ -68,16 +68,16 @@ public: bool isLoaded(); /// Return a sound corresponding to a name. - CSound *getSound(const NLMISC::CSheetId &name); + CSound *getSound(const NLMISC::CSheetId &sheetId); /// Return the names of the sounds - void getNames( std::vector &names ); + void getNames( std::vector &sheetIds ); /// Return the number of sounds in this bank. uint countSounds(); void addSound(CSound *sound); - void removeSound(const NLMISC::CSheetId &name); + void removeSound(const NLMISC::CSheetId &sheetId); private: @@ -89,7 +89,8 @@ private: typedef CHashMap TBufferAssocContainer; /// Sound names hash map // typedef std::hash_map TSoundTable; - typedef CHashMap TSoundTable; +// typedef CHashMap TSoundTable; + typedef std::vector TSoundTable; // list the sheets by shortId of the sheetId /// Assoc from buffer to sound. Used for sound unloading. TBufferAssocContainer _BufferAssoc; diff --git a/code/nel/samples/sound/sound_sources/main.cpp b/code/nel/samples/sound/sound_sources/main.cpp index 3ece14f73..75f732b5a 100644 --- a/code/nel/samples/sound/sound_sources/main.cpp +++ b/code/nel/samples/sound/sound_sources/main.cpp @@ -49,6 +49,7 @@ void Init() { try { + CSheetId::initWithoutSheet(); CPath::addSearchPath(NL_SOUND_DATA"/data", true, false); @@ -100,7 +101,7 @@ USource *OnAddSource( const char *name, float x, float y, float z ) /* * Create a source with sound 'name', and set some of its initial properties, if successful */ - USource *source = AudioMixer->createSource( /*CStringMapper::map(name)*/ CSheetId(name) ); + USource *source = AudioMixer->createSource(CSheetId(name, "sound")); if ( source != NULL ) { source->setPos( CVector(x,y,z) ); diff --git a/code/nel/samples/sound/stream_file/stream_file.cpp b/code/nel/samples/sound/stream_file/stream_file.cpp index 060c4b433..6362a0414 100644 --- a/code/nel/samples/sound/stream_file/stream_file.cpp +++ b/code/nel/samples/sound/stream_file/stream_file.cpp @@ -62,6 +62,7 @@ static void initSample() { if (!INelContext::isContextInitialised()) new CApplicationContext(); + CSheetId::initWithoutSheet(); CPath::addSearchPath(NL_SOUND_DATA"/data", true, false); printf("Sample demonstrating OGG playback using stream file .sound sheets."); @@ -97,7 +98,7 @@ static void initSample() //NLMISC::CHTimer::startBench(); - s_Source = s_AudioMixer->createSource(/*CStringMapper::map("stream_file")*/ CSheetId("stream_file")); + s_Source = s_AudioMixer->createSource(CSheetId("stream_file.sound")); nlassert(s_Source); s_StreamFileSource = dynamic_cast(s_Source); nlassert(s_StreamFileSource); diff --git a/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp b/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp index 490ae8dd5..1f491b21c 100644 --- a/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp +++ b/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp @@ -59,6 +59,7 @@ static void initSample() { if (!INelContext::isContextInitialised()) new CApplicationContext(); + CSheetId::initWithoutSheet(); CPath::addSearchPath(NL_SOUND_DATA"/database/build/", true, false); printf("Sample demonstrating OGG playback using UStreamSource."); @@ -87,7 +88,7 @@ static void initSample() //NLMISC::CHTimer::startBench(); - USource *source = s_AudioMixer->createSource(CSheetId("default_stream")/*CStringMapper::map("default_stream")*/); + USource *source = s_AudioMixer->createSource(CSheetId("default_stream.sound")); nlassert(source); s_StreamSource = dynamic_cast(source); nlassert(s_StreamSource); diff --git a/code/nel/src/3d/cluster.cpp b/code/nel/src/3d/cluster.cpp index cb34b7f10..2faebcec7 100644 --- a/code/nel/src/3d/cluster.cpp +++ b/code/nel/src/3d/cluster.cpp @@ -51,9 +51,7 @@ CCluster::CCluster () // map a no fx string _EnvironmentFxId = CStringMapper::map("no fx"); // map a no soundgroup string - _SoundGroupId = NLMISC::CSheetId::Unknown; /*CStringMapper::map("")*/; - nldebug("SOUNDSHEET: %s", _SoundGroupId.toString().c_str()); - + _SoundGroupId = CStringMapper::map(""); // I am a transform cluster CTransform::setIsCluster(true); @@ -78,21 +76,18 @@ CCluster::~CCluster() void CCluster::setSoundGroup(const std::string &soundGroup) { - _SoundGroupId = NLMISC::CSheetId(soundGroup);/*CStringMapper::map(soundGroup);*/ - nldebug("SOUNDSHEET: %s", _SoundGroupId.toString().c_str()); - + _SoundGroupId = CStringMapper::map(soundGroup); } -void CCluster::setSoundGroup(const NLMISC::CSheetId &soundGroupId) +void CCluster::setSoundGroup(const NLMISC::TStringId &soundGroupId) { _SoundGroupId = soundGroupId; - nldebug("SOUNDSHEET: %s", _SoundGroupId.toString().c_str()); } const std::string &CCluster::getSoundGroup() { - return _SoundGroupId.toString();/*CStringMapper::unmap(_SoundGroupId)*/; + return CStringMapper::unmap(_SoundGroupId); } -NLMISC::CSheetId CCluster::getSoundGroupId() +NLMISC::TStringId CCluster::getSoundGroupId() { return _SoundGroupId; } @@ -309,8 +304,7 @@ void CCluster::serial (NLMISC::IStream&f) std::string envFxName; f.serial(soundGroup); - _SoundGroupId = NLMISC::CSheetId(soundGroup); /*CStringMapper::map(soundGroup)*/; - nldebug("SOUNDSHEET: %s", _SoundGroupId.toString().c_str()); + _SoundGroupId = CStringMapper::map(soundGroup); f.serial(envFxName); if (envFxName == "") @@ -320,7 +314,7 @@ void CCluster::serial (NLMISC::IStream&f) else { // write the sound group - std::string soundGroup = _SoundGroupId.toString();/*CStringMapper::unmap(_SoundGroupId)*/; + std::string soundGroup = CStringMapper::unmap(_SoundGroupId); f.serial(soundGroup); // write the env fx name std::string envFxName = CStringMapper::unmap(_EnvironmentFxId); diff --git a/code/nel/src/3d/ps_sound.cpp b/code/nel/src/3d/ps_sound.cpp index 322bd2729..a5ae6ad26 100644 --- a/code/nel/src/3d/ps_sound.cpp +++ b/code/nel/src/3d/ps_sound.cpp @@ -261,17 +261,16 @@ void CPSSound::serial(NLMISC::IStream &f) throw(NLMISC::EStream) CPSLocatedBindable::serial(f); // version 3 : added option to keep original pitch from the .sound sint ver = f.serialVersion(3); - if (f.isReading()) - { - std::string soundName; - f.serial(soundName); - _SoundName = NLMISC::CSheetId(soundName)/*NLMISC::CStringMapper::map(soundName)*/; - } - else - { - std::string soundName = _SoundName.toString()/*NLMISC::CStringMapper::unmap(_SoundName)*/; - f.serial(soundName); - } + + // FIXME: CPSSound is reserialized from the _ParticleSystemProto + // cache when a non-_Shared particle system is instanced, this + // causes unnecessary sheet id lookups from string. + // SLN1: Serialize as uint32, but this requires the editor to know + // the correct sheet id (and thus requires a built sheet_id.bin). + // SLN2: Create a tool that reserializes all ps with sound sheet id + // instead of sheet names, based on a global flag, and serialize + // a flag that specifies if the ps is serialized with id or name. + _SoundName.serialString(f, "sound"); sint32 nbSounds; bool hasScheme; diff --git a/code/nel/src/misc/sheet_id.cpp b/code/nel/src/misc/sheet_id.cpp index b68011cf9..fb2627b5e 100644 --- a/code/nel/src/misc/sheet_id.cpp +++ b/code/nel/src/misc/sheet_id.cpp @@ -40,6 +40,15 @@ vector CSheetId::_FileExtensions; bool CSheetId::_Initialised=false; bool CSheetId::_RemoveUnknownSheet=true; bool CSheetId::_DontHaveSheetKnowledge = false; +std::map CSheetId::_DevTypeNameToId; +std::vector > CSheetId::_DevSheetIdToName; +std::map CSheetId::_DevSheetNameToId; + +#define NL_TEMP_YUBO_NO_SOUND_SHEET_ID + +#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID +namespace { bool a_NoSoundSheetId = false; } +#endif const CSheetId CSheetId::Unknown(0); @@ -103,6 +112,18 @@ CSheetId::CSheetId( const string& sheetName ) } // CSheetId // +CSheetId::CSheetId( const std::string& sheetName, const std::string &defaultType ) +{ + if (CFile::getExtension(sheetName) == "" && defaultType != "") + { + std::string withType = sheetName + "." + defaultType; + *this = CSheetId(withType); + // nldebug("SHEETID: Constructing CSheetId from name '%s' without explicit type, defaulting as '%s' to '%s'", sheetName.c_str(), defaultType.c_str(), withType.c_str()); + } + else + *this = CSheetId(sheetName); +} + //----------------------------------------------- // Build @@ -111,7 +132,41 @@ CSheetId::CSheetId( const string& sheetName ) bool CSheetId::buildSheetId(const std::string& sheetName) { nlassert(_Initialised); - nlassert(!_DontHaveSheetKnowledge); + + // When no sheet_id.bin is loaded, use dynamically assigned IDs. + if (_DontHaveSheetKnowledge) + { + std::string sheetNameLc = toLower(sheetName); + std::map::iterator it = _DevSheetNameToId.find(sheetNameLc); + if (it == _DevSheetNameToId.end()) + { + // Create a new dynamic sheet ID. + // nldebug("SHEETID: Creating a dynamic sheet id for '%s'", sheetName.c_str()); + std::string sheetType = CFile::getExtension(sheetNameLc); + std::string sheetName = CFile::getFilenameWithoutExtension(sheetNameLc); + std::map::iterator tit = _DevTypeNameToId.find(sheetType); + uint32 typeId; + if (tit == _DevTypeNameToId.end()) + { + _FileExtensions.push_back(sheetType); + _DevSheetIdToName.push_back(std::vector()); + typeId = _FileExtensions.size() - 1; + _DevTypeNameToId[sheetType] = typeId; + } + else + { + typeId = tit->second; + } + _DevSheetIdToName[typeId].push_back(sheetName); + _Id.IdInfos.Type = typeId; + _Id.IdInfos.Id = _DevSheetIdToName[typeId].size() - 1; + // nldebug("SHEETID: Type %i, id %i, sheetid %i", _Id.IdInfos.Type, _Id.IdInfos.Id, _Id.Id); + _DevSheetNameToId[sheetNameLc] = _Id.Id; + return true; + } + _Id.Id = it->second; + return true; + } // try looking up the sheet name in _SheetNameToId CStaticMap::const_iterator itId; @@ -143,6 +198,27 @@ bool CSheetId::buildSheetId(const std::string& sheetName) return true; } } + +#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID + if (a_NoSoundSheetId && sheetName.find(".sound") != std::string::npos) + { + std::string sheetNameLc = toLower(sheetName); + std::map::iterator it = _DevSheetNameToId.find(sheetNameLc); + if (it == _DevSheetNameToId.end()) + { + uint32 typeId = ((1 << (NL_SHEET_ID_TYPE_BITS)) - 1); + // nldebug("SHEETID: Creating a temporary sheet id for '%s'", sheetName.c_str()); + _DevSheetIdToName[0].push_back(sheetName); + _Id.IdInfos.Type = typeId; + _Id.IdInfos.Id = _DevSheetIdToName[0].size() - 1; + _DevSheetNameToId[sheetNameLc] = _Id.Id; + return true; + } + _Id.Id = it->second; + return true; + } +#endif + return false; } @@ -283,7 +359,11 @@ void CSheetId::init(bool removeUnknownSheet) { // allow multiple calls to init in case libraries depending on sheetid call this init from their own if (_Initialised) + { + if (_DontHaveSheetKnowledge) + nlinfo("SHEETID: CSheetId is already initialized without sheet_id.bin"); return; + } // CFile::addFileChangeCallback ("sheet_id.bin", cbFileChange); @@ -292,13 +372,33 @@ void CSheetId::init(bool removeUnknownSheet) loadSheetId (); _Initialised=true; +#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID + if (typeFromFileExtension("sound") == std::numeric_limits::max()) + { + nlwarning("SHEETID: Loading without known sound sheet id, please update sheet_id.bin with .sound sheets"); + nlassert(_FileExtensions.size() == 1 << (NL_SHEET_ID_TYPE_BITS)); + _FileExtensions[((1 << (NL_SHEET_ID_TYPE_BITS)) - 1)] == "sound"; + _DevSheetIdToName.push_back(std::vector()); + a_NoSoundSheetId = true; + } +#endif } // init // void CSheetId::initWithoutSheet() { + if (_Initialised) + { + nlassert(_DontHaveSheetKnowledge); + return; + } + _Initialised = true; _DontHaveSheetKnowledge = true; + + // Initialize id 0,0 as unknown.unknown + CSheetId unknownunknown = CSheetId("unknown.unknown"); + nlassert(unknownunknown == CSheetId::Unknown); } @@ -310,6 +410,10 @@ void CSheetId::initWithoutSheet() void CSheetId::uninit() { delete [] _AllStrings.Ptr; + _FileExtensions.clear(); + _DevTypeNameToId.clear(); + _DevSheetIdToName.clear(); + _DevSheetNameToId.clear(); } // uninit // //----------------------------------------------- @@ -343,23 +447,9 @@ CSheetId& CSheetId::operator=( const CSheetId& sheetId ) //----------------------------------------------- CSheetId& CSheetId::operator=( const string& sheetName ) { - nlassert(_Initialised); - nlassert(!_DontHaveSheetKnowledge); - CStaticMap::const_iterator itId; - CChar c; - c.Ptr = new char [sheetName.size()+1]; - strcpy(c.Ptr, sheetName.c_str()); - toLower(c.Ptr); - - itId = _SheetNameToId.find (c); - delete [] c.Ptr; - if( itId != _SheetNameToId.end() ) - { - _Id.Id = (*itId).second; - return *this; - } - *this = Unknown; + if (!buildSheetId(sheetName)) + *this = Unknown; return *this; } // operator= // @@ -407,6 +497,13 @@ bool CSheetId::operator < (const CSheetId& sheetRef ) const string CSheetId::toString(bool ifNotFoundUseNumericId) const { if (!_Initialised) init(false); + + if (_DontHaveSheetKnowledge) + { + // FIXME: When someone punches in a fake sheet id this will + // fail. + return _DevSheetIdToName[_Id.IdInfos.Type][_Id.IdInfos.Id]; + } CStaticMap::const_iterator itStr = _SheetIdToName.find (_Id.Id); if( itStr != _SheetIdToName.end() ) @@ -415,6 +512,12 @@ string CSheetId::toString(bool ifNotFoundUseNumericId) const } else { +#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID + if (a_NoSoundSheetId && _Id.IdInfos.Type == ((1 << (NL_SHEET_ID_TYPE_BITS)) - 1)) + { + return _DevSheetIdToName[0][_Id.IdInfos.Id]; + } +#endif // This nlwarning is commented out because the loggers are mutexed, therefore // you couldn't use toString() within a nlwarning(). //nlwarning(" The sheet %08x is not in sheet_id.bin",_Id.Id); @@ -432,6 +535,8 @@ string CSheetId::toString(bool ifNotFoundUseNumericId) const void CSheetId::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { + nlassert(!_DontHaveSheetKnowledge); + f.serial( _Id.Id ); #ifdef NL_DEBUG_SHEET_ID @@ -443,6 +548,24 @@ void CSheetId::serial(NLMISC::IStream &f) throw(NLMISC::EStream) #endif } +void CSheetId::serialString(NLMISC::IStream &f, const std::string &defaultType) throw(NLMISC::EStream) +{ + nlassert(_Initialised); + + if (f.isReading()) + { + std::string sheetName; + f.serial(sheetName); + *this = CSheetId(sheetName, defaultType); + } + else + { + // if this assert fails, you may be using an outdated id bin + nlassert(*this != CSheetId::Unknown); + std::string sheetName = toString(); + f.serial(sheetName); + } +} //----------------------------------------------- diff --git a/code/nel/src/sound/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index 016f3d13d..da3c7d177 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -468,7 +468,7 @@ void CAudioMixerUser::initDevice(const std::string &deviceName, const CInitInfo nlwarning("AM: OptionSoftwareBuffer not available, forceSoftwareBuffer = false"); forceSoftware = false; // not really needed, but set anyway in case this is still used later in this function } - if (manualRolloff && !_SoundDriver->getOption(ISoundDriver::OptionLocalBufferCopy)) + if (manualRolloff && !_SoundDriver->getOption(ISoundDriver::OptionManualRolloff)) { nlwarning("AM: OptionManualRolloff not available, manualRolloff = false"); manualRolloff = false; // not really needed, but set anyway in case this is still used later in this function @@ -971,10 +971,14 @@ void CAudioMixerUser::buildSampleBankList() /// Build the sound bank packed sheets file from georges sound sheet files with .sound extension in the search path, and return the path to the written file. std::string UAudioMixer::buildSoundBank(const std::string &packedSheetDir) { + CGroupControllerRoot *tempRoot = NULL; + if (!CGroupControllerRoot::isInitialized()) + tempRoot = new CGroupControllerRoot(); std::string dir = CPath::standardizePath(packedSheetDir, true); CSoundBank *soundBank = new CSoundBank(); soundBank->load(dir, true); delete soundBank; + delete tempRoot; return dir + "sounds.packed_sheets"; } @@ -1050,9 +1054,8 @@ public: for (uint i=0; igetArrayValue(soundName, i); - soundName = soundName.substr(0, soundName.find(".sound")); - - cs.SoundNames.push_back(CSheetId(soundName)/*CStringMapper::map(soundName)*/); + nlassert(soundName.find(".sound") != std::string::npos); + cs.SoundNames.push_back(CSheetId(soundName)); } if (!cs.SoundNames.empty()) @@ -1133,7 +1136,7 @@ void CAudioMixerUser::CControledSources::serial(NLMISC::IStream &s) for (uint i=0; igetValueByName(soundName, "Sound"); - sound.SoundName = NLMISC::CSheetId(CFile::getFilenameWithoutExtension(soundName));/*CStringMapper::map(CFile::getFilenameWithoutExtension(soundName))*/; + nlassert(soundName.find(".sound") != std::string::npos); + sound.SoundName = NLMISC::CSheetId(soundName); // Read the environnement flag. diff --git a/code/nel/src/sound/background_sound_manager.cpp b/code/nel/src/sound/background_sound_manager.cpp index 4eb5b042d..4713d03f8 100644 --- a/code/nel/src/sound/background_sound_manager.cpp +++ b/code/nel/src/sound/background_sound_manager.cpp @@ -86,7 +86,7 @@ void CBackgroundSoundManager::addSound(const std::string &soundName, uint layerI CAudioMixerUser *mixer = CAudioMixerUser::instance(); TSoundData sd; - sd.SoundName = /*CStringMapper::map(soundName)*/ NLMISC::CSheetId(soundName); + sd.SoundName = NLMISC::CSheetId(soundName, "sound"); // note: loaded from .primitive sd.Sound = mixer->getSoundId(sd.SoundName); sd.Source = 0; @@ -1431,21 +1431,15 @@ void CBackgroundSoundManager::TBanksData::serial(NLMISC::IStream &s) void CBackgroundSoundManager::TSoundData::serial(NLMISC::IStream &s) { - std::string str; - + //std::string str; + SoundName.serialString(s, "sound"); if (s.isReading()) { CAudioMixerUser *mixer = CAudioMixerUser::instance(); - s.serial(str); - SoundName = /*NLMISC::CStringMapper::map(str)*/ NLMISC::CSheetId(str); Sound = mixer->getSoundId(SoundName); Source = NULL; Selected = false; } - else - { - s.serial(const_cast(SoundName.toString()/*NLMISC::CStringMapper::unmap(SoundName)*/)); - } s.serial(MinBox); s.serial(MaxBox); s.serial(Surface); diff --git a/code/nel/src/sound/clustered_sound.cpp b/code/nel/src/sound/clustered_sound.cpp index c2a8db8ef..25f0e5b64 100644 --- a/code/nel/src/sound/clustered_sound.cpp +++ b/code/nel/src/sound/clustered_sound.cpp @@ -70,7 +70,7 @@ float EAX_MATERIAL_PARAM[] = class CSoundGroupSerializer { public: - std::vector > _SoundGroupAssoc; + std::vector > _SoundGroupAssoc; // load the values using the george sheet (called by GEORGE::loadForm) void readGeorges (const NLMISC::CSmartPtr &form, const std::string &/* name */) @@ -95,15 +95,9 @@ public: item->getValueByName(soundGroup, ".SoundGroup"); item->getValueByName(sound, ".Sound"); - string::size_type n = sound.rfind(".sound"); + nlassert(sound.find(".sound") != std::string::npos); - if (n != string::npos) - { - // remove the tailing .sound - sound = sound.substr(0, n); - } - - _SoundGroupAssoc.push_back(make_pair(CSheetId(soundGroup), CSheetId(sound) /*CStringMapper::map(soundGroup), CStringMapper::map(sound)*/)); + _SoundGroupAssoc.push_back(make_pair(CStringMapper::map(soundGroup), CSheetId(sound))); } } catch(...) @@ -125,24 +119,18 @@ public: { if (s.isReading()) { - std::string soundGroup; - std::string sound; + TStringId soundGroup; + CSheetId sound; - s.serial(soundGroup); - s.serial(sound); + CStringMapper::serialString(s, soundGroup); + sound.serialString(s, "sound"); - _SoundGroupAssoc.push_back(make_pair(CSheetId(soundGroup), CSheetId(sound) /*CStringMapper::map(soundGroup), CStringMapper::map(sound)*/)); + _SoundGroupAssoc.push_back(make_pair(soundGroup, sound)); } else { - std::string soundGroup; - std::string sound; - - soundGroup = _SoundGroupAssoc[i].first.toString();// CStringMapper::unmap(_SoundGroupAssoc[i].first); - sound = _SoundGroupAssoc[i].second.toString(); //CStringMapper::unmap(_SoundGroupAssoc[i].second); - - s.serial(soundGroup); - s.serial(sound); + CStringMapper::serialString(s, _SoundGroupAssoc[i].first); + _SoundGroupAssoc[i].second.serialString(s, "sound"); } } } @@ -254,10 +242,10 @@ void CClusteredSound::update(const CVector &listenerPos, const CVector &/* view TClusterStatusMap::const_iterator first(_AudibleClusters.begin()), last(_AudibleClusters.end()); for (; first != last; ++first ) { - static NLMISC::CSheetId NO_SOUND_GROUP = /*CStringMapper::emptyId()*/NLMISC::CSheetId::Unknown; + static NLMISC::TStringId NO_SOUND_GROUP = CStringMapper::emptyId(); const CClusterSoundStatus &css = first->second; CCluster *cluster = first->first; - NLMISC::CSheetId soundGroup; + NLMISC::TStringId soundGroup; soundGroup = cluster->getSoundGroupId(); @@ -289,7 +277,7 @@ void CClusteredSound::update(const CVector &listenerPos, const CVector &/* view // nldebug("Searching sound assoc for group [%s]", CStringMapper::unmap(soundGroup).c_str()); - TStringStringMap::iterator it2(_SoundGroupToSound.find(soundGroup)); + TStringSheetMap::iterator it2(_SoundGroupToSound.find(soundGroup)); if (it2 != _SoundGroupToSound.end()) { NLMISC::CSheetId soundName = it2->second; diff --git a/code/nel/src/sound/complex_sound.cpp b/code/nel/src/sound/complex_sound.cpp index ae770eb8d..9e0ab2022 100644 --- a/code/nel/src/sound/complex_sound.cpp +++ b/code/nel/src/sound/complex_sound.cpp @@ -237,7 +237,7 @@ void CComplexSound::serial(NLMISC::IStream &s) { std::string name; s.serial(name); - _Sounds.push_back(/*CStringMapper::map(name)*/NLMISC::CSheetId(name)); + _Sounds.push_back(NLMISC::CSheetId(name, "sound")); } } else @@ -246,7 +246,7 @@ void CComplexSound::serial(NLMISC::IStream &s) s.serial(nb); for (uint i=0; igetArrayValue(soundname, i)) { - soundname = CFile::getFilenameWithoutExtension(soundname); - _Sounds.push_back(NLMISC::CSheetId(soundname)/*CStringMapper::map(soundname)*/); + nlassert(soundname.find(".sound") != std::string::npos); + _Sounds.push_back(NLMISC::CSheetId(soundname)); } } } diff --git a/code/nel/src/sound/driver/source.cpp b/code/nel/src/sound/driver/source.cpp index df99b59ee..6ef5e420c 100644 --- a/code/nel/src/sound/driver/source.cpp +++ b/code/nel/src/sound/driver/source.cpp @@ -65,12 +65,68 @@ sint32 ISource::computeManualRollOff(sint32 volumeMB, sint32 mbMin, sint32 mbMax // common method used only with OptionManualRolloff. return the rolloff in amplitude ratio (gain) float ISource::computeManualRolloff(double alpha, float sqrdist, float distMin, float distMax) { - static const sint32 mbMin = -10000; - static const sint32 mbMax = 0; + /*static const sint mbMin = -10000; + static const sint mbMax = 0; sint32 rolloffMb = ISource::computeManualRollOff(mbMax, mbMin, mbMax, alpha, sqrdist, distMin, distMax); float rolloffGain = (float)pow(10.0, (double)rolloffMb / 2000.0); clamp(rolloffGain, 0.0f, 1.0f); - return rolloffGain; + return rolloffGain;*/ + + static const double mbMin = -10000; + static const double mbMax = 0; + + if (sqrdist < distMin * distMin) + { + // no attenuation + return 1.0f; + } + else + { + if (alpha < 0.0f) + { + double dist = (double)sqrt(sqrdist); + // inverse distance rolloff + float rolloff = distMin / dist; + if (alpha <= -1.0f) return rolloff; + + if (dist > distMax) + { + // full attenuation of mbrolloff + return (-alpha * rolloff); + } + else + { + double mb = mbMin * (dist - distMin) / (distMax - distMin); + float mbrolloff = (float)pow(10.0, (double)mb / 2000.0); + return ((1.0 + alpha) * mbrolloff - alpha * rolloff); + } + } + else + { + if (sqrdist > distMax * distMax) + { + // full attenuation + return 0.0f; + } + double dist = (double)sqrt(sqrdist); + if (alpha == 0.0f) + { + // linearly descending volume on a dB scale + double mb = mbMin * (dist - distMin) / (distMax - distMin); + return (float)pow(10.0, (double)mb / 2000.0); + } + else // if (alpha > 0.0f) + { + // linear distance rolloff + float rolloff = (distMax - dist) / (distMax - distMin); + if (alpha >= 1.0f) return rolloff; + + double mb = mbMin * (dist - distMin) / (distMax - distMin); + float mbrolloff = (float)pow(10.0, (double)mb / 2000.0); + return ((1.0 - alpha) * mbrolloff + alpha * rolloff); + } + } + } } } // NLSOUND diff --git a/code/nel/src/sound/group_controller_root.cpp b/code/nel/src/sound/group_controller_root.cpp index f460a808b..254dc16f4 100644 --- a/code/nel/src/sound/group_controller_root.cpp +++ b/code/nel/src/sound/group_controller_root.cpp @@ -43,7 +43,7 @@ using namespace std; namespace NLSOUND { -CGroupControllerRoot::CGroupControllerRoot() : CGroupController(NULL) +CGroupControllerRoot::CGroupControllerRoot() : CGroupController(NULL), NLMISC::CManualSingleton() { } diff --git a/code/nel/src/sound/sound.cpp b/code/nel/src/sound/sound.cpp index bb9fd9372..a1c9fd595 100644 --- a/code/nel/src/sound/sound.cpp +++ b/code/nel/src/sound/sound.cpp @@ -133,27 +133,18 @@ void CSound::serial(NLMISC::IStream &s) s.serial(_Direction); s.serial(_Looping); s.serial(_MaxDist); - if (s.isReading()) - { - std::string name; - s.serial(name); - _Name = NLMISC::CSheetId(name);//CStringMapper::map(name); - } - else - { - std::string name = _Name.toString();//CStringMapper::unmap(_Name); - s.serial(name); - } - - nlassert(CGroupControllerRoot::getInstance()); // not sure + + _Name.serialString(s, "sound"); + + nlassert(CGroupControllerRoot::isInitialized()); // not sure #if NLSOUND_SHEET_VERSION_BUILT < 2 - if (s.isReading()) _GroupController = static_cast(CAudioMixerUser::instance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_GROUP_CONTROLLER)); + if (s.isReading()) _GroupController = CGroupControllerRoot::getInstance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_GROUP_CONTROLLER); #else if (s.isReading()) { std::string groupControllerPath; s.serial(groupControllerPath); - _GroupController = static_cast(CAudioMixerUser::instance()->getGroupController(groupControllerPath)); + _GroupController = CGroupControllerRoot::getInstance()->getGroupController(groupControllerPath); } else { @@ -170,7 +161,8 @@ void CSound::serial(NLMISC::IStream &s) void CSound::importForm(const std::string& filename, NLGEORGES::UFormElm& root) { // Name - _Name = NLMISC::CSheetId(CFile::getFilenameWithoutExtension(filename));//CStringMapper::map(CFile::getFilenameWithoutExtension(filename)); + nlassert(filename.find(".sound") != std::string::npos); + _Name = NLMISC::CSheetId(filename); // InternalConeAngle uint32 inner; @@ -253,7 +245,7 @@ void CSound::importForm(const std::string& filename, NLGEORGES::UFormElm& roo _Priority = MidPri; } - nlassert(CGroupControllerRoot::getInstance()); // not sure + nlassert(CGroupControllerRoot::isInitialized()); // not sure #if NLSOUND_SHEET_VERSION_BUILT < 2 _GroupController = CGroupControllerRoot::getInstance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_GROUP_CONTROLLER); #else diff --git a/code/nel/src/sound/sound_anim_marker.cpp b/code/nel/src/sound/sound_anim_marker.cpp index 40e058589..b64e02f3c 100644 --- a/code/nel/src/sound/sound_anim_marker.cpp +++ b/code/nel/src/sound/sound_anim_marker.cpp @@ -41,7 +41,7 @@ void CSoundAnimMarker::play(UAudioMixer* mixer, NL3D::CCluster *cluster, CSoundC for (; first != last; ++first) { - USource* source = mixer->createSource(NLMISC::CSheetId(*first), true, NULL, NULL, cluster, &context); + USource* source = mixer->createSource((*first), true, NULL, NULL, cluster, &context); if (source != NULL) { source->setRelativeGain(context.RelativeGain); diff --git a/code/nel/src/sound/sound_animation.cpp b/code/nel/src/sound/sound_animation.cpp index 5ea3f87cb..5a6f1c256 100644 --- a/code/nel/src/sound/sound_animation.cpp +++ b/code/nel/src/sound/sound_animation.cpp @@ -190,7 +190,7 @@ void CSoundAnimation::load() throw NLMISC::Exception("Invalid sound animation marker"); } - marker->addSound(NLMISC::CSheetId(string(name))/*CStringMapper::map(string(name))*/); + marker->addSound(NLMISC::CSheetId(string(name), "sound")); xmlFree ((void*)name); diff --git a/code/nel/src/sound/sound_bank.cpp b/code/nel/src/sound/sound_bank.cpp index 93cf09de4..6421e722b 100644 --- a/code/nel/src/sound/sound_bank.cpp +++ b/code/nel/src/sound/sound_bank.cpp @@ -123,14 +123,16 @@ CSoundBank::~CSoundBank() void CSoundBank::addSound(CSound *sound) { - std::pair ret; - ret = _Sounds.insert(make_pair(sound->getName(), sound)); - nlassert(ret.second); + // nlassert(_Sounds.size() > sound->getName().getShortId()); + // nldebug("SOUNDBANK: Add %s", sound->getName().toString().c_str()); + if (_Sounds.size() <= sound->getName().getShortId()) + _Sounds.resize(sound->getName().getShortId() + 1); + _Sounds[sound->getName().getShortId()] = sound; } -void CSoundBank::removeSound(const NLMISC::CSheetId &name) +void CSoundBank::removeSound(const NLMISC::CSheetId &sheetId) { - _Sounds.erase(name); + _Sounds[sheetId.getShortId()] = NULL; } @@ -152,10 +154,10 @@ public: {} // load the values using the george sheet (called by GEORGE::loadForm) - void readGeorges (const NLMISC::CSmartPtr &form, const NLMISC::CSheetId &name) + void readGeorges (const NLMISC::CSmartPtr &form, const std::string &name) { // just call the sound creation method with the xml form. - Sound = CSound::createSound(name.toString(), form->getRootNode()); + Sound = CSound::createSound(name, form->getRootNode()); // success ? // if (_Sound != 0) @@ -258,37 +260,59 @@ public: void CSoundBank::load(const std::string &packedSheetDir, bool packedSheetUpdate) { // this structure is fill by the loadForm() function and will contain all you need - //std::map Container; - std::map Container; + std::map container; // load the old way for compatibility nlassert(!_Loaded); // Just call the GEORGE::loadFrom method to read all available sounds - ::loadForm("sound", packedSheetDir + "sounds.packed_sheets", Container, packedSheetUpdate, false); + ::loadForm("sound", packedSheetDir + "sounds.packed_sheets", container, packedSheetUpdate, false); _Loaded = true; + // get the largest sheet id needed and init the sound bank + uint32 maxShortId = 0; + { + std::map::iterator first(container.begin()), last(container.end()); + for (; first != last; ++first) + { + if (first->second.Sound != 0) + if (first->second.Sound->getName().getShortId() > maxShortId) + maxShortId = first->second.Sound->getName().getShortId(); + } + ++maxShortId; // inc for size = last idx + 1 + if (container.size() == 0) + { + nlwarning("NLSOUND: No sound sheets have been loaded, missing sound sheet directory or packed sound sheets file"); + } + else + { + nlassert(maxShortId < (container.size() * 8)); // ensure no ridiculous sheet id values + if (maxShortId > _Sounds.size()) + _Sounds.resize(maxShortId); + } + } + // add all the loaded sound in the sound banks - //std::map::iterator first(Container.begin()), last(Container.end()); - std::map::iterator first(Container.begin()), last(Container.end()); - for (; first != last; ++first) { - if (first->second.Sound != 0) - addSound(first->second.Sound); + std::map::iterator first(container.begin()), last(container.end()); + for (; first != last; ++first) + { + if (first->second.Sound != 0) + addSound(first->second.Sound); + } } - Container.clear(); + container.clear(); } /* * Unload all the sound samples in this bank. */ -void CSoundBank::unload() +void CSoundBank::unload() { nlassert(_Loaded); - TSoundTable::iterator first(_Sounds.begin()), last(_Sounds.end()); - for (; first != last; ++first) + for (TSoundTable::size_type i = 0; i < _Sounds.size(); ++i) { - delete first->second; + delete _Sounds[i]; } _Sounds.clear(); @@ -322,7 +346,7 @@ void CSoundBank::unload() /* * Returns true if the samples in this bank have been loaded. */ -bool CSoundBank::isLoaded() +bool CSoundBank::isLoaded() { return _Loaded; } @@ -330,37 +354,38 @@ bool CSoundBank::isLoaded() /* * Return a sound sample corresponding to a name. */ -CSound* CSoundBank::getSound(const NLMISC::CSheetId &name) +CSound* CSoundBank::getSound(const NLMISC::CSheetId &sheetId) { - // Find sound - TSoundTable::iterator iter = _Sounds.find(name); - if ( iter == _Sounds.end() ) - { - return 0; - } - else + if (sheetId == NLMISC::CSheetId::Unknown) + return NULL; + + // nlassert(sheetId.getShortId() < _Sounds.size()); + if (sheetId.getShortId() >= _Sounds.size()) { - return (*iter).second; + std::string sheetName = sheetId.toString(); + nlwarning("NLSOUND: Sound sheet id '%s' exceeds loaded sound sheets", sheetName.c_str()); + return NULL; } + + return _Sounds[sheetId.getShortId()]; } /** * Return the names of the sounds */ -void CSoundBank::getNames( std::vector &names ) +void CSoundBank::getNames( std::vector &sheetIds ) { - TSoundTable::const_iterator iter; - for (iter = _Sounds.begin(); iter != _Sounds.end(); ++iter) + for (TSoundTable::size_type i = 0; i < _Sounds.size(); ++i) { - names.push_back((*iter).first); - //nlwarning("getting sound %s", (*iter).first); + if (_Sounds[i]) + sheetIds.push_back(_Sounds[i]->getName()); } } /* * Return the number of buffers in this bank. */ -uint CSoundBank::countSounds() +uint CSoundBank::countSounds() { return (uint)_Sounds.size(); } diff --git a/code/nel/src/sound/stream_file_sound.cpp b/code/nel/src/sound/stream_file_sound.cpp index b86f0b5df..fbf0c91a1 100644 --- a/code/nel/src/sound/stream_file_sound.cpp +++ b/code/nel/src/sound/stream_file_sound.cpp @@ -73,13 +73,13 @@ void CStreamFileSound::serial(NLMISC::IStream &s) void CStreamFileSound::setMusicFilePath(const std::string &filePath, bool async, bool loop) { -#if !FINAL_VERSION +/*#if !FINAL_VERSION //_Name = NLMISC::CStringMapper::map(std::string(""); _Name = NLMISC::CSheetId(std::string(""); #else //_Name = NLMISC::CStringMapper::map(""); - _Name = NLMISC::CSheetId(""); -#endif +#endif*/ + _Name = NLMISC::CSheetId("music_channel.sound"); _ConeInnerAngle = NLMISC::Pi * 2; _ConeOuterAngle = NLMISC::Pi * 2; _Looping = loop; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/particle_sound_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/particle_sound_page.cpp index 17e0c09d7..ce7034e56 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/particle_sound_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/particle_sound_page.cpp @@ -86,7 +86,7 @@ void CSoundPage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocatedBindab _ui.pitchWidget->setWorkspaceNode(_Node); _ui.pitchWidget->updateUi(); - _ui.soundNameLineEdit->setText(QString(NLMISC::CStringMapper::unmap(_Sound->getSoundName()).c_str())); + _ui.soundNameLineEdit->setText(QString(_Sound->getSoundName().toString().c_str())); _ui.spawnCheckBox->setChecked(_Sound->getSpawn()); _ui.muteCheckBox->setChecked(_Sound->getMute()); @@ -95,7 +95,7 @@ void CSoundPage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocatedBindab void CSoundPage::browse() { - std::vector names; + std::vector names; NLSOUND::UAudioMixer *audioMixer = Modules::sound().getAudioMixer(); @@ -108,7 +108,7 @@ void CSoundPage::browse() QStringList items; items << tr(""); for(size_t i = 0; i < names.size(); ++i) - items << QString(names[i]->c_str()); + items << QString(names[i].toString().c_str()); bool ok; QString item = QInputDialog::getItem(this, tr("Select your sound"), @@ -162,7 +162,7 @@ void CSoundPage::setKeepPitch(bool state) void CSoundPage::setSoundName(const QString &text) { - _Sound->setSoundName(NLMISC::CStringMapper::map(text.toStdString())); + _Sound->setSoundName(NLMISC::CSheetId(text.toStdString())); } void CSoundPage::setEmissionPercent(float value) @@ -171,4 +171,4 @@ void CSoundPage::setEmissionPercent(float value) updateModifiedFlag(); } -} /* namespace NLQT */ \ No newline at end of file +} /* namespace NLQT */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_system.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_system.cpp index a8a204c96..5ca313b0f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_system.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_system.cpp @@ -30,6 +30,8 @@ #include #include #include +#include + // Qt includes #include @@ -67,6 +69,9 @@ void CSoundSystem::init() { //H_AUTO2 nldebug("CSoundSystem::init"); + + // require sheet id without sheet id bin + NLMISC::CSheetId::initWithoutSheet(); // create audiomixer _AudioMixer = NULL; @@ -153,9 +158,10 @@ void CSoundSystem::play(const std::string &soundName) { if (_AudioMixer) { - NLSOUND::USource *src = _AudioMixer->createSource(NLMISC::CStringMapper::map(soundName), true); + NLSOUND::USource *src = _AudioMixer->createSource(NLMISC::CSheetId(soundName, "sound"), true); if (src) { + // FIXME: Use relative positioning, and set pos to 0,0,0 src->setLooping(false); const NLMISC::CVector &pos = _AudioMixer->getListener()->getPos(); src->setPos(pos); @@ -172,9 +178,10 @@ NLSOUND::USource *CSoundSystem::create(const std::string &soundName) { if (_AudioMixer) { - NLSOUND::USource *src = _AudioMixer->createSource(NLMISC::CStringMapper::map(soundName), false); + NLSOUND::USource *src = _AudioMixer->createSource(NLMISC::CSheetId(soundName, "sound"), false); if (src) { + // FIXME: Use relative positioning, and set pos to 0,0,0 src->setLooping(false); const NLMISC::CVector &pos = _AudioMixer->getListener()->getPos(); src->setPos(pos); @@ -236,4 +243,4 @@ void CSoundSystem::releaseGraphics() NL3D::UParticleSystemSound::setPSSound(NULL); } -} /* namespace NLQT */ \ No newline at end of file +} /* namespace NLQT */ diff --git a/code/nel/tools/sound/build_soundbank/build_soundbank.cpp b/code/nel/tools/sound/build_soundbank/build_soundbank.cpp index 60abe4592..b8a79d9cf 100644 --- a/code/nel/tools/sound/build_soundbank/build_soundbank.cpp +++ b/code/nel/tools/sound/build_soundbank/build_soundbank.cpp @@ -29,6 +29,7 @@ #include #include #include +#include // Project includes // ... @@ -75,6 +76,9 @@ int main(int nNbArg, char **ppArgs) // add search paths CPath::addSearchPath(leveldesignDir, true, false); CPath::addSearchPath(dfnDir, true, false); + + // init sheet_id.bin + NLMISC::CSheetId::initWithoutSheet(); // build the sound bank UAudioMixer::buildSoundBank(exportDir); diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index f6f7d7e3f..84ba25060 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -419,7 +419,7 @@ CClientConfig::CClientConfig() // only force patching under Windows by default #ifdef NL_OS_WINDOWS - PatchWanted = false;//true; + PatchWanted = true; #else PatchWanted = false; #endif diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index 3f94368d5..ffbba52e9 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -2006,8 +2006,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { string sName = getParam(Params, "name"); - //TStringId id = CStringMapper::map(sName); - CSheetId id = CSheetId(sName); + CSheetId id = CSheetId(sName, "sound"); if (SoundMngr != NULL) SoundMngr->spawnSource(id,CVector(0,0,0)); } diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index d78864684..11d01934f 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -1265,6 +1265,19 @@ void postlogInit() // set the primitive context CPrimitiveContext::instance().CurrentLigoConfig = &LigoConfig; + { + H_AUTO(InitRZShIdI) + + nmsg = "Initializing sheets..."; + ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); + + // Initialize Sheet IDs. + CSheetId::init (ClientCfg.UpdatePackedSheet); + + initLast = initCurrent; + initCurrent = ryzomGetLocalTime(); + } + { H_AUTO(InitRZSound) @@ -1275,12 +1288,13 @@ void postlogInit() { // tmp fix : it seems that, at this point, if the bg downloader window has focus and // not the Ryzom one, then sound init fails - #ifdef NL_OS_WINDOWS + /*#ifdef NL_OS_WINDOWS HWND hWnd = Driver->getDisplay (); nlassert (hWnd); ShowWindow(hWnd, SW_RESTORE); SetForegroundWindow(hWnd); - #endif + #endif*/ + // bg downloader not used anymore anyways SoundMngr = new CSoundManager(&ProgressBar); try { @@ -1323,13 +1337,7 @@ void postlogInit() } { - H_AUTO(InitRZShIdI) - - nmsg = "Initializing sheets..."; - ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); - - // Initialize Sheet IDs. - CSheetId::init (ClientCfg.UpdatePackedSheet); + H_AUTO(InitRZSheetL) // load packed sheets nmsg = "Loading sheets...";