Allow to rename room
authorunc0rr
Sun, 03 Apr 2011 20:07:05 +0400
changeset 5098 cb9cf41a208c
parent 5097 53e9d9451328
child 5099 ce1a761d3c1e
Allow to rename room
gameServer/HWProtoInRoomState.hs
--- a/gameServer/HWProtoInRoomState.hs	Sun Apr 03 19:27:48 2011 +0400
+++ b/gameServer/HWProtoInRoomState.hs	Sun Apr 03 20:07:05 2011 +0400
@@ -242,6 +242,20 @@
             [ModifyRoom (\r -> r{isRestrictedTeams = not $ isRestrictedTeams r})]
 
 
+handleCmd_inRoom ["ROOM_NAME", newName] = do
+    cl <- thisClient
+    rs <- allRoomInfos
+    
+    return $
+        if not $ isMaster cl then
+            [ProtocolError "Not room master"]
+        else
+        if isJust $ find (\r -> newName == name r) rs then
+            [Warning "Room with such name already exists"]
+        else
+            [ModifyRoom (\r -> r{name = newName})]
+
+
 handleCmd_inRoom ["KICK", kickNick] = do
     (thisClientId, rnc) <- ask
     maybeClientId <- clientByNick kickNick