diff --git a/ghcidOutput b/ghcidOutput index d4a645330..79e0680a2 100644 --- a/ghcidOutput +++ b/ghcidOutput @@ -1 +1 @@ -All good (620 modules, at 09:25:41) +All good (620 modules, at 18:04:30) diff --git a/src/Dodge/Inventory/Add.hs b/src/Dodge/Inventory/Add.hs index ddb1348df..7eb41494f 100644 --- a/src/Dodge/Inventory/Add.hs +++ b/src/Dodge/Inventory/Add.hs @@ -33,11 +33,12 @@ tryPutItemInInv cid flit w = case maybeInvSlot of Just ( i , w - & updateItLocation i & cWorld . lWorld . floorItems . unNIntMap %~ IM.delete (_unNInt $ _flItID flit) & cWorld . lWorld . creatures . ix cid . crInv %~ IM.insert i it + & updateItLocation i -- I forget whether using "at" rather than "IM.insert" here caused problems -- & cWorld . lWorld . creatures . ix cid . crInv . at i ?~ it + & cWorld . lWorld %~ crUpdateItemLocations cid & setInvPosFromSS & cWorld . lWorld %~ crUpdateItemLocations cid ) diff --git a/src/Dodge/Inventory/Location.hs b/src/Dodge/Inventory/Location.hs index 043126243..bdd1a65c5 100644 --- a/src/Dodge/Inventory/Location.hs +++ b/src/Dodge/Inventory/Location.hs @@ -15,6 +15,8 @@ import Dodge.Item.Grammar import Data.Maybe import Control.Applicative + -- this assumes the creature inventory is well formed, specifically the + -- location ids tryGetRootItemInvID :: Int -> Creature -> Maybe Int tryGetRootItemInvID i cr = do let adj = case invAdj' (_crInv cr) of @@ -39,7 +41,7 @@ crUpdateItemLocations crid lw = fromMaybe lw $ do crUpdateInvidLocations :: ManipulatedObject -> Int -> LWorld -> Int -> Item -> LWorld crUpdateInvidLocations mo crid lw invid itm = lw & creatures . ix crid . crInv . ix invid . itLocation .~ newloc - & itemLocations . ix itid .~ newloc + & itemLocations %~ IM.insert itid newloc where itid = itm ^. itID newloc = InInv crid invid (Just invid == mo ^? inInventory . imSelectedItem) diff --git a/src/Dodge/Item/Grammar.hs b/src/Dodge/Item/Grammar.hs index e852c0496..8d1ebd45a 100644 --- a/src/Dodge/Item/Grammar.hs +++ b/src/Dodge/Item/Grammar.hs @@ -101,6 +101,8 @@ invLDT = joinItemsInList (leftRightCombine leftIsParentCombine rightIsParentComb -- (error ("invAdj item " ++ show (_itID itm) ++ " location:" ++ show (itm ^? itLocation . ilInvID)) ) -- $ itm ^? itLocation . ilInvID + -- this assumes the creature inventory is well formed, specifically the + -- location ids invAdj' :: IM.IntMap Item -> Either String (IM.IntMap (Maybe (Int,Int),[Int],[Int])) invAdj' im = do l <- mapM g $ invLDT im