# HG changeset patch # User displacer # Date 1165612492 0 # Node ID afa378f1e961fb1a17835de24d77597548dc86a8 # Parent 09738170c557041433278dfbbdf1202c4102e915 automatic assign of game server TCP port diff -r 09738170c557 -r afa378f1e961 QTfrontend/game.cpp --- a/QTfrontend/game.cpp Thu Dec 07 21:24:58 2006 +0000 +++ b/QTfrontend/game.cpp Fri Dec 08 21:14:52 2006 +0000 @@ -189,7 +189,7 @@ arguments << resolutions[0][config->vid_Resolution()]; arguments << resolutions[1][config->vid_Resolution()]; arguments << "16"; - arguments << "46631"; + arguments << QString("%1").arg(ipc_port); arguments << (config->vid_Fullscreen() ? "1" : "0"); arguments << (config->isSoundEnabled() ? "1" : "0"); arguments << tr("en.txt"); diff -r 09738170c557 -r afa378f1e961 QTfrontend/hwmap.cpp --- a/QTfrontend/hwmap.cpp Thu Dec 07 21:24:58 2006 +0000 +++ b/QTfrontend/hwmap.cpp Fri Dec 08 21:14:52 2006 +0000 @@ -35,7 +35,7 @@ QStringList HWMap::setArguments() { QStringList arguments; - arguments << "46631"; + arguments << QString("%1").arg(ipc_port); arguments << "landpreview"; return arguments; } diff -r 09738170c557 -r afa378f1e961 QTfrontend/tcpBase.cpp --- a/QTfrontend/tcpBase.cpp Thu Dec 07 21:24:58 2006 +0000 +++ b/QTfrontend/tcpBase.cpp Fri Dec 08 21:14:52 2006 +0000 @@ -35,12 +35,14 @@ if(!IPCServer) { IPCServer = new QTcpServer(this); IPCServer->setMaxPendingConnections(1); - if (!IPCServer->listen(QHostAddress::LocalHost, IPC_PORT)) { + if (!IPCServer->listen(QHostAddress::LocalHost)) { QMessageBox::critical(0, tr("Error"), tr("Unable to start the server: %1.") .arg(IPCServer->errorString())); + exit(0); // FIXME - should be graceful exit here } } + ipc_port=IPCServer->serverPort(); } void TCPBase::NewConnection() diff -r 09738170c557 -r afa378f1e961 QTfrontend/tcpBase.h --- a/QTfrontend/tcpBase.h Thu Dec 07 21:24:58 2006 +0000 +++ b/QTfrontend/tcpBase.h Fri Dec 08 21:14:52 2006 +0000 @@ -29,7 +29,6 @@ #include -#define IPC_PORT 46631 #define MAXMSGCHARS 255 class TCPBase : public QObject @@ -43,6 +42,8 @@ void isReadyNow(); protected: + quint16 ipc_port; + void Start(); QByteArray readbuffer;