gameServer/RoomsAndClients.hs
changeset 3502 ad38c653b7d9
parent 3501 a3159a410e5c
child 3555 4c5ca656d1bb
--- a/gameServer/RoomsAndClients.hs	Sun Jun 06 19:03:06 2010 +0000
+++ b/gameServer/RoomsAndClients.hs	Tue Jun 08 18:20:49 2010 +0000
@@ -19,6 +19,7 @@
     room,
     client'sM,
     clientsM,
+    roomClientsM,
     withRoomsAndClients,
     allRooms,
     allClients,
@@ -143,6 +144,9 @@
 clientsM :: MRoomsAndClients r c -> IO [c]
 clientsM (MRoomsAndClients (_, clients)) = indicesM clients >>= mapM (\ci -> liftM client' $ readElem clients ci)
 
+roomClientsM :: MRoomsAndClients r c -> RoomIndex -> IO [c]
+roomClientsM (MRoomsAndClients (rooms, clients)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri) >>= mapM (\(ClientIndex ci) -> liftM client' $ readElem clients ci)
+
 withRoomsAndClients :: MRoomsAndClients r c -> (IRoomsAndClients r c -> a) -> IO a
 withRoomsAndClients (MRoomsAndClients (rooms, clients)) f =
     withIStore2 rooms clients (\r c -> f $ IRoomsAndClients (r, c))