# HG changeset patch # User unc0rr # Date 1358450259 -14400 # Node ID 5123eac2f9d62a4f4f1da8257e9f8de08d5b4b38 # Parent 0b357c57e01c55b119d3b524e87264de96771448 - Pass unknown chat commands to server - Make server recognize /delegate command diff -r 0b357c57e01c -r 5123eac2f9d6 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Thu Jan 17 18:12:30 2013 +0100 +++ b/QTfrontend/hwform.cpp Thu Jan 17 23:17:39 2013 +0400 @@ -1266,6 +1266,8 @@ hwnet, SLOT(infoPlayer(const QString&))); connect(ui.pageRoomsList->chatWidget, SIGNAL(follow(const QString&)), hwnet, SLOT(followPlayer(const QString&))); + connect(ui.pageRoomsList->chatWidget, SIGNAL(consoleCommand(const QString&)), + hwnet, SLOT(consoleCommand(const QString&))); // chatting connect(ui.pageRoomsList->chatWidget, SIGNAL(chatLine(const QString&)), diff -r 0b357c57e01c -r 5123eac2f9d6 QTfrontend/net/newnetclient.cpp --- a/QTfrontend/net/newnetclient.cpp Thu Jan 17 18:12:30 2013 +0100 +++ b/QTfrontend/net/newnetclient.cpp Thu Jan 17 23:17:39 2013 +0400 @@ -926,6 +926,11 @@ } } +void HWNewNet::consoleCommand(const QString & cmd) +{ + RawSendNet(QString("CMD%1%2").arg(delimeter).arg(cmd)); +} + void HWNewNet::startGame() { RawSendNet(QString("START_GAME")); diff -r 0b357c57e01c -r 5123eac2f9d6 QTfrontend/net/newnetclient.h --- a/QTfrontend/net/newnetclient.h Thu Jan 17 18:12:30 2013 +0100 +++ b/QTfrontend/net/newnetclient.h Thu Jan 17 23:17:39 2013 +0400 @@ -155,6 +155,7 @@ void kickPlayer(const QString &); void infoPlayer(const QString &); void followPlayer(const QString &); + void consoleCommand(const QString &); void startGame(); void toggleRestrictJoins(); void toggleRestrictTeamAdds(); diff -r 0b357c57e01c -r 5123eac2f9d6 QTfrontend/ui/widget/chatwidget.cpp --- a/QTfrontend/ui/widget/chatwidget.cpp Thu Jan 17 18:12:30 2013 +0100 +++ b/QTfrontend/ui/widget/chatwidget.cpp Thu Jan 17 23:17:39 2013 +0400 @@ -798,11 +798,7 @@ else if (tline == "/saveStyleSheet") saveStyleSheet(); else - { - static QRegExp post("\\s.*$"); - tline.remove(post); - displayWarning(tr("%1 is not a valid command!").arg(tline)); - } + emit consoleCommand(tline.mid(1)); return true; } diff -r 0b357c57e01c -r 5123eac2f9d6 QTfrontend/ui/widget/chatwidget.h --- a/QTfrontend/ui/widget/chatwidget.h Thu Jan 17 18:12:30 2013 +0100 +++ b/QTfrontend/ui/widget/chatwidget.h Thu Jan 17 23:17:39 2013 +0400 @@ -100,6 +100,7 @@ void info(const QString & str); void follow(const QString &); void nickCountUpdate(int cnt); + void consoleCommand(const QString & command); private: bool m_isAdmin; diff -r 0b357c57e01c -r 5123eac2f9d6 gameServer/Actions.hs --- a/gameServer/Actions.hs Thu Jan 17 18:12:30 2013 +0100 +++ b/gameServer/Actions.hs Thu Jan 17 23:17:39 2013 +0400 @@ -459,7 +459,7 @@ isBanned = do processAction $ CheckBanned False liftM B.null $ client's nick - checkerLogin p False = processAction $ ByeClient "No checker rights" + checkerLogin _ False = processAction $ ByeClient "No checker rights" checkerLogin p True = do wp <- client's webPassword processAction $ diff -r 0b357c57e01c -r 5123eac2f9d6 gameServer/HWProtoCore.hs --- a/gameServer/HWProtoCore.hs Thu Jan 17 18:12:30 2013 +0100 +++ b/gameServer/HWProtoCore.hs Thu Jan 17 23:17:39 2013 +0400 @@ -4,6 +4,7 @@ import Control.Monad.Reader import Data.Maybe import qualified Data.ByteString.Char8 as B +import qualified Data.List as L -------------------------------------- import CoreTypes import Actions @@ -32,6 +33,16 @@ else return [ModifyClient (\c -> c{pingsQueue = pingsQueue c - 1})] +handleCmd ("CMD" : params) = + let c = concatMap B.words params in + if not $ null c then + h $ (upperCase . head $ c) : tail c + else + return [] + where + h ["DELEGATE", n] = handleCmd ["DELEGATE", n] + h c = return [Warning . B.concat . L.intersperse " " $ "Unknown cmd" : c] + handleCmd cmd = do (ci, irnc) <- ask if logonPassed (irnc `client` ci) then diff -r 0b357c57e01c -r 5123eac2f9d6 gameServer/Utils.hs --- a/gameServer/Utils.hs Thu Jan 17 18:12:30 2013 +0100 +++ b/gameServer/Utils.hs Thu Jan 17 23:17:39 2013 +0400 @@ -118,10 +118,10 @@ cutHost = B.intercalate "." . flip (++) ["*","*"] . List.take 2 . B.split '.' caseInsensitiveCompare :: B.ByteString -> B.ByteString -> Bool -caseInsensitiveCompare a b = f a == f b - where - f = map Char.toUpper . UTF8.toString +caseInsensitiveCompare a b = upperCase a == upperCase b +upperCase :: B.ByteString -> B.ByteString +upperCase = UTF8.fromString . map Char.toUpper . UTF8.toString roomInfo :: B.ByteString -> RoomInfo -> [B.ByteString] roomInfo n r = [ diff -r 0b357c57e01c -r 5123eac2f9d6 project_files/hedgewars.pro --- a/project_files/hedgewars.pro Thu Jan 17 18:12:30 2013 +0100 +++ b/project_files/hedgewars.pro Thu Jan 17 23:17:39 2013 +0400 @@ -92,7 +92,6 @@ ../QTfrontend/hwconsts.h \ ../QTfrontend/sdlkeys.h \ ../QTfrontend/ui/mouseoverfilter.h \ - ../QTfrontend/ui/qpushbuttonwithsound.h \ ../QTfrontend/ui/widget/qpushbuttonwithsound.h \ ../QTfrontend/ui/page/pagefeedback.h \ ../QTfrontend/model/roomslistmodel.h \