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
+1 -1
View File
@@ -92,7 +92,7 @@ handlePressedMouseButton but w
| but == ButtonMiddle || _carteDisplay (_uvWorld w)
= Just $ w & uvWorld . clickMousePos .~ _mousePos (_uvWorld w)
| but == ButtonLeft = case _inventoryMode (_uvWorld w) of
CombineInventory mi -> Just $ fromMaybe w $ do -- ugly
CombineInventory mi -> Just $ fromMaybe (w & uvWorld . inventoryMode .~ TopInventory) $ do -- ugly
i <- mi
return $ over uvWorld (doCombine i) w
_ -> Just w