diff --git a/Liner/Liner/MapsCollection.cs b/Liner/Liner/MapsCollection.cs index 2eed3e7..4b4a13e 100644 --- a/Liner/Liner/MapsCollection.cs +++ b/Liner/Liner/MapsCollection.cs @@ -74,43 +74,32 @@ namespace Liner string bufferTextFromFile = ""; using (StreamReader sr = new(filename)) { - bool isFirst = true; - string str; + string str = sr.ReadLine(); + if (!str.Contains("MapsCollection")) + { + return false; + } + _mapStorages.Clear(); while ((str = sr.ReadLine()) != null) { - if (isFirst) + var tempElem = str.Split(separatorDict); + AbstractMap map = null; + switch (tempElem[1]) { - if (!str.Contains("MapsCollection")) - { - return false; - } - else - { - _mapStorages.Clear(); - } - isFirst = false; - } - else - { - var tempElem = str.Split(separatorDict); - AbstractMap map = null; - switch (tempElem[1]) - { - case "SimpleMap": - map = new SimpleMap(); - break; - case "SeaMap": - map = new SeaMap(); - break; - case "SwampMap": - map = new SwampMap(); - break; + case "SimpleMap": + map = new SimpleMap(); + break; + case "SeaMap": + map = new SeaMap(); + break; + case "SwampMap": + map = new SwampMap(); + break; - } - _mapStorages.Add(tempElem[0], new MapWithSetShipsGeneric(_pictureWidth, _pictureHeight, map)); - _mapStorages[tempElem[0]].LoadData(tempElem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); } - } + _mapStorages.Add(tempElem[0], new MapWithSetShipsGeneric(_pictureWidth, _pictureHeight, map)); + _mapStorages[tempElem[0]].LoadData(tempElem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); + } } return true; }