From 1a32d2691c0ebc87b6de32119147cf7e70890ac6 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 2 Jun 2012 18:12:38 +0200 Subject: [PATCH] Fixed: Sound CSheetId implementation --- code/nel/include/nel/sound/sound.h | 2 +- .../src/sound/background_sound_manager.cpp | 3 +-- code/nel/src/sound/sound.cpp | 6 ++--- code/nel/src/sound/sound_bank.cpp | 14 +++++----- code/ryzom/client/src/init.cpp | 26 ++++++++++++------- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/code/nel/include/nel/sound/sound.h b/code/nel/include/nel/sound/sound.h index a84393944..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 NLMISC::CSheetId &sheetId, NLGEORGES::UFormElm& formRoot); + static CSound *createSound(const std::string &name, NLGEORGES::UFormElm& formRoot); enum TSOUND_TYPE { diff --git a/code/nel/src/sound/background_sound_manager.cpp b/code/nel/src/sound/background_sound_manager.cpp index 2008b37db..4713d03f8 100644 --- a/code/nel/src/sound/background_sound_manager.cpp +++ b/code/nel/src/sound/background_sound_manager.cpp @@ -86,8 +86,7 @@ void CBackgroundSoundManager::addSound(const std::string &soundName, uint layerI CAudioMixerUser *mixer = CAudioMixerUser::instance(); TSoundData sd; - nlassert(soundName.find(".sound") != std::string::npos); - sd.SoundName = NLMISC::CSheetId(soundName); + sd.SoundName = NLMISC::CSheetId(soundName, "sound"); // note: loaded from .primitive sd.Sound = mixer->getSoundId(sd.SoundName); sd.Source = 0; diff --git a/code/nel/src/sound/sound.cpp b/code/nel/src/sound/sound.cpp index cc69455af..e7162b3a1 100644 --- a/code/nel/src/sound/sound.cpp +++ b/code/nel/src/sound/sound.cpp @@ -37,9 +37,8 @@ using namespace NLMISC; namespace NLSOUND { -CSound *CSound::createSound(const NLMISC::CSheetId &sheetId, NLGEORGES::UFormElm& formRoot) +CSound *CSound::createSound(const std::string &filename, NLGEORGES::UFormElm& formRoot) { - std::string filename = sheetId.toString(); CSound *ret = NULL; string soundType; @@ -134,8 +133,9 @@ void CSound::serial(NLMISC::IStream &s) s.serial(_Direction); s.serial(_Looping); s.serial(_MaxDist); + _Name.serialString(s, "sound"); - + nlassert(CGroupControllerRoot::getInstance()); // not sure #if NLSOUND_SHEET_VERSION_BUILT < 2 if (s.isReading()) _GroupController = static_cast(CAudioMixerUser::instance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_GROUP_CONTROLLER)); diff --git a/code/nel/src/sound/sound_bank.cpp b/code/nel/src/sound/sound_bank.cpp index e48ed6254..6e24947dd 100644 --- a/code/nel/src/sound/sound_bank.cpp +++ b/code/nel/src/sound/sound_bank.cpp @@ -153,7 +153,7 @@ 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, form->getRootNode()); @@ -259,8 +259,7 @@ 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); @@ -269,11 +268,12 @@ void CSoundBank::load(const std::string &packedSheetDir, bool packedSheetUpdate) // get the largest sheet id needed and init the sound bank uint32 maxShortId = 0; { - std::map::iterator first(container.begin()), last(container.end()); + std::map::iterator first(container.begin()), last(container.end()); for (; first != last; ++first) { - if (first->first.getShortId() > maxShortId) - maxShortId = first->first.getShortId(); + 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) @@ -290,7 +290,7 @@ void CSoundBank::load(const std::string &packedSheetDir, bool packedSheetUpdate) // 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) 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...";