Fix crash on empty inventory left click
This commit is contained in:
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user