Don't store keepalive messages in game server spectators buffer
authorunc0rr
Wed, 16 Sep 2009 12:48:27 +0000
changeset 2381 959da8402cac
parent 2380 603965eca22b
child 2382 bfd378dfc4e7
Don't store keepalive messages in game server spectators buffer
gameServer/HWProtoInRoomState.hs
gameServer/Utils.hs
--- a/gameServer/HWProtoInRoomState.hs	Sun Sep 13 17:51:25 2009 +0000
+++ b/gameServer/HWProtoInRoomState.hs	Wed Sep 16 12:48:27 2009 +0000
@@ -140,13 +140,13 @@
 
 
 handleCmd_inRoom clID clients rooms ["EM", msg] =
-	if (teamsInGame client > 0) && (isLegalNetCommand msg) then
-		[ModifyRoom (\r -> r{roundMsgs = roundMsgs r |> msg}),
-		AnswerOthersInRoom ["EM", msg]]
+	if (teamsInGame client > 0) && isLegal then
+		(AnswerOthersInRoom ["EM", msg]) : [ModifyRoom (\r -> r{roundMsgs = roundMsgs r |> msg}) | not isKeepAlive]
 	else
 		[]
 	where
 		client = clients IntMap.! clID
+		(isLegal, isKeepAlive) = checkNetCmd msg
 
 handleCmd_inRoom clID clients rooms ["ROUNDFINISHED"] =
 	if isMaster client then
--- a/gameServer/Utils.hs	Sun Sep 13 17:51:25 2009 +0000
+++ b/gameServer/Utils.hs	Wed Sep 16 12:48:27 2009 +0000
@@ -36,13 +36,13 @@
 		removeLength (x:xs) = if length xs == fromIntegral x then Just xs else Nothing
 		removeLength _ = Nothing
 
-isLegalNetCommand :: String -> Bool
-isLegalNetCommand msg = test decoded
+checkNetCmd :: String -> (Bool, Bool)
+checkNetCmd msg = check decoded
 	where
 		decoded = fromEngineMsg msg
-		test Nothing = False
-		test (Just (m:ms)) = m `Set.member` legalMessages
-		test _ = False
+		check Nothing = (False, False)
+		check (Just (m:ms)) = (m `Set.member` legalMessages, m == '+')
+		check _ = (False, False)
 		legalMessages = Set.fromList $ "M#+LlRrUuDdZzAaSjJ,sFNpPwtghb12345" ++ slotMessages
 		slotMessages = "\128\129\130\131\132\133\134\135\136\137\138"