Mes recomanacions de cppcheck
This commit is contained in:
@@ -21,7 +21,9 @@ TextFile LoadTextFile(std::string file_path)
|
||||
}
|
||||
|
||||
// Abre el fichero para leer los valores
|
||||
#ifdef VERBOSE
|
||||
const std::string file_name = file_path.substr(file_path.find_last_of("\\/") + 1).c_str();
|
||||
#endif
|
||||
std::ifstream file(file_path);
|
||||
|
||||
if (file.is_open() && file.good())
|
||||
@@ -55,7 +57,7 @@ TextFile LoadTextFile(std::string file_path)
|
||||
|
||||
// Cierra el fichero
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Text loaded: " << file_name.c_str() << std::endl;
|
||||
std::cout << "Text loaded: " << file_name << std::endl;
|
||||
#endif
|
||||
file.close();
|
||||
}
|
||||
@@ -64,7 +66,7 @@ TextFile LoadTextFile(std::string file_path)
|
||||
else
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Warning: Unable to open " << file_name.c_str() << " file" << std::endl;
|
||||
std::cout << "Warning: Unable to open " << file_name << " file" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -146,7 +148,7 @@ Text::Text(TextFile *text_file, std::shared_ptr<Texture> texture)
|
||||
}
|
||||
|
||||
// Escribe texto en pantalla
|
||||
void Text::write(int x, int y, std::string text, int kerning, int lenght)
|
||||
void Text::write(int x, int y, const std::string &text, int kerning, int lenght)
|
||||
{
|
||||
auto shift = 0;
|
||||
|
||||
@@ -169,7 +171,7 @@ void Text::write(int x, int y, std::string text, int kerning, int lenght)
|
||||
}
|
||||
|
||||
// Escribe el texto con colores
|
||||
void Text::writeColored(int x, int y, std::string text, Color color, int kerning, int lenght)
|
||||
void Text::writeColored(int x, int y, const std::string &text, Color color, int kerning, int lenght)
|
||||
{
|
||||
sprite_->getTexture()->setColor(color.r, color.g, color.b);
|
||||
write(x, y, text, kerning, lenght);
|
||||
@@ -177,7 +179,7 @@ void Text::writeColored(int x, int y, std::string text, Color color, int kerning
|
||||
}
|
||||
|
||||
// Escribe el texto con sombra
|
||||
void Text::writeShadowed(int x, int y, std::string text, Color color, Uint8 shadow_distance, int kerning, int lenght)
|
||||
void Text::writeShadowed(int x, int y, const std::string &text, Color color, Uint8 shadow_distance, int kerning, int lenght)
|
||||
{
|
||||
sprite_->getTexture()->setColor(color.r, color.g, color.b);
|
||||
write(x + shadow_distance, y + shadow_distance, text, kerning, lenght);
|
||||
@@ -186,14 +188,14 @@ void Text::writeShadowed(int x, int y, std::string text, Color color, Uint8 shad
|
||||
}
|
||||
|
||||
// Escribe el texto centrado en un punto x
|
||||
void Text::writeCentered(int x, int y, std::string text, int kerning, int lenght)
|
||||
void Text::writeCentered(int x, int y, const std::string &text, int kerning, int lenght)
|
||||
{
|
||||
x -= (Text::lenght(text, kerning) / 2);
|
||||
write(x, y, text, kerning, lenght);
|
||||
}
|
||||
|
||||
// Escribe texto con extras
|
||||
void Text::writeDX(Uint8 flags, int x, int y, std::string text, int kerning, Color textColor, Uint8 shadow_distance, Color shadow_color, int lenght)
|
||||
void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning, Color textColor, Uint8 shadow_distance, Color shadow_color, int lenght)
|
||||
{
|
||||
const auto centered = ((flags & TEXT_CENTER) == TEXT_CENTER);
|
||||
const auto shadowed = ((flags & TEXT_SHADOW) == TEXT_SHADOW);
|
||||
@@ -235,7 +237,7 @@ void Text::writeDX(Uint8 flags, int x, int y, std::string text, int kerning, Col
|
||||
}
|
||||
|
||||
// Obtiene la longitud en pixels de una cadena
|
||||
int Text::lenght(std::string text, int kerning) const
|
||||
int Text::lenght(const std::string &text, int kerning) const
|
||||
{
|
||||
auto shift = 0;
|
||||
|
||||
@@ -267,7 +269,7 @@ void Text::setFixedWidth(bool value)
|
||||
}
|
||||
|
||||
// Carga una paleta de colores para el texto
|
||||
void Text::addPalette(std::string path)
|
||||
void Text::addPalette(const std::string &path)
|
||||
{
|
||||
texture_->addPalette(path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user