initial commit

This commit is contained in:
Max-Wilhelm Bruker 2009-03-13 22:50:41 +01:00
commit a11f93df4d
99 changed files with 7493 additions and 0 deletions

View file

@ -0,0 +1,21 @@
/***************************************************************************
* Copyright (C) 2008 by Max-Wilhelm Bruker *
* brukie@laptop *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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 "counter.h"

37
servatrice/src/counter.h Normal file
View file

@ -0,0 +1,37 @@
/***************************************************************************
* Copyright (C) 2008 by Max-Wilhelm Bruker *
* brukie@laptop *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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 COUNTER_H
#define COUNTER_H
#include <QString>
class Counter {
protected:
QString name;
int count;
public:
Counter(QString _name, int _count = 0) : name(_name), count(_count) { }
~Counter() { }
int getCount() { return count; }
void setCount(int _count) { count = _count; }
QString getName() const { return name; }
};
#endif

33
servatrice/src/main.cpp Normal file
View file

@ -0,0 +1,33 @@
/***************************************************************************
* Copyright (C) 2008 by Max-Wilhelm Bruker *
* brukie@laptop *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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 <QCoreApplication>
#include "testserver.h"
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
TestServer server;
server.listen(QHostAddress::Any, 4747);
return app.exec();
}

View file

@ -0,0 +1,86 @@
/***************************************************************************
* Copyright (C) 2008 by Max-Wilhelm Bruker *
* brukie@laptop *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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 "playerzone.h"
PlayerZone::PlayerZone(QString _name, bool _has_coords, bool _is_public, bool _id_access)
: name(_name), has_coords(_has_coords), is_public(_is_public), id_access(_id_access)
{
}
PlayerZone::~PlayerZone()
{
qDebug(QString("PlayerZone destructor: %1").arg(name).toLatin1());
clear();
}
void PlayerZone::shuffle(TestRandom *rnd)
{
QList<TestCard *> temp;
for (int i = cards.size(); i; i--)
temp.append(cards.takeAt(rnd->getNumber(0, i - 1)));
cards = temp;
}
TestCard *PlayerZone::getCard(int id, bool remove, int *position)
{
if (hasIdAccess()) {
QListIterator<TestCard *> CardIterator(cards);
int i = 0;
while (CardIterator.hasNext()) {
TestCard *tmp = CardIterator.next();
if (tmp->getId() == id) {
if (remove)
cards.removeAt(i);
if (position)
*position = i;
return tmp;
}
i++;
}
return NULL;
} else {
if (id >= cards.size())
return NULL;
TestCard *tmp = cards[id];
if (remove)
cards.removeAt(id);
if (position)
*position = id;
return tmp;
}
}
void PlayerZone::insertCard(TestCard *card, int x, int y)
{
if (hasCoords()) {
card->setCoords(x, y);
cards.append(card);
} else {
card->setCoords(0, 0);
cards.insert(x, card);
}
}
void PlayerZone::clear()
{
for (int i = 0; i < cards.size(); i++)
delete cards.at(i);
cards.clear();
}

View file

@ -0,0 +1,55 @@
/***************************************************************************
* Copyright (C) 2008 by Max-Wilhelm Bruker *
* brukie@laptop *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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 PLAYERZONE_H
#define PLAYERZONE_H
#include <QList>
#include "testcard.h"
#include "testrandom.h"
class PlayerZone {
private:
QString name;
bool has_coords;
bool is_public; // Contents of the zone are visible for anyone
bool id_access; // getCard() finds by id, not by list index
// Example: When moving a card from the library to the table,
// the card has to be found by list index because the client
// does not know the id. But when moving a card from the hand
// to the table, the card can be found by id because the client
// knows the id and the hand does not need to have a specific order.
public:
PlayerZone(QString _name, bool _has_coords, bool _is_public, bool _id_access);
~PlayerZone();
TestCard *getCard(int id, bool remove, int *position = NULL);
bool isPublic() { return is_public; }
bool hasCoords() { return has_coords; }
bool hasIdAccess() { return id_access; }
QString getName() { return name; }
QList<TestCard *> cards;
void insertCard(TestCard *card, int x, int y);
void shuffle(TestRandom *rnd);
void clear();
};
#endif

View file

@ -0,0 +1,33 @@
#include "returnmessage.h"
#include "testserversocket.h"
void ReturnMessage::setMsgId(unsigned int _msg_id)
{
msg_id = _msg_id;
}
bool ReturnMessage::send(const QString &args, bool success)
{
TestServerSocket *s = qobject_cast<TestServerSocket *>(parent());
if (!s)
return false;
s->msg(QString("resp|%1|%2|%3").arg(msg_id)
.arg(success ? "ok" : "err")
.arg(args));
return success;
}
bool ReturnMessage::sendList(const QStringList &args)
{
TestServerSocket *s = qobject_cast<TestServerSocket *>(parent());
if (!s)
return false;
for (int i = 0; i < args.size(); i++)
s->msg(QString("%1|%2|%3").arg(cmd)
.arg(msg_id)
.arg(args[i]));
s->msg(QString("%1|%2|.").arg(cmd).arg(msg_id));
return true;
}

View file

@ -0,0 +1,21 @@
#ifndef RETURNMESSAGE_H
#define RETURNMESSAGE_H
#include <QString>
#include <QObject>
class ReturnMessage : public QObject {
Q_OBJECT
private:
unsigned int msg_id;
QString cmd;
public:
ReturnMessage(QObject *parent = 0) : QObject(parent), msg_id(0) { }
unsigned int getMsgId() const { return msg_id; }
void setMsgId(unsigned int _msg_id);
void setCmd(const QString &_cmd) { cmd = _cmd; }
bool send(const QString &args = QString(), bool success = true);
bool sendList(const QStringList &args);
};
#endif

View file

@ -0,0 +1,62 @@
/***************************************************************************
* Copyright (C) 2008 by Max-Wilhelm Bruker *
* brukie@laptop *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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 "testcard.h"
TestCard::TestCard(QString _name, int _id, int _coord_x, int _coord_y)
: id(_id), coord_x(_coord_x), coord_y(_coord_y), name(_name), counters(0), tapped(false), attacking(false)
{
}
TestCard::~TestCard()
{
}
void TestCard::resetState()
{
setCoords(0, 0);
setCounters(0);
setTapped(false);
setAttacking(false);
setFaceDown(false);
setAnnotation("");
}
bool TestCard::setAttribute(const QString &aname, const QString &avalue)
{
if (!aname.compare("counters")) {
bool ok;
int tmp_int = avalue.toInt(&ok);
if (!ok)
return false;
setCounters(tmp_int);
} else if (!aname.compare("tapped")) {
setTapped(!avalue.compare("1"));
} else if (!aname.compare("attacking")) {
setAttacking(!avalue.compare("1"));
} else if (!aname.compare("facedown")) {
setFaceDown(!avalue.compare("1"));
} else if (!aname.compare("annotation")) {
setAnnotation(avalue);
} else
return false;
return true;
}

63
servatrice/src/testcard.h Normal file
View file

@ -0,0 +1,63 @@
/***************************************************************************
* Copyright (C) 2008 by Max-Wilhelm Bruker *
* brukie@laptop *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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 TESTCARD_H
#define TESTCARD_H
#include <QString>
/**
@author Max-Wilhelm Bruker <brukie@laptop>
*/
class TestCard {
private:
int id;
int coord_x, coord_y;
QString name;
int counters;
bool tapped;
bool attacking;
bool facedown;
QString annotation;
public:
TestCard(QString _name, int _id, int _coord_x, int _coord_y);
~TestCard();
int getId() { return id; }
int getX() { return coord_x; }
int getY() { return coord_y; }
QString getName() { return name; }
int getCounters() { return counters; }
bool getTapped() { return tapped; }
bool getAttacking() { return attacking; }
bool getFaceDown() { return facedown; }
QString getAnnotation() { return annotation; }
void setCoords(int x, int y) { coord_x = x; coord_y = y; }
void setName(const QString &_name) { name = _name; }
void setCounters(int _counters) { counters = _counters; }
void setTapped(bool _tapped) { tapped = _tapped; }
void setAttacking(bool _attacking) { attacking = _attacking; }
void setFaceDown(bool _facedown) { facedown = _facedown; }
void setAnnotation(const QString &_annotation) { annotation = _annotation; }
void resetState();
bool setAttribute(const QString &aname, const QString &avalue);
};
#endif

