rework log function and protocol

* remove some protocol ifdefs, replace with game features system
This commit is contained in:
Eduardo Bart
2012-05-28 19:04:44 -03:00
parent 4c80d783d6
commit c01b32b032
51 changed files with 391 additions and 280 deletions

View File

@@ -48,8 +48,6 @@ bool FontManager::importFont(std::string fontFile)
OTMLNodePtr fontNode = doc->at("Font");
std::string name = fontNode->valueAt("name");
//if(fontExists(name))
// stdext::throw_exception("font '", name, "' already exists, cannot have duplicate font names");
// remove any font with the same name
for(auto it = m_fonts.begin(); it != m_fonts.end(); ++it) {
@@ -69,7 +67,7 @@ bool FontManager::importFont(std::string fontFile)
return true;
} catch(stdext::exception& e) {
logError("Unable to load font from file '", fontFile, "': ", e.what());
logError("Unable to load font from file '%s': %s", fontFile, e.what());
return false;
}
}
@@ -92,7 +90,7 @@ FontPtr FontManager::getFont(const std::string& fontName)
}
// when not found, fallback to default font
logError("font '", fontName, "' not found");
logError("font '%s' not found", fontName);
return getDefaultFont();
}

View File

@@ -45,8 +45,8 @@ Graphics::Graphics()
void Graphics::init()
{
logInfo("GPU ", glGetString(GL_RENDERER));
logInfo("OpenGL ", glGetString(GL_VERSION));
logInfo("GPU %s", glGetString(GL_RENDERER));
logInfo("OpenGL %s", glGetString(GL_VERSION));
#if OPENGL_ES==2
g_painterOGL2 = new PainterOGL2;
@@ -56,7 +56,7 @@ void Graphics::init()
// init GL extensions
GLenum err = glewInit();
if(err != GLEW_OK)
logFatal("Unable to init GLEW: ", glewGetErrorString(err));
logFatal("Unable to init GLEW: %s", glewGetErrorString(err));
// overwrite framebuffer API if needed
if(GLEW_EXT_framebuffer_object && !GLEW_ARB_framebuffer_object) {

View File

@@ -46,7 +46,7 @@ ImagePtr Image::load(const std::string& file)
// load image file data
image = loadPNG(file);
} catch(stdext::exception& e) {
logError("unable to load image '", file, "': ", e.what());
logError("unable to load image '%s': %s", file, e.what());
}
return image;
}

View File

@@ -39,7 +39,7 @@ bool ParticleManager::load(const std::string& filename)
}
return true;
} catch(stdext::exception& e) {
logError("could not load particles: ", e.what());
logError("could not load particles: %s", e.what());
return false;
}
}

View File

@@ -48,7 +48,7 @@ bool ShaderProgram::addShader(const ShaderPtr& shader) {
bool ShaderProgram::addShaderFromSourceCode(Shader::ShaderType shaderType, const std::string& sourceCode) {
ShaderPtr shader(new Shader(shaderType));
if(!shader->compileSourceCode(sourceCode)) {
logError("failed to compile shader: ", shader->log());
logError("failed to compile shader: %s", shader->log());
return false;
}
return addShader(shader);
@@ -57,7 +57,7 @@ bool ShaderProgram::addShaderFromSourceCode(Shader::ShaderType shaderType, const
bool ShaderProgram::addShaderFromSourceFile(Shader::ShaderType shaderType, const std::string& sourceFile) {
ShaderPtr shader(new Shader(shaderType));
if(!shader->compileSourceFile(sourceFile)) {
logError("failed to compile shader: ", shader->log());
logError("failed to compile shader: %s", shader->log());
return false;
}
return addShader(shader);

View File

@@ -82,9 +82,10 @@ uint Texture::internalLoadGLTexture(uchar *pixels, int channels, int width, int
// checks texture max size
if(std::max(glSize.width(), glSize.height()) > g_graphics.getMaxTextureSize()) {
logError("loading texture with size ", width, "x", height, " failed, "
"the maximum size allowed by the graphics card is ", g_graphics.getMaxTextureSize(), "x", g_graphics.getMaxTextureSize(), ",",
"to prevent crashes the texture will be displayed as a blank texture");
logError("loading texture with size %dx%d failed, "
"the maximum size allowed by the graphics card is %dx%d,"
"to prevent crashes the texture will be displayed as a blank texture",
width, height, g_graphics.getMaxTextureSize(), g_graphics.getMaxTextureSize());
//TODO: make a workaround, could be bilinear scaling the texture
return 0;
}

View File

@@ -57,7 +57,7 @@ TexturePtr TextureManager::getTexture(const std::string& fileName)
g_resources.loadFile(filePath, fin);
texture = loadPNG(fin);
} catch(stdext::exception& e) {
logError("unable to load texture '", fileName, "': ", e.what());
logError("unable to load texture '%s': %s", fileName, e.what());
texture = g_graphics.getEmptyTexture();
}