diff --git a/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs b/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs
index 6c98db3..b05f916 100644
--- a/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs
+++ b/AirBomber/AirBomber/MapWithSetAirplanesGeneric.cs
@@ -180,6 +180,11 @@ namespace AirBomber
}
}
+ public void Clear()
+ {
+ SetAirplanes.Clear();
+ }
+
///
/// Получение данных в виде строки
///
diff --git a/AirBomber/AirBomber/MapsCollection.cs b/AirBomber/AirBomber/MapsCollection.cs
index 1959822..a789dee 100644
--- a/AirBomber/AirBomber/MapsCollection.cs
+++ b/AirBomber/AirBomber/MapsCollection.cs
@@ -142,7 +142,14 @@ namespace AirBomber
map = new WallMap();
break;
}
- _mapStorages[nameMapStorage] = new(_pictureWidth, _pictureHeight, map);
+ if (_mapStorages.ContainsKey(nameMapStorage))
+ {
+ _mapStorages[nameMapStorage].Clear();
+ }
+ else
+ {
+ _mapStorages[nameMapStorage] = new(_pictureWidth, _pictureHeight, map);
+ }
_mapStorages[nameMapStorage].LoadData(lineData.Split(separatorData, StringSplitOptions.RemoveEmptyEntries));
return true;
}
@@ -158,33 +165,30 @@ namespace AirBomber
{
return false;
}
- List strs = new List();
using (StreamReader fs = new(filename))
{
+ var formatData = fs.ReadLine() ?? string.Empty;
+ bool isNotMapsCollection = !formatData.Contains("MapsCollection");
+ if (formatData.Contains("Map") && isNotMapsCollection)
+ {
+ var nameMap = fs.ReadLine().Replace("Name: ", "");
+ var elem = fs.ReadLine().Split(separatorDict);
+ return LoadMap(nameMap, elem[0], elem[1]);
+ }
+ if (isNotMapsCollection)
+ {
+ //если нет такой записи, то это не те данные
+ return false;
+ }
+ //очищаем записи
+ _mapStorages.Clear();
while (!fs.EndOfStream)
{
- strs.Add(fs.ReadLine());
+ var elem = fs.ReadLine().Split(separatorDict);
+ LoadMap(elem[0], elem[1], elem[2]);
}
+ return true;
}
- bool isNotMapsCollection = !strs[0].Contains("MapsCollection");
- if (strs[0].Contains("Map") && isNotMapsCollection)
- {
- var elem = strs[2].Split(separatorDict);
- return LoadMap(strs[1].Replace("Name: ", ""), elem[0], elem[1]);
- }
- else if (isNotMapsCollection)
- {
- //если нет такой записи, то это не те данные
- return false;
- }
- //очищаем записи
- _mapStorages.Clear();
- for (int i = 1; i < strs.Count; ++i)
- {
- var elem = strs[i].Split(separatorDict);
- LoadMap(elem[0], elem[1], elem[2]);
- }
- return true;
}
}
}
diff --git a/AirBomber/AirBomber/SetAirplanesGeneric.cs b/AirBomber/AirBomber/SetAirplanesGeneric.cs
index fffa285..b044dcc 100644
--- a/AirBomber/AirBomber/SetAirplanesGeneric.cs
+++ b/AirBomber/AirBomber/SetAirplanesGeneric.cs
@@ -109,5 +109,10 @@ namespace AirBomber
}
}
+
+ public void Clear()
+ {
+ _places.Clear();
+ }
}
}