Mes recomanacions de cppcheck aplicades
Abans de tocar unes cosetes de strings buits
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
Param param;
|
||||
|
||||
// Asigna variables a partir de dos cadenas
|
||||
bool setParams(std::string var, std::string value);
|
||||
bool setParams(const std::string &var, const std::string &value);
|
||||
|
||||
// Calcula variables a partir de otras variables
|
||||
void precalculateZones();
|
||||
@@ -55,13 +55,13 @@ void initParam()
|
||||
}
|
||||
|
||||
// Establece valores para los parametros a partir de un fichero de texto
|
||||
void loadParamsFromFile(std::string filePath)
|
||||
void loadParamsFromFile(std::string file_path)
|
||||
{
|
||||
// Pone valores por defecto a las variables
|
||||
initParam();
|
||||
|
||||
// Variables para manejar el fichero
|
||||
std::ifstream file(filePath);
|
||||
std::ifstream file(file_path);
|
||||
std::string line;
|
||||
std::string param1;
|
||||
std::string param2;
|
||||
@@ -70,15 +70,15 @@ void loadParamsFromFile(std::string filePath)
|
||||
if (file.good())
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
const std::string filename = filePath.substr(filePath.find_last_of("\\/") + 1);
|
||||
std::cout << "Reading file: " << filename << std::endl;
|
||||
const std::string file_name = file_path.substr(file_path.find_last_of("\\/") + 1);
|
||||
std::cout << "Reading file: " << file_name << std::endl;
|
||||
#endif
|
||||
// Procesa cada linea del fichero
|
||||
while (std::getline(file, line))
|
||||
{
|
||||
// Reinicia variables
|
||||
param1 = "";
|
||||
param2 = "";
|
||||
param1.clear();
|
||||
param2.clear();
|
||||
|
||||
// Elimina los comentarios
|
||||
line = line.substr(0, line.find("#"));
|
||||
@@ -145,17 +145,17 @@ void loadParamsFromFile(std::string filePath)
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
else
|
||||
std::cout << "Failed to load file: " << filePath << std::endl;
|
||||
std::cout << "Failed to load file: " << file_path << std::endl;
|
||||
#endif
|
||||
|
||||
precalculateZones();
|
||||
}
|
||||
|
||||
// Asigna variables a partir de dos cadenas
|
||||
bool setParams(std::string var, std::string value)
|
||||
bool setParams(const std::string &var, const std::string &value)
|
||||
{
|
||||
// Indicador de éxito en la asignación
|
||||
bool success = true;
|
||||
auto success = true;
|
||||
|
||||
// GAME
|
||||
if (var == "game.width")
|
||||
|
||||
Reference in New Issue
Block a user