# HG changeset patch # User unc0rr # Date 1270284426 0 # Node ID 18ee933a586432b131f38c077c466e2f12880595 # Parent 9ca28cef559a4d4149baac3be740d0d40e2fde23 Some stuff for game server administration task diff -r 9ca28cef559a -r 18ee933a5864 QTfrontend/hwform.cpp --- 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 diff -r 9ca28cef559a -r 18ee933a5864 QTfrontend/newnetclient.cpp --- 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 diff -r 9ca28cef559a -r 18ee933a5864 QTfrontend/newnetclient.h --- 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); diff -r 9ca28cef559a -r 18ee933a5864 QTfrontend/pages.cpp --- 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); } ///////////////////////////////////////////////// diff -r 9ca28cef559a -r 18ee933a5864 QTfrontend/pages.h --- 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(); }; diff -r 9ca28cef559a -r 18ee933a5864 gameServer/Actions.hs --- 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 diff -r 9ca28cef559a -r 18ee933a5864 gameServer/CoreTypes.hs --- 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 "
" "