Fix dropping items creating indexes outside of filter
This commit is contained in:
+11
-2
@@ -64,19 +64,27 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount
|
||||
& pointcid . crInv %~ f
|
||||
& pointcid %~ crCancelReloading
|
||||
-- & pointcid . crInvSel . iselPos %~ g THIS NEEDS CHECKING
|
||||
& pointcid . crManipulation . manObject . inInventory . ispItem %~ g
|
||||
-- & pointcid . crManipulation . manObject . inInventory . ispItem %~ g
|
||||
-- & pointcid . crManipulation . manObject %~ h
|
||||
& pointcid . crLeftInvSel . lisMPos %~ g'
|
||||
& removeAnySlotEquipment
|
||||
& dounequipfunction
|
||||
& doanyitemeffect
|
||||
& pointcid . crInvEquipped %~ IM.delete invid
|
||||
& pointcid . crInvEquipped %~ IM.mapKeys g
|
||||
& updatemanipulation
|
||||
where
|
||||
-- TODO check whether this can be mapKeysMonotonic
|
||||
|
||||
getcid = cWorld . lWorld . creatures . ix cid
|
||||
pointcid = cWorld . lWorld . creatures . ix cid
|
||||
|
||||
updatemanipulation
|
||||
| cid == 0 && cr ^? crManipulation . manObject . inInventory . ispItem == Just invid
|
||||
= (pointcid . crManipulation . manObject . inInventory . ispItem %~ g) . changeAugInvSel (-1)
|
||||
| otherwise
|
||||
= pointcid . crManipulation . manObject . inInventory . ispItem %~ g
|
||||
|
||||
cr = w ^?! cWorld . lWorld . creatures . ix cid
|
||||
itm = _crInv cr IM.! invid
|
||||
dounequipfunction = fromMaybe id $ do
|
||||
@@ -92,6 +100,7 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount
|
||||
f inv =
|
||||
let (xs, ys) = IM.split invid inv
|
||||
in xs `IM.union` IM.mapKeys (subtract 1) ys
|
||||
-- the following might not work if a non-player creature drops their last item
|
||||
g x
|
||||
| x > invid || Just x == maxk = max 0 $ x - 1
|
||||
| otherwise = x
|
||||
@@ -429,7 +438,7 @@ ssLookupDown :: Int -> Int -> SelectionSections a -> Maybe (Int,Int,SelectionIte
|
||||
ssLookupDown i j sss = case ssLookupGT i j sss of
|
||||
Nothing -> ssLookupMin sss
|
||||
x -> x
|
||||
|
||||
|
||||
ssLookupLT :: Int -> Int -> SelectionSections a -> Maybe (Int,Int,SelectionItem a)
|
||||
ssLookupLT i j sss = fromMaybe (ssLookupLT' i sss) $ do
|
||||
ss <- sss ^? sssSections . ix i
|
||||
|
||||
Reference in New Issue
Block a user