diff -r edd12b259e7c -r 6c5d504af2ba gameServer/Actions.hs --- a/gameServer/Actions.hs Fri Oct 02 18:56:54 2009 +0000 +++ b/gameServer/Actions.hs Sat Oct 03 09:35:14 2009 +0000 @@ -19,6 +19,7 @@ | AnswerAllOthers [String] | AnswerThisRoom [String] | AnswerOthersInRoom [String] + | AnswerSameClan [String] | AnswerLobby [String] | SendServerMessage | RoomAddThisClient Int -- roomID @@ -35,6 +36,7 @@ | BanClient String -- nick | RemoveClientTeams Int -- clID | ModifyClient (ClientInfo -> ClientInfo) + | ModifyClient2 Int (ClientInfo -> ClientInfo) | ModifyRoom (RoomInfo -> RoomInfo) | ModifyServerInfo (ServerInfo -> ServerInfo) | AddRoom String String @@ -64,13 +66,13 @@ processAction (clID, serverInfo, clients, rooms) (AnswerAllOthers msg) = do - mapM_ (\id -> writeChan (sendChan $ clients ! id) msg) $ + mapM_ (\id' -> writeChan (sendChan $ clients ! id') msg) $ Prelude.filter (\id' -> (id' /= clID) && logonPassed (clients ! id')) (keys clients) return (clID, serverInfo, clients, rooms) processAction (clID, serverInfo, clients, rooms) (AnswerThisRoom msg) = do - mapM_ (\id -> writeChan (sendChan $ clients ! id) msg) roomClients + mapM_ (\id' -> writeChan (sendChan $ clients ! id') msg) roomClients return (clID, serverInfo, clients, rooms) where roomClients = IntSet.elems $ playersIDs room @@ -80,7 +82,7 @@ processAction (clID, serverInfo, clients, rooms) (AnswerOthersInRoom msg) = do - mapM_ (\id -> writeChan (sendChan $ clients ! id) msg) $ Prelude.filter (/= clID) roomClients + mapM_ (\id' -> writeChan (sendChan $ clients ! id') msg) $ Prelude.filter (/= clID) roomClients return (clID, serverInfo, clients, rooms) where roomClients = IntSet.elems $ playersIDs room @@ -90,13 +92,25 @@ processAction (clID, serverInfo, clients, rooms) (AnswerLobby msg) = do - mapM_ (\id -> writeChan (sendChan $ clients ! id) msg) roomClients + mapM_ (\id' -> writeChan (sendChan $ clients ! id') msg) roomClients return (clID, serverInfo, clients, rooms) where roomClients = IntSet.elems $ playersIDs room room = rooms ! 0 +processAction (clID, serverInfo, clients, rooms) (AnswerSameClan msg) = do + mapM_ (\cl -> writeChan (sendChan cl) msg) sameClanClients + return (clID, serverInfo, clients, rooms) + where + otherRoomClients = Prelude.map ((!) clients) $ IntSet.elems $ clID `IntSet.delete` (playersIDs room) + sameClanClients = Prelude.filter (\cl -> teamsInGame cl > 0 && clientClan cl == thisClan) otherRoomClients + thisClan = clientClan client + room = rooms ! rID + rID = roomID client + client = clients ! clID + + processAction (clID, serverInfo, clients, rooms) SendServerMessage = do writeChan (sendChan $ clients ! clID) ["SERVER_MESSAGE", message serverInfo] return (clID, serverInfo, clients, rooms) @@ -163,6 +177,10 @@ return (clID, serverInfo, adjust func clID clients, rooms) +processAction (clID, serverInfo, clients, rooms) (ModifyClient2 cl2ID func) = + return (clID, serverInfo, adjust func cl2ID clients, rooms) + + processAction (clID, serverInfo, clients, rooms) (ModifyRoom func) = return (clID, serverInfo, clients, adjust func rID rooms) where