netserver/HWProto.hs
changeset 1577 e3e37c730dc0
parent 1571 574063b456c0
child 1578 f02806f66e00
--- a/netserver/HWProto.hs	Sat Jan 03 19:01:50 2009 +0000
+++ b/netserver/HWProto.hs	Sat Jan 03 20:48:37 2009 +0000
@@ -45,6 +45,7 @@
 answerConnected         = answerClientOnly ["CONNECTED", "Hedgewars server http://www.hedgewars.org/"]
 answerNotOwner          = answerClientOnly ["ERROR", "You do not own this team"]
 answerCannotCreateRoom  = answerClientOnly ["WARNING", "Cannot create more rooms"]
+answerInfo client       = answerClientOnly ["INFO", nick client, proto2ver $ protocol client]
 
 answerAbandoned           = answerOthersRoom ["BYE", "Room abandoned"]
 answerChatString nick msg = answerOthersRoom ["CHAT_STRING", nick, msg]
@@ -130,6 +131,17 @@
 handleCmd _ _ _ ["ERROR", msg] =
 	(noChangeClients, noChangeRooms, answerErrorMsg msg)
 
+handleCmd _ clients _ ["INFO", asknick] =
+	if noSuchClient then
+		(noChangeClients, noChangeRooms, [])
+	else
+		(noChangeClients, noChangeRooms, answerInfo client)
+	where
+		maybeClient = find (\cl -> asknick == nick cl) clients
+		noSuchClient = isNothing maybeClient
+		client = fromJust maybeClient
+
+
 -- check state and call state-dependent commmand handlers
 handleCmd client clients rooms cmd =
 	if null (nick client) || protocol client == 0 then