diff --git a/Celeste.Mod.mm/Patches/Level.cs b/Celeste.Mod.mm/Patches/Level.cs index a4ab6b674..54930d323 100644 --- a/Celeste.Mod.mm/Patches/Level.cs +++ b/Celeste.Mod.mm/Patches/Level.cs @@ -245,9 +245,8 @@ private IEnumerator TransitionRoutine(LevelData next, Vector2 direction) { playerIntro = introType; try { - if (Session.Level == "") { + if (string.IsNullOrEmpty(Session.Level)) { patch_LevelEnter.ErrorMessage = Dialog.Get("postcard_levelnorooms"); - Logger.Log(LogLevel.Error, "MapData", "Current map has no rooms!"); throw new NullReferenceException("Current map has no rooms."); } Logger.Log(LogLevel.Verbose, "LoadLevel", $"Loading room {Session.LevelData.Name} of {Session.Area.GetSID()}"); diff --git a/Celeste.Mod.mm/Patches/MapData.cs b/Celeste.Mod.mm/Patches/MapData.cs index ae5f68a6e..c14806050 100644 --- a/Celeste.Mod.mm/Patches/MapData.cs +++ b/Celeste.Mod.mm/Patches/MapData.cs @@ -115,21 +115,24 @@ private void Load() { public new LevelData StartLevel() { MapMetaModeProperties meta = Meta; LevelData level; - if (meta != null && !string.IsNullOrEmpty(meta.StartLevel)) { - level = Levels.FirstOrDefault(_ => _.Name == meta.StartLevel); + if (!string.IsNullOrEmpty(meta?.StartLevel)) { + level = Levels.FirstOrDefault(lvl => lvl.Name == meta.StartLevel); if (level != null) return level; - Logger.Log(LogLevel.Warn, "MapData", $"The starting room defined in metadata, \"{meta.StartLevel}\", does not exist!"); + Logger.Log(LogLevel.Warn, "MapData", $"The starting room defined in metadata, \"{meta.StartLevel}\", does not exist for map {((patch_AreaData) Data)?.SID}!"); } level = orig_StartLevel(); if (level != null) return level; - Logger.Log(LogLevel.Debug, "MapData", $"There is no room at (0,0), falling back to the first room."); - level = Levels.Count > 0 ? Levels[0] : null; + Logger.Log(LogLevel.Debug, "MapData", $"There is no room at (0,0) in map {((patch_AreaData) Data)?.SID}, attempting fallback to the first room."); + level = Levels.FirstOrDefault(); + if (level == null) { + Logger.Log(LogLevel.Warn, "MapData", $"Map {((patch_AreaData) Data)?.SID} has no rooms!"); + } return level; }