# HG changeset patch # User unc0rr # Date 1231452069 0 # Node ID 2b9cadc232ab8c185c39e7ad76d45f2af141ddc1 # Parent 30170c63a9dd7deb4ada83b85092ee9b48c30d68 Fix server bugs: - Wrong room destryed notification - Not proper notifying when room master quits - smth else I forgot already diff -r 30170c63a9dd -r 2b9cadc232ab CMakeLists.txt --- a/CMakeLists.txt Thu Jan 08 21:04:36 2009 +0000 +++ b/CMakeLists.txt Thu Jan 08 22:01:09 2009 +0000 @@ -19,7 +19,7 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") -set(HEDGEWARS_PROTO_VER 21) +set(HEDGEWARS_PROTO_VER 22) if(WITH_SERVER) set(HAVE_NETSERVER true) diff -r 30170c63a9dd -r 2b9cadc232ab netserver/HWProto.hs --- a/netserver/HWProto.hs Thu Jan 08 21:04:36 2009 +0000 +++ b/netserver/HWProto.hs Thu Jan 08 22:01:09 2009 +0000 @@ -22,6 +22,7 @@ answerOthersRoom = makeAnswer othersInRoom answerSameRoom = makeAnswer sameRoom answerSameProtoLobby = makeAnswer sameProtoLobbyClients +answerOtherLobby = makeAnswer otherLobbyClients answerAll = makeAnswer allClients answerBadCmd = answerClientOnly ["ERROR", "Bad command, state or incorrect parameter"] @@ -126,7 +127,7 @@ if null (room client) then (noChangeClients, noChangeRooms, answerQuit msg ++ (answerQuitLobby (nick client) msg) ) else if isMaster client then - (modifyRoomClients clRoom (\cl -> cl{isReady = False}), removeRoom (room client), (answerQuit msg) ++ (answerQuitLobby (nick client) msg) ++ (answerAbandoned $ protocol client) ++ (answerRoomDeleted $ room client)) -- core disconnects clients on ROOMABANDONED answer + (modifyRoomClients clRoom (\cl -> cl{room = [], isReady = False}), removeRoom (room client), (answerQuit msg) ++ (answerQuitLobby (nick client) msg) ++ (answerAbandoned $ protocol client) ++ (answerRoomDeleted $ room client)) -- core disconnects clients on ROOMABANDONED answer else (noChangeClients, modifyRoom clRoom{teams = othersTeams, playersIn = (playersIn clRoom) - 1, readyPlayers = newReadyPlayers}, (answerQuit msg) ++ (answerQuitInform (nick client) msg) ++ (answerQuitLobby (nick client) msg) ++ answerRemoveClientTeams) where @@ -174,8 +175,8 @@ if (null $ nick client) || (protocol client == 0) then [] else - (answerClientOnly $ ["LOBBY:JOINED"] ++ (filter (not . null) $ map nick $ clients)) ++ - (answerOthersRoom ["LOBBY:JOINED", nick client]) ++ + (answerClientOnly $ ["LOBBY:JOINED"] ++ (filter (\n -> (not (null n)) && n /= nick client) $ map nick $ clients)) ++ + (answerAll ["LOBBY:JOINED", nick client]) ++ (answerServerMessage client clients) handleCmd_noInfo :: CmdHandler @@ -270,7 +271,7 @@ handleCmd_inRoom client _ rooms ["PART"] = if isMaster client then - (modifyRoomClients clRoom (\cl -> cl{room = [], isReady = False, isMaster = False}), removeRoom (room client), (answerAbandoned $ protocol client) ++ (answerRoomDeleted $ room client)) + (modifyRoomClients clRoom (\cl -> cl{isReady = False, isMaster = False, partRoom = True}), removeRoom (room client), (answerAbandoned $ protocol client) ++ (answerRoomDeleted $ room client)) else (modifyClient client{isReady = False, partRoom = True}, modifyRoom clRoom{teams = othersTeams, playersIn = (playersIn clRoom) - 1, readyPlayers = newReadyPlayers}, (answerPartInform (nick client)) ++ answerRemoveClientTeams) where diff -r 30170c63a9dd -r 2b9cadc232ab netserver/Miscutils.hs --- a/netserver/Miscutils.hs Thu Jan 08 21:04:36 2009 +0000 +++ b/netserver/Miscutils.hs Thu Jan 08 22:01:09 2009 +0000 @@ -130,6 +130,9 @@ sameProtoLobbyClients :: HandlesSelector sameProtoLobbyClients client clients rooms = filter (\ci -> room ci == [] && protocol ci == protocol client) clients +otherLobbyClients :: HandlesSelector +otherLobbyClients client clients rooms = filter (\ci -> room ci == []) clients + noRoomSameProto :: HandlesSelector noRoomSameProto client clients _ = filter (null . room) $ filter (\ci -> protocol client == protocol ci) clients