summaryrefslogtreecommitdiff
path: root/lib/CheckMap.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CheckMap.hs')
-rw-r--r--lib/CheckMap.hs17
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs
index 0b5b58a..6cd2893 100644
--- a/lib/CheckMap.hs
+++ b/lib/CheckMap.hs
@@ -25,6 +25,9 @@ import qualified Data.Vector as V
import Badges (Badge)
+import Data.Tiled (Layer (layerLayers, layerName),
+ Tiledmap (tiledmapLayers, tiledmapTilesets),
+ loadTiledmap)
import LintConfig (LintConfig')
import LintWriter (LintResult, invertLintResult,
resultToAdjusted, resultToBadges,
@@ -32,10 +35,6 @@ import LintWriter (LintResult, invertLintResult,
runLintWriter)
import Properties (checkLayer, checkMap, checkTileset)
import System.FilePath (takeFileName)
-import Data.Tiled (Layer (layerLayers, layerName),
- LoadResult (..),
- Tiledmap (tiledmapLayers, tiledmapTilesets),
- loadTiledmap)
import Types (Dep (MapLink),
Hint (Hint, hintLevel, hintMsg), Level (..),
lintsToHints)
@@ -94,14 +93,13 @@ shrinkMapResult !res = res { mapresultAdjusted = () }
-- Lints the map at `path`, and limits local links to at most `depth`
-- layers upwards in the file hierarchy
loadAndLintMap :: LintConfig' -> FilePath -> Int -> IO (Maybe (MapResult Full))
-loadAndLintMap config path depth = loadTiledmap path <&> (\case
- DecodeErr err -> Just (MapResult mempty mempty mempty mempty Nothing mempty
+loadAndLintMap config path depth = loadTiledmap path <&> \case
+ Left err -> Just (MapResult mempty mempty mempty mempty Nothing mempty
[ Hint Fatal . toText $
path <> ": Fatal: " <> err
])
- IOErr _ -> Nothing
- Loaded waMap ->
- Just (runLinter (takeFileName path == "main.json") config waMap depth))
+ Right waMap ->
+ Just (runLinter (takeFileName path == "main.json") config waMap depth)
-- | lint a loaded map
runLinter :: Bool -> LintConfig' -> Tiledmap -> Int -> MapResult Full
@@ -203,7 +201,6 @@ instance PrettyPrint (Level, MapResult a) where
prettyLints getter = fmap
(\(h, cs) -> prettyprint h
<> "\n (in "
- -- foldl :: ((length of current line, acc) -> next ctxt -> list) -> ...
<> snd (foldl (\(l,a) c -> case l of
0 -> (T.length c, c)
_ | l < 70 -> (l+2+T.length c, a <> ", " <> c)