netserver/HWProto.hs
changeset 1461 87e5a6c3882c
parent 1452 8505cbfd9a21
child 1462 d3323637da1f
equal deleted inserted replaced
1460:54e4b03e6ba6 1461:87e5a6c3882c
    60 answerCannotCreateRoom = [(clientOnly, ["WARNING", "Cannot create more rooms"])]
    60 answerCannotCreateRoom = [(clientOnly, ["WARNING", "Cannot create more rooms"])]
    61 answerIsReady nick = [(sameRoom, ["READY", nick])]
    61 answerIsReady nick = [(sameRoom, ["READY", nick])]
    62 answerNotReady nick = [(sameRoom, ["NOT_READY", nick])]
    62 answerNotReady nick = [(sameRoom, ["NOT_READY", nick])]
    63 answerTooFewClans = [(clientOnly, ["ERROR", "Too few clans in game"])]
    63 answerTooFewClans = [(clientOnly, ["ERROR", "Too few clans in game"])]
    64 answerRestricted = [(clientOnly, ["WARNING", "Room joining restricted"])]
    64 answerRestricted = [(clientOnly, ["WARNING", "Room joining restricted"])]
       
    65 answerPing = [(allClients, ["PING"])]
    65 
    66 
    66 -- Main state-independent cmd handler
    67 -- Main state-independent cmd handler
    67 handleCmd :: CmdHandler
    68 handleCmd :: CmdHandler
    68 handleCmd client _ rooms ("QUIT":xs) =
    69 handleCmd client _ rooms ("QUIT":xs) =
    69 	if null (room client) then
    70 	if null (room client) then
    76 		clRoom = roomByName (room client) rooms
    77 		clRoom = roomByName (room client) rooms
    77 		answerRemoveClientTeams = map (\tn -> (othersInRoom, ["REMOVE_TEAM", teamname tn])) clientTeams
    78 		answerRemoveClientTeams = map (\tn -> (othersInRoom, ["REMOVE_TEAM", teamname tn])) clientTeams
    78 		(clientTeams, othersTeams) = partition (\t -> teamowner t == nick client) $ teams clRoom
    79 		(clientTeams, othersTeams) = partition (\t -> teamowner t == nick client) $ teams clRoom
    79 		newReadyPlayers = if isReady client then (readyPlayers clRoom) - 1 else readyPlayers clRoom
    80 		newReadyPlayers = if isReady client then (readyPlayers clRoom) - 1 else readyPlayers clRoom
    80 
    81 
       
    82 handleCmd _ _ _ ["PING"] = -- core requsted
       
    83 	(noChangeClients, noChangeRooms, answerPing)
    81 
    84 
    82 -- check state and call state-dependent commmand handlers
    85 -- check state and call state-dependent commmand handlers
    83 handleCmd client clients rooms cmd =
    86 handleCmd client clients rooms cmd =
    84 	if null (nick client) || protocol client == 0 then
    87 	if null (nick client) || protocol client == 0 then
    85 		handleCmd_noInfo client clients rooms cmd
    88 		handleCmd_noInfo client clients rooms cmd