Fix bug in item loc when combining items, rethink centralizing item locs
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
All good (620 modules, at 09:25:41)
|
||||
All good (620 modules, at 18:04:30)
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user