summaryrefslogtreecommitdiff
path: root/lib/CheckMap.hs
diff options
context:
space:
mode:
authorstuebinm2021-09-30 02:02:29 +0200
committerstuebinm2021-09-30 02:02:29 +0200
commitca8552c4eb69b2b8267fe0046320bccf9f547b52 (patch)
treeefda222c28b3d6267c89dd8b1793e4c6c259e53d /lib/CheckMap.hs
parent68af04a4da6ba4ec61d1469337ce53457526d861 (diff)
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.
Diffstat (limited to 'lib/CheckMap.hs')
-rw-r--r--lib/CheckMap.hs11
1 files changed, 7 insertions, 4 deletions
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)