From 401fa5cbd7159a187ac2ac5fda5f278ccd88719c Mon Sep 17 00:00:00 2001 From: Pavel_Sorokin Date: Mon, 7 Nov 2022 22:37:13 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Liner/Liner/MapsCollection.cs | 53 ++++++++++++++--------------------- 1 file changed, 21 insertions(+), 32 deletions(-) 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; }