mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 22:13:27 +02:00
Update item OTBM attributes reader
* Fix some lua errors generated by playMusic * Fix possible crash when starting otcliet without dat loaded
This commit is contained in:
@@ -107,8 +107,10 @@ void SoundManager::poll()
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::preload(const std::string& filename)
|
||||
void SoundManager::preload(std::string filename)
|
||||
{
|
||||
filename = g_resources.resolvePath(filename);
|
||||
|
||||
auto it = m_buffers.find(filename);
|
||||
if(it != m_buffers.end())
|
||||
return;
|
||||
@@ -130,11 +132,13 @@ void SoundManager::enableSound(bool enable)
|
||||
return;
|
||||
}
|
||||
|
||||
void SoundManager::play(const std::string& filename)
|
||||
void SoundManager::play(std::string filename)
|
||||
{
|
||||
if(!m_soundEnabled)
|
||||
if(!m_soundEnabled || filename.empty())
|
||||
return;
|
||||
|
||||
filename = g_resources.resolvePath(filename);
|
||||
|
||||
SoundSourcePtr soundSource = createSoundSource(filename);
|
||||
if(!soundSource) {
|
||||
g_logger.error(stdext::format("unable to play '%s'", filename));
|
||||
@@ -154,17 +158,21 @@ void SoundManager::enableMusic(bool enable)
|
||||
|
||||
m_musicEnabled = enable;
|
||||
|
||||
if(enable)
|
||||
if(enable && !m_currentMusic.empty())
|
||||
playMusic(m_currentMusic, 3.0f);
|
||||
else
|
||||
m_musicSource = nullptr;
|
||||
}
|
||||
|
||||
void SoundManager::playMusic(const std::string& filename, float fadetime)
|
||||
void SoundManager::playMusic(std::string filename, float fadetime)
|
||||
{
|
||||
if(filename.empty())
|
||||
return;
|
||||
|
||||
filename = g_resources.resolvePath(filename);
|
||||
|
||||
if(m_currentMusic == filename && m_musicSource)
|
||||
return;
|
||||
m_currentMusic = g_resources.resolvePath(filename);
|
||||
|
||||
if(!m_musicEnabled)
|
||||
return;
|
||||
|
@@ -38,12 +38,12 @@ public:
|
||||
void terminate();
|
||||
void poll();
|
||||
|
||||
void preload(const std::string& filename);
|
||||
void preload(std::string filename);
|
||||
void enableSound(bool enable);
|
||||
void play(const std::string& filename);
|
||||
void play(std::string filename);
|
||||
|
||||
void enableMusic(bool enable);
|
||||
void playMusic(const std::string& filename, float fadetime);
|
||||
void playMusic(std::string filename, float fadetime);
|
||||
void stopMusic(float fadetime = 0);
|
||||
|
||||
bool isMusicEnabled() { return m_musicEnabled; }
|
||||
|
Reference in New Issue
Block a user