From ca8552c4eb69b2b8267fe0046320bccf9f547b52 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Thu, 30 Sep 2021 02:02:29 +0200 Subject: simple map-map link dependency checking This is purely based on a set difference, i.e. it won't catch stupid things like a map linking to itself, a map link going only one-way, etc. Also, it only handles map links; it doesn't check if all ressource files referenced by a map actually exist. --- lib/CheckMap.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/CheckMap.hs') diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs index eaeac55..176e3d5 100644 --- a/lib/CheckMap.hs +++ b/lib/CheckMap.hs @@ -19,7 +19,7 @@ import GHC.Generics (Generic) import LintWriter (LintResult (..), LintWriter, askContext, filterLintLevel, lintToDep, resultToDeps, - resultToLints, runLintWriter) + resultToLints, resultToOffers, runLintWriter) import Properties (checkLayerProperty, checkMap) import Tiled2 (Layer (layerName, layerProperties), Tiledmap (tiledmapLayers), loadTiledmap) @@ -30,9 +30,10 @@ import Util (PrettyPrint (prettyprint), prettyprint) -- | What this linter produces: lints for a single map data MapResult = MapResult - { mapresultLayer :: Maybe (Map Text (LintResult Layer)) - , mapresultGeneral :: [Lint] - , mapresultDepends :: [Dep] + { mapresultLayer :: Maybe (Map Text (LintResult Layer)) + , mapresultGeneral :: [Lint] + , mapresultDepends :: [Dep] + , mapresultProvides :: [Text] } deriving (Generic, ToJSON) @@ -45,6 +46,7 @@ loadAndLintMap path depth = loadTiledmap path >>= pure . \case Left err -> MapResult { mapresultLayer = Nothing , mapresultDepends = [] + , mapresultProvides = [] , mapresultGeneral = [ hint Fatal . T.pack $ path <> ": Fatal: " <> err @@ -60,6 +62,7 @@ runLinter tiledmap depth = MapResult , mapresultGeneral = generalLints -- no general lints for now , mapresultDepends = concatMap (resultToDeps . snd) layer <> mapMaybe lintToDep generalLints + , mapresultProvides = concatMap (resultToOffers . snd) layer } where layerMap :: Map Text (LintResult Layer) -- cgit v1.2.3