Menu

#4 The game data is not found when built with default settings

future
closed
nobody
None
5
2015-05-28
2011-10-11
Ishmael
No

The trigger executable cannot find its data directory when built from a tarball or source control checkout using the standard build commands - ./configure; jam. The executable either has to be moved to the data directory or the datadir options specified to configure. When trigger starts it should look in a few places to find the data directory and use the first valid directory found from then on. The search directories are relative to either the current directory (the directory that the executable is in - $DIR) or the configured data directory ($DATADIR). The search directories could be, in order:

$DIR
$DIR\data
$DATADIR

The test for a valid data directory could be the presence of a well known file, perhaps data/textures/splash/splash.jpg. The trigger.config.defs file is not suitable for the test as Debian installs that file to /etc not the data directory.

Discussion

  • Ishmael

    Ishmael - 2012-03-31

    The attached patch adjust the datadir handling to try to use the data sub-directory if PHYSFS could not find the configured datadir. It doesn't do any of the other suggestions in this bug report. If the trigger executable is copied to the data subdir then it will still find the data.

    The readme is also updated to remove the suggestion to copy trigger to the data subdir as it is not necessary. The note about calling 'jam clean' was moved as well.

     
  • landroni

    landroni - 2012-03-31

    I tried to test the patch but the following fails:
    sh>patch -p0 < "trigger-rally-datadir.patch" (15158)
    patching file b/doc/README.txt
    Hunk #1 FAILED at 98.
    Hunk #2 FAILED at 146.
    2 out of 2 hunks FAILED -- saving rejects to file b/doc/README.txt.rej
    patching file b/src/pengine/app.cpp
    Hunk #1 FAILED at 202.
    1 out of 1 hunk FAILED -- saving rejects to file b/src/pengine/app.cpp.rej
    sh>patch -p0 < "trigger-rally-datadir.patch" (15158) returned '1'

    Am I doing something wrong?

     
  • Ishmael

    Ishmael - 2012-03-31

    New data subdir patch

     
  • Ishmael

    Ishmael - 2012-03-31

    Sorry, I used 'git diff' instead of 'svn diff', and forgot to check if there were any differences in the patch format. 'git diff' adds an extra parent directory so the original patch should be applied with -p1.

    I have found a few things to tweak in the patch, to remove a double declaration of a variable and to simplify the readme a bit more. I have uploaded a new patch, trigger-rally-datadir.1.patch with those changes. The new patch can be applied with -p0 as expected.

     
  • landroni

    landroni - 2012-04-01

    The patch worked now, thanks. But 'trigger' still fails to start:
    liv@liv-laptop:~$ ./Build/trigger/trigger
    Trigger init
    Build: 0.6.0 on Apr 1 2012 at 11:11:04
    Initialising PhysFS
    Set writable user directory to "/home/liv/"
    Reset writable user directory to "/home/liv/.trigger"
    Application base directory "/home/liv/Build/trigger/"
    Main game data directory datadir="${prefix}/share"
    Failed to add PhysFS search directory "${prefix}/share"
    PhysFS: File not found
    Main game data directory datadir="data"
    Failed to add PhysFS search directory "data"
    PhysFS: File not found
    Loading game configuration
    Initialising SDL
    Create window and set video mode
    Found 0 joysticks
    GLEW initialized
    Graphics: Tungsten Graphics, Inc Mesa DRI Mobile Intel® GM45 Express Chipset GEM 20091221 2009Q4
    Using OpenGL 2.0
    Initialising render subsystem
    Initialising texture subsystem [SDL_Image]
    Initialising effects subsystem
    Initialising model subsystem
    Initialising audio subsystem [OpenAL]
    Performing app load
    Loading image "textures/splash/splash.jpg"
    Failed to load textures/splash/splash.jpg: textures/splash/splash.jpg, PhysFS: File not found at src/pengine/texture.cpp:74
    App load failed: Failed to load splash screen at src/trigger/main.cpp:36
    Shutting down audio subsystem
    Shutting down model subsystem
    Shutting down effects subsystem
    Shutting down texture subsystem
    Shutting down render subsystem

    THe file
    ./data/textures/splash/splash.jpg

    is present.

     
  • Ishmael

    Ishmael - 2012-04-02

    Judging by the output posted the current working directory is home (~/) and the trigger executable is in ~/Build/trigger. Where is the data directory? Is it in ~/data or in ~/Build/trigger/data? If the former then that could be considered an advanced usage and be handled by using the datadir option to configure. If the later then the patch won't find the data dir as it only tries to find the data directory relative to the current working directory, not relative to the executable's location.

    Searching relative to the executable's location might also be possible to do, but it is a little more difficult to find the executable's location from what I can see, in a cross-platform way, but maybe PHYSFS has some functionality for that.

     
  • landroni

    landroni - 2012-04-02

    I see. The data dir was located in ~/Build/trigger/data. And the reason the working dir wasn't ~/Build/trigger is that I'm using a launcher on the Xfce panel to run the executable, and the launcher launches the command from the working dir '~'. After switching the working dir to '~/Build/trigger', execution went fine. Pretty cool!

    I guess this should be documented, and then feel free to check in.

     
  • Ishmael

    Ishmael - 2012-04-03

    I'll write some notes about the datadir searching and check-in.

     
  • landroni

    landroni - 2012-06-10

    Ishmael, did you get a chance to check this in? I accidentally reverted src/pengine/app.cpp to the SVN version (on my local tree), and loading Trigger fails now, so I guess the patch is not in SVN.

     
  • qubodup

    qubodup - 2015-04-29

    Note: an alternative solution might be to make the build process create the binary inside the data/ directory.

     
  • qubodup

    qubodup - 2015-05-27
    • status: open --> closed
    • Group: --> v1.0_(example)
     

Log in to post a comment.