mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 22:13:27 +02:00
rework log function and protocol
* remove some protocol ifdefs, replace with game features system
This commit is contained in:
@@ -39,7 +39,7 @@ bool OggSoundFile::prepareOgg()
|
||||
|
||||
vorbis_info* vi = ov_info(&m_vorbisFile, -1);
|
||||
if(!vi) {
|
||||
logError("ogg file not supported: ", m_file->name());
|
||||
logError("ogg file not supported: %s", m_file->name());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -40,14 +40,14 @@ bool SoundBuffer::fillBuffer(const SoundFilePtr& soundFile)
|
||||
{
|
||||
ALenum format = soundFile->getSampleFormat();
|
||||
if(format == AL_UNDETERMINED) {
|
||||
logError("unable to determine sample format for '", soundFile->getName(), "'");
|
||||
logError("unable to determine sample format for '%s'", soundFile->getName());
|
||||
return false;
|
||||
}
|
||||
|
||||
DataBuffer<char> samples(soundFile->getSize());
|
||||
int read = soundFile->read(&samples[0], soundFile->getSize());
|
||||
if(read <= 0) {
|
||||
logError("unable to fill audio buffer data for '", soundFile->getName(), "'");
|
||||
logError("unable to fill audio buffer data for '%s'", soundFile->getName());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ bool SoundBuffer::fillBuffer(ALenum sampleFormat, const DataBuffer<char>& data,
|
||||
alBufferData(m_bufferId, sampleFormat, &data[0], size, rate);
|
||||
ALenum err = alGetError();
|
||||
if(err != AL_NO_ERROR) {
|
||||
logError("unable to fill audio buffer data: ", alGetString(err));
|
||||
logError("unable to fill audio buffer data: %s", alGetString(err));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@@ -33,7 +33,7 @@ SoundFilePtr SoundFile::loadSoundFile(const std::string& filename)
|
||||
{
|
||||
FileStreamPtr file = g_resources.openFile(filename);
|
||||
if(!file) {
|
||||
logTraceError("unable to open ", filename);
|
||||
logTraceError("unable to open %s", filename);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ SoundFilePtr SoundFile::loadSoundFile(const std::string& filename)
|
||||
if(oggSoundFile->prepareOgg())
|
||||
soundFile = oggSoundFile;
|
||||
} else
|
||||
logError("unknown sound file format ", filename);
|
||||
logError("unknown sound file format %s", filename);
|
||||
|
||||
return soundFile;
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ void SoundManager::init()
|
||||
|
||||
m_context = alcCreateContext(m_device, NULL);
|
||||
if(!m_context) {
|
||||
logError("unable to create audio context: ", alcGetString(m_device, alcGetError(m_device)));
|
||||
logError("unable to create audio context: %s", alcGetString(m_device, alcGetError(m_device)));
|
||||
return;
|
||||
}
|
||||
alcMakeContextCurrent(m_context);
|
||||
@@ -136,7 +136,7 @@ void SoundManager::play(const std::string& filename)
|
||||
|
||||
SoundSourcePtr soundSource = createSoundSource(filename);
|
||||
if(!soundSource) {
|
||||
logError("unable to play '", filename, "'");
|
||||
logError("unable to play '%s'", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ void SoundManager::playMusic(const std::string& filename, float fadetime)
|
||||
|
||||
m_musicSource = createSoundSource(filename);
|
||||
if(!m_musicSource) {
|
||||
logError("unable to play '", filename, "'");
|
||||
logError("unable to play '%s'", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ SoundSourcePtr SoundManager::createSoundSource(const std::string& filename)
|
||||
buffer->fillBuffer(soundFile);
|
||||
source->setBuffer(buffer);
|
||||
m_buffers[filename] = buffer;
|
||||
logWarning("uncached sound '", filename, "' requested to be played");
|
||||
logWarning("uncached sound '%s' requested to be played", filename);
|
||||
} else {
|
||||
StreamSoundSourcePtr streamSource(new StreamSoundSource);
|
||||
streamSource->setSoundFile(soundFile);
|
||||
|
@@ -143,12 +143,12 @@ bool StreamSoundSource::fillBufferAndQueue(ALuint buffer)
|
||||
alBufferData(buffer, format, &bufferData[0], bytesRead, m_soundFile->getRate());
|
||||
ALenum err = alGetError();
|
||||
if(err != AL_NO_ERROR)
|
||||
logError("unable to refill audio buffer for '", m_soundFile->getName(), "': ", alGetString(err));
|
||||
logError("unable to refill audio buffer for '%s': %s", m_soundFile->getName(), alGetString(err));
|
||||
|
||||
alSourceQueueBuffers(m_sourceId, 1, &buffer);
|
||||
err = alGetError();
|
||||
if(err != AL_NO_ERROR)
|
||||
logError("unable to queue audio buffer for '", m_soundFile->getName(), "': ", alGetString(err));
|
||||
logError("unable to queue audio buffer for '%s': %s", m_soundFile->getName(), alGetString(err));
|
||||
}
|
||||
|
||||
// return false if there aren't more buffers to fill
|
||||
|
Reference in New Issue
Block a user