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] |
150 eml ["eaddhh ", showB $ difficulty t, " ", initHealth, " ", hname] |
155 eml ["eaddhh ", showB $ difficulty t, " ", initHealth, " ", hname] |
151 , eml ["ehat ", hhat] |
156 , eml ["ehat ", hhat] |
152 ]) |
157 ]) |
153 $ hedgehogs t |
158 $ hedgehogs t |
154 ) |
159 ) |
|
160 #endif |
155 |
161 |
156 drawnMapData :: B.ByteString -> [B.ByteString] |
162 drawnMapData :: B.ByteString -> [B.ByteString] |
157 drawnMapData = |
163 drawnMapData = |
158 L.map (\m -> eml ["edraw ", BW.pack m]) |
164 L.map (\m -> eml ["edraw ", BW.pack m]) |
159 . L.unfoldr by200 |
165 . L.unfoldr by200 |