Dedicated server no longer depends on qt. Added code for utf-8 conversion on windows and linux (without qt). Some small issues remain (like the data-dir and charset for the server).

This commit is contained in:
lotodore
2007-10-01 00:33:05 +00:00
parent c17be5af25
commit b4a1ce8bd5
18 changed files with 465 additions and 60 deletions
@@ -0,0 +1,51 @@
/***************************************************************************
* Copyright (C) 2007 by Lothar May *
* *
* 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 "nonqthelper.h"
#include <core/convhelper.h>
#include <boost/filesystem.hpp>
NonQtHelper::NonQtHelper()
{
}
NonQtHelper::~NonQtHelper()
{
}
std::string
NonQtHelper::stringToUtf8(const std::string &myString)
{
return ConvHelper::NativeToUtf8(myString);
}
std::string
NonQtHelper::getDefaultLanguage()
{
return "en";
}
std::string
NonQtHelper::getDataPathStdString(const char *argv0)
{
boost::filesystem::path startPath(argv0);
return stringToUtf8(startPath.remove_leaf().directory_string() + "data/");
}
@@ -0,0 +1,44 @@
/***************************************************************************
* Copyright (C) 2007 by Lothar May *
* *
* 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 NONQTHELPER_H
#define NONQTHELPER_H
#ifndef POKERTH_DEDICATED_SERVER
#error This file is only for the server.
#endif
#include <string>
class NonQtHelper
{
public:
NonQtHelper();
~NonQtHelper();
std::string stringToUtf8(const std::string &);
std::string getDefaultLanguage();
std::string getDataPathStdString(const char *argv0);
};
#endif
+50
View File
@@ -0,0 +1,50 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 "nonqttoolswrapper.h"
#include <nonqthelper/nonqthelper.h>
using namespace std;
QtToolsInterface *CreateQtToolsWrapper()
{
return new NonQtToolsWrapper;
}
NonQtToolsWrapper::NonQtToolsWrapper() : myQtHelper(0)
{
myQtHelper = new NonQtHelper();
}
NonQtToolsWrapper::~NonQtToolsWrapper()
{
delete myQtHelper;
myQtHelper = 0;
}
std::string NonQtToolsWrapper::stringToUtf8(const std::string &myString) { return myQtHelper->stringToUtf8(myString); }
std::string NonQtToolsWrapper::getDefaultLanguage() { return myQtHelper->getDefaultLanguage(); }
std::string NonQtToolsWrapper::getDataPathStdString(const char * argv0) { return myQtHelper->getDataPathStdString(argv0); }
+45
View File
@@ -0,0 +1,45 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* 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 NONQTTOOLSWRAPPER_H
#define NONQTTOOLSWRAPPER_H
#include <qttoolsinterface.h>
#include <string>
class NonQtHelper;
class NonQtToolsWrapper : public QtToolsInterface
{
public:
NonQtToolsWrapper();
~NonQtToolsWrapper();
std::string stringToUtf8(const std::string &myString);
std::string getDefaultLanguage();
std::string getDataPathStdString(const char *argv0);
private:
NonQtHelper *myQtHelper;
};
#endif
+4 -3
View File
@@ -11,6 +11,7 @@
//
#include "qthelper.h"
QtHelper::QtHelper()
{
}
@@ -32,7 +33,7 @@ std::string QtHelper::getDefaultLanguage() { return QLocale::system().name().toS
QString QtHelper::getDataPath()
{
QString path = QCoreApplication::instance()->applicationDirPath();
QString path(QCoreApplication::instance()->applicationDirPath());
#ifdef _WIN32
path += "/data/";
@@ -57,9 +58,9 @@ QString QtHelper::getDataPath()
return QDir::cleanPath(path) + "/";
}
std::string QtHelper::getDataPathStdString(const std::string &appPath)
std::string QtHelper::getDataPathStdString(const char * /*argv0*/)
{
QString path(appPath.c_str());
QString path(QCoreApplication::instance()->applicationDirPath());
#ifdef _WIN32
path += "/data/";
+13 -9
View File
@@ -12,23 +12,27 @@
#ifndef QTHELPER_H
#define QTHELPER_H
#ifdef POKERTH_DEDICATED_SERVER
#error This file is not for the server.
#endif
#include <QtCore>
/**
@author FThauer FHammer <webmaster@pokerth.net>
*/
class QtHelper : public QObject{
Q_OBJECT
class QtHelper
{
public:
QtHelper();
QtHelper();
~QtHelper();
~QtHelper();
std::string stringToUtf8(const std::string &);
std::string getDefaultLanguage();
QString getDataPath();
std::string getDataPathStdString(const std::string &appPath);
std::string stringToUtf8(const std::string &);
std::string getDefaultLanguage();
QString getDataPath();
std::string getDataPathStdString(const char *argv0);
};
#endif
+9 -2
View File
@@ -19,11 +19,18 @@
***************************************************************************/
#include "qttoolswrapper.h"
#include <qthelper.h>
#include <qthelper/qthelper.h>
using namespace std;
QtToolsInterface *CreateQtToolsWrapper()
{
return new QtToolsWrapper;
}
QtToolsWrapper::QtToolsWrapper() : myQtHelper(0)
{
@@ -39,5 +46,5 @@ QtToolsWrapper::~QtToolsWrapper()
std::string QtToolsWrapper::stringToUtf8(const std::string &myString) { return myQtHelper->stringToUtf8(myString); }
std::string QtToolsWrapper::getDefaultLanguage() { return myQtHelper->getDefaultLanguage(); }
std::string QtToolsWrapper::getDataPathStdString(const std::string &appPath) { return myQtHelper->getDataPathStdString(appPath); }
std::string QtToolsWrapper::getDataPathStdString(const char * argv0) { return myQtHelper->getDataPathStdString(argv0); }
+1 -1
View File
@@ -35,7 +35,7 @@ public:
std::string stringToUtf8(const std::string &myString);
std::string getDefaultLanguage();
std::string getDataPathStdString(const std::string &appPath);
std::string getDataPathStdString(const char *argv0);
private:
+1 -1
View File
@@ -29,7 +29,7 @@ public:
//qthelper.cpp
virtual std::string stringToUtf8(const std::string &) =0;
virtual std::string getDefaultLanguage() =0;
virtual std::string getDataPathStdString(const std::string &) =0;
virtual std::string getDataPathStdString(const char *argv0) =0;
};