Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 52679 | Differences between
and this patch

Collapse All | Expand All

(-)wormux/wormux/src/avatar.cpp (-35 / +39 lines)
Lines 32-37 Link Here
32
#include "graphisme.h"
32
#include "graphisme.h"
33
#include "gst_fichier.h"
33
#include "gst_fichier.h"
34
#include <dirent.h>
34
#include <dirent.h>
35
#include <sys/stat.h>
35
using namespace Wormux;
36
using namespace Wormux;
36
using namespace std;
37
using namespace std;
37
38
Lines 84-124 Link Here
84
85
85
//-----------------------------------------------------------------------------
86
//-----------------------------------------------------------------------------
86
87
87
void InitAvatars()
88
{
89
  Avatar avatar;
90
  std::string repertoire = DATADIR+"avatar/";
91
  std::string nom_avatar, nomfich, rep_avatar;
92
  struct dirent *fichier;
93
  DIR *dir;
94
95
  dir = opendir(repertoire.c_str());
96
  if (dir == NULL) 
97
    Erreur ("Impossible d'ouvrir le répertoire des avatars ("+repertoire+")");
98
99
  // Parcours le répertoire des avatars
100
  while ((fichier = readdir(dir)) != NULL)
101
  {
102
    // On a trouvé un répertoire ?
103
    if ((fichier -> d_type == DT_DIR) && (fichier -> d_name[0] != '.'))
104
    {
105
      nom_avatar = fichier -> d_name;
106
      rep_avatar = repertoire+nom_avatar+'/';
107
108
      // Si on arrive à le charger correctement, l'ajoute à la liste
109
      if (FichierExiste(rep_avatar+NOMFICH_CONFIG)
110
	  && avatar.Charge (nom_avatar, rep_avatar))
111
      {
112
	lst_avatar.insert (paire_avatar(nom_avatar, avatar));
113
      }
114
    }
115
  }
116
117
  closedir (dir);
118
}
119
120
//-----------------------------------------------------------------------------
121
122
bool Avatar::Charge (const std::string &nom, const std::string &repertoire)
88
bool Avatar::Charge (const std::string &nom, const std::string &repertoire)
123
{
89
{
124
  try
90
  try
Lines 221-226 Link Here
221
    Xml_LitArme (baseball, LitDocXml::AccesBalise (armes, "baseball"));
187
    Xml_LitArme (baseball, LitDocXml::AccesBalise (armes, "baseball"));
222
  }
188
  }
223
  return true;
189
  return true;
190
}
191
192
//-----------------------------------------------------------------------------
193
194
void InitAvatars()
195
{
196
  Avatar avatar;
197
  std::string repertoire = DATADIR+"avatar/";
198
  struct dirent *fichier;
199
  DIR *dir;
200
201
  dir = opendir(repertoire.c_str());
202
  if (dir == NULL) 
203
    Erreur ("Impossible d'ouvrir le répertoire des avatars ("+repertoire+")");
204
205
  // Parcours le répertoire des avatars
206
  while ((fichier = readdir(dir)) != NULL)
207
  {
208
    std::string nomfich_complet = repertoire+fichier -> d_name;
209
    struct stat stat_file;
210
211
    // On a trouvé un répertoire ?
212
    if ((fichier -> d_name[0] != '.')
213
	&& (stat(nomfich_complet.c_str(), &stat_file) == 0)
214
	&& (S_ISDIR(stat_file.st_mode)))
215
    {
216
      std::string rep_avatar = nomfich_complet+'/';
217
218
      // Si on arrive à le charger correctement, l'ajoute à la liste
219
      if (FichierExiste(rep_avatar+NOMFICH_CONFIG)
220
	  && avatar.Charge (fichier -> d_name, rep_avatar))
221
      {
222
	lst_avatar.insert (paire_avatar(fichier -> d_name, avatar));
223
      }
224
    }
225
  }
226
227
  closedir (dir);
224
}
228
}
225
229
226
//-----------------------------------------------------------------------------
230
//-----------------------------------------------------------------------------
(-)wormux/wormux/src/gst_equipes.cpp (-5 / +16 lines)
Lines 24-29 Link Here
24
#include "constante.h"
24
#include "constante.h"
25
#include "gst_fichier.h"
25
#include "gst_fichier.h"
26
#include <dirent.h>
26
#include <dirent.h>
27
#include <sys/stat.h>
27
#include <algorithm>
28
#include <algorithm>
28
//-----------------------------------------------------------------------------
29
//-----------------------------------------------------------------------------
29
GestionEquipes gst_equipes;
30
GestionEquipes gst_equipes;
Lines 76-83 Link Here
76
77
77
void GestionEquipes::ChargeListe()
78
void GestionEquipes::ChargeListe()
78
{
79
{
79
  std::string repertoire = DATADIR+"equipe/";
80
  const std::string repertoire = DATADIR+"equipe/";
80
  std::string nom_equipe, nomfich, rep_equipe ;
81
  struct dirent *fichier;
81
  struct dirent *fichier;
82
  DIR *dir;
82
  DIR *dir;
83
  
83
  
Lines 89-101 Link Here
89
  liste.clear() ;
89
  liste.clear() ;
90
  while ((fichier = readdir(dir)) != NULL)
90
  while ((fichier = readdir(dir)) != NULL)
91
  {
91
  {
92
    std::string nomfich_complet = repertoire+fichier -> d_name;
93
    struct stat stat_file;
94
92
    // On a trouvé un fichier normal ?
95
    // On a trouvé un fichier normal ?
93
    if ((fichier -> d_type == DT_DIR) && (fichier -> d_name[0] != '.'))
96
    if ((fichier -> d_name[0] != '.')
97
	&& (stat(nomfich_complet.c_str(), &stat_file) == 0)
98
	&& (S_ISDIR(stat_file.st_mode)))
94
    {
99
    {
100
      // Ajoute l'équipe à la liste
95
      Equipe nv_equipe;
101
      Equipe nv_equipe;
96
      liste_complete.push_back(nv_equipe);
102
      liste_complete.push_back(nv_equipe);
97
      std::string nomfich = fichier -> d_name;
103
98
      if (!liste_complete.back().Init (-1, nomfich)) liste_complete.pop_back();
104
      // Charge les données de l'équipe, 
105
      // en cas d'erreur retire l'équipe de la liste
106
      if (!liste_complete.back().Init (-1, fichier -> d_name)) 
107
      {
108
	liste_complete.pop_back();
109
      }
99
    }
110
    }
100
  }  
111
  }  
101
  closedir (dir);
112
  closedir (dir);
(-)wormux/wormux/src/lst_terrain.cpp (-2 / +7 lines)
Lines 25-30 Link Here
25
#include "monde.h"
25
#include "monde.h"
26
#include "gst_fichier.h"
26
#include "gst_fichier.h"
27
#include <dirent.h>
27
#include <dirent.h>
28
#include <sys/stat.h>
28
//-----------------------------------------------------------------------------
29
//-----------------------------------------------------------------------------
29
ListeTerrain lst_terrain;
30
ListeTerrain lst_terrain;
30
//-----------------------------------------------------------------------------
31
//-----------------------------------------------------------------------------
Lines 96-103 Link Here
96
  struct dirent *fichier;
97
  struct dirent *fichier;
97
  while ((fichier = readdir(dir)) != NULL)
98
  while ((fichier = readdir(dir)) != NULL)
98
  {
99
  {
99
    // On a trouvé un répertoire ?
100
    std::string nomfich_complet = repertoire+fichier -> d_name;
100
    if ((fichier -> d_type == DT_DIR) && (fichier -> d_name[0] != '.'))
101
    struct stat stat_file;
102
103
    if ((fichier -> d_name[0] != '.')
104
	&& (stat(nomfich_complet.c_str(), &stat_file) == 0)
105
	&& (S_ISDIR(stat_file.st_mode)))
101
    {
106
    {
102
      InfoTerrain nv_terrain;  
107
      InfoTerrain nv_terrain;  
103
      bool ok = nv_terrain.Init (fichier -> d_name);
108
      bool ok = nv_terrain.Init (fichier -> d_name);

Return to bug 52679