Fix crash on empty inventory left click

This commit is contained in:
2022-03-09 18:17:08 +00:00
parent 3bfebc266b
commit 4a1ca905f7
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -49,11 +49,11 @@ toggleEquipmentAt invid cr = cr & crInvEquipped . at invid %~ f
useLeftItem :: Int -> World -> World
useLeftItem cid w
| _crInvLock cr = w
| isJust (citem ^? itUse . cUse) = useItem cr w
| itConsumable = useItem cr w
| otherwise = fromMaybe w $ do
invid <- _crLeftInvSel cr
f <- cr ^? crInv . ix invid . itUse . lUse
return $ f cr invid w
where
cr = _creatures w IM.! cid
citem = _crInv cr IM.! _crInvSel cr
itConsumable = isJust $ cr ^? crInv . ix (_crInvSel cr) . itUse . cUse