Okay, after playing around a bit (actually, a lot), I found the source of the problems.
Remember, we install the binary to /usr/games/bin (the file is therefore called /usr/games/bin/pokerth, but this is not a subdirectory!) and the data to /usr/share/games/pokerth/data/.
Now, PokerTH can't find its data directory. Looking into the config file (of course I've deleted it first) reveals that AppDataDir is set to "/data/", and indeed, strace confirms that PokerTH is looking for a "data" directory in the root directory of my system. The question is, why does it think that "/data/" is the correct directory?
To debug it, I've modified src/gui/qt/qttools/qthelper/qthelper.cpp like that:
| Code: |
Index: qthelper.cpp
===================================================================
--- qthelper.cpp (revision 890)
+++ qthelper.cpp (working copy)
@@ -34,22 +34,22 @@
{
QString path = QCoreApplication::instance()->applicationDirPath();
-#ifdef _WIN32
- path += "/data/";
+#ifdef _WIN32
+ path += "/dataA/";
#else
#ifdef __APPLE__
if (QRegExp("Contents/MacOS/?$"«»).indexIn(path) != -1) {
// pointing into an macosx application bundle
- path += "/../Resources/data/";
- } else { path += "/data/"; }
+ path += "/../Resources/dataB/";
+ } else { path += "/dataC/"; }
#else //Unix
if (QRegExp("pokerth/?$"«»).indexIn(path) != -1) {
// there is an own application directory
- path += "/data/";
+ path += "/dataD/";
} else if (QRegExp("bin/?$"«»).indexIn(path) != -1) {
// we are in a bin directory. e.g. /usr/bin
- path += "/../share/pokerth/data/";
- } else { path += "/data/"; }
+ path += "/../share/pokerth/dataE/";
+ } else { path += "/dataF/"; }
#endif
#endif
@@ -61,25 +61,25 @@
{
QString path(appPath.c_str());
-#ifdef _WIN32
- path += "/data/";
+#ifdef _WIN32
+ path += "/dataG/";
#else
#ifdef __APPLE__
if (QRegExp("Contents/MacOS/?$"«»).indexIn(path) != -1) {
// pointing into an macosx application bundle
- path += "/../Resources/data/";
- } else { path += "/data/"; }
+ path += "/../Resources/dataH/";
+ } else { path += "/dataI/"; }
#else //Unix
if (QRegExp("pokerth/?$"«»).indexIn(path) != -1) {
// there is an own application directory
- path += "/data/";
+ path += "/dataJ/";
} else if (QRegExp("bin/?$"«»).indexIn(path) != -1) {
// we are in a bin directory. e.g. /usr/bin
- path += "/../share/pokerth/data/";
- } else { path += "/data/"; }
+ path += "/../share/pokerth/dataK/";
+ } else { path += "/dataL/"; }
#endif
#endif
return (QDir::cleanPath(path) + "/"«»).toUtf8().constData();
-}
\ No newline at end of file
+}
|
As a result, PokerTH now looks for the /dataL/ directory. Then I had a look at src/config/configfile.cpp. This is the relevant part (lines 148 to 154) in "svn blame" view (I'm at r890):
| Code: |
830 lotodore boost::filesystem::«»path startPath(argv[0]);
830 lotodore
406 doitux ostringstream tempIntToString;
406 doitux tempIntToString << configRev;
406 doitux configList.push_back(ConfigInfo("ConfigRevision", CONFIG_TYPE_INT, tempIntToString.str()));
849 doitux configList.push_back(ConfigInfo("AppDataDir", CONFIG_TYPE_STRING, myQtToolsInterface->getDataPathStdString(startPath.remove_leaf().directory_
string())));
|
Using argv[0] here is obviously causing problems when running PokerTH from within the $PATH: argv[0] is just "pokerth" in that case, leading to getDataPathStdString() called with an empty string, falling through all "if"s and returning "" + "/data/" as data location.
getDataPath() does this far more clever by using QCoreApplication::instance()->applicationDirPath() to get the location of the binary.
My first question would be, why are you using two seperate functions to achieve the same goal (getDataPath() and getDataPathStdString())? I'd suggest to let getDataPathStdString() call getDataPath() and convert the types around in order to get a std:

tring, if possible (I'm not a C++ programmer). You could then change line 154 in configfile.cpp accordingly.
The second question is whether it's possible to add an override possibility to the getDataPath() code, to be able to choose the data dir at compile time. There is already a setting for where to install the data directory in pokerth_game.pro, could this be used? Because for example on Gentoo the getDataPath() code would still not be able to find the data directory (it would look in /usr/games/share/pokerth/data, not /usr/share/games/pokerth/data). We could of course patch qthelper.cpp to fix this on Gentoo, but you probably want to include a fix in PokerTH itself.
By the way, thanks for a great piece of software, hope this wasn't too long and helped you reproduce the problem.