# HG changeset patch # User unc0rr # Date 1223491134 0 # Node ID d166f9069c2bb91f7b0a5c2651cedcdcec96798b # Parent c624b04699fbc271fc5a7fe12ad9a41b157af16e Build neccessary structures in memory on ADDTEAM message, but don't send answer yet (need to review team id concept) diff -r c624b04699fb -r d166f9069c2b doc/Protocol.odt Binary file doc/Protocol.odt has changed diff -r c624b04699fb -r d166f9069c2b netserver/HWProto.hs --- a/netserver/HWProto.hs Wed Oct 08 18:29:16 2008 +0000 +++ b/netserver/HWProto.hs Wed Oct 08 18:38:54 2008 +0000 @@ -29,6 +29,7 @@ where toAnswer (paramName, paramStrs) = (clientOnly, "CONFIG_PARAM" : paramName : paramStrs) +answerCantAdd = [(clientOnly, ["WARNING", "Too many teams"])] -- Main state-independent cmd handler handleCmd :: CmdHandler @@ -123,7 +124,17 @@ where clRoom = roomByName (room client) rooms -handleCmd_inRoom client _ _ ("ADDTEAM" : name : color : grave : fort : difStr : hhsInfo) - | length hhsInfo == 16 = (noChangeClients, noChangeRooms, answerBadCmd) +handleCmd_inRoom client _ rooms ("ADDTEAM" : name : color : grave : fort : difStr : hhsInfo) + | length hhsInfo == 16 = + if length (teams clRoom) == 6 then + (noChangeClients, noChangeRooms, answerCantAdd) + else + (noChangeClients, modifyRoom clRoom{teams = newTeam : teams clRoom}, []) + where + clRoom = roomByName (room client) rooms + newTeam = (TeamInfo name color grave fort difficulty (hhsList hhsInfo)) + difficulty = fromMaybe 0 (maybeRead difStr :: Maybe Int) + hhsList (n:h:hhs) = HedgehogInfo n h : hhsList hhs + handleCmd_inRoom _ _ _ _ = (noChangeClients, noChangeRooms, answerBadCmd)