# HG changeset patch # User unc0rr # Date 1238169534 0 # Node ID ec923e56c4447eff08b415dc1fb9a9ec9f072f77 # Parent 8f8fe856ce9d1148dcee388b6e54f7553ef96799 Allow admin to set server's motd diff -r 8f8fe856ce9d -r ec923e56c444 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Fri Mar 27 14:02:27 2009 +0000 +++ b/QTfrontend/hwform.cpp Fri Mar 27 15:58:54 2009 +0000 @@ -595,6 +595,7 @@ // admin stuff connect(hwnet, SIGNAL(serverMessage(const QString&)), ui.pageAdmin, SLOT(serverMessage(const QString &))); + connect(ui.pageAdmin, SIGNAL(setServerMessage(const QString&)), hwnet, SLOT(newServerMessage(const QString &))); // disconnect connect(hwnet, SIGNAL(Disconnected()), this, SLOT(ForcedDisconnect()), Qt::QueuedConnection); diff -r 8f8fe856ce9d -r ec923e56c444 QTfrontend/newnetclient.cpp --- a/QTfrontend/newnetclient.cpp Fri Mar 27 14:02:27 2009 +0000 +++ b/QTfrontend/newnetclient.cpp Fri Mar 27 15:58:54 2009 +0000 @@ -657,3 +657,8 @@ { return netClientState > 2; } + +void HWNewNet::newServerMessage(const QString & msg) +{ + RawSendNet(QString("SET_SERVER_MESSAGE%1%2").arg(delimeter).arg(msg)); +} diff -r 8f8fe856ce9d -r ec923e56c444 QTfrontend/newnetclient.h --- a/QTfrontend/newnetclient.h Fri Mar 27 14:02:27 2009 +0000 +++ b/QTfrontend/newnetclient.h Fri Mar 27 15:58:54 2009 +0000 @@ -130,6 +130,8 @@ void onHedgehogsNumChanged(const HWTeam& team); void onTeamColorChanged(const HWTeam& team); void onParamChanged(const QString & param, const QStringList & value); + + void newServerMessage(const QString &); void JoinRoom(const QString & room); diff -r 8f8fe856ce9d -r ec923e56c444 gameServer/Actions.hs --- a/gameServer/Actions.hs Fri Mar 27 14:02:27 2009 +0000 +++ b/gameServer/Actions.hs Fri Mar 27 15:58:54 2009 +0000 @@ -34,6 +34,7 @@ | RemoveClientTeams Int -- clID | ModifyClient (ClientInfo -> ClientInfo) | ModifyRoom (RoomInfo -> RoomInfo) + | ModifyServerInfo (ServerInfo -> ServerInfo) | AddRoom String String | CheckRegistered | ProcessAccountInfo AccountInfo @@ -150,6 +151,10 @@ rID = roomID $ clients ! clID +processAction (clID, serverInfo, clients, rooms) (ModifyServerInfo func) = do + return (clID, func serverInfo, clients, rooms) + + processAction (clID, serverInfo, clients, rooms) (RoomAddThisClient rID) = do processAction ( clID, diff -r 8f8fe856ce9d -r ec923e56c444 gameServer/HWProtoLobbyState.hs --- a/gameServer/HWProtoLobbyState.hs Fri Mar 27 14:02:27 2009 +0000 +++ b/gameServer/HWProtoLobbyState.hs Fri Mar 27 15:58:54 2009 +0000 @@ -137,4 +137,13 @@ client = clients IntMap.! clID +handleCmd_lobby clID clients rooms ["SET_SERVER_MESSAGE", newMessage] = + if not $ isAdministrator client then + [] + else + [ModifyServerInfo (\si -> si{serverMessage = newMessage})] + where + client = clients IntMap.! clID + + handleCmd_lobby clID _ _ _ = [ProtocolError "Incorrect command (state: in lobby)"]