gameServer/EngineInteraction.hs
branch0.9.21
changeset 10771 ac06370b7436
parent 10460 8dcea9087d75
child 10773 c91811e09361
equal deleted inserted replaced
10769:e603fac0ce7f 10771:ac06370b7436
    14  * You should have received a copy of the GNU General Public License
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    17  \-}
    17  \-}
    18 
    18 
    19 {-# LANGUAGE OverloadedStrings #-}
    19 {-# LANGUAGE CPP, OverloadedStrings #-}
    20 
    20 
       
    21 #if defined(OFFICIAL_SERVER)
    21 module EngineInteraction(replayToDemo, checkNetCmd, toEngineMsg, drawnMapData) where
    22 module EngineInteraction(replayToDemo, checkNetCmd, toEngineMsg, drawnMapData) where
       
    23 #else
       
    24 module EngineInteraction(checkNetCmd, toEngineMsg, drawnMapData) where
       
    25 #endif
    22 
    26 
    23 import qualified Data.Set as Set
    27 import qualified Data.Set as Set
    24 import Control.Monad
    28 import Control.Monad
    25 import qualified Codec.Binary.Base64 as Base64
    29 import qualified Codec.Binary.Base64 as Base64
    26 import qualified Data.ByteString.Char8 as B
    30 import qualified Data.ByteString.Char8 as B
    87         isNonEmpty = (/=) '+' . B.head . B.tail
    91         isNonEmpty = (/=) '+' . B.head . B.tail
    88         legalMessages = Set.fromList $ "M#+LlRrUuDdZzAaSjJ,sNpPwtgfhbc12345" ++ slotMessages
    92         legalMessages = Set.fromList $ "M#+LlRrUuDdZzAaSjJ,sNpPwtgfhbc12345" ++ slotMessages
    89         slotMessages = "\128\129\130\131\132\133\134\135\136\137\138"
    93         slotMessages = "\128\129\130\131\132\133\134\135\136\137\138"
    90         timedMessages = Set.fromList $ "+LlRrUuDdZzAaSjJ,NpPwtgfc12345" ++ slotMessages
    94         timedMessages = Set.fromList $ "+LlRrUuDdZzAaSjJ,NpPwtgfc12345" ++ slotMessages
    91 
    95 
       
    96 #if defined(OFFICIAL_SERVER)
    92 replayToDemo :: [TeamInfo]
    97 replayToDemo :: [TeamInfo]
    93         -> Map.Map B.ByteString B.ByteString
    98         -> Map.Map B.ByteString B.ByteString
    94         -> Map.Map B.ByteString [B.ByteString]
    99         -> Map.Map B.ByteString [B.ByteString]
    95         -> [B.ByteString]
   100         -> [B.ByteString]
    96         -> [B.ByteString]
   101         -> [B.ByteString]
   147                             eml ["eaddhh ", showB $ difficulty t, " ", initHealth, " ", hname]
   152                             eml ["eaddhh ", showB $ difficulty t, " ", initHealth, " ", hname]
   148                             , eml ["ehat ", hhat]
   153                             , eml ["ehat ", hhat]
   149                             ])
   154                             ])
   150                         $ hedgehogs t
   155                         $ hedgehogs t
   151                         )
   156                         )
       
   157 #endif
   152 
   158 
   153 drawnMapData :: B.ByteString -> [B.ByteString]
   159 drawnMapData :: B.ByteString -> [B.ByteString]
   154 drawnMapData =
   160 drawnMapData =
   155           L.map (\m -> eml ["edraw ", BW.pack m])
   161           L.map (\m -> eml ["edraw ", BW.pack m])
   156         . L.unfoldr by200
   162         . L.unfoldr by200