Reimplement CFG protocol command
authorunc0rr
Wed, 23 Jun 2010 22:13:12 +0400
changeset 3540 b602a57ba0fb
parent 3538 b11ac2677e42
child 3542 f216b24aeb7f
Reimplement CFG protocol command
gameServer/HWProtoInRoomState.hs
gameServer/HWProtoLobbyState.hs
--- a/gameServer/HWProtoInRoomState.hs	Tue Jun 22 22:40:49 2010 +0400
+++ b/gameServer/HWProtoInRoomState.hs	Wed Jun 23 22:13:12 2010 +0400
@@ -24,17 +24,20 @@
 handleCmd_inRoom ["PART"] = return [MoveToLobby "part"]
 handleCmd_inRoom ["PART", msg] = return [MoveToLobby $ "part: " `B.append` msg]
 
-{-
 
-handleCmd_inRoom clID clients rooms ("CFG" : paramName : paramStrs)
-    | null paramStrs = [ProtocolError "Empty config entry"]
-    | isMaster client =
-        [ModifyRoom (\r -> r{params = Map.insert paramName paramStrs (params r)}),
-        AnswerOthersInRoom ("CFG" : paramName : paramStrs)]
-    | otherwise = [ProtocolError "Not room master"]
-    where
-        client = clients IntMap.! clID
+handleCmd_inRoom ("CFG" : paramName : paramStrs)
+    | null paramStrs = return [ProtocolError "Empty config entry"]
+    | otherwise = do
+        chans <- roomOthersChans
+        cl <- thisClient
+        if isMaster cl then
+           return [
+                ModifyRoom (\r -> r{params = Map.insert paramName paramStrs (params r)}),
+                AnswerClients chans ("CFG" : paramName : paramStrs)]
+            else
+            return [ProtocolError "Not room master"]
 
+{-
 handleCmd_inRoom clID clients rooms ("ADD_TEAM" : name : color : grave : fort : voicepack : flag : difStr : hhsInfo)
     | length hhsInfo == 15 && clientProto client < 30 = handleCmd_inRoom clID clients rooms ("ADD_TEAM" : name : color : grave : fort : voicepack : " " : flag : difStr : hhsInfo)
     | length hhsInfo /= 16 = [ProtocolError "Corrupted hedgehogs info"]
--- a/gameServer/HWProtoLobbyState.hs	Tue Jun 22 22:40:49 2010 +0400
+++ b/gameServer/HWProtoLobbyState.hs	Wed Jun 23 22:13:12 2010 +0400
@@ -78,7 +78,7 @@
 handleCmd_lobby ["JOIN_ROOM", roomName, roomPassword] = do
     (ci, irnc) <- ask
     let ris = allRooms irnc
-    let cl =  irnc `client` ci
+    cl <- thisClient
     let maybeRI = find (\ri -> roomName == name (irnc `room` ri)) ris
     let jRI = fromJust maybeRI
     let jRoom = irnc `room` jRI