packages feed

DefendTheKing 0.3 → 0.3.1

raw patch · 3 files changed

+21/−11 lines, 3 filesdep −haskell98

Dependencies removed: haskell98

Files

DefendTheKing.cabal view
@@ -1,5 +1,5 @@ Name:                DefendTheKing-Version:             0.3+Version:             0.3.1 Cabal-Version:       >= 1.2 Synopsis:            A simple RTS game Category:            game, FRP@@ -27,7 +27,7 @@   Main-IS:           defend.hs   Other-Modules:     Geometry, Networking, ParseStun, Intro, Draw, Parse, NetMatching, NetEngine, Chess, GameLogic, Font   Build-Depends:     base >=2 && < 5, peakachu >= 0.3.0, GLUT, containers,-                     random, time, utility-ht, haskell98,+                     random, time, utility-ht,                      network, HTTP >= 4000.0.5, mtl, bytestring, binary,                      MaybeT, zlib   GHC-Options:       -O2 -Wall
src/Geometry.hs view
@@ -13,7 +13,7 @@     base = map (zipWith (-) offset) (tail points)     [[a0, a1, a2], [b0, b1, b2]] = base -normalizeVector :: Floating a => [a] -> [a]+normalizeVector :: (Eq a, Floating a) => [a] -> [a] normalizeVector vec   | all (== 0) vec = vec   | otherwise = map (/ norm) vec@@ -29,7 +29,7 @@  type Line a = ((a, a), (a, a)) -slope :: Fractional a => Line a -> Maybe a+slope :: (Eq a, Fractional a) => Line a -> Maybe a slope ((x0, y0), (x1, y1))   | x0 == x1 = Nothing   | otherwise = Just $ (y1-y0) / (x1-x0)@@ -49,7 +49,7 @@         in           Just (x, yAt0 a da + x * da) -expandPolygon :: Floating a => a -> [(a, a)] -> [(a, a)]+expandPolygon :: (Eq a, Floating a) => a -> [(a, a)] -> [(a, a)] expandPolygon ammount outline   | null t = []   | otherwise = last t : init t
src/Networking.hs view
@@ -14,6 +14,7 @@ import Control.Concurrent (forkIO, threadDelay) import Control.Concurrent.MVar (newMVar, readMVar) import Control.Concurrent.MVar.YC (modifyMVarPure, writeMVar)+import Control.Exception (try) import Control.Monad (forever, join, liftM2, unless, when, replicateM) import Data.ADT.Getters import Data.Char (chr)@@ -23,16 +24,16 @@ import Data.Monoid (Monoid(..)) import FRP.Peakachu.Backend (Backend(..)) import FRP.Peakachu.Backend.Internal (Sink(..))-import Network.BSD (getHostByName, getHostName, hostAddress)+import Network.BSD (getHostByName, hostAddress) import Network.HTTP (getRequest, rspBody, simpleHTTP) import Network.Socket (   Family(..), HostAddress, PortNumber(..),   SockAddr(..), Socket, SocketType(..),-  bindSocket, iNADDR_ANY,+  bindSocket, connect, getSocketName, iNADDR_ANY,   recvFrom, sendTo, socket   )-import Random (randomRIO)-import System.IO.Error (isAlreadyInUseError, try)+import System.Random (randomRIO)+import System.IO.Error (isAlreadyInUseError) import Text.Read.HT (maybeRead)  data ProgToUdp a@@ -89,8 +90,17 @@   fmap hostAddress . getHostByName  getHostAddress :: IO HostAddress-getHostAddress =-  getHostName >>= getHostAddrByName+getHostAddress = do+  sock <- socket AF_INET Datagram 0+  connect sock (SockAddrInet 80 anInternetHostAddress)+  SockAddrInet _ r <- getSocketName sock+  return r+  where+    -- a random IP from the internet (74.125.230.83).+    -- It's one of "google.com".+    -- we're going to fake UDP connect to it. See:+    -- http://stackoverflow.com/questions/166506/finding-local-ip-addresses-in-python/166589#166589+    anInternetHostAddress = 1407614282  stunPort :: PortNumber stunPort = fromInteger 3478