# HG changeset patch # User unc0rr # Date 1359439823 -14400 # Node ID 071d118b3283662d1776817842a7ea51bebbb265 # Parent c86c7d1fc9fcd20260bcddfedec65cc2b0f98712# Parent 3b318a130a62771c6d166c896c86fef395f43793 Merge diff -r c86c7d1fc9fc -r 071d118b3283 gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Mon Jan 28 15:54:40 2013 -0500 +++ b/gameServer/CoreTypes.hs Tue Jan 29 10:10:23 2013 +0400 @@ -38,7 +38,7 @@ isAdministrator :: Bool, isChecker :: Bool, isKickedFromServer :: Bool, - clientClan :: Maybe B.ByteString, + clientClan :: !(Maybe B.ByteString), teamsInGame :: Word } @@ -66,6 +66,9 @@ } deriving (Show, Read) +instance Eq TeamInfo where + (==) = (==) `on` teamname + data GameInfo = GameInfo { diff -r c86c7d1fc9fc -r 071d118b3283 gameServer/HWProtoInRoomState.hs --- a/gameServer/HWProtoInRoomState.hs Mon Jan 28 15:54:40 2013 -0500 +++ b/gameServer/HWProtoInRoomState.hs Tue Jan 29 10:10:23 2013 +0400 @@ -97,7 +97,6 @@ handleCmd_inRoom ["REMOVE_TEAM", tName] = do (ci, _) <- ask r <- thisRoom - clNick <- clientNick let maybeTeam = findTeam r let team = fromJust maybeTeam @@ -105,18 +104,18 @@ return $ if isNothing $ maybeTeam then [Warning $ loc "REMOVE_TEAM: no such team"] - else if clNick /= teamowner team then + else if ci /= teamownerId team then [ProtocolError $ loc "Not team owner!"] else [RemoveTeam tName, ModifyClient (\c -> c{ teamsInGame = teamsInGame c - 1, - clientClan = if teamsInGame c == 1 then Nothing else Just $ anotherTeamClan ci r + clientClan = if teamsInGame c == 1 then Nothing else Just $ anotherTeamClan ci team r }) ] where - anotherTeamClan ci = teamcolor . fromJust . find (\t -> teamownerId t == ci) . teams + anotherTeamClan ci team = teamcolor . fromMaybe (error "CHECKPOINT 011") . find (\t -> (teamownerId t == ci) && (t /= team)) . teams findTeam = find (\t -> tName == teamname t) . teams