Cleanup, trying to diagnose space leak in crit update

This commit is contained in:
2021-12-09 22:12:44 +00:00
parent bd94044445
commit 3c35a04531
23 changed files with 203 additions and 178 deletions
+4 -4
View File
@@ -33,7 +33,6 @@ import Control.Monad.State
import System.Random
--import qualified Data.Set as S
--import qualified Data.Map as M
import Data.Monoid
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as MV
@@ -42,13 +41,14 @@ import qualified Data.Vector.Mutable as MV
-- the creature before or after it has moved?
-- currently invSideEffects are applied after the creature moves, to correctly
-- update shield positions
stateUpdate :: CRUpdate -> CRUpdate
stateUpdate = stateUpdateDamage doDamage
stateUpdate :: CRUpdate -> Creature -> World -> World
stateUpdate f cr w = let (fw,mcr) = stateUpdateDamage doDamage f cr w
in fw $ w & creatures . at (_crID cr) .~ mcr
stateUpdateDamage :: (Creature -> Creature) -> CRUpdate -> CRUpdate
stateUpdateDamage damageupdate u cr w = case u (updateMovement cr) w of
(f, maybeCr) ->
( Endo $ invSideEff (fromMaybe cr maybeCr) . movementSideEff cr . deathEff . appEndo f
( invSideEff (fromMaybe cr maybeCr) . movementSideEff cr . deathEff . f
, fmap (stepReloading . damageupdate) $ crOrCorpse =<< maybeCr
)
where