Menu Content/Inhalt
Home

Articles

Poker Tips

Login






Lost Password?
No account yet? Register

PokerTH - Forum

homepost replythreaded viewruleshelp
 
<< Start < Prev 1 2 Next > End >>
Inte
avatar User

Junior Boarder
Posts: 8
graphgraph
Karma: 0  
Re:SVN rev884 - pixmap issues - 2007/09/28 15:39 I patched pokerth_game.pro's data.path from /usr/share/pokerth/data to /usr/share/games/pokerth/data

Then I installed the bin to /usr/games/bin and the data/* to /usr/share/games/pokerth/data

What am I missing? Overlooked I some Makefile settings?
Jabber: kral@jabber.org
  The administrator has disabled public write access.
Inte
avatar User

Junior Boarder
Posts: 8
graphgraph
Karma: 0  
Re:SVN rev884 - pixmap issues - 2007/09/28 18:48 <Inte> why is the binary 23mb big? :/
<Scytale> # strings pokerth | grep share/
<Scytale> /../share/pokerth/data/
<Scytale> I'll call that "broken".
<Inte> weird
<Scytale> Hah. I got it.
<Scytale> "ln -s /usr/share/games/pokerth/data/ /data" works. An "strace pokerth 2>&1 | grep ENOENT" made me try this.
<Scytale> open("/data/gfx/cards/default/flipside.png.bmp", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
<Scytale> and lots and lots more
Jabber: kral@jabber.org
  The administrator has disabled public write access.
Scytale
User

Fresh Boarder
Posts: 4
graphgraph
Karma: 1  
Re:SVN rev884 - pixmap issues - 2007/09/28 21:41 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:

  Indexqthelper.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_INTtempIntToString.str()));    849     doitux       configList.push_back(ConfigInfo("AppDataDir"CONFIG_TYPE_STRINGmyQtToolsInterface->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.
  The administrator has disabled public write access.
lotodore
Admin

Admin
Posts: 182
graphgraph
Karma: 10  
Re:SVN rev884 - pixmap issues - 2007/09/29 00:09 Scytale wrote:
getDataPath() does this far more clever by using QCoreApplication::instance()->applicationDirPath() to get the location of the binary.


argv[0] was used to make configfile independant of QT, since it is used in the dedicated server. We'll find a way around this problem, thanks for reporting.
--
Use IPv6. http://www.sixxs.net/
  The administrator has disabled public write access.
doitux
Admin

Admin
Posts: 254
graph
Karma: 16  
Re:SVN rev884 - pixmap issues - 2007/10/01 17:13 Hi Scytale

SVN rev 931 should work with "/usr/games/bin/pokerth" and "/usr/share/games/pokerth/data/*". I hope this helps for building an ebuild.
regards
doitux
____________________________
doitux@pokerth.net
  The administrator has disabled public write access.
Scytale
User

Fresh Boarder
Posts: 4
graphgraph
Karma: 1  
Re:SVN rev884 - pixmap issues - 2007/10/01 21:52 doitux wrote:
SVN rev 931 should work with "/usr/games/bin/pokerth" and "/usr/share/games/pokerth/data/*". I hope this helps for building an ebuild.
We've talked about this on IRC already, just for the sake of completeness: It seems to work, see the Gentoo ebuild bug. A non-Gentoo-specific solution might still be better, but who knows, maybe you'll get away with this and other distributions won't bother.
  The administrator has disabled public write access.
<< Start < Prev 1 2 Next > End >>
designed by www.madeyourweb.com