diff --git a/Libraries/Core/Services/OpenZoneService.cs b/Libraries/Core/Services/OpenZoneService.cs index e59e245e..38ecfe24 100644 --- a/Libraries/Core/Services/OpenZoneService.cs +++ b/Libraries/Core/Services/OpenZoneService.cs @@ -11,22 +11,18 @@ public class OpenZoneService( DatabaseService _databaseService, LocalisationService _localisationService, ConfigServer _configServer - ) +) { protected LocationConfig _locationConfig = _configServer.GetConfig(); /// - /// Add open zone to specified map + /// Add open zone to specified map /// /// map location (e.g. factory4_day) /// zone to add public void AddZoneToMap(string locationId, string zoneToAdd) { - var location = _locationConfig.OpenZones[locationId]; - if (location is null) - { - _locationConfig.OpenZones[locationId] = []; - } + _locationConfig.OpenZones.TryAdd(locationId, []); if (!_locationConfig.OpenZones[locationId].Contains(zoneToAdd)) { @@ -35,12 +31,13 @@ public class OpenZoneService( } /// - /// Add open zones to all maps found in config/location.json to db + /// Add open zones to all maps found in config/location.json to db /// public void ApplyZoneChangesToAllMaps() { var dbLocations = _databaseService.GetLocations().GetDictionary(); - foreach (var mapKvP in _locationConfig.OpenZones) { + foreach (var mapKvP in _locationConfig.OpenZones) + { if (!dbLocations.ContainsKey(mapKvP.Key)) { _logger.Error(_localisationService.GetText("openzone-unable_to_find_map", mapKvP));