Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider d768f06d rédigé par Florian Dargère's avatar Florian Dargère
Parcourir les fichiers

Destructeur de CMap

parent f7dd96e5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -23,7 +23,19 @@ CMap::CMap(const SMap* map) ...@@ -23,7 +23,19 @@ CMap::CMap(const SMap* map)
cells[i]->neighbors[j] = cells[map->cells[i].neighbors[j]->infos.id]; cells[i]->neighbors[j] = cells[map->cells[i].neighbors[j]->infos.id];
} }
} }
}
CMap::~CMap()
{
for (auto& cell : cells) {
delete(cell);
}
for (auto& region_pair : regions) {
for (auto& region : region_pair.second) {
delete(region);
}
}
} }
...@@ -32,7 +44,7 @@ void CMap::FindConnexComponent(int idPlayer) ...@@ -32,7 +44,7 @@ void CMap::FindConnexComponent(int idPlayer)
int* MarkedCells = new int[nbCells]; int* MarkedCells = new int[nbCells];
for (unsigned int i = 0; i < nbCells; i++) MarkedCells[i] = 0; for (unsigned int i = 0; i < nbCells; i++) MarkedCells[i] = 0;
std::vector<Region*> vec_regions = *new(std::vector<Region*>); //Vecteur de composantes connexes std::vector<Region*> vec_regions; //Vecteur de composantes connexes
for (unsigned int i = 0; i < nbCells; i++) { for (unsigned int i = 0; i < nbCells; i++) {
if (cells[i]->owner == idPlayer && MarkedCells[i] == 0) { if (cells[i]->owner == idPlayer && MarkedCells[i] == 0) {
...@@ -57,6 +69,7 @@ void CMap::FindConnexComponent(int idPlayer) ...@@ -57,6 +69,7 @@ void CMap::FindConnexComponent(int idPlayer)
} }
} }
regions[idPlayer] = vec_regions; regions[idPlayer] = vec_regions;
delete[](MarkedCells);
} }
std::pair<std::vector<Cell*>, int> CMap::DijkstraAlgo(Cell* cell_depart, Cell* cell_arrivee) std::pair<std::vector<Cell*>, int> CMap::DijkstraAlgo(Cell* cell_depart, Cell* cell_arrivee)
......
...@@ -18,7 +18,7 @@ public: ...@@ -18,7 +18,7 @@ public:
//CMap()=delete; //CMap()=delete;
CMap(const SMap*); CMap(const SMap*);
~CMap()=default; ~CMap();
CMap(const CMap&) = delete; CMap(const CMap&) = delete;
CMap(CMap&&) = default; CMap(CMap&&) = default;
CMap& operator=(const CMap&) = delete; CMap& operator=(const CMap&) = delete;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter