author | unc0rr |
Fri, 07 Mar 2014 23:59:04 +0400 | |
changeset 10182 | 9d34898b22f7 |
parent 10063 | 52e293f14977 |
child 10351 | 0eff41e9f63f |
permissions | -rw-r--r-- |
4295
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
1 |
{-# LANGUAGE OverloadedStrings #-} |
1804 | 2 |
module Utils where |
3 |
||
4 |
import Data.Char |
|
5 |
import Data.Word |
|
6 |
import qualified Data.Map as Map |
|
6191 | 7 |
import qualified Data.Char as Char |
1917 | 8 |
import Numeric |
9 |
import Network.Socket |
|
1964 | 10 |
import System.IO |
1917 | 11 |
import qualified Data.List as List |
2349 | 12 |
import Control.Monad |
5030
42746c5d4a80
Changed the standard show function to Text.Show.ByteString, and misc.
EJ <eivind.jahren@gmail.com>
parents:
4975
diff
changeset
|
13 |
import qualified Data.ByteString.Lazy as BL |
42746c5d4a80
Changed the standard show function to Text.Show.ByteString, and misc.
EJ <eivind.jahren@gmail.com>
parents:
4975
diff
changeset
|
14 |
import qualified Text.Show.ByteString as BS |
4295
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
15 |
import qualified Data.ByteString.Char8 as B |
6191 | 16 |
import qualified Data.ByteString.UTF8 as UTF8 |
6541
08ed346ed341
Send full room info on room add and update events. Less(?) traffic, but current frontend doesn't behave good with this change to server.
unc0rr
parents:
6370
diff
changeset
|
17 |
import Data.Maybe |
4975
31da8979e5b1
Use Data.TConfig to read and store server config in hedgewars.ini (a little bit of hate to the author for not exporting Conf type)
unc0rr
parents:
4972
diff
changeset
|
18 |
------------------------------------------------- |
1804 | 19 |
import CoreTypes |
20 |
||
1917 | 21 |
|
4295
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
22 |
sockAddr2String :: SockAddr -> IO B.ByteString |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
23 |
sockAddr2String (SockAddrInet _ hostAddr) = liftM B.pack $ inet_ntoa hostAddr |
1917 | 24 |
sockAddr2String (SockAddrInet6 _ _ (a, b, c, d) _) = |
4295
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
25 |
return $ B.pack $ (foldr1 (.) |
4932 | 26 |
$ List.intersperse (':':) |
27 |
$ concatMap (\n -> (\(a0, a1) -> [showHex a0, showHex a1]) $ divMod n 65536) [a, b, c, d]) [] |
|
1917 | 28 |
|
1804 | 29 |
maybeRead :: Read a => String -> Maybe a |
30 |
maybeRead s = case reads s of |
|
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2747
diff
changeset
|
31 |
[(x, rest)] | all isSpace rest -> Just x |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2747
diff
changeset
|
32 |
_ -> Nothing |
1804 | 33 |
|
4295
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
34 |
teamToNet :: TeamInfo -> [B.ByteString] |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
35 |
teamToNet team = |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
36 |
"ADD_TEAM" |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
37 |
: teamname team |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
38 |
: teamgrave team |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
39 |
: teamfort team |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
40 |
: teamvoicepack team |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
41 |
: teamflag team |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
42 |
: teamowner team |
5030
42746c5d4a80
Changed the standard show function to Text.Show.ByteString, and misc.
EJ <eivind.jahren@gmail.com>
parents:
4975
diff
changeset
|
43 |
: (showB . difficulty $ team) |
4295
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
44 |
: hhsInfo |
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2747
diff
changeset
|
45 |
where |
4932 | 46 |
hhsInfo = concatMap (\(HedgehogInfo n hat) -> [n, hat]) $ hedgehogs team |
1804 | 47 |
|
48 |
modifyTeam :: TeamInfo -> RoomInfo -> RoomInfo |
|
49 |
modifyTeam team room = room{teams = replaceTeam team $ teams room} |
|
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2747
diff
changeset
|
50 |
where |
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2747
diff
changeset
|
51 |
replaceTeam _ [] = error "modifyTeam: no such team" |
4932 | 52 |
replaceTeam tm (t:ts) = |
53 |
if teamname tm == teamname t then |
|
54 |
tm : ts |
|
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2747
diff
changeset
|
55 |
else |
4932 | 56 |
t : replaceTeam tm ts |
1804 | 57 |
|
4295
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
58 |
illegalName :: B.ByteString -> Bool |
10063 | 59 |
illegalName b = B.null b || length s > 40 || all isSpace s || isSpace (head s) || isSpace (last s) || any isIllegalChar s |
5269 | 60 |
where |
10063 | 61 |
s = UTF8.toString b |
10062
8ef80bd0402f
turned out this blocked CJK characters too. stick to ASCII control char ban only, do NOT include UTF-8 control chars
sheepluva
parents:
10059
diff
changeset
|
62 |
isIllegalChar c = c `List.elem` ("$()*+?[]^{|}\x7F" ++ ['\x00'..'\x1F']) |
2150
45b695f3a7b9
Forbid room names and nicknames consisting only of space characters
unc0rr
parents:
2113
diff
changeset
|
63 |
|
4295
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
64 |
protoNumber2ver :: Word16 -> B.ByteString |
4569 | 65 |
protoNumber2ver v = Map.findWithDefault "Unknown" v vermap |
66 |
where |
|
67 |
vermap = Map.fromList [ |
|
4936
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
68 |
(17, "0.9.7-dev") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
69 |
, (19, "0.9.7") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
70 |
, (20, "0.9.8-dev") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
71 |
, (21, "0.9.8") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
72 |
, (22, "0.9.9-dev") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
73 |
, (23, "0.9.9") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
74 |
, (24, "0.9.10-dev") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
75 |
, (25, "0.9.10") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
76 |
, (26, "0.9.11-dev") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
77 |
, (27, "0.9.11") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
78 |
, (28, "0.9.12-dev") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
79 |
, (29, "0.9.12") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
80 |
, (30, "0.9.13-dev") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
81 |
, (31, "0.9.13") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
82 |
, (32, "0.9.14-dev") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
83 |
, (33, "0.9.14") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
84 |
, (34, "0.9.15-dev") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
85 |
, (35, "0.9.14.1") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
86 |
, (37, "0.9.15") |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
87 |
, (38, "0.9.16-dev") |
5880 | 88 |
, (39, "0.9.16") |
89 |
, (40, "0.9.17-dev") |
|
6370 | 90 |
, (41, "0.9.17") |
91 |
, (42, "0.9.18-dev") |
|
7862
bd76ca40db68
Choose first unused color for added team (addresses issue 431) + other small changes
unc0rr
parents:
7766
diff
changeset
|
92 |
, (43, "0.9.18") |
bd76ca40db68
Choose first unused color for added team (addresses issue 431) + other small changes
unc0rr
parents:
7766
diff
changeset
|
93 |
, (44, "0.9.19-dev") |
9086 | 94 |
, (45, "0.9.19") |
95 |
, (46, "0.9.20-dev") |
|
9837 | 96 |
, (47, "0.9.20") |
97 |
, (48, "0.9.21-dev") |
|
4936
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4932
diff
changeset
|
98 |
] |
1804 | 99 |
|
4921 | 100 |
askFromConsole :: B.ByteString -> IO B.ByteString |
1964 | 101 |
askFromConsole msg = do |
4921 | 102 |
B.putStr msg |
2867
9be6693c78cb
- Unbreak support for client versions prior to 0.9.13-dev
unc0rr
parents:
2747
diff
changeset
|
103 |
hFlush stdout |
4921 | 104 |
B.getLine |
4295
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
105 |
|
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
106 |
|
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
107 |
unfoldrE :: (b -> Either b (a, b)) -> b -> ([a], b) |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
108 |
unfoldrE f b = |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
109 |
case f b of |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
110 |
Right (a, new_b) -> let (a', b') = unfoldrE f new_b in (a : a', b') |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
111 |
Left new_b -> ([], new_b) |
1f5604cd99be
This revision should, in theory, correctly merge 0.9.14 and tip, so that future merges of 0.9.14 should work properly
nemo
parents:
4242
diff
changeset
|
112 |
|
5030
42746c5d4a80
Changed the standard show function to Text.Show.ByteString, and misc.
EJ <eivind.jahren@gmail.com>
parents:
4975
diff
changeset
|
113 |
showB :: (BS.Show a) => a -> B.ByteString |
42746c5d4a80
Changed the standard show function to Text.Show.ByteString, and misc.
EJ <eivind.jahren@gmail.com>
parents:
4975
diff
changeset
|
114 |
showB = B.concat . BL.toChunks . BS.show |
42746c5d4a80
Changed the standard show function to Text.Show.ByteString, and misc.
EJ <eivind.jahren@gmail.com>
parents:
4975
diff
changeset
|
115 |
|
42746c5d4a80
Changed the standard show function to Text.Show.ByteString, and misc.
EJ <eivind.jahren@gmail.com>
parents:
4975
diff
changeset
|
116 |
readInt_ :: (Num a) => B.ByteString -> a |
42746c5d4a80
Changed the standard show function to Text.Show.ByteString, and misc.
EJ <eivind.jahren@gmail.com>
parents:
4975
diff
changeset
|
117 |
readInt_ str = |
42746c5d4a80
Changed the standard show function to Text.Show.ByteString, and misc.
EJ <eivind.jahren@gmail.com>
parents:
4975
diff
changeset
|
118 |
case B.readInt str of |
42746c5d4a80
Changed the standard show function to Text.Show.ByteString, and misc.
EJ <eivind.jahren@gmail.com>
parents:
4975
diff
changeset
|
119 |
Just (i, t) | B.null t -> fromIntegral i |
10017 | 120 |
_ -> 0 |
5060
7d0f6e5b1c1c
Hide last two octets of IP address from usual users
unc0rr
parents:
5030
diff
changeset
|
121 |
|
7d0f6e5b1c1c
Hide last two octets of IP address from usual users
unc0rr
parents:
5030
diff
changeset
|
122 |
cutHost :: B.ByteString -> B.ByteString |
7d0f6e5b1c1c
Hide last two octets of IP address from usual users
unc0rr
parents:
5030
diff
changeset
|
123 |
cutHost = B.intercalate "." . flip (++) ["*","*"] . List.take 2 . B.split '.' |
6191 | 124 |
|
125 |
caseInsensitiveCompare :: B.ByteString -> B.ByteString -> Bool |
|
8396 | 126 |
caseInsensitiveCompare a b = upperCase a == upperCase b |
6541
08ed346ed341
Send full room info on room add and update events. Less(?) traffic, but current frontend doesn't behave good with this change to server.
unc0rr
parents:
6370
diff
changeset
|
127 |
|
8396 | 128 |
upperCase :: B.ByteString -> B.ByteString |
129 |
upperCase = UTF8.fromString . map Char.toUpper . UTF8.toString |
|
7766 | 130 |
|
9702 | 131 |
roomInfo :: Word16 -> B.ByteString -> RoomInfo -> [B.ByteString] |
10017 | 132 |
roomInfo p n r |
9702 | 133 |
| p < 46 = [ |
6541
08ed346ed341
Send full room info on room add and update events. Less(?) traffic, but current frontend doesn't behave good with this change to server.
unc0rr
parents:
6370
diff
changeset
|
134 |
showB $ isJust $ gameInfo r, |
08ed346ed341
Send full room info on room add and update events. Less(?) traffic, but current frontend doesn't behave good with this change to server.
unc0rr
parents:
6370
diff
changeset
|
135 |
name r, |
08ed346ed341
Send full room info on room add and update events. Less(?) traffic, but current frontend doesn't behave good with this change to server.
unc0rr
parents:
6370
diff
changeset
|
136 |
showB $ playersIn r, |
08ed346ed341
Send full room info on room add and update events. Less(?) traffic, but current frontend doesn't behave good with this change to server.
unc0rr
parents:
6370
diff
changeset
|
137 |
showB $ length $ teams r, |
08ed346ed341
Send full room info on room add and update events. Less(?) traffic, but current frontend doesn't behave good with this change to server.
unc0rr
parents:
6370
diff
changeset
|
138 |
n, |
08ed346ed341
Send full room info on room add and update events. Less(?) traffic, but current frontend doesn't behave good with this change to server.
unc0rr
parents:
6370
diff
changeset
|
139 |
Map.findWithDefault "+rnd+" "MAP" (mapParams r), |
08ed346ed341
Send full room info on room add and update events. Less(?) traffic, but current frontend doesn't behave good with this change to server.
unc0rr
parents:
6370
diff
changeset
|
140 |
head (Map.findWithDefault ["Default"] "SCHEME" (params r)), |
08ed346ed341
Send full room info on room add and update events. Less(?) traffic, but current frontend doesn't behave good with this change to server.
unc0rr
parents:
6370
diff
changeset
|
141 |
head (Map.findWithDefault ["Default"] "AMMO" (params r)) |
08ed346ed341
Send full room info on room add and update events. Less(?) traffic, but current frontend doesn't behave good with this change to server.
unc0rr
parents:
6370
diff
changeset
|
142 |
] |
9702 | 143 |
| otherwise = [ |
144 |
showB $ isJust $ gameInfo r, |
|
145 |
name r, |
|
146 |
showB $ playersIn r, |
|
147 |
showB $ length $ teams r, |
|
148 |
n, |
|
149 |
Map.findWithDefault "+rnd+" "MAP" (mapParams r), |
|
150 |
head (Map.findWithDefault ["Normal"] "SCRIPT" (params r)), |
|
151 |
head (Map.findWithDefault ["Default"] "SCHEME" (params r)), |
|
152 |
head (Map.findWithDefault ["Default"] "AMMO" (params r)) |
|
153 |
] |
|
9109
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
154 |
|
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
155 |
answerFullConfigParams :: |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
156 |
ClientInfo |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
157 |
-> Map.Map B.ByteString B.ByteString |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
158 |
-> Map.Map B.ByteString [B.ByteString] |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
159 |
-> [Action] |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
160 |
answerFullConfigParams cl mpr pr |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
161 |
| clientProto cl < 38 = map (toAnswer cl) $ |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
162 |
(reverse . map (\(a, b) -> (a, [b])) $ Map.toList mpr) |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
163 |
++ (("SCHEME", pr Map.! "SCHEME") |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
164 |
: (filter (\(p, _) -> p /= "SCHEME") $ Map.toList pr)) |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
165 |
|
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
166 |
| otherwise = map (toAnswer cl) $ |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
167 |
("FULLMAPCONFIG", Map.elems mpr) |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
168 |
: ("SCHEME", pr Map.! "SCHEME") |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
169 |
: (filter (\(p, _) -> p /= "SCHEME") $ Map.toList pr) |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
170 |
where |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
171 |
toAnswer cl (paramName, paramStrs) = AnswerClients [sendChan cl] $ "CFG" : paramName : paramStrs |
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
172 |
|
878f06e9c484
- Fix issue 521 by resending FULLMAPCONFIG on game finish to those who joined mid-game. Semitested.
unc0rr
parents:
9086
diff
changeset
|
173 |
|
9448 | 174 |
answerAllTeams :: ClientInfo -> [TeamInfo] -> [Action] |
175 |
answerAllTeams cl = concatMap toAnswer |
|
176 |
where |
|
177 |
clChan = sendChan cl |
|
178 |
toAnswer team = |
|
179 |
[AnswerClients [clChan] $ teamToNet team, |
|
180 |
AnswerClients [clChan] ["TEAM_COLOR", teamname team, teamcolor team], |
|
181 |
AnswerClients [clChan] ["HH_NUM", teamname team, showB $ hhnum team]] |
|
182 |
||
183 |
||
8401
87410ae372f6
Server messages localization using Qt's l10n subsystem:
unc0rr
parents:
8396
diff
changeset
|
184 |
loc :: B.ByteString -> B.ByteString |
87410ae372f6
Server messages localization using Qt's l10n subsystem:
unc0rr
parents:
8396
diff
changeset
|
185 |
loc = id |
9753
9579596cf471
- Special rooms which stay even when last player quits. Not useful for now, and can't be removed at all.
unc0rr
parents:
9702
diff
changeset
|
186 |
|
9579596cf471
- Special rooms which stay even when last player quits. Not useful for now, and can't be removed at all.
unc0rr
parents:
9702
diff
changeset
|
187 |
maybeNick :: Maybe ClientInfo -> B.ByteString |
9579596cf471
- Special rooms which stay even when last player quits. Not useful for now, and can't be removed at all.
unc0rr
parents:
9702
diff
changeset
|
188 |
maybeNick = fromMaybe "[empty]" . liftM nick |