~ubuntu-branches/ubuntu/maverick/hedgewars/maverick-proposed

« back to all changes in this revision

Viewing changes to debian/patches/haskell-backwards-compat.patch

  • Committer: Package Import Robot
  • Author(s): Evan Broder
  • Date: 2011-11-22 04:49:51 UTC
  • mfrom: (3.2.15 sid)
  • Revision ID: package-import@ubuntu.com-20111122044951-elrt8tvvs5andmuw
Tags: 0.9.17-1~maverick0.1
* Backport 0.9.17-1 to Maverick to fix network play (LP: #852603):
  - debian/patches/haskell-backwards-compat.patch: Replace or
    reimplement functions used by the server that weren't available in
    Maverick's Haskell stack
  - Drop libghc-bytestring-show-dev build-dependency.
  - Add 6's to get libghc6-deepseq-dev, libghc6-utf8-string-dev
    build-dependencies
  - Change libghc6-network-dev build-dependency to libghc6-network-bytestring-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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:
 
4
 .
 
5
 1. Reimplement Control.Exception.mask, as it wasn't available.
 
6
 .
 
7
 2. Use the Control.Monad.State.State type constructor instead of the
 
8
 Control.Monad.State.state function; the latter wasn't available.
 
9
 .
 
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).
 
14
 .
 
15
 Thanks to Anders Kaseorg for helping generate the patch.
 
16
Forwarded: not-needed
 
17
Author: Evan Broder <evan@ebroder.net>
 
18
Author: Anders Kaseorg <andersk@mit.edu>
 
19
Last-Update: 2011-11-22
 
20
 
 
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
 
25
@@ -1,4 +1,4 @@
 
26
-{-# LANGUAGE CPP, OverloadedStrings #-}
 
27
+{-# LANGUAGE CPP, OverloadedStrings, RankNTypes #-}
 
28
 module Actions where
 
29
 
 
30
 import Control.Concurrent
 
31
@@ -85,6 +85,11 @@
 
32
     ri <- clientRoomA
 
33
     liftM (map sendChan . filter (/= cl)) $ roomClientsS ri
 
34
 
 
35
+exceptionMask:: ((forall a. IO a -> IO a) -> IO b) -> IO b
 
36
+exceptionMask io = do
 
37
+    b <- blocked
 
38
+    if b then io id else block (io unblock)
 
39
+
 
40
 processAction :: Action -> StateT ServerState IO ()
 
41
 
 
42
 
 
43
@@ -429,7 +434,7 @@
 
44
     si <- gets serverInfo
 
45
     newClId <- io $ do
 
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)
 
49
 
 
50
         infoM "Clients" (show ci ++ ": New client. Time: " ++ show (connectTime cl))
 
51
 
 
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
 
56
@@ -22,7 +22,7 @@
 
57
 takePacks :: State B.ByteString [[B.ByteString]]
 
58
 takePacks
 
59
   = do modify (until (not . B.isPrefixOf pDelim) (B.drop 2))
 
60
-       packet <- state $ B.breakSubstring pDelim
 
61
+       packet <- State $ B.breakSubstring pDelim
 
62
        buf <- get
 
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
 
69
@@ -13,7 +13,6 @@
 
70
 import Control.Monad
 
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
 
77
@@ -105,8 +104,8 @@
 
78
         Right (a, new_b) -> let (a', b') = unfoldrE f new_b in (a : a', b')
 
79
         Left new_b       -> ([], new_b)
 
80
 
 
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
 
85
 
 
86
 readInt_ :: (Num a) => B.ByteString -> a
 
87
 readInt_ str =