Reimplement REMOVE_TEAM
authorunc0rr
Sat, 26 Jun 2010 16:57:43 +0400
changeset 3564 7c583c88327b
parent 3563 48452ee0c925
child 3565 bc3410104894
Reimplement REMOVE_TEAM
gameServer/HWProtoInRoomState.hs
--- a/gameServer/HWProtoInRoomState.hs	Sat Jun 26 16:56:02 2010 +0400
+++ b/gameServer/HWProtoInRoomState.hs	Sat Jun 26 16:57:43 2010 +0400
@@ -79,26 +79,27 @@
 handleCmd_inRoom ["REMOVE_TEAM", name] = do
         (ci, rnc) <- ask
         let r = room rnc $ clientRoom rnc ci
-		clNick <- clientNick
-		
-		let maybeTeam = findTeam r
-		let team = fromJust maybeTeam
-		
-		return $
-			if isNothing $ findTeam r then
-				[Warning "REMOVE_TEAM: no such team"]
-			else if clNick /= teamowner team then
-				[ProtocolError "Not team owner!"]
-			else
-				[RemoveTeam name,
-				ModifyClient 
-					(\c -> c{
-						teamsInGame = teamsInGame c - 1, 
-						clientClan = if teamsInGame client == 1 then undefined else anotherTeamClan ci r
-						})
-				]
+        clNick <- clientNick
+
+        let maybeTeam = findTeam r
+        let team = fromJust maybeTeam
+
+        return $
+            if isNothing $ findTeam r then
+                [Warning "REMOVE_TEAM: no such team"]
+            else if clNick /= teamowner team then
+                [ProtocolError "Not team owner!"]
+            else
+                [RemoveTeam name,
+                ModifyClient
+                    (\c -> c{
+                        teamsInGame = teamsInGame c - 1,
+                        clientClan = if teamsInGame c == 1 then undefined else anotherTeamClan ci r
+                        })
+                ]
     where
         anotherTeamClan ci = teamcolor . fromJust . find (\t -> teamownerId t == ci) . teams
+        findTeam = find (\t -> name == teamname t) . teams
 
 {-