--- a/gameServer/HWProtoCore.hs Thu Mar 05 14:54:02 2009 +0000
+++ b/gameServer/HWProtoCore.hs Thu Mar 05 19:53:40 2009 +0000
@@ -1,6 +1,8 @@
module HWProtoCore where
import qualified Data.IntMap as IntMap
+import Data.Foldable
+import Maybe
--------------------------------------
import CoreTypes
import Actions
@@ -9,7 +11,7 @@
import HWProtoLobbyState
import HWProtoInRoomState
-handleCmd:: CmdHandler
+handleCmd, handleCmd_loggedin :: CmdHandler
handleCmd clID _ _ ["PING"] = [AnswerThisClient ["PONG"]]
@@ -24,13 +26,38 @@
clientTeams = filter (\t -> teamowner t == nick client) $ teams room
removeClientTeams = map (RemoveTeam . teamname) clientTeams
+
handleCmd clID clients rooms cmd =
if not $ logonPassed client then
handleCmd_NotEntered clID clients rooms cmd
- else if roomID client == 0 then
+ else
+ handleCmd_loggedin clID clients rooms cmd
+ where
+ client = clients IntMap.! clID
+
+
+handleCmd_loggedin clID clients rooms ["INFO", asknick] =
+ if noSuchClient then
+ []
+ else
+ [AnswerThisClient
+ ["INFO",
+ nick client,
+ "[" ++ host client ++ "]",
+ protoNumber2ver $ clientProto client,
+ roomInfo]]
+ where
+ maybeClient = find (\cl -> asknick == nick cl) clients
+ noSuchClient = isNothing maybeClient
+ client = fromJust maybeClient
+ room = rooms IntMap.! roomID client
+ roomInfo = if roomID client /= 0 then "room " ++ (name room) else "lobby"
+
+
+handleCmd_loggedin clID clients rooms cmd =
+ if roomID client == 0 then
handleCmd_lobby clID clients rooms cmd
else
handleCmd_inRoom clID clients rooms cmd
where
client = clients IntMap.! clID
-