View file

@ -0,0 +1,18 @@
#include "testrandom.h"
#include <QThread>
void TestRandom::init()
{
if (initialized)
return;
int seed = QDateTime::currentDateTime().toTime_t();
qDebug(QString("%1: qsrand(%2)").arg(thread()->metaObject()->className()).arg(seed).toLatin1());
qsrand(seed);
initialized = true;
}
unsigned int TestRandom::getNumber(unsigned int min, unsigned int max)
{
int r = qrand();
return min + (unsigned int) (((double) (max + 1 - min)) * r / (RAND_MAX + 1.0));
}

View file

@ -0,0 +1,18 @@
#ifndef TESTRANDOM_H
#define TESTRANDOM_H
#include <QObject>
#include <QDateTime>
#include <stdlib.h>
class TestRandom : public QObject {
Q_OBJECT
private:
bool initialized;
public:
TestRandom(QObject *parent) : QObject(parent), initialized(false) { }
void init();
unsigned int getNumber(unsigned int min, unsigned int max);
};
#endif

View file

@ -0,0 +1,107 @@
/***************************************************************************
* Copyright (C) 2008 by Max-Wilhelm Bruker *
* brukie@laptop *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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 "testserver.h"
TestServer::TestServer(QObject *parent)
: QTcpServer(parent)
{
}
TestServer::~TestServer()
{
}
void TestServer::gameCreated(TestServerGame *_game, TestServerSocket *_creator)
{
games << _game;
_creator->moveToThread(_game->thread());
_game->addPlayer(_creator);
}
void TestServer::addGame(const QString name, const QString description, const QString password, const int maxPlayers, TestServerSocket *creator)
{
TestServerGameThread *newThread = new TestServerGameThread(name, description, password, maxPlayers, creator);
connect(newThread, SIGNAL(gameCreated(TestServerGame *, TestServerSocket *)), this, SLOT(gameCreated(TestServerGame *, TestServerSocket *)));
connect(newThread, SIGNAL(finished()), this, SLOT(gameClosed()));
newThread->start();
}
void TestServer::incomingConnection(int socketId)
{
TestServerSocket *socket = new TestServerSocket(this);
socket->setSocketDescriptor(socketId);
connect(socket, SIGNAL(createGame(const QString, const QString, const QString, const int, TestServerSocket *)), this, SLOT(addGame(const QString, const QString, const QString, const int, TestServerSocket *)));
connect(socket, SIGNAL(joinGame(const QString, TestServerSocket *)), this, SLOT(addClientToGame(const QString, TestServerSocket *)));
socket->initConnection();
}
TestServerGame *TestServer::getGame(const QString &name)
{
QListIterator<TestServerGame *> i(games);
while (i.hasNext()) {
TestServerGame *tmp = i.next();
if ((!tmp->name.compare(name, Qt::CaseSensitive)) && !tmp->getGameStarted())
return tmp;
}
return NULL;
}
QList<TestServerGame *> TestServer::listOpenGames()
{
QList<TestServerGame *> result;
QListIterator<TestServerGame *> i(games);
while (i.hasNext()) {
TestServerGame *tmp = i.next();
tmp->mutex->lock();
if ((!tmp->getGameStarted())
&& (tmp->getPlayerCount() < tmp->maxPlayers))
result.append(tmp);
tmp->mutex->unlock();
}
return result;
}
bool TestServer::checkGamePassword(const QString &name, const QString &password)
{
TestServerGame *tmp;
if ((tmp = getGame(name))) {
QMutexLocker locker(tmp->mutex);
if ((!tmp->getGameStarted())
&& (!tmp->password.compare(password, Qt::CaseSensitive))
&& (tmp->getPlayerCount() < tmp->maxPlayers))
return true;
}
return false;
}
void TestServer::addClientToGame(const QString name, TestServerSocket *client)
{
TestServerGame *tmp = getGame(name);
client->moveToThread(tmp->thread());
tmp->addPlayer(client);
}
void TestServer::gameClosed()
{
qDebug("TestServer::gameClosed");
TestServerGameThread *t = qobject_cast<TestServerGameThread *>(sender());
games.removeAt(games.indexOf(t->getGame()));
delete t;
}

View file

@ -0,0 +1,49 @@
/***************************************************************************
* Copyright (C) 2008 by Max-Wilhelm Bruker *
* brukie@laptop *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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 TESTSERVER_H
#define TESTSERVER_H
#include <QTcpServer>
#include "testservergamethread.h"
#include "testservergame.h"
class TestServerGame;
class TestServerSocket;
class TestServer : public QTcpServer
{
Q_OBJECT
private slots:
void addGame(const QString name, const QString description, const QString password, const int maxPlayers, TestServerSocket *creator);
void addClientToGame(const QString name, TestServerSocket *client);
void gameCreated(TestServerGame *_game, TestServerSocket *_creator);
void gameClosed();
public:
TestServer(QObject *parent = 0);
~TestServer();
bool checkGamePassword(const QString &name, const QString &password);
QList<TestServerGame *> listOpenGames();
TestServerGame *getGame(const QString &name);
private:
void incomingConnection(int SocketId);
QList<TestServerGame *> games;
};
#endif

View file

@ -0,0 +1,155 @@
/***************************************************************************
* Copyright (C) 2008 by Max-Wilhelm Bruker *
* brukie@laptop *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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 "testservergame.h"
TestServerGame::TestServerGame(QString _name, QString _description, QString _password, int _maxPlayers, QObject *parent)
: QObject(parent), name(_name), description(_description), password(_password), maxPlayers(_maxPlayers)
{
gameStarted = false;
mutex = new QMutex(QMutex::Recursive);
rnd = NULL;
}
TestServerGame::~TestServerGame()
{
if (rnd)
delete rnd;
delete mutex;
qDebug("TestServerGame destructor");
}
bool TestServerGame::getGameStarted()
{
return gameStarted;
}
int TestServerGame::getPlayerCount()
{
QMutexLocker locker(mutex);
return players.size();
}
QStringList TestServerGame::getPlayerNames()
{
QMutexLocker locker(mutex);
QStringList result;
QListIterator<TestServerSocket *> i(players);
while (i.hasNext()) {
TestServerSocket *tmp = i.next();
result << QString("%1|%2").arg(tmp->getPlayerId()).arg(tmp->PlayerName);
}
return result;
}
TestServerSocket *TestServerGame::getPlayer(int player_id)
{
QListIterator<TestServerSocket *> i(players);
while (i.hasNext()) {
TestServerSocket *tmp = i.next();
if (tmp->getPlayerId() == player_id)
return tmp;
}
return NULL;
}
void TestServerGame::msg(const QString &s)
{
QMutexLocker locker(mutex);
QListIterator<TestServerSocket *> i(players);
while (i.hasNext())
i.next()->msg(s);
}
void TestServerGame::broadcastEvent(const QString &cmd, TestServerSocket *player)
{
if (player)
msg(QString("public|%1|%2|%3").arg(player->getPlayerId()).arg(player->PlayerName).arg(cmd));
else
msg(QString("public|||%1").arg(cmd));
}
void TestServerGame::startGameIfReady()
{
QMutexLocker locker(mutex);
if (players.size() < maxPlayers)
return;
for (int i = 0; i < players.size(); i++)
if (players.at(i)->getStatus() != StatusReadyStart)
return;
rnd = new TestRandom(this);
rnd->init();
for (int i = 0; i < players.size(); i++)
players.at(i)->setupZones();
activePlayer = 0;
activePhase = 0;
gameStarted = true;
broadcastEvent("game_start", NULL);
}
void TestServerGame::addPlayer(TestServerSocket *player)
{
QMutexLocker locker(mutex);
int max = -1;
QListIterator<TestServerSocket *> i(players);
while (i.hasNext()) {
int tmp = i.next()->getPlayerId();
if (tmp > max)
max = tmp;
}
player->setPlayerId(max + 1);
player->setGame(this);
player->msg(QString("private|||player_id|%1|%2").arg(max + 1).arg(player->PlayerName));
broadcastEvent("join", player);
players << player;
connect(player, SIGNAL(broadcastEvent(const QString &, TestServerSocket *)), this, SLOT(broadcastEvent(const QString &, TestServerSocket *)));
}
void TestServerGame::removePlayer(TestServerSocket *player)
{
QMutexLocker locker(mutex);
players.removeAt(players.indexOf(player));
broadcastEvent("leave", player);
if (!players.size())
thread()->quit();
}
void TestServerGame::setActivePlayer(int _activePlayer)
{
activePlayer = _activePlayer;
broadcastEvent(QString("set_active_player|%1").arg(_activePlayer), NULL);
setActivePhase(0);
}
void TestServerGame::setActivePhase(int _activePhase)
{
activePhase = _activePhase;
broadcastEvent(QString("set_active_phase|%1").arg(_activePhase), NULL);
}

View file

@ -0,0 +1,64 @@
/***************************************************************************
* Copyright (C) 2008 by Max-Wilhelm Bruker *
* brukie@laptop *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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 TESTSERVERGAME_H
#define TESTSERVERGAME_H
#include <QThread>
#include <QMutex>
#include <QStringList>
#include "testserversocket.h"
#include "testrandom.h"
class TestServerSocket;
class TestServerGame : public QObject {
Q_OBJECT
private:
QList<TestServerSocket *> players;
bool gameStarted;
int activePlayer;
int activePhase;
public slots:
void broadcastEvent(const QString &event, TestServerSocket *player);
public:
QMutex *mutex;
TestRandom *rnd;
QString name;
QString description;
QString password;
int maxPlayers;
TestServerGame(QString _name, QString _description, QString _password, int _maxPlayers, QObject *parent = 0);
~TestServerGame();
bool getGameStarted();
int getPlayerCount();
QStringList getPlayerNames();
TestServerSocket *getPlayer(int player_id);
void addPlayer(TestServerSocket *player);
void removePlayer(TestServerSocket *player);
void startGameIfReady();
void msg(const QString &s);
int getActivePlayer() { return activePlayer; }
int getActivePhase() { return activePhase; }
void setActivePlayer(int _activePlayer);
void setActivePhase(int _activePhase);
};
#endif

View file

@ -0,0 +1,20 @@
#include "testservergamethread.h"
TestServerGameThread::TestServerGameThread(const QString _name, const QString _description, const QString _password, const int _maxPlayers, TestServerSocket *_creator, QObject *parent)
: QThread(parent), name(_name), description(_description), password(_password), maxPlayers(_maxPlayers), creator(_creator), game(0)
{
}
TestServerGameThread::~TestServerGameThread()
{
if (game)
delete game;
}
void TestServerGameThread::run()
{
game = new TestServerGame(name, description, password, maxPlayers);
emit gameCreated(game, creator);
exec();
}

View file

@ -0,0 +1,30 @@
#ifndef TESTSERVERGAMETHREAD_H
#define TESTSERVERGAMETHREAD_H
#include <QThread>
#include <QMutex>
#include "testservergame.h"
#include "testserversocket.h"
class TestServerGame;
class TestServerSocket;
class TestServerGameThread : public QThread {
Q_OBJECT
signals:
void gameCreated(TestServerGame *_game, TestServerSocket *creator);
private:
QString name;
QString description;
QString password;
int maxPlayers;
TestServerSocket *creator;
TestServerGame *game;
public:
TestServerGameThread(const QString _name, const QString _description, const QString _password, const int _maxPlayers, TestServerSocket *_creator, QObject *parent = 0);
~TestServerGameThread();
TestServerGame *getGame() { return game; }
void run();
};
#endif

View file

@ -0,0 +1,595 @@
/***************************************************************************
* Copyright (C) 2008 by Max-Wilhelm Bruker *
* brukie@laptop *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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 <QStringList>
#include "testserver.h"
#include "testserversocket.h"
#include "version.h"
TestServerSocket::TestServerSocket(TestServer *_server, QObject *parent)
: QTcpSocket(parent), server(_server)
{
remsg = new ReturnMessage(this);
connect(this, SIGNAL(readyRead()), this, SLOT(readClient()));
connect(this, SIGNAL(disconnected()), this, SLOT(deleteLater()));
connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(catchSocketError(QAbstractSocket::SocketError)));
setTextModeEnabled(true);
PlayerStatus = StatusNormal;
game = 0;
}
TestServerSocket::~TestServerSocket()
{
qDebug("TestServerSocket destructor");
if (game)
game->removePlayer(this);
}
void TestServerSocket::setName(const QString &name)
{
emit broadcastEvent(QString("name|%1|%2").arg(PlayerName).arg(name), this);
PlayerName = name;
}
PlayerZone *TestServerSocket::getZone(const QString &name)
{
QListIterator<PlayerZone *> ZoneIterator(zones);
while (ZoneIterator.hasNext()) {
PlayerZone *temp = ZoneIterator.next();
if (!temp->getName().compare(name))
return temp;
}
return NULL;
}
Counter *TestServerSocket::getCounter(const QString &name)
{
QListIterator<Counter *> CounterIterator(counters);
while (CounterIterator.hasNext()) {
Counter *temp = CounterIterator.next();
if (!temp->getName().compare(name))
return temp;
}
return NULL;
}
void TestServerSocket::setupZones()
{
// Delete existing zones and counters
clearZones();
// This may need to be customized according to the game rules.
// ------------------------------------------------------------------
// Create zones
PlayerZone *deck = new PlayerZone("deck", false, false, false);
zones << deck;
PlayerZone *sb = new PlayerZone("sb", false, false, false);
zones << sb;
zones << new PlayerZone("table", true, true, true);
zones << new PlayerZone("hand", false, false, true);
zones << new PlayerZone("grave", false, true, true);
zones << new PlayerZone("rfg", false, true, true);
// Create life counter
Counter *life = new Counter("life", 20);
counters << life;
// ------------------------------------------------------------------
// Assign card ids and create deck from decklist
QListIterator<QString> DeckIterator(DeckList);
int i = 0;
while (DeckIterator.hasNext())
deck->cards.append(new TestCard(DeckIterator.next(), i++, 0, 0));
deck->shuffle(game->rnd);
QListIterator<QString> SBIterator(SideboardList);
while (SBIterator.hasNext())
sb->cards.append(new TestCard(SBIterator.next(), i++, 0, 0));
nextCardId = i;
PlayerStatus = StatusPlaying;
broadcastEvent(QString("setup_zones|%1|%2|%3").arg(getCounter("life")->getCount())
.arg(deck->cards.size())
.arg(getZone("sb")->cards.size()), this);
}
void TestServerSocket::clearZones()
{
for (int i = 0; i < zones.size(); i++)
delete zones.at(i);
zones.clear();
for (int i = 0; i < counters.size(); i++)
delete counters.at(i);
counters.clear();
}
void TestServerSocket::leaveGame()
{
if (!game)
return;
game->removePlayer(this);
game = 0;
PlayerStatus = StatusNormal;
clearZones();
moveToThread(server->thread());
}
void TestServerSocket::readClient()
{
QTextStream *stream = new QTextStream(this);
stream->setCodec("UTF-8");
QStringList lines;
// Before parsing, everything has to be buffered so that the stream
// can be deleted in order to avoid problems when moving the object
// to another thread while this function is still running.
for (;;) {
QString line = stream->readLine();
if (line.isNull())
break;
lines << line;
}
delete stream;
QStringListIterator i(lines);
while (i.hasNext()) {
QString line = i.next();
qDebug(QString("<<< %1").arg(line).toLatin1());
switch (PlayerStatus) {
case StatusNormal:
case StatusReadyStart:
case StatusPlaying:
parseCommand(line);
break;
case StatusSubmitDeck:
QString card = line;
if (!card.compare(".")) {
PlayerStatus = StatusNormal;
remsg->send();
} else if (card.startsWith("SB:"))
SideboardList << card.mid(3);
else
DeckList << card;
}
}
}
bool TestServerSocket::parseCommand(QString line)
{
QStringList params = line.split("|");
// Extract message id
bool conv_ok;
int msgId = params.takeFirst().toInt(&conv_ok);
if (!conv_ok) {
remsg->setMsgId(0);
return remsg->send("syntax", false);
}
remsg->setMsgId(msgId);
if (params.empty()) {
remsg->setMsgId(0);
return remsg->send("syntax", false);
}
// Extract command
QString cmd = params.takeFirst();
remsg->setCmd(cmd);
// parse command
if (!cmd.compare("list_games", Qt::CaseInsensitive)) {
remsg->send();
QList<TestServerGame *> gameList = server->listOpenGames();
QListIterator<TestServerGame *> gameListIterator(gameList);
QStringList result;
while (gameListIterator.hasNext()) {
TestServerGame *tmp = gameListIterator.next();
tmp->mutex->lock();
result << QString("%1|%2|%3|%4|%5").arg(tmp->name)
.arg(tmp->description)
.arg(tmp->password == "" ? 0 : 1)
.arg(tmp->getPlayerCount())
.arg(tmp->maxPlayers);
tmp->mutex->unlock();
}
remsg->sendList(result);
} else if (!cmd.compare("create_game", Qt::CaseInsensitive)) {
if (params.size() != 4)
return remsg->send("syntax", false);
QString name = params[0];
QString description = params[1];
QString password = params[2];
int maxPlayers = params[3].toInt();
if (server->getGame(name))
return remsg->send("name_not_found", false);
remsg->send();
leaveGame();
emit createGame(name, description, password, maxPlayers, this);
} else if (!cmd.compare("join_game", Qt::CaseInsensitive)) {
if (params.size() != 2)
return remsg->send("syntax", false);
QString name = params[0];
QString password = params[1];
if (!server->checkGamePassword(name, password))
return remsg->send("wrong_password", false);
remsg->send();
leaveGame();
emit joinGame(name, this);
} else if (!cmd.compare("leave_game", Qt::CaseInsensitive)) {
remsg->send();
leaveGame();
} else if (!cmd.compare("set_name", Qt::CaseInsensitive)) {
if (params.size() != 1)
return remsg->send("syntax", false);
remsg->send();
setName(params[0]);
} else if (!cmd.compare("list_players", Qt::CaseInsensitive)) {
if (!game)
return remsg->send("game_state", false);
remsg->send();
remsg->sendList(game->getPlayerNames());
} else if (!cmd.compare("say", Qt::CaseInsensitive)) {
if (params.size() != 1)
return remsg->send("syntax", false);
remsg->send();
emit broadcastEvent(QString("say|%1").arg(params[0]), this);
} else if (!cmd.compare("submit_deck", Qt::CaseInsensitive)) {
PlayerStatus = StatusSubmitDeck;
DeckList.clear();
SideboardList.clear();
} else if (!cmd.compare("shuffle", Qt::CaseInsensitive)) {
if (!game)
return remsg->send("game_state", false);
if (!game->getGameStarted())
return remsg->send("game_state", false);
getZone("deck")->shuffle(game->rnd);
remsg->send();
emit broadcastEvent("shuffle", this);
} else if (!cmd.compare("ready_start", Qt::CaseInsensitive)) {
if (!game)
return remsg->send("game_state", false);
remsg->send();
PlayerStatus = StatusReadyStart;
emit broadcastEvent(QString("ready_start"), this);
game->startGameIfReady();
} else if (!cmd.compare("draw_cards", Qt::CaseInsensitive)) {
if (params.size() != 1)
return remsg->send("syntax", false);
bool ok;
int number = params[0].toInt(&ok);
if (!ok)
return remsg->send("syntax", false);
PlayerZone *deck = getZone("deck");
PlayerZone *hand = getZone("hand");
if (deck->cards.size() < number)
return remsg->send("game_state", false);
remsg->send();
for (int i = 0; i < number; ++i) {
TestCard *card = deck->cards.first();
deck->cards.removeFirst();
hand->cards.append(card);
msg(QString("private|||draw|%1|%2").arg(card->getId()).arg(card->getName()));
}
emit broadcastEvent(QString("draw|%1").arg(number), this);
} else if (!cmd.compare("move_card", Qt::CaseInsensitive)) {
// ID Karte, Startzone, Zielzone, Koordinaten X, Y
if (params.size() != 5)
return remsg->send("syntax", false);
bool ok;
int cardid = params[0].toInt(&ok);
if (!ok)
return remsg->send("syntax", false);
PlayerZone *startzone = getZone(params[1]);
PlayerZone *targetzone = getZone(params[2]);
if ((!startzone) || (!targetzone))
return remsg->send("game_state", false);
int position = -1;
TestCard *card = startzone->getCard(cardid, true, &position);
if (!card)
return remsg->send("game_state", false);
int x = params[3].toInt(&ok);
if (!ok)
return remsg->send("syntax", false);
int y = 0;
if (targetzone->hasCoords()) {
y = params[4].toInt(&ok);
if (!ok)
return remsg->send("syntax", false);
}
targetzone->insertCard(card, x, y);
remsg->send();
msg(QString("private|||move_card|%1|%2|%3|%4|%5|%6|%7").arg(card->getId())
.arg(card->getName())
.arg(startzone->getName())
.arg(position)
.arg(targetzone->getName())
.arg(x)
.arg(y));
// Was ist mit Facedown-Karten?
if ((startzone->isPublic()) || (targetzone->isPublic()))
emit broadcastEvent(QString("move_card|%1|%2|%3|%4|%5|%6|%7").arg(card->getId())
.arg(card->getName())
.arg(startzone->getName())
.arg(position)
.arg(targetzone->getName())
.arg(x)
.arg(y), this);
else
emit broadcastEvent(QString("move_card|||%1|%2|%3|%4|%5").arg(startzone->getName())
.arg(position)
.arg(targetzone->getName())
.arg(x)
.arg(y), this);
} else if (!cmd.compare("create_token", Qt::CaseInsensitive)) {
// zone, cardname, powtough, x, y
// powtough wird erst mal ignoriert
if (params.size() != 5)
return remsg->send("syntax", false);
PlayerZone *zone = getZone(params[0]);
if (!zone)
return remsg->send("game_state", false);
QString cardname = params[1];
int x = params[3].toInt();
int y = params[4].toInt();
int cardid = nextCardId++;
QString powtough = params[2];
remsg->send();
TestCard *card = new TestCard(cardname, cardid, x, y);
zone->insertCard(card, x, y);
emit broadcastEvent(QString("create_token|%1|%2|%3|%4|%5|%6").arg(zone->getName())
.arg(cardid)
.arg(cardname)
.arg(powtough)
.arg(x)
.arg(y), this);
} else if (!cmd.compare("set_card_attr", Qt::CaseInsensitive)) {
if (params.size() != 4)
return remsg->send("syntax", false);
// zone, card id, attr name, attr value
// card id = -1 => affects all cards in the specified zone
PlayerZone *zone = getZone(params[0]);
if (!zone)
return remsg->send("game_state", false);
bool ok;
int cardid = params[1].toInt(&ok);
if (!ok)
return remsg->send("syntax", false);
if (cardid == -1) {
QListIterator<TestCard *> CardIterator(zone->cards);
while (CardIterator.hasNext())
if (!CardIterator.next()->setAttribute(params[2], params[3]))
return remsg->send("syntax", false);
} else {
TestCard *card = zone->getCard(cardid, false);
if (!card)
return remsg->send("game_state", false);
if (!card->setAttribute(params[2], params[3]))
return remsg->send("syntax", false);
}
remsg->send();
emit broadcastEvent(QString("set_card_attr|%1|%2|%3|%4").arg(zone->getName()).arg(cardid).arg(params[2]).arg(params[3]), this);
} else if (!cmd.compare("inc_counter", Qt::CaseInsensitive)) {
if (params.size() != 2)
return remsg->send("syntax", false);
Counter *c = getCounter(params[0]);
if (!c)
return remsg->send("game_state", false);
bool ok;
int delta = params[1].toInt(&ok);
if (!ok)
return remsg->send("syntax", false);
remsg->send();
c->setCount(c->getCount() + delta);
emit broadcastEvent(QString("set_counter|%1|%2").arg(params[0]).arg(c->getCount()), this);
} else if (!cmd.compare("set_counter", Qt::CaseInsensitive)) {
if (params.size() != 2)
return remsg->send("syntax", false);
Counter *c = getCounter(params[0]);
bool ok;
int count = params[1].toInt(&ok);
if (!ok)
return remsg->send("syntax", false);
if (!c) {
c = new Counter(params[0], count);
counters << c;
} else
c->setCount(count);
remsg->send();
emit broadcastEvent(QString("set_counter|%1|%2").arg(params[0]).arg(count), this);
} else if (!cmd.compare("del_counter", Qt::CaseInsensitive)) {
if (params.size() != 1)
return remsg->send("syntax", false);
Counter *c = getCounter(params[0]);
if (!c)
return remsg->send("game_state", false);
delete c;
counters.removeAt(counters.indexOf(c));
remsg->send();
emit broadcastEvent(QString("del_counter|%1").arg(params[0]), this);
} else if (!cmd.compare("list_counters", Qt::CaseInsensitive)) {
if (params.size() != 1)
return remsg->send("syntax", false);
bool ok;
int player_id = params[0].toInt(&ok);
if (!ok)
return remsg->send("syntax", false);
TestServerSocket *player = game->getPlayer(player_id);
if (!player)
return remsg->send("game_state", false);
remsg->send();
remsg->sendList(player->listCounters());
} else if (!cmd.compare("list_zones", Qt::CaseInsensitive)) {
if (params.size() != 1)
return remsg->send("syntax", false);
bool ok;
int player_id = params[0].toInt(&ok);
if (!ok)
return remsg->send("syntax", false);
TestServerSocket *player = game->getPlayer(player_id);
if (!player)
return remsg->send("game_state", false);
remsg->send();
remsg->sendList(player->listZones());
} else if (!cmd.compare("dump_zone", Qt::CaseInsensitive)) {
if (params.size() != 3)
return remsg->send("syntax", false);
bool ok;
int player_id = params[0].toInt(&ok);
if (!ok)
return remsg->send("syntax", false);
int number_cards = params[2].toInt(&ok);
if (!ok)
return remsg->send("syntax", false);
TestServerSocket *player = game->getPlayer(player_id);
if (!player)
return remsg->send("game_state", false);
PlayerZone *zone = player->getZone(params[1]);
if (!zone)
return remsg->send("game_state", false);
if (!(zone->isPublic() || (player_id == PlayerId)))
return remsg->send("game_state", false);
remsg->send();
QListIterator<TestCard *> card_iterator(zone->cards);
QStringList result;
for (int i = 0; card_iterator.hasNext() && (i < number_cards || number_cards == 0); i++) {
TestCard *tmp = card_iterator.next();
// XXX Face down cards
if (zone->hasIdAccess())
result << QString("%1|%2|%3|%4|%5|%6|%7|%8").arg(tmp->getId())
.arg(tmp->getName())
.arg(tmp->getX())
.arg(tmp->getY())
.arg(tmp->getCounters())
.arg(tmp->getTapped())
.arg(tmp->getAttacking())
.arg(tmp->getAnnotation());
else
result << QString("%1|%2||||||").arg(i).arg(tmp->getName());
}
remsg->sendList(result);
emit broadcastEvent(QString("dump_zone|%1|%2|%3").arg(player_id).arg(zone->getName()).arg(number_cards), this);
} else if (!cmd.compare("roll_dice", Qt::CaseInsensitive)) {
if (params.size() != 1)
return remsg->send("syntax", false);
bool ok;
int sides = params[0].toInt(&ok);
if (!ok)
return remsg->send("syntax", false);
remsg->send();
emit broadcastEvent(QString("roll_dice|%1|%2").arg(sides).arg(game->rnd->getNumber(1, sides)), this);
} else if (!cmd.compare("set_active_player", Qt::CaseInsensitive)) {
if (params.size() != 1)
return remsg->send("syntax", false);
bool ok;
int active_player = params[0].toInt(&ok);
if (!ok)
return remsg->send("syntax", false);
if (!game->getPlayer(active_player))
return remsg->send("game_state", false);
remsg->send();
game->setActivePlayer(active_player);
} else if (!cmd.compare("set_active_phase", Qt::CaseInsensitive)) {
if (params.size() != 1)
return remsg->send("syntax", false);
bool ok;
int active_phase = params[0].toInt(&ok);
if (!ok)
return remsg->send("syntax", false);
// XXX Überprüfung, ob die Phase existiert...
remsg->send();
game->setActivePhase(active_phase);
} else
return remsg->send("syntax", false);
return true;
}
PlayerStatusEnum TestServerSocket::getStatus()
{
return PlayerStatus;
}
void TestServerSocket::setStatus(PlayerStatusEnum status)
{
PlayerStatus = status;
}
void TestServerSocket::setGame(TestServerGame *g)
{
game = g;
}
QStringList TestServerSocket::listCounters()
{
QStringList counter_list;
QListIterator<Counter *> i(counters);
while (i.hasNext()) {
Counter *tmp = i.next();
counter_list << QString("%1|%2").arg(tmp->getName()).arg(tmp->getCount());
}
return counter_list;
}
QStringList TestServerSocket::listZones()
{
QStringList zone_list;
QListIterator<PlayerZone *> i(zones);
while (i.hasNext()) {
PlayerZone *tmp = i.next();
zone_list << QString("%1|%2|%3|%4").arg(tmp->getName()).arg(tmp->isPublic()).arg(tmp->hasCoords()).arg(tmp->cards.size());
}
return zone_list;
}
void TestServerSocket::msg(const QString &s)
{
qDebug(QString(">>> %1").arg(s).toLatin1());
QTextStream stream(this);
stream.setCodec("UTF-8");
stream << s << endl;
stream.flush();
flush();
}
void TestServerSocket::initConnection()
{
msg(QString("welcome||%1").arg(VERSION_STRING));
msg("welcome||.");
}
void TestServerSocket::catchSocketError(QAbstractSocket::SocketError socketError)
{
qDebug(QString("socket error: %1").arg(socketError).toLatin1());
deleteLater();
}

View file

@ -0,0 +1,81 @@
/***************************************************************************
* Copyright (C) 2008 by Max-Wilhelm Bruker *
* brukie@laptop *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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 TESTSERVERSOCKET_H
#define TESTSERVERSOCKET_H
#include <QTcpSocket>
#include "testserver.h"
#include "testservergame.h"
#include "playerzone.h"
#include "returnmessage.h"
#include "counter.h"
class TestServer;
class TestServerGame;
class PlayerZone;
enum PlayerStatusEnum { StatusNormal, StatusSubmitDeck, StatusReadyStart, StatusPlaying };
class TestServerSocket : public QTcpSocket
{
Q_OBJECT
private slots:
void readClient();
void catchSocketError(QAbstractSocket::SocketError socketError);
signals:
void createGame(const QString name, const QString description, const QString password, const int maxPlayers, TestServerSocket *creator);
void joinGame(const QString name, TestServerSocket *player);
void commandReceived(QString cmd, TestServerSocket *player);
void broadcastEvent(const QString &event, TestServerSocket *player);
void startGameIfReady();
private:
TestServer *server;
TestServerGame *game;
QList<QString> DeckList;
QList<QString> SideboardList;
QList<PlayerZone *> zones;
QList<Counter *> counters;
int PlayerId;
int nextCardId;
PlayerZone *getZone(const QString &name);
Counter *getCounter(const QString &name);
void setName(const QString &name);
void clearZones();
void leaveGame();
bool parseCommand(QString line);
PlayerStatusEnum PlayerStatus;
ReturnMessage *remsg;
public:
QString PlayerName;
TestServerSocket(TestServer *_server, QObject *parent = 0);
~TestServerSocket();
void msg(const QString &s);
void setGame(TestServerGame *g);
PlayerStatusEnum getStatus();
void setStatus(PlayerStatusEnum status);
void initConnection();
int getPlayerId() { return PlayerId; }
void setPlayerId(int _id) { PlayerId = _id; }
QStringList listCounters();
QStringList listZones();
void setupZones();
};
#endif

21
servatrice/src/version.h Normal file
View file

@ -0,0 +1,21 @@
/***************************************************************************
* Copyright (C) 2008 by Max-Wilhelm Bruker *
* brukie@laptop *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* 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. *
***************************************************************************/
const char *VERSION_STRING = "Testserver 0.20090304";