Okay, a compatibility layer for clients of 0.9.15 version (not sure about old versions, as I removed all compatibility hacks for older versions previously)
--- a/gameServer/Actions.hs Tue Feb 15 21:12:22 2011 +0300
+++ b/gameServer/Actions.hs Wed Feb 16 12:07:30 2011 +0300
@@ -261,9 +261,12 @@
ri <- clientRoomA
roomPlayers <- roomClientsS ri
roomClIDs <- io $ roomClientsIndicesM rnc ri
- processAction $ AnswerClients (map sendChan roomPlayers) ("CLIENT_FLAGS" : "-r" : map nick roomPlayers)
+ pr <- client's clientProto
+ processAction $ AnswerClients (map sendChan roomPlayers) $ notReadyMessage pr (map nick roomPlayers)
io $ mapM_ (modifyClient rnc (\cl -> cl{isReady = False})) roomClIDs
processAction $ ModifyRoom (\r -> r{readyPlayers = 0})
+ where
+ notReadyMessage p nicks = if p < 38 then "NOT_READY" : nicks else "CLIENT_FLAGS" : "-r" : nicks
processAction (RemoveTeam teamName) = do
@@ -340,22 +343,7 @@
: AnswerClients [chan] ("LOBBY:JOINED" : clientNick : lobbyNicks)
: [ModifyClient (\cl -> cl{logonPassed = True}), SendServerMessage]
-{-
-processAction (clID, serverInfo, rnc) (RoomAddThisClient rID) =
- processAction (
- clID,
- serverInfo,
- adjust (\cl -> cl{roomID = rID, teamsInGame = if rID == 0 then teamsInGame cl else 0}) clID clients,
- adjust (\r -> r{playersIDs = IntSet.insert clID (playersIDs r), playersIn = (playersIn r) + 1}) rID $
- adjust (\r -> r{playersIDs = IntSet.delete clID (playersIDs r)}) 0 rooms
- ) joinMsg
- where
- client = clients ! clID
- joinMsg = if rID == 0 then
- AnswerAllOthers ["LOBBY:JOINED", nick client]
- else
- AnswerThisRoom ["JOINED", nick client]
- -}
+
processAction (KickClient kickId) = do
modify (\s -> s{clientIndex = Just kickId})
processAction $ ByeClient "Kicked"
--- a/gameServer/HWProtoInRoomState.hs Tue Feb 15 21:12:22 2011 +0300
+++ b/gameServer/HWProtoInRoomState.hs Wed Feb 16 12:07:30 2011 +0300
@@ -159,7 +159,10 @@
return [
ModifyClient (\c -> c{isReady = not $ isReady cl}),
ModifyRoom (\r -> r{readyPlayers = readyPlayers r + (if isReady cl then -1 else 1)}),
- AnswerClients chans ["CLIENT_FLAGS", if isReady cl then "-r" else "+r", nick cl]
+ AnswerClients chans $ if clientProto cl < 38 then
+ [if isReady cl then "NOT_READY" else "READY", nick cl]
+ else
+ ["CLIENT_FLAGS", if isReady cl then "-r" else "+r", nick cl]
]
handleCmd_inRoom ["START_GAME"] = do
@@ -221,6 +224,10 @@
where
answerRemovedTeams chans = map (\t -> AnswerClients chans ["REMOVE_TEAM", t]) . leftTeams
+-- compatibility with clients with protocol < 38
+handleCmd_inRoom ["ROUNDFINISHED"] =
+ handleCmd_inRoom ["ROUNDFINISHED", "1"]
+
handleCmd_inRoom ["TOGGLE_RESTRICT_JOINS"] = do
cl <- thisClient
return $
--- a/gameServer/HWProtoLobbyState.hs Tue Feb 15 21:12:22 2011 +0300
+++ b/gameServer/HWProtoLobbyState.hs Wed Feb 16 12:07:30 2011 +0300
@@ -40,7 +40,7 @@
showB $ playersIn r,
showB $ length $ teams r,
nick $ irnc `client` masterID r,
- head (Map.findWithDefault ["+rnd+"] "MAP" (mapParams r)),
+ Map.findWithDefault "+rnd+" "MAP" (mapParams r),
head (Map.findWithDefault ["Default"] "SCHEME" (params r)),
head (Map.findWithDefault ["Default"] "AMMO" (params r))
]
@@ -98,11 +98,21 @@
++ watchRound cl jRoom
where
- readynessMessage cl c = AnswerClients [sendChan cl] ["CLIENT_FLAGS", if isReady c then "+r" else "-r", nick c]
+ readynessMessage cl c = AnswerClients [sendChan cl] $
+ if clientProto cl < 38 then
+ [if isReady c then "READY" else "NOT_READY", nick c]
+ else
+ ["CLIENT_FLAGS", if isReady c then "+r" else "-r", nick c]
toAnswer cl (paramName, paramStrs) = AnswerClients [sendChan cl] $ "CFG" : paramName : paramStrs
- answerFullConfig cl mpr pr = map (toAnswer cl) $
+ answerFullConfig cl mpr pr
+ | clientProto cl < 38 = map (toAnswer cl) $
+ (map (\(a, b) -> (a, [b])) $ Map.toList mpr)
+ ++ (("SCHEME", pr Map.! "SCHEME")
+ : (filter (\(p, _) -> p /= "SCHEME") $ Map.toList pr))
+
+ | otherwise = map (toAnswer cl) $
("FULLMAPCONFIG", Map.elems mpr)
: ("SCHEME", pr Map.! "SCHEME")
: (filter (\(p, _) -> p /= "SCHEME") $ Map.toList pr)
--- a/gameServer/HWProtoNEState.hs Tue Feb 15 21:12:22 2011 +0300
+++ b/gameServer/HWProtoNEState.hs Wed Feb 16 12:07:30 2011 +0300
@@ -18,7 +18,7 @@
let cl = irnc `client` ci
if not . B.null $ nick cl then return [ProtocolError "Nickname already chosen"]
else
- if haveSameNick irnc then return [NoticeMessage NickAlreadyInUse]
+ if haveSameNick irnc then if clientProto cl < 38 then return [ByeClient "Nickname is already in use"] else return [NoticeMessage NickAlreadyInUse]
else
if illegalName newNick then return [ByeClient "Illegal nickname"]
else