about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--users/grfn/xanthous/src/Xanthous/App/Time.hs2
-rw-r--r--users/grfn/xanthous/src/Xanthous/Game/Lenses.hs10
2 files changed, 9 insertions, 3 deletions
diff --git a/users/grfn/xanthous/src/Xanthous/App/Time.hs b/users/grfn/xanthous/src/Xanthous/App/Time.hs
index b17348f3853e..cca352858d9c 100644
--- a/users/grfn/xanthous/src/Xanthous/App/Time.hs
+++ b/users/grfn/xanthous/src/Xanthous/App/Time.hs
@@ -16,6 +16,7 @@ import           Xanthous.Game.State
 import           Xanthous.Game.Prompt
 import           Xanthous.Game.Lenses
 import           Control.Monad.State (modify)
+import qualified Xanthous.Game.Memo as Memo
 --------------------------------------------------------------------------------
 
 
@@ -26,6 +27,7 @@ stepGameBy ticks = do
     pEntity' <- step ticks pEntity
     entities . ix eid .= pEntity'
 
+  clearMemo Memo.characterVisiblePositions
   modify updateCharacterVision
 
   whenM (uses character isDead)
diff --git a/users/grfn/xanthous/src/Xanthous/Game/Lenses.hs b/users/grfn/xanthous/src/Xanthous/Game/Lenses.hs
index 051493192323..f7b4d5fb9fd2 100644
--- a/users/grfn/xanthous/src/Xanthous/Game/Lenses.hs
+++ b/users/grfn/xanthous/src/Xanthous/Game/Lenses.hs
@@ -3,7 +3,8 @@
 {-# LANGUAGE AllowAmbiguousTypes #-}
 --------------------------------------------------------------------------------
 module Xanthous.Game.Lenses
-  ( positionedCharacter
+  ( clearMemo
+  , positionedCharacter
   , character
   , characterPosition
   , updateCharacterVision
@@ -38,8 +39,8 @@ import           Xanthous.Data.EntityMap.Graphics
 import           Xanthous.Data.VectorBag
 import           Xanthous.Entities.Character (Character, mkCharacter)
 import           {-# SOURCE #-} Xanthous.Entities.Entities ()
-import Xanthous.Game.Memo (emptyMemoState)
-import Xanthous.Data.Memo (fillWithM)
+import           Xanthous.Game.Memo (emptyMemoState, MemoState)
+import           Xanthous.Data.Memo (fillWithM, Memoized)
 --------------------------------------------------------------------------------
 
 getInitialState :: IO GameState
@@ -68,6 +69,9 @@ initialStateFromSeed seed =
       _memo = emptyMemoState
   in GameState {..}
 
+clearMemo :: MonadState GameState m => Lens' MemoState (Memoized k v) -> m ()
+clearMemo l = memo %= Memo.clear l
+
 positionedCharacter :: Lens' GameState (Positioned Character)
 positionedCharacter = lens getPositionedCharacter setPositionedCharacter
   where