--- a/QTfrontend/hwform.cpp Sat Apr 03 08:46:01 2010 +0000
+++ b/QTfrontend/hwform.cpp Sat Apr 03 08:47:06 2010 +0000
@@ -744,8 +744,13 @@
ui.pageNetGame->pNetTeamsWidget, SLOT(changeTeamColor(const HWTeam&)));
// 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 &)));
+ connect(hwnet, SIGNAL(serverMessageNew(const QString&)), ui.pageAdmin, SLOT(serverMessageNew(const QString &)));
+ connect(hwnet, SIGNAL(serverMessageOld(const QString&)), ui.pageAdmin, SLOT(serverMessageOld(const QString &)));
+ connect(hwnet, SIGNAL(latestProtocolVar(int)), ui.pageAdmin, SLOT(protocol(int)));
+ connect(ui.pageAdmin, SIGNAL(setServerMessageNew(const QString&)), hwnet, SLOT(setServerMessageNew(const QString &)));
+ connect(ui.pageAdmin, SIGNAL(setServerMessageOld(const QString&)), hwnet, SLOT(setServerMessageOld(const QString &)));
+ connect(ui.pageAdmin, SIGNAL(setProtocol(int)), hwnet, SLOT(setLatestProtocolVar(int)));
+ connect(ui.pageAdmin, SIGNAL(askServerVars()), hwnet, SLOT(askServerVars()));
connect(ui.pageAdmin->pbClearAccountsCache, SIGNAL(clicked()), hwnet, SLOT(clearAccountsCache()));
// disconnect
--- a/QTfrontend/newnetclient.cpp Sat Apr 03 08:46:01 2010 +0000
+++ b/QTfrontend/newnetclient.cpp Sat Apr 03 08:47:06 2010 +0000
@@ -153,7 +153,7 @@
void HWNewNet::RawSendNet(const QByteArray & buf)
{
-// qDebug() << "Client: " << QString(buf).split("\n");
+ //qDebug() << "Client: " << QString(buf).split("\n");
NetSocket.write(buf);
NetSocket.write("\n\n", 2);
}
@@ -202,7 +202,7 @@
void HWNewNet::ParseCmd(const QStringList & lst)
{
-// qDebug() << "Server: " << lst;
+ //qDebug() << "Server: " << lst;
if(!lst.size())
{
@@ -297,6 +297,21 @@
return;
}
+ if (lst[0] == "SERVER_VARS") {
+ QStringList tmp = lst;
+ tmp.removeFirst();
+ while (tmp.size() >= 2)
+ {
+ if(tmp[0] == "MOTD_NEW") emit serverMessageNew(tmp[1]);
+ else if(tmp[0] == "MOTD_OLD") emit serverMessageOld(tmp[1]);
+ else if(tmp[0] == "LATEST_PROTO") emit latestProtocolVar(tmp[1].toInt());
+
+ tmp.removeFirst();
+ tmp.removeFirst();
+ }
+ return;
+ }
+
if (lst[0] == "READY") {
if(lst.size() < 2)
{
@@ -718,7 +733,22 @@
return netClientState > 2;
}
-void HWNewNet::newServerMessage(const QString & msg)
+void HWNewNet::setServerMessageNew(const QString & msg)
+{
+ RawSendNet(QString("SET_SERVER_VAR%1MOTD_NEW%1%2").arg(delimeter).arg(msg));
+}
+
+void HWNewNet::setServerMessageOld(const QString & msg)
{
- RawSendNet(QString("SET_SERVER_MESSAGE%1%2").arg(delimeter).arg(msg));
+ RawSendNet(QString("SET_SERVER_VAR%1MOTD_OLD%1%2").arg(delimeter).arg(msg));
}
+
+void HWNewNet::setLatestProtocolVar(int proto)
+{
+ RawSendNet(QString("SET_SERVER_VAR%1LATEST_PROTO%1%2").arg(delimeter).arg(proto));
+}
+
+void HWNewNet::askServerVars()
+{
+ RawSendNet(QString("GET_SERVER_VAR"));
+}
\ No newline at end of file
--- a/QTfrontend/newnetclient.h Sat Apr 03 08:46:01 2010 +0000
+++ b/QTfrontend/newnetclient.h Sat Apr 03 08:47:06 2010 +0000
@@ -118,6 +118,9 @@
void roomsList(const QStringList&);
void serverMessage(const QString &);
+ void serverMessageNew(const QString &);
+ void serverMessageOld(const QString &);
+ void latestProtocolVar(int);
void setReadyStatus(const QString & nick, bool isReady);
void setMyReadyStatus(bool isReady);
@@ -135,8 +138,10 @@
void onTeamColorChanged(const HWTeam& team);
void onParamChanged(const QString & param, const QStringList & value);
- void newServerMessage(const QString &);
-
+ void setServerMessageNew(const QString &);
+ void setServerMessageOld(const QString &);
+ void setLatestProtocolVar(int proto);
+ void askServerVars();
void JoinRoom(const QString & room);
void CreateRoom(const QString & room);
--- a/QTfrontend/pages.cpp Sat Apr 03 08:46:01 2010 +0000
+++ b/QTfrontend/pages.cpp Sat Apr 03 08:47:06 2010 +0000
@@ -1459,29 +1459,75 @@
{
QGridLayout * pageLayout = new QGridLayout(this);
- QLabel * lblSM = new QLabel(this);
- lblSM->setText(tr("Server message:"));
- pageLayout->addWidget(lblSM, 0, 0);
+ // 0
+ pbAsk = addButton(tr("Fetch data"), pageLayout, 0, 0, 1, 3);
+ connect(pbAsk, SIGNAL(clicked()), this, SIGNAL(askServerVars()));
+
+ // 1
+ QLabel * lblSMN = new QLabel(this);
+ lblSMN->setText(tr("Server message for latest version:"));
+ pageLayout->addWidget(lblSMN, 1, 0);
+
+ leServerMessageNew = new QLineEdit(this);
+ pageLayout->addWidget(leServerMessageNew, 1, 1);
+
+ // 2
+ QLabel * lblSMO = new QLabel(this);
+ lblSMO->setText(tr("Server message for previous versions:"));
+ pageLayout->addWidget(lblSMO, 2, 0);
+
+ leServerMessageOld = new QLineEdit(this);
+ pageLayout->addWidget(leServerMessageOld, 2, 1);
- leServerMessage = new QLineEdit(this);
- pageLayout->addWidget(leServerMessage, 0, 1);
+ // 3
+ QLabel * lblP = new QLabel(this);
+ lblP->setText(tr("Latest version protocol number:"));
+ pageLayout->addWidget(lblP, 3, 0);
+
+ sbProtocol = new QSpinBox(this);
+ pageLayout->addWidget(sbProtocol, 3, 1);
+
+ // 4
+ QLabel * lblPreview = new QLabel(this);
+ lblPreview->setText(tr("MOTD preview:"));
+ pageLayout->addWidget(lblPreview, 4, 0);
- pbSetSM = addButton(tr("Set message"), pageLayout, 0, 2);
- pbClearAccountsCache = addButton(tr("Clear Accounts Cache"), pageLayout, 1, 0);
+ tb = new QTextBrowser(this);
+ pageLayout->addWidget(tb, 4, 1, 1, 2);
+ connect(leServerMessageNew, SIGNAL(textEdited(const QString &)), tb, SLOT(setHtml(const QString &)));
+ connect(leServerMessageOld, SIGNAL(textEdited(const QString &)), tb, SLOT(setHtml(const QString &)));
+
+ // 5
+ pbClearAccountsCache = addButton(tr("Clear Accounts Cache"), pageLayout, 5, 0);
+
+ // 6
+ pbSetSM = addButton(tr("Set data"), pageLayout, 6, 0, 1, 3);
- BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true);
+ // 7
+ BtnBack = addButton(":/res/Exit.png", pageLayout, 7, 0, true);
connect(pbSetSM, SIGNAL(clicked()), this, SLOT(smChanged()));
}
void PageAdmin::smChanged()
{
- emit setServerMessage(leServerMessage->text());
+ emit setServerMessageNew(leServerMessageNew->text());
+ emit setServerMessageOld(leServerMessageOld->text());
+ emit setProtocol(sbProtocol->value());
}
-void PageAdmin::serverMessage(const QString & str)
+void PageAdmin::serverMessageNew(const QString & str)
{
- leServerMessage->setText(str);
+ leServerMessageNew->setText(str);
+}
+
+void PageAdmin::serverMessageOld(const QString & str)
+{
+ leServerMessageOld->setText(str);
+}
+void PageAdmin::protocol(int proto)
+{
+ sbProtocol->setValue(proto);
}
/////////////////////////////////////////////////
--- a/QTfrontend/pages.h Sat Apr 03 08:46:01 2010 +0000
+++ b/QTfrontend/pages.h Sat Apr 03 08:47:06 2010 +0000
@@ -479,17 +479,26 @@
QPushButton * pbClearAccountsCache;
private:
- QLineEdit * leServerMessage;
+ QLineEdit * leServerMessageNew;
+ QLineEdit * leServerMessageOld;
QPushButton * pbSetSM;
+ QPushButton * pbAsk;
+ QSpinBox * sbProtocol;
+ QTextBrowser * tb;
private slots:
void smChanged();
public slots:
- void serverMessage(const QString & str);
+ void serverMessageNew(const QString & str);
+ void serverMessageOld(const QString & str);
+ void protocol(int proto);
signals:
- void setServerMessage(const QString & str);
+ void setServerMessageNew(const QString & str);
+ void setServerMessageOld(const QString & str);
+ void setProtocol(int proto);
+ void askServerVars();
};
--- a/gameServer/Actions.hs Sat Apr 03 08:46:01 2010 +0000
+++ b/gameServer/Actions.hs Sat Apr 03 08:47:06 2010 +0000
@@ -22,6 +22,7 @@
| AnswerSameClan [String]
| AnswerLobby [String]
| SendServerMessage
+ | SendServerVars
| RoomAddThisClient Int -- roomID
| RoomRemoveThisClient String
| RemoveTeam String
@@ -118,10 +119,21 @@
return (clID, serverInfo, clients, rooms)
where
client = clients ! clID
- message = if clientProto client < 29 then
- serverMessageForOldVersions
+ message si = if clientProto client < latestReleaseVersion si then
+ serverMessageForOldVersions si
else
- serverMessage
+ serverMessage si
+
+processAction (clID, serverInfo, clients, rooms) SendServerVars = do
+ writeChan (sendChan $ clients ! clID) ("SERVER_VARS" : vars)
+ return (clID, serverInfo, clients, rooms)
+ where
+ client = clients ! clID
+ vars = [
+ "MOTD_NEW", serverMessage serverInfo,
+ "MOTD_OLD", serverMessageForOldVersions serverInfo,
+ "LATEST_PROTO", show $ latestReleaseVersion serverInfo
+ ]
processAction (clID, serverInfo, clients, rooms) (ProtocolError msg) = do
--- a/gameServer/CoreTypes.hs Sat Apr 03 08:46:01 2010 +0000
+++ b/gameServer/CoreTypes.hs Sat Apr 03 08:47:06 2010 +0000
@@ -150,8 +150,8 @@
True
"<h2><p align=center><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p></h2>"
"<font color=yellow><h3>Hedgewars 0.9.12 is out! Please update.</h3><p align=center><a href=http://hedgewars.org/download.html>Download page here</a></font>"
+ 31
46631
- 30
0
""
""
--- a/gameServer/HWProtoLobbyState.hs Sat Apr 03 08:46:01 2010 +0000
+++ b/gameServer/HWProtoLobbyState.hs Sat Apr 03 08:47:06 2010 +0000
@@ -153,22 +153,29 @@
client = clients IntMap.! clID
-handleCmd_lobby clID clients rooms ["SET_SERVER_MESSAGE", "NEW", newMessage] =
+
+handleCmd_lobby clID clients rooms ["SET_SERVER_VAR", "MOTD_NEW", newMessage] =
[ModifyServerInfo (\si -> si{serverMessage = newMessage}) | isAdministrator client]
where
client = clients IntMap.! clID
-handleCmd_lobby clID clients rooms ["SET_SERVER_MESSAGE", "OLD", newMessage] =
+handleCmd_lobby clID clients rooms ["SET_SERVER_VAR", "MOTD_OLD", newMessage] =
[ModifyServerInfo (\si -> si{serverMessageForOldVersions = newMessage}) | isAdministrator client]
where
client = clients IntMap.! clID
-handleCmd_lobby clID clients rooms ["SET_RELEASE_PROTOCOL_NUMBER", protoNum] =
+handleCmd_lobby clID clients rooms ["SET_SERVER_VAR", "LATEST_PROTO", protoNum] =
[ModifyServerInfo (\si -> si{latestReleaseVersion = fromJust readNum}) | isAdministrator client && isJust readNum]
where
client = clients IntMap.! clID
readNum = maybeRead protoNum :: Maybe Word16
+handleCmd_lobby clID clients rooms ["GET_SERVER_VAR"] =
+ [SendServerVars | isAdministrator client]
+ where
+ client = clients IntMap.! clID
+
+
handleCmd_lobby clID clients rooms ["CLEAR_ACCOUNTS_CACHE"] =
[ClearAccountsCache | isAdministrator client]
where