Reduced checkFileList function
This commit is contained in:
@@ -271,22 +271,19 @@ void Director::setFileList()
|
||||
mFileList[51] = mExecutablePath + "/" + "../media/lang/ba_BA.txt";
|
||||
}
|
||||
|
||||
// Comprueba que todos los ficheros existen
|
||||
bool Director::checkFileList()
|
||||
// Comprueba los ficheros del vector de ficheros que coinciden con una ruta dada
|
||||
bool Director::checkFolder(std::string name, std::string path)
|
||||
{
|
||||
bool success = true;
|
||||
std::string p;
|
||||
std::string filename;
|
||||
SDL_RWops *file;
|
||||
|
||||
printf("Checking files...\n\n");
|
||||
|
||||
// Comprueba los ficheros de musica
|
||||
printf(">> MUSIC FILES\n");
|
||||
if (success)
|
||||
// Comprueba los ficheros de la carpeta
|
||||
printf("\n>> %s FILES\n", name.c_str());
|
||||
for (int i = 3; i < MAX_FILE_LIST; i++)
|
||||
{
|
||||
if (mFileList[i].find("/media/music/") != std::string::npos)
|
||||
if (mFileList[i].find(path.c_str()) != std::string::npos)
|
||||
{
|
||||
p = mFileList[i].c_str();
|
||||
filename = p.substr(p.find_last_of("\\/") + 1);
|
||||
@@ -304,102 +301,29 @@ bool Director::checkFileList()
|
||||
SDL_RWclose(file);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
// Comprueba los ficheros de sonidos
|
||||
printf("\n>> SOUND FILES\n");
|
||||
if (success)
|
||||
for (int i = 3; i < MAX_FILE_LIST; i++)
|
||||
{
|
||||
if (mFileList[i].find("/media/sound/") != std::string::npos)
|
||||
{
|
||||
p = mFileList[i].c_str();
|
||||
filename = p.substr(p.find_last_of("\\/") + 1);
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", filename.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Checking file %-20s [ERROR]\n", filename.c_str());
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
}
|
||||
}
|
||||
// Comprueba que todos los ficheros existen
|
||||
bool Director::checkFileList()
|
||||
{
|
||||
bool success = true;
|
||||
printf("Checking files...\n");
|
||||
|
||||
// Comprueba los ficheros con graficos
|
||||
printf("\n>> BITMAP FILES\n");
|
||||
if (success)
|
||||
for (int i = 3; i < MAX_FILE_LIST; i++)
|
||||
{
|
||||
if (mFileList[i].find("/media/gfx/") != std::string::npos)
|
||||
{
|
||||
p = mFileList[i].c_str();
|
||||
filename = p.substr(p.find_last_of("\\/") + 1);
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", filename.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Checking file %-20s [ERROR]\n", filename.c_str());
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
}
|
||||
}
|
||||
success &= checkFolder("MUSIC", "/media/music/");
|
||||
|
||||
// Comprueba los ficheros con fuentes de texto
|
||||
printf("\n>> FONT FILES\n");
|
||||
if (success)
|
||||
for (int i = 3; i < MAX_FILE_LIST; i++)
|
||||
{
|
||||
if (mFileList[i].find("/media/font/") != std::string::npos)
|
||||
{
|
||||
p = mFileList[i].c_str();
|
||||
filename = p.substr(p.find_last_of("\\/") + 1);
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", filename.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Checking file %-20s [ERROR]\n", filename.c_str());
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
}
|
||||
}
|
||||
success &= checkFolder("SOUND", "/media/sound/");
|
||||
|
||||
// Comprueba los ficheros con textos en diferentes idiomas
|
||||
printf("\n>> LANG FILES\n");
|
||||
if (success)
|
||||
for (int i = 3; i < 100; i++)
|
||||
{
|
||||
if (mFileList[i].find("/media/lang/") != std::string::npos)
|
||||
{
|
||||
p = mFileList[i].c_str();
|
||||
filename = p.substr(p.find_last_of("\\/") + 1);
|
||||
file = SDL_RWFromFile(p.c_str(), "r+b");
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("Checking file %-20s [OK]\n", filename.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Checking file %-20s [ERROR]\n", filename.c_str());
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
SDL_RWclose(file);
|
||||
}
|
||||
}
|
||||
success &= checkFolder("GFX", "/media/gfx/");
|
||||
|
||||
if (success)
|
||||
success &= checkFolder("FONT", "/media/font/");
|
||||
|
||||
if (success)
|
||||
success &= checkFolder("LANG", "/media/lang/");
|
||||
|
||||
// Resultado
|
||||
if (success)
|
||||
|
||||
@@ -89,6 +89,9 @@ private:
|
||||
// Ejecuta la seccion de juego donde se juega
|
||||
void runGame();
|
||||
|
||||
// Comprueba los ficheros del vector de ficheros que coinciden con una ruta dada
|
||||
bool checkFolder(std::string name, std::string path);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Director(std::string path);
|
||||
|
||||
Reference in New Issue
Block a user