more optimization

This commit is contained in:
nek0 2018-09-18 03:13:53 +02:00
parent a68b186fd0
commit aed0732d3e
2 changed files with 25 additions and 17 deletions

View file

@ -520,10 +520,12 @@ drawTile ud ctx posanims pr pc row col img =
updateMap :: Double -> Affection UserData ()
updateMap dt = do
ud <- getAffection
if stateData ud == None
-- empty <- liftIO $ isEmptyMVar (stateMVar ud)
if stateData ud == None -- && empty
then do
liftIO $ logIO A.Debug "Loaded game data"
(nws, mendat) <- liftIO $ takeMVar (stateMVar ud)
mstart <- liftIO $ tryTakeMVar (stateMVar ud)
case mstart of
Just (nws, mendat) -> do
putAffection ud
{ worldState = nws
, stateData = mendat
@ -532,6 +534,8 @@ updateMap dt = do
updateMap 0.1
updateMap 0.1
updateMap 19
liftIO $ logIO A.Debug "Loaded game data"
Nothing -> return ()
else do
(nws, _) <- yieldSystemT (worldState ud) $ do
emap allEnts $ do

View file

@ -11,6 +11,8 @@ import Data.Graph.AStar
import Data.Maybe
import qualified Data.Text as T
import Control.Monad (join)
import qualified SDL
import qualified Graphics.Rendering.OpenGL as GL hiding (get)
@ -164,7 +166,8 @@ naviGraph imgmat animBounds (V2 r c) =
(\acc (rr, cc) ->
if null
(maybe [] collisionObstacle
(M.safeGet (r + rr) (c + cc) imgmat) ++
(join $ M.safeGet (r + rr) (c + cc) imgmat)
++
map snd (filter
(\(V2 br bc, _) -> floor br == r + rr && floor bc == c + cc)
animBounds))
@ -177,14 +180,15 @@ naviGraph imgmat animBounds (V2 r c) =
foldl
(\acc (rr, cc) ->
if null
(maybe [] (collisionObstacle <$>)
([M.safeGet (r + rr) (c + cc) imgmat] ++
(maybe [] collisionObstacle
(join $ M.safeGet (r + rr) (c + cc) imgmat)
++
map snd (filter (\(V2 br bc, _) -> floor br == r + rr && floor bc == c + cc)
animBounds)))
animBounds))
&& all null
(map
(\(oor, ooc) -> (maybe [] collisionObstacle
(M.safeGet (r + oor) (c + ooc) imgmat)) ++
(join $ M.safeGet (r + oor) (c + ooc) imgmat)) ++
map snd (filter
(\(V2 br bc, _) -> floor br == r + oor && floor bc == c + ooc)
animBounds))