1
Description: Make game server compatible with older Haskell stack
2
The Hedgewars server uses several Haskell libraries and functions
3
that weren't available in older versions of Ubuntu:
5
1. Reimplement Control.Exception.mask, as it wasn't available.
7
2. Use the Control.Monad.State.State type constructor instead of the
8
Control.Monad.State.state function; the latter wasn't available.
10
3. Utils.hs contains showB, which uses Text.Show.ByteString. Instead
11
of using the Text.Show.ByteString.Show class, use plain old Show
12
instead (which should be able to render everything
13
Text.Show.ByteString.Show could).
15
Thanks to Anders Kaseorg for helping generate the patch.
17
Author: Evan Broder <evan@ebroder.net>
18
Author: Anders Kaseorg <andersk@mit.edu>
19
Last-Update: 2011-11-22
21
Index: hedgewars-0.9.17/gameServer/Actions.hs
22
===================================================================
23
--- hedgewars-0.9.17.orig/gameServer/Actions.hs 2011-11-22 17:57:10.482642522 -0800
24
+++ hedgewars-0.9.17/gameServer/Actions.hs 2011-11-22 17:57:11.838642515 -0800
26
-{-# LANGUAGE CPP, OverloadedStrings #-}
27
+{-# LANGUAGE CPP, OverloadedStrings, RankNTypes #-}
30
import Control.Concurrent
33
liftM (map sendChan . filter (/= cl)) $ roomClientsS ri
35
+exceptionMask:: ((forall a. IO a -> IO a) -> IO b) -> IO b
36
+exceptionMask io = do
38
+ if b then io id else block (io unblock)
40
processAction :: Action -> StateT ServerState IO ()
46
ci <- addClient rnc cl
47
- _ <- Exception.mask (forkIO . clientRecvLoop (clientSocket cl) (coreChan si) (sendChan cl) ci)
48
+ _ <- exceptionMask (forkIO . clientRecvLoop (clientSocket cl) (coreChan si) (sendChan cl) ci)
50
infoM "Clients" (show ci ++ ": New client. Time: " ++ show (connectTime cl))
52
Index: hedgewars-0.9.17/gameServer/ClientIO.hs
53
===================================================================
54
--- hedgewars-0.9.17.orig/gameServer/ClientIO.hs 2011-11-22 17:57:10.502642524 -0800
55
+++ hedgewars-0.9.17/gameServer/ClientIO.hs 2011-11-22 17:57:11.838642515 -0800
57
takePacks :: State B.ByteString [[B.ByteString]]
59
= do modify (until (not . B.isPrefixOf pDelim) (B.drop 2))
60
- packet <- state $ B.breakSubstring pDelim
61
+ packet <- State $ B.breakSubstring pDelim
63
if B.null buf then put packet >> return [] else
64
if B.null packet then return [] else
65
Index: hedgewars-0.9.17/gameServer/Utils.hs
66
===================================================================
67
--- hedgewars-0.9.17.orig/gameServer/Utils.hs 2011-11-22 17:57:10.530642521 -0800
68
+++ hedgewars-0.9.17/gameServer/Utils.hs 2011-11-22 17:57:11.842642515 -0800
71
import qualified Codec.Binary.Base64 as Base64
72
import qualified Data.ByteString.Lazy as BL
73
-import qualified Text.Show.ByteString as BS
74
import qualified Data.ByteString.Char8 as B
75
import qualified Data.ByteString.UTF8 as UTF8
76
import qualified Data.ByteString as BW
78
Right (a, new_b) -> let (a', b') = unfoldrE f new_b in (a : a', b')
79
Left new_b -> ([], new_b)
81
-showB :: (BS.Show a) => a -> B.ByteString
82
-showB = B.concat . BL.toChunks . BS.show
83
+showB :: (Show a) => a -> B.ByteString
84
+showB = B.pack . show
86
readInt_ :: (Num a) => B.ByteString -> a