gameServer/Actions.hs
changeset 4991 90d1fb9fc2e1
parent 4989 4771fed9272e
child 4998 cdcdf37e5532
--- a/gameServer/Actions.hs	Sun Mar 06 21:55:44 2011 +0300
+++ b/gameServer/Actions.hs	Tue Mar 08 21:27:44 2011 +0300
@@ -315,10 +315,21 @@
     (Just ci) <- gets clientIndex
     n <- client's nick
     h <- client's host
+    p <- client's clientProto
     uid <- client's clUID
-    db <- gets (dbQueries . serverInfo)
-    io $ writeChan db $ CheckAccount ci (hashUnique uid) n h
-    return ()
+    haveSameNick <- liftM (not . null . tail . filter (\c -> nick c == n)) allClientsS
+    if haveSameNick then
+        if p < 38 then
+            mapM_ processAction [ByeClient "Nickname is already in use", removeNick]
+            else
+            mapM_ processAction [NoticeMessage NickAlreadyInUse, removeNick]
+        else
+        do
+        db <- gets (dbQueries . serverInfo)
+        io $ writeChan db $ CheckAccount ci (hashUnique uid) n h
+        return ()
+   where
+       removeNick = ModifyClient (\c -> c{nick = ""})
 
 
 processAction ClearAccountsCache = do