restore gameServer changes
authorkoda
Tue, 21 Jan 2014 23:15:25 +0100
changeset 10041 82d062e36e96
parent 10040 4ac87acbaed9
child 10042 703931eec680
restore gameServer changes
gameServer/CoreTypes.hs
gameServer/HWProtoCore.hs
--- a/gameServer/CoreTypes.hs	Tue Jan 21 22:53:15 2014 +0100
+++ b/gameServer/CoreTypes.hs	Tue Jan 21 23:15:25 2014 +0100
@@ -183,6 +183,7 @@
         isRegisteredOnly :: Bool,
         isSpecial :: Bool,
         greeting :: B.ByteString,
+        voting :: Maybe Voting,
         roomBansList :: ![B.ByteString],
         mapParams :: Map.Map B.ByteString B.ByteString,
         params :: Map.Map B.ByteString [B.ByteString]
@@ -204,6 +205,7 @@
         False
         False
         ""
+        Nothing
         []
         (
             Map.fromList $ Prelude.zip
@@ -212,8 +214,8 @@
         )
         (
             Map.fromList $ Prelude.zip
-                ["SCHEME", "SCRIPT", "Theme"]
-                [["Default"], ["Normal"], ["Theme"]]
+                ["SCHEME", "SCRIPT", "THEME", "MAZE_SIZE", "DRAWNMAP"]
+                [["Default"], ["Normal"], ["Theme"], ["0"], ["-"]]
         )
 
 
@@ -264,6 +266,21 @@
         False
         []
 
+data Voting = Voting {
+        voteTTL :: Int,
+        entitledToVote :: [Unique],
+        votes :: [(Unique, Bool)],
+        voteType :: VoteType
+    }
+
+
+data VoteType = VoteKick B.ByteString
+
+
+newVote :: VoteType -> Voting
+newVote = Voting 2 [] []
+
+
 data AccountInfo =
     HasAccount B.ByteString Bool Bool
     | Guest
--- a/gameServer/HWProtoCore.hs	Tue Jan 21 22:53:15 2014 +0100
+++ b/gameServer/HWProtoCore.hs	Tue Jan 21 23:15:25 2014 +0100
@@ -33,10 +33,7 @@
         else
         return [ModifyClient (\c -> c{pingsQueue = pingsQueue c - 1})]
 
-handleCmd ["CMD", parameters] = do
-        let (cmd, plist) = B.break (== ' ') parameters
-        let param = B.dropWhile (== ' ') plist
-        h (upperCase cmd) param
+handleCmd ["CMD", parameters] = uncurry h $ extractParameters parameters
     where
         h "DELEGATE" n | not $ B.null n = handleCmd ["DELEGATE", n]
         h "STATS" _ = handleCmd ["STATS"]
@@ -54,8 +51,15 @@
         h "FIX" _ = handleCmd ["FIX"]
         h "UNFIX" _ = handleCmd ["UNFIX"]
         h "GREETING" msg = handleCmd ["GREETING", msg]
+        h "CALLVOTE" msg | B.null msg = handleCmd ["CALLVOTE"]
+                         | otherwise = let (c, p) = extractParameters msg in
+                                           if B.null p then handleCmd ["CALLVOTE", c] else handleCmd ["CALLVOTE", c, p]
+        h "VOTE" msg = handleCmd ["VOTE", upperCase msg]
         h c p = return [Warning $ B.concat ["Unknown cmd: /", c, p]]
 
+        extractParameters p = let (a, b) = B.break (== ' ') p in (upperCase a, B.dropWhile (== ' ') b)
+
+
 handleCmd cmd = do
     (ci, irnc) <- ask
     let cl = irnc `client` ci