--- a/QTfrontend/CMakeLists.txt Mon Oct 06 18:40:47 2008 +0000
+++ b/QTfrontend/CMakeLists.txt Mon Oct 06 19:01:59 2008 +0000
@@ -66,8 +66,6 @@
newnetclient.cpp
netudpserver.cpp
netudpwidget.cpp
- netwwwserver.cpp
- netwwwwidget.cpp
netregister.cpp
netserverslist.cpp
chatwidget.cpp
@@ -116,8 +114,6 @@
newnetclient.h
netudpserver.h
netudpwidget.h
- netwwwserver.h
- netwwwwidget.h
netregister.h
netserverslist.h
chatwidget.h
--- a/QTfrontend/hedgewars.pro Mon Oct 06 18:40:47 2008 +0000
+++ b/QTfrontend/hedgewars.pro Mon Oct 06 19:01:59 2008 +0000
@@ -38,7 +38,6 @@
newnetclient.h \
netudpserver.h \
netudpwidget.h \
- netwwwwidget.h \
netserverslist.h \
chatwidget.h \
SDLs.h \
@@ -74,7 +73,6 @@
newnetclient.cpp \
netudpserver.cpp \
netudpwidget.cpp \
- netwwwwidget.cpp \
netserverslist.cpp \
chatwidget.cpp \
SDLs.cpp \
--- a/QTfrontend/hwform.cpp Mon Oct 06 18:40:47 2008 +0000
+++ b/QTfrontend/hwform.cpp Mon Oct 06 19:01:59 2008 +0000
@@ -41,7 +41,6 @@
#include "gamecfgwidget.h"
#include "netserverslist.h"
#include "netudpserver.h"
-#include "netwwwserver.h"
#include "chatwidget.h"
#include "playrecordpage.h"
#include "input_ip.h"
@@ -480,10 +479,7 @@
_NetConnect("localhost", pnetserver->getRunningPort(), ui.pageOptions->editNetNick->text());
- if (ui.pageNet->rbLocalGame->isChecked())
- pRegisterServer = new HWNetUdpServer(0, ui.pageNetServer->leServerDescr->text(), ui.pageNetServer->sbPort->value());
- else
- pRegisterServer = new HWNetWwwServer(0, ui.pageNetServer->leServerDescr->text(), ui.pageNetServer->sbPort->value());
+ pRegisterServer = new HWNetUdpServer(0, ui.pageNetServer->leServerDescr->text(), ui.pageNetServer->sbPort->value());
}
void HWForm::NetDisconnect()
--- a/QTfrontend/netwwwserver.cpp Mon Oct 06 18:40:47 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2007, 2008 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <QHttp>
-#include <QMessageBox>
-#include <QTimer>
-#include <QStringList>
-#include "netwwwserver.h"
-#include "hwconsts.h"
-
-HWNetWwwServer::HWNetWwwServer(QObject *parent, const QString & descr, quint16 port) :
- HWNetRegisterServer(parent, descr, port), timer(0)
-{
- destroyPosted = false;
- destroyPostId = 0;
-
- http = new QHttp(this);
- http->setHost("www.hedgewars.org", 80);
- connect(http, SIGNAL(requestFinished(int, bool)), this, SLOT(onClientRead(int, bool)));
-
- QString request = QString("game[title]=%1&game[port]=%2&game[password]=%3&game[protocol_version]=%4")
- .arg(descr)
- .arg(port)
- .arg(false ? "true" : "false")
- .arg(*cProtoVer);
- http->post("/games/create", request.toUtf8());
-}
-
-void HWNetWwwServer::onClientRead(int id, bool error)
-{
- if (destroyPosted && (id == destroyPostId))
- {
- deleteLater();
- return;
- }
-
- if (error)
- {
- QMessageBox::critical(0,
- tr("Error"),
- tr("Server registration error") + "\n" +
- http->errorString());
- return;
- }
-
- QString str = http->readAll();
-
- if (!str.size()) return; // ??
-
- if (str[1] == QChar('0')) return; // error on server
- if (!timer)
- {
- QStringList sl = str.split(',');
- if (sl.size() != 2) return;
- servid = sl[0];
- servkey = sl[1];
-
- timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(updateInList()));
- timer->start(60000);
- }
-}
-
-void HWNetWwwServer::updateInList()
-{
- QString request = QString("id=%1&key=%2")
- .arg(servid)
- .arg(servkey);
- http->post("/games/update_game", request.toUtf8());
-}
-
-void HWNetWwwServer::unregister()
-{
- QString request = QString("id=%1&key=%2")
- .arg(servid)
- .arg(servkey);
- destroyPostId = http->post("/games/destroy_game", request.toUtf8());
- destroyPosted = true;
-}
--- a/QTfrontend/netwwwserver.h Mon Oct 06 18:40:47 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2007, 2008 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#ifndef _NET_WWWSERVER_INCLUDED
-#define _NET_WWWSERVER_INCLUDED
-
-#include <QObject>
-#include "netregister.h"
-
-class QHttp;
-class QTimer;
-
-class HWNetWwwServer : public HWNetRegisterServer
-{
- Q_OBJECT
-
-public:
- HWNetWwwServer(QObject *parent, const QString & descr, quint16 port);
-
-public slots:
- void unregister();
-
-private slots:
- void onClientRead(int id, bool error);
- void updateInList();
-
-private:
- QHttp * http;
- QTimer * timer;
- QString servid, servkey;
- bool destroyPosted;
- int destroyPostId;
-};
-
-#endif // _NET_WWWSERVER_INCLUDED
--- a/QTfrontend/netwwwwidget.cpp Mon Oct 06 18:40:47 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2007, 2008 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <QHttp>
-#include <QDomDocument>
-#include <QDomElement>
-#include <QDomNode>
-#include <QDomText>
-#include <QDebug>
-
-#include "netwwwwidget.h"
-#include "hwconsts.h"
-
-
-HWNetWwwModel::HWNetWwwModel(QObject *parent) : HWNetServersModel(parent)
-{
- http = new QHttp(this);
- http->setHost("www.hedgewars.org", 80);
- connect(http, SIGNAL(requestFinished(int, bool)), this, SLOT(onClientRead(int, bool)));
-}
-
-QVariant HWNetWwwModel::data(const QModelIndex &index,
- int role) const
-{
- if (!index.isValid() || index.row() < 0
- || index.row() >= games.size()
- || role != Qt::DisplayRole)
- return QVariant();
-
- return games[index.row()][index.column()];
-}
-
-void HWNetWwwModel::updateList()
-{
- QString request = QString("protocol_version=%1")
- .arg(*cProtoVer);
- http->post("/games/list_games", request.toUtf8());
-
- games.clear();
-
- reset();
-}
-
-void HWNetWwwModel::onClientRead(int id, bool error)
-{
- if (error)
- {
- qWarning() << "Error" << http->errorString();
- return;
- }
- games.clear();
-
- QDomDocument doc;
- if (!doc.setContent(http->readAll())) return;
-
- QDomElement docElem = doc.documentElement();
-
- QDomNode n = docElem.firstChild();
- while (!n.isNull())
- {
- QDomElement game = n.toElement(); // try to convert the node to an element.
-
- if(!game.isNull())
- {
- QDomNode p = game.firstChild();
- QStringList sl;
- sl << "-" << "-" << "-";
- while (!p.isNull())
- {
- QDomElement e = p.toElement();
-
- if(!p.isNull())
- {
- int i = -1;
- if (e.tagName() == "title") i = 0;
- else if (e.tagName() == "ip") i = 1;
- else if (e.tagName() == "port") i = 2;
-
- QDomText t = e.firstChild().toText();
- if(!t.isNull() && (i >= 0))
- sl[i] = t.data();
- }
- p = p.nextSibling();
- }
- games.append(sl);
- }
- n = n.nextSibling();
- }
-
- reset();
-}
--- a/QTfrontend/netwwwwidget.h Mon Oct 06 18:40:47 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2007, 2008 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#ifndef _NET_WWWWIDGET_INCLUDED
-#define _NET_WWWWIDGET_INCLUDED
-
-#include "netserverslist.h"
-
-class QHttp;
-
-class HWNetWwwModel : public HWNetServersModel
-{
- Q_OBJECT
-
-public:
- HWNetWwwModel(QObject *parent = 0);
-
- QVariant data(const QModelIndex &index, int role) const;
-
-private:
- QHttp * http;
-
-private slots:
- void onClientRead(int id, bool error);
-
-public slots:
- void updateList();
-};
-
-#endif // _NET_WWWWIDGET_INCLUDED
--- a/QTfrontend/newnetclient.cpp Mon Oct 06 18:40:47 2008 +0000
+++ b/QTfrontend/newnetclient.cpp Mon Oct 06 19:01:59 2008 +0000
@@ -129,10 +129,10 @@
void HWNewNet::OnConnect()
{
- RawSendNet(QString("NICK%1%2").arg(delimeter).arg(mynick));
- RawSendNet(QString("PROTO%1%2").arg(delimeter).arg(*cProtoVer));
- RawSendNet(QString("CREATE%1%2").arg(delimeter).arg("myroom"));
- RawSendNet(QString("JOIN%1%2").arg(delimeter).arg("myroom"));
+ RawSendNet(QString("NICK%1%2").arg(delimeter).arg(mynick));
+ RawSendNet(QString("PROTO%1%2").arg(delimeter).arg(*cProtoVer));
+ RawSendNet(QString("CREATE%1%2").arg(delimeter).arg("myroom"));
+ RawSendNet(QString("JOIN%1%2").arg(delimeter).arg("myroom"));
}
void HWNewNet::OnDisconnect()
@@ -248,21 +248,21 @@
return;
}
- if(lst[0]=="LEFT") {
- if(lst.size() < 2)
- {
- qWarning("Net: Bad LEFT message");
- return;
- }
- emit nickRemoved(lst[1]);
- return;
- }
+ if(lst[0]=="LEFT") {
+ if(lst.size() < 2)
+ {
+ qWarning("Net: Bad LEFT message");
+ return;
+ }
+ emit nickRemoved(lst[1]);
+ return;
+ }
- if (lst[0] == "CONFIGASKED") {
- isChief=true;
- ConfigAsked();
- return;
- }
+ if (lst[0] == "CONFIGASKED") { // клиент знает CREATE он делал или JOIN
+ isChief=true;
+ ConfigAsked();
+ return;
+ }
if (lst[0] == "RUNGAME") {
RunGame();
@@ -358,10 +358,10 @@
// should be kinda game states, which don't allow "GAMEMSG:" at configure step,
// "CONNECTED" at round phase, etc.
- if (lst[0] == "GAMEMSG:") {
+ if (lst[0] == "GAMEMSG") {
if(lst.size() < 2)
{
- qWarning("Net: Bad LEFT message");
+ qWarning("Net: Bad GAMEMSG message");
return;
}
QByteArray em = QByteArray::fromBase64(lst[1].toAscii());
@@ -375,22 +375,22 @@
void HWNewNet::ConfigAsked()
{
- QString map = m_pGameCFGWidget->getCurrentMap();
- if (map.size())
- onMapChanged(map);
+ QString map = m_pGameCFGWidget->getCurrentMap();
+ if (map.size())
+ onMapChanged(map);
- onSeedChanged(m_pGameCFGWidget->getCurrentSeed());
- onThemeChanged(m_pGameCFGWidget->getCurrentTheme());
- onInitHealthChanged(m_pGameCFGWidget->getInitHealth());
- onTurnTimeChanged(m_pGameCFGWidget->getTurnTime());
- onFortsModeChanged(m_pGameCFGWidget->getGameFlags() & 0x1);
- // always initialize with default ammo (also avoiding complicated cross-class dependencies)
- onWeaponsNameChanged("Default", cDefaultAmmoStore->mid(10));
+ onSeedChanged(m_pGameCFGWidget->getCurrentSeed());
+ onThemeChanged(m_pGameCFGWidget->getCurrentTheme());
+ onInitHealthChanged(m_pGameCFGWidget->getInitHealth());
+ onTurnTimeChanged(m_pGameCFGWidget->getTurnTime());
+ onFortsModeChanged(m_pGameCFGWidget->getGameFlags() & 0x1);
+ // always initialize with default ammo (also avoiding complicated cross-class dependencies)
+ onWeaponsNameChanged("Default", cDefaultAmmoStore->mid(10));
}
void HWNewNet::RunGame()
{
- emit AskForRunGame();
+ emit AskForRunGame();
}
void HWNewNet::onHedgehogsNumChanged(const HWTeam& team)
--- a/QTfrontend/pages.cpp Mon Oct 06 18:40:47 2008 +0000
+++ b/QTfrontend/pages.cpp Mon Oct 06 19:01:59 2008 +0000
@@ -46,7 +46,6 @@
#include "fpsedit.h"
#include "netserverslist.h"
#include "netudpwidget.h"
-#include "netwwwwidget.h"
#include "chatwidget.h"
#include "playrecordpage.h"
#include "selectWeapon.h"
@@ -384,20 +383,6 @@
BtnNetSvrStart->setText(QPushButton::tr("Start server"));
pageLayout->addWidget(BtnNetSvrStart, 3, 2);
- QGroupBox * NetTypeGroupBox = new QGroupBox(this);
- NetTypeGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
- NetTypeGroupBox->setTitle(QGroupBox::tr("Servers list"));
- pageLayout->addWidget(NetTypeGroupBox, 0, 1);
-
- QVBoxLayout * GBTlayout = new QVBoxLayout(NetTypeGroupBox);
- rbLocalGame = new QRadioButton(NetTypeGroupBox);
- rbLocalGame->setText(tr("Local"));
- rbLocalGame->setChecked(true);
- GBTlayout->addWidget(rbLocalGame);
- rbInternetGame = new QRadioButton(NetTypeGroupBox);
- rbInternetGame->setText(tr("Internet"));
- GBTlayout->addWidget(rbInternetGame);
-
ConnGroupBox = new QGroupBox(this);
ConnGroupBox->setTitle(QGroupBox::tr("Net game"));
pageLayout->addWidget(ConnGroupBox, 2, 0, 1, 3);
@@ -427,16 +412,12 @@
BtnBack = addButton(":/res/Exit.png", pageLayout, 3, 0, true);
- connect(rbLocalGame, SIGNAL(toggled(bool)), this, SLOT(updateServersList()));
connect(BtnNetConnect, SIGNAL(clicked()), this, SLOT(slotConnect()));
}
void PageNet::updateServersList()
{
- if (rbLocalGame->isChecked())
- tvServersList->setModel(new HWNetUdpModel(tvServersList));
- else
- tvServersList->setModel(new HWNetWwwModel(tvServersList));
+ tvServersList->setModel(new HWNetUdpModel(tvServersList));
tvServersList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
--- a/QTfrontend/pages.h Mon Oct 06 18:40:47 2008 +0000
+++ b/QTfrontend/pages.h Mon Oct 06 19:01:59 2008 +0000
@@ -215,8 +215,6 @@
QPushButton * BtnNetConnect;
QPushButton * BtnNetSvrStart;
QPushButton * BtnSpecifyServer;
- QRadioButton * rbLocalGame;
- QRadioButton * rbInternetGame;
private:
QGroupBox * ConnGroupBox;