mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-15 12:09:06 +00:00
Fixed: Sound CSheetId implementation
This commit is contained in:
parent
75936288f5
commit
f2fcd1fe62
5 changed files with 29 additions and 22 deletions
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<CGroupController *>(CAudioMixerUser::instance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_GROUP_CONTROLLER));
|
||||
|
|
|
@ -153,7 +153,7 @@ public:
|
|||
{}
|
||||
|
||||
// load the values using the george sheet (called by GEORGE::loadForm)
|
||||
void readGeorges (const NLMISC::CSmartPtr<NLGEORGES::UForm> &form, const NLMISC::CSheetId &name)
|
||||
void readGeorges (const NLMISC::CSmartPtr<NLGEORGES::UForm> &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<std::string, CSoundSerializer> Container;
|
||||
std::map<NLMISC::CSheetId, CSoundSerializer> container;
|
||||
std::map<std::string, CSoundSerializer> 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<NLMISC::CSheetId, CSoundSerializer>::iterator first(container.begin()), last(container.end());
|
||||
std::map<std::string, CSoundSerializer>::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<NLMISC::CSheetId, CSoundSerializer>::iterator first(container.begin()), last(container.end());
|
||||
std::map<std::string, CSoundSerializer>::iterator first(container.begin()), last(container.end());
|
||||
for (; first != last; ++first)
|
||||
{
|
||||
if (first->second.Sound != 0)
|
||||
|
|
|
@ -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...";
|
||||
|
|
Loading…
Reference in a new issue