# HG changeset patch # User unc0rr # Date 1231264299 0 # Node ID 1db9b654f880ecc05bbf1cf533e83a42e363e4bd # Parent 646d56eacb8f4e57f8438af2afee074b396dea00 Notify lobby when a room is created or deleted diff -r 646d56eacb8f -r 1db9b654f880 QTfrontend/newnetclient.cpp --- a/QTfrontend/newnetclient.cpp Tue Jan 06 17:37:18 2009 +0000 +++ b/QTfrontend/newnetclient.cpp Tue Jan 06 17:51:39 2009 +0000 @@ -190,7 +190,7 @@ void HWNewNet::ParseCmd(const QStringList & lst) { -// qDebug() << "Server: " << lst; + qDebug() << "Server: " << lst; if(!lst.size()) { @@ -293,6 +293,7 @@ emit setReadyStatus(lst[1], true); return; } + if (lst[0] == "NOT_READY") { if(lst.size() != 2) { @@ -382,6 +383,16 @@ return; } + if(lst[0] == "ROOM") { + if(lst.size() < 2) + { + qWarning("Net: Bad ROOM message"); + return; + } + RawSendNet(QString("LIST")); + return; + } + if(lst[0] == "LOBBY:LEFT") { if(lst.size() < 2) { diff -r 646d56eacb8f -r 1db9b654f880 netserver/HWProto.hs --- a/netserver/HWProto.hs Tue Jan 06 17:37:18 2009 +0000 +++ b/netserver/HWProto.hs Tue Jan 06 17:51:39 2009 +0000 @@ -21,6 +21,7 @@ answerClientOnly = makeAnswer clientOnly answerOthersRoom = makeAnswer othersInRoom answerSameRoom = makeAnswer sameRoom +answerSameProtoLobby = makeAnswer sameProtoLobbyClients answerAll = makeAnswer allClients answerBadCmd = answerClientOnly ["ERROR", "Bad command, state or incorrect parameter"] @@ -76,6 +77,9 @@ answerIsReady nick = answerSameRoom ["READY", nick] answerNotReady nick = answerSameRoom ["NOT_READY", nick] +answerRoomAdded name = answerSameProtoLobby ["ROOM", "ADD", name] +answerRoomDeleted name = answerSameProtoLobby ["ROOM", "DEL", name] + answerFullConfig room = concatMap toAnswer (Map.toList $ params room) ++ (answerClientOnly ["MAP", gamemap room]) where toAnswer (paramName, paramStrs) = @@ -114,7 +118,7 @@ if null (room client) then (noChangeClients, noChangeRooms, answerQuit msg ++ (answerQuitLobby (nick client) msg) ) else if isMaster client then - (noChangeClients, removeRoom (room client), (answerQuit msg) ++ (answerQuitLobby (nick client) msg) ++ answerAbandoned) -- core disconnects clients on ROOMABANDONED answer + (noChangeClients, removeRoom (room client), (answerQuit msg) ++ (answerQuitLobby (nick client) msg) ++ answerAbandoned ++ (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 @@ -206,7 +210,7 @@ if haveSameRoom then (noChangeClients, noChangeRooms, answerRoomExists) else - (modifyClient client{room = newRoom, isMaster = True}, addRoom createRoom{name = newRoom, password = roomPassword, roomProto = (protocol client)}, (answerJoined $ nick client) ++ (answerNotReady $ nick client)) + (modifyClient client{room = newRoom, isMaster = True}, addRoom createRoom{name = newRoom, password = roomPassword, roomProto = (protocol client)}, (answerJoined $ nick client) ++ (answerNotReady $ nick client) ++ (answerRoomAdded newRoom)) where haveSameRoom = isJust $ find (\room -> newRoom == name room) rooms diff -r 646d56eacb8f -r 1db9b654f880 netserver/Miscutils.hs --- a/netserver/Miscutils.hs Tue Jan 06 17:37:18 2009 +0000 +++ b/netserver/Miscutils.hs Tue Jan 06 17:51:39 2009 +0000 @@ -126,6 +126,9 @@ sameRoom :: HandlesSelector sameRoom client clients rooms = filter (\ci -> room ci == room client) clients +sameProtoLobbyClients :: HandlesSelector +sameProtoLobbyClients client clients rooms = filter (\ci -> room ci == [] && protocol ci == protocol client) clients + noRoomSameProto :: HandlesSelector noRoomSameProto client clients _ = filter (null . room) $ filter (\ci -> protocol client == protocol ci) clients