Allow admin to set server's motd
authorunc0rr
Fri, 27 Mar 2009 15:58:54 +0000
changeset 1925 ec923e56c444
parent 1924 8f8fe856ce9d
child 1926 cb46fbdcaa41
Allow admin to set server's motd
QTfrontend/hwform.cpp
QTfrontend/newnetclient.cpp
QTfrontend/newnetclient.h
gameServer/Actions.hs
gameServer/HWProtoLobbyState.hs
--- 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);
--- 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));
+}
--- 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);
--- 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,
--- 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)"]