# HG changeset patch # User unc0rr # Date 1223249273 0 # Node ID 453882eb4467143f55fa21af9c967b65835a531e # Parent 05cebf68ebd8c7a476a1f1ca1fb3690c71538a70 - Fix build of server (has some bugs now) - Start converting client diff -r 05cebf68ebd8 -r 453882eb4467 QTfrontend/newnetclient.cpp --- a/QTfrontend/newnetclient.cpp Sun Oct 05 23:22:14 2008 +0000 +++ b/QTfrontend/newnetclient.cpp Sun Oct 05 23:27:53 2008 +0000 @@ -163,18 +163,21 @@ void HWNewNet::ParseCmd(const QStringList & lst) { - qDebug() << "Server: " << lst; + qDebug() << "Server: " << lst; + + if(!lst.size()) + { + qWarning("Net client: Bad message"); + return; + } - if(!lst.size()) - { - qWarning("Net client: Bad message"); - return; - } - - if (lst[0] == "ERRONEUSNICKNAME") { - QMessageBox::information(0, 0, "Your net nickname is in use or cannot be used"); - return; - } + if (lst[0] == "ERROR") { + if (lst.size() == 2) + QMessageBox::information(0, 0, lst[1]); + else + QMessageBox::information(0, 0, "Unknown error"); + return; + } if (lst[0] == "CONNECTED") { m_game_connected=true; diff -r 05cebf68ebd8 -r 453882eb4467 netserver/HWProto.hs --- a/netserver/HWProto.hs Sun Oct 05 23:22:14 2008 +0000 +++ b/netserver/HWProto.hs Sun Oct 05 23:27:53 2008 +0000 @@ -7,8 +7,8 @@ import Maybe (fromMaybe, fromJust) answerBadCmd = [(clientOnly, ["ERROR", "Bad command, state or incorrect parameter"])] -answerQuit = [(clientOnly, ["QUIT"])] -answerAbandoned = [(sameRoom, ["ROOMABANDONED"])] +answerQuit = [(clientOnly, ["BYE"])] +answerAbandoned = [(sameRoom, ["BYE"])] answerQuitInform nick = [(sameRoom, ["QUIT", nick])] answerNickChosen = [(clientOnly, ["ERROR", "The nick already chosen"])] answerNickChooseAnother = [(clientOnly, ["WARNING", "Choose another nick"])] diff -r 05cebf68ebd8 -r 453882eb4467 netserver/newhwserv.hs --- a/netserver/newhwserv.hs Sun Oct 05 23:22:14 2008 +0000 +++ b/netserver/newhwserv.hs Sun Oct 05 23:27:53 2008 +0000 @@ -43,24 +43,24 @@ mainLoop servSock acceptChan (ci:clients) rooms Right (cmd, client) -> do putStrLn ("> " ++ show cmd) - let (clientsFunc, roomsFunc, handlesFunc, answer) = handleCmd client clients rooms $ cmd - putStrLn ("< " ++ show answer) + let (clientsFunc, roomsFunc, answers) = handleCmd client clients rooms $ cmd let mclients = clientsFunc clients let mrooms = roomsFunc rooms - let recipients = handlesFunc client mclients mrooms - - clHandles' <- forM recipients $ - \ch -> do + + clHandles' <- forM answers $ + \(handlesFunc, answer) -> do + putStrLn ("< " ++ show answer) + let recipients = handlesFunc client mclients mrooms + forM recipients $ + \ch -> do forM_ answer (\str -> hPutStrLn ch str) hPutStrLn ch "" hFlush ch - if (not $ null answer) && (head answer == "ROOMABANDONED") then hClose ch >> return [ch] else return [] - `catch` const (hClose ch >> return [ch]) + if (not $ null answer) && (head answer == "BYE") then hClose ch >> return [ch] else return [] + `catch` const (hClose ch >> return [ch]) - clHandle' <- if (not $ null answer) && (head answer == "QUIT") then hClose (handle client) >> return [handle client] else return [] - - mainLoop servSock acceptChan (remove (remove mclients (concat clHandles')) clHandle') mrooms + mainLoop servSock acceptChan (remove mclients (concat $ concat clHandles')) mrooms where remove list rmClHandles = deleteFirstsBy2t (\ a b -> (handle a) == b) list rmClHandles