Reimplement FOLLOW server_refactor
authorunc0rr
Sun, 30 Jan 2011 20:36:32 +0300
branchserver_refactor
changeset 4616 cc3485866b93
parent 4614 26661bf28dd5
child 4618 0f56fa511f65
Reimplement FOLLOW
gameServer/HWProtoLobbyState.hs
--- a/gameServer/HWProtoLobbyState.hs	Sun Jan 30 20:32:23 2011 +0300
+++ b/gameServer/HWProtoLobbyState.hs	Sun Jan 30 20:36:32 2011 +0300
@@ -119,19 +119,18 @@
 handleCmd_lobby ["JOIN_ROOM", roomName] =
     handleCmd_lobby ["JOIN_ROOM", roomName, ""]
 
+
+handleCmd_lobby ["FOLLOW", asknick] = do
+    (_, rnc) <- ask
+    ci <- clientByNick asknick
+    let ri = clientRoom rnc $ fromJust ci
+    let clRoom = room rnc ri
+    if isNothing ci || ri == lobbyId then
+        return []
+        else
+        handleCmd_lobby ["JOIN_ROOM", name clRoom]
+
 {-
-handleCmd_lobby clID clients rooms ["FOLLOW", asknick] =
-    if noSuchClient || roomID followClient == 0 then
-        []
-    else
-        handleCmd_lobby clID clients rooms ["JOIN_ROOM", roomName]
-    where
-        maybeClient = Foldable.find (\cl -> asknick == nick cl) clients
-        noSuchClient = isNothing maybeClient
-        followClient = fromJust maybeClient
-        roomName = name $ rooms IntMap.! roomID followClient
-
-
     ---------------------------
     -- Administrator's stuff